From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Jiri Olsa <jolsa@redhat.com>,
linux-kernel@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>,
Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Tom Zanussi <tom.zanussi@linux.intel.com>,
linux-rt-users@vger.kernel.org,
linux-trace-users@vger.kernel.org,
Clark Williams <williams@redhat.com>,
Daniel Bristot de Oliveira <bristot@redhat.com>,
Juri Lelli <juri.lelli@redhat.com>
Subject: Re: [PATCH 11/20 v2] tracing: Add symbol type to function based events
Date: Thu, 8 Feb 2018 13:22:50 -0300 [thread overview]
Message-ID: <20180208162250.GA5132@kernel.org> (raw)
In-Reply-To: <20180208105900.71a8ee8c@gandalf.local.home>
Em Thu, Feb 08, 2018 at 10:59:00AM -0500, Steven Rostedt escreveu:
> On Thu, 8 Feb 2018 12:20:31 +0100
> Jiri Olsa <jolsa@redhat.com> wrote:
>
> > > +Symbols (function names)
> > > +========================
> > > +
> > > +To display kallsyms "%pS" type of output, use the special type "symbol".
> > > +
> > > +Again, using gdb to find the offset of the "func" field of struct work_struct
> > > +
> > > +(gdb) printf "%d\n", &((struct work_struct *)0)->func
> > > +24
> >
> > you could also use Arnaldo's pahole for this, seems like less typing:
> >
> > $ pahole ./vmlinux -C work_struct
> > die__process_function: tag not supported (INVALID)!
> > struct work_struct {
> > atomic_long_t data; /* 0 8 */
> > struct list_head entry; /* 8 16 */
> > work_func_t func; /* 24 8 */
> >
> > it's in 'dwarves' package
>
> Nice, I'll have to document that:
>
> $ pahole ./vmlinux -C net_device |grep perm
> unsigned char perm_addr[32]; /* 558 32 */
You can also use just one .o file to speed things up instead of using
vmlinux, where it ill go on parsing stuff till it finds a .o with that
struct definition, i.e.:
[acme@jouet linux]$ pahole -C work_struct ../build/v4.15.0-rc9+/kernel/sys.o
struct work_struct {
atomic_long_t data; /* 0 8 */
struct list_head entry; /* 8 16 */
work_func_t func; /* 24 8 */
/* size: 32, cachelines: 1, members: 3 */
/* last cacheline: 32 bytes */
};
One may prefer hexadecimal numbers:
[acme@jouet linux]$ pahole --hex -C work_struct ../build/v4.15.0-rc9+/kernel/sys.o
struct work_struct {
atomic_long_t data; /* 0 0x8 */
struct list_head entry; /* 0x8 0x10 */
work_func_t func; /* 0x18 0x8 */
/* size: 32, cachelines: 1, members: 3 */
/* last cacheline: 32 bytes */
};
[acme@jouet linux]$
Or even expand everything and get offsets from that work_struct to
inside the list_head or other embedded types:
[acme@jouet linux]$ pahole -E --hex -C work_struct ../build/v4.15.0-rc9+/kernel/sys.o
struct work_struct {
/* typedef atomic_long_t -> atomic64_t */ struct {
long int counter; /* 0 0x8 */
} data; /* 0 0x8 */
struct list_head {
struct list_head * next; /* 0x8 0x8 */
struct list_head * prev; /* 0x10 0x8 */
} entry; /* 0x8 0x10 */
/* typedef work_func_t */ void (*func)(struct work_struct *); /* 0x18 0x8 */
/* size: 32, cachelines: 1, members: 3 */
/* last cacheline: 32 bytes */
};
[acme@jouet linux]$
A long time ago I put the expansion of task_struct somewhere... yeah,
almost a decade ago, 2008, but it was not -E, was -p (i.e. expand
pointer types):
http://vger.kernel.org/~acme/vmlinux-expand_pointers-task_struct.txt
/* size: 1680, cachelines: 27, members: 141 */
/* sum members: 1641, holes: 10, sum holes: 39 */
/* bit holes: 1, sum bit holes: 31 bits */
/* paddings: 1, sum paddings: 4 */
/* last cacheline: 16 bytes */
};
Anyway, now we have:
[acme@jouet linux]$ pahole -C task_struct ../build/v4.15.0-rc9+/kernel/sys.o | tail -6
struct thread_struct thread; /* 6592 4352 */
/* size: 10944, cachelines: 171, members: 4 */
/* sum members: 10896, holes: 1, sum holes: 48 */
/* paddings: 1, sum paddings: 48 */
};
[acme@jouet linux]$
We have way more memory and features now :-)
The number of members is because now we have that randomize_struct stuff
that creates an unamed struct inside task_struct, so we have:
struct task_struct {
struct thread_info thread_info; /* 0 8 */
volatile long int state; /* 8 8 */
/* XXX 48 bytes hole, try to pack */
/* --- cacheline 1 boundary (64 bytes) --- */
struct {
void * stack; /* 64 8 */
atomic_t usage; /* 72 4 */
<SNIP>
int pagefault_disabled; /* 6504 4 */
/* XXX 4 bytes hole, try to pack */
struct task_struct * oom_reaper_list; /* 6512 8 */
struct vm_struct * stack_vm_area; /* 6520 8 */
/* --- cacheline 102 boundary (6528 bytes) --- */
atomic_t stack_refcount; /* 6528 4 */
/* XXX 4 bytes hole, try to pack */
void * security; /* 6536 8 */
}; /* 64 6528 */
/* XXX last struct has 48 bytes of padding */
/* --- cacheline 103 boundary (6592 bytes) --- */
struct thread_struct thread; /* 6592 4352 */
/* size: 10944, cachelines: 171, members: 4 */
/* sum members: 10896, holes: 1, sum holes: 48 */
/* paddings: 1, sum paddings: 48 */
};
So indeed, 'just' 4 members.
I guess I'll have to add some new mode where one can ask for unnamed
structs to be removed for the sake of --reorganize and the summary
information at the end, erm...
Anyway, digressed too much :-)
- Arnaldo
next prev parent reply other threads:[~2018-02-08 16:22 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-07 20:24 [PATCH 00/20 v2] tracing: Dynamically created function based events Steven Rostedt
2018-02-07 20:24 ` [PATCH 01/20 v2] tracing: Add " Steven Rostedt
2018-02-08 11:20 ` Jiri Olsa
2018-02-08 15:53 ` Steven Rostedt
2018-02-07 20:24 ` [PATCH 02/20 v2] tracing: Add documentation for " Steven Rostedt
2018-02-07 20:24 ` [PATCH 03/20 v2] tracing: Add simple arguments to " Steven Rostedt
2018-02-07 20:24 ` [PATCH 04/20 v2] tracing/x86: Add arch_get_func_args() function Steven Rostedt
2018-02-07 20:24 ` [PATCH 05/20 v2] tracing: Add hex print for dynamic ftrace based events Steven Rostedt
2018-02-07 20:24 ` [PATCH 06/20 v2] tracing: Add indirect offset to args of " Steven Rostedt
2018-02-07 20:24 ` [PATCH 07/20 v2] tracing: Add dereferencing multiple fields per arg Steven Rostedt
2018-02-07 20:24 ` [PATCH 08/20 v2] tracing: Add "unsigned" to function based events Steven Rostedt
2018-02-07 20:24 ` [PATCH 09/20 v2] tracing: Add indexing of arguments for " Steven Rostedt
2018-02-07 20:24 ` [PATCH 10/20 v2] tracing: Make func_type enums for easier comparing of arg types Steven Rostedt
2018-02-07 20:24 ` [PATCH 11/20 v2] tracing: Add symbol type to function based events Steven Rostedt
2018-02-08 11:20 ` Jiri Olsa
2018-02-08 15:59 ` Steven Rostedt
2018-02-08 16:22 ` Arnaldo Carvalho de Melo [this message]
2018-02-09 15:03 ` Masami Hiramatsu
2018-02-07 20:24 ` [PATCH 12/20 v2] tracing: Add accessing direct address from " Steven Rostedt
2018-02-07 20:24 ` [PATCH 13/20 v2] tracing: Add array type to " Steven Rostedt
2018-02-07 20:24 ` [PATCH 14/20 v2] tracing: Have char arrays be strings for " Steven Rostedt
2018-02-07 20:24 ` [PATCH 15/20 v2] tracing: Add string type for dynamic strings in " Steven Rostedt
2018-02-07 20:24 ` [PATCH 16/20 v2] tracing: Add NULL to skip args for " Steven Rostedt
2018-02-07 20:24 ` [PATCH 17/20 v2] tracing: Add indirect to indirect access " Steven Rostedt
2018-02-07 20:24 ` [PATCH 18/20 v2] tracing/perf: Allow perf to use " Steven Rostedt
2018-02-07 20:24 ` [PATCH 19/20 v2] tracing: Add error messages for failed writes to function_events Steven Rostedt
2018-02-07 20:24 ` [PATCH 20/20 v2] tracing: Add argument error message too many args for function based events 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=20180208162250.GA5132@kernel.org \
--to=acme@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=bristot@redhat.com \
--cc=jolsa@redhat.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=linux-trace-users@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=tom.zanussi@linux.intel.com \
--cc=torvalds@linux-foundation.org \
--cc=williams@redhat.com \
/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).