From: William Kucharski <william.kucharski@oracle.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@redhat.com>, Tejun Heo <tj@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH V2] cgroup: Trace event cgroup id fields should be u64
Date: Wed, 1 Dec 2021 16:27:54 +0000 [thread overview]
Message-ID: <AF25430B-AE4E-443B-A231-3C93C6CD2901@oracle.com> (raw)
In-Reply-To: <20211201111459.4ac7f84c@gandalf.local.home>
I had pondered that as a consequence for two of the three uses but wasn't sure
if it was worth reordering things; I can easily do so.
What do you suggest for cgroup_migrate as that will have a hole either way
as it's:
TP_STRUCT__entry(
__field( int, dst_root )
__field( u64, dst_id )
__field( int, dst_level )
__field( int, pid )
__string( dst_path, path )
__string( comm, task->comm )
),
if I put dst_level above dst_id, the int for pid field will leave a hole
anyway because the string pointer for dst_path will want to be 64-bit
aligned.
Thanks in advance.
> On Dec 1, 2021, at 9:14 AM, Steven Rostedt <rostedt@goodmis.org> wrote:
>
> On Wed, 1 Dec 2021 09:07:46 -0700
> William Kucharski <william.kucharski@oracle.com> wrote:
>
>> Various trace event fields that store cgroup IDs were declared as
>> ints, but cgroup_id(() returns a u64 and the structures and associated
>> TP_printk() calls were not updated to reflect this.
>>
>> Fixes: 743210386c03 ("cgroup: use cgrp->kn->id as the cgroup ID")
>> Signed-off-by: William Kucharski <william.kucharski@oracle.com>
>> ---
>> V2: Do not remove spaces from macro arguments
>>
>> include/trace/events/cgroup.h | 12 ++++++------
>> 1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/include/trace/events/cgroup.h b/include/trace/events/cgroup.h
>> index 7f42a3de59e6..1b68c842ac46 100644
>> --- a/include/trace/events/cgroup.h
>> +++ b/include/trace/events/cgroup.h
>> @@ -59,7 +59,7 @@ DECLARE_EVENT_CLASS(cgroup,
>>
>> TP_STRUCT__entry(
>> __field( int, root )
>> - __field( int, id )
>> + __field( u64, id )
>> __field( int, level )
>
> It's best to move them around to prevent holes. This is not a packed
> structure, and the above will create a structure on the ring buffer that
> looks like:
>
> int root;
> u64 id;
> int level;
> short path_offset;
> short path_size;
>
> (the string() macro is a 4 byte word where the half is the offset of the
> actual string and the other half is the size of the string).
>
> Having a 8 byte word between two 4 byte words, will add a 4 byte padding
> after the first 4 byte word (before the 8 byte word), and waste space on
> the ring buffer.
>
> Better to move it around to be:
>
> TP_STRUCT__entry(
> __field( int, root )
> __field( int, level )
> __field( u64, id )
>
> That way the two 4 byte words will be together followed directly by the 8
> byte word.
>
>> __string( path, path )
>> ),
>> @@ -71,7 +71,7 @@ DECLARE_EVENT_CLASS(cgroup,
>> __assign_str(path, path);
>> ),
>>
>> - TP_printk("root=%d id=%d level=%d path=%s",
>> + TP_printk("root=%d id=%llu level=%d path=%s",
>> __entry->root, __entry->id, __entry->level, __get_str(path))
>> );
>>
>> @@ -126,7 +126,7 @@ DECLARE_EVENT_CLASS(cgroup_migrate,
>>
>> TP_STRUCT__entry(
>> __field( int, dst_root )
>> - __field( int, dst_id )
>> + __field( u64, dst_id )
>
> Same here. Just move dst_level above dst_id.
>
>> __field( int, dst_level )
>> __field( int, pid )
>> __string( dst_path, path )
>> @@ -142,7 +142,7 @@ DECLARE_EVENT_CLASS(cgroup_migrate,
>> __assign_str(comm, task->comm);
>> ),
>>
>> - TP_printk("dst_root=%d dst_id=%d dst_level=%d dst_path=%s pid=%d comm=%s",
>> + TP_printk("dst_root=%d dst_id=%llu dst_level=%d dst_path=%s pid=%d comm=%s",
>> __entry->dst_root, __entry->dst_id, __entry->dst_level,
>> __get_str(dst_path), __entry->pid, __get_str(comm))
>> );
>> @@ -171,7 +171,7 @@ DECLARE_EVENT_CLASS(cgroup_event,
>>
>> TP_STRUCT__entry(
>> __field( int, root )
>> - __field( int, id )
>> + __field( u64, id )
>
> And here.
>
>> __field( int, level )
>> __string( path, path )
>> __field( int, val )
>> @@ -185,7 +185,7 @@ DECLARE_EVENT_CLASS(cgroup_event,
>> __entry->val = val;
>> ),
>>
>> - TP_printk("root=%d id=%d level=%d path=%s val=%d",
>> + TP_printk("root=%d id=%llu level=%d path=%s val=%d",
>> __entry->root, __entry->id, __entry->level, __get_str(path),
>> __entry->val)
>> );
>
>
>
> -- Steve
next prev parent reply other threads:[~2021-12-01 16:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-01 16:07 [PATCH V2] cgroup: Trace event cgroup id fields should be u64 William Kucharski
2021-12-01 16:14 ` Steven Rostedt
2021-12-01 16:27 ` William Kucharski [this message]
2021-12-01 16:44 ` Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AF25430B-AE4E-443B-A231-3C93C6CD2901@oracle.com \
--to=william.kucharski@oracle.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).