Re: [PATCH v14 4/4] Documentation: trace/objtrace: Add documentation for objtrace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Aug 18, 2022 at 1:34 PM Jeff Xie <xiehuan09@xxxxxxxxx> wrote:
>
> Hi Joel,
>
> On Fri, Aug 19, 2022 at 1:05 AM Joel Fernandes <joel@xxxxxxxxxxxxxxxxx> wrote:
> >
> > On Thu, Aug 18, 2022 at 12:38 PM Jeff Xie <xiehuan09@xxxxxxxxx> wrote:
> > >
> > > Hi Joel,
> > >
> > > Thank you for your review.
> > >
> > > On Thu, Aug 18, 2022 at 11:53 PM Joel Fernandes <joel@xxxxxxxxxxxxxxxxx> wrote:
> > > >
> > > > On Tue, Jun 28, 2022 at 10:55:52PM +0800, Jeff Xie wrote:
> > > > > Add documentation explaining how to use objtrace trigger to get the value
> > > > > of the object.
> > > > >
> > > > > Cc: Jonathan Corbet <corbet@xxxxxxx>
> > > > > Cc: Bagas Sanjaya <bagasdotme@xxxxxxxxx>
> > > > > Cc: linux-doc@xxxxxxxxxxxxxxx
> > > > > Signed-off-by: Jeff Xie <xiehuan09@xxxxxxxxx>
> > > > > Reviewed-by: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
> > > > > ---
> > > > > Changelog:
> > > > > v14:
> > > > > - make documentation more readable and fix literal code block by Bagas Sanjaya
> > > > >
> > > > >  Documentation/trace/events.rst | 87 ++++++++++++++++++++++++++++++++++
> > > > >  1 file changed, 87 insertions(+)
> > > > >
> > > > > diff --git a/Documentation/trace/events.rst b/Documentation/trace/events.rst
> > > > > index c47f381d0c00..c15f1d25d4a0 100644
> > > > > --- a/Documentation/trace/events.rst
> > > > > +++ b/Documentation/trace/events.rst
> > > > > @@ -546,6 +546,93 @@ The following commands are supported:
> > > > >
> > > > >    See Documentation/trace/histogram.rst for details and examples.
> > > > >
> > > > > +- objtrace
> > > > > +
> > > > > +  This command provides a way to get the value of any object, The object
> > > > > +  can be obtained from the dynamic event (kprobe_event/uprobe_event) or the
> > > > > +  static event (tracepoint).
> > > > > +
> > > > > +  Usage:
> > > > > +  When using the kprobe event, by only need to set the objtrace (a new
> > > > > +  trigger), we can get the value of object that is set by kprobe event.
> > > > > +
> > > > > +  For example, for the function bio_add_page():
> > > > > +
> > > > > +  .. code-block:: c
> > > > > +
> > > > > +     int bio_add_page(struct bio *bio, struct page *page,
> > > > > +                   unsigned int len, unsigned int offset)
> > > > > +
> > > > > +  Firstly, we can set the base of the object as first parameter (arg1) to
> > > > > +  to the function:
> > > > > +
> > > > > +  .. code-block::
> > > > > +
> > > > > +     # echo 'p bio_add_page arg1=$arg1' > ./kprobe_events
> > > > > +
> > > > > +  Secondly, we can get the value dynamically based on the object:
> > > > > +
> > > > > +  .. code-block::
> > > > > +
> > > > > +     find the offset of the bi_size in struct bio:
> > > > > +     $ gdb vmlinux
> > > > > +     (gdb) p &(((struct bio *)0)->bi_iter.bi_size)
> > > > > +     $1 = (unsigned int *) 0x28
> > > > > +
> > > > > +     # echo 'objtrace:add:arg1,0x28:u32:1 if comm == "cat"' > ./events/kprobes/ \
> > > > > +       p_bio_add_page_0/trigger
> > > > > +
> > > > > +     # cd /sys/kernel/debug/tracing/
> > > > > +     # echo 'p bio_add_page arg1=$arg1' > ./kprobe_events
> > > > > +     # echo 'objtrace:add:arg1,0x28:u32:1 if comm == "cat"' > ./events/kprobes/p_bio_add_page_0/trigger
> > > >
> > > > No offense but this documentation is not well written and hard to read.
> > > >
> > > > Admittedly though I am just casually browsing through, so apologies.
> > > >
> > > > So basically, 0x28 is the offset of the u32 within the bio, that you want to
> > > > track down, as it passes through functions?
> > >
> > > Yes, Not only track the bio, but also get a value with an offset of
> > > 0x28 relative to the bio.
> >
> > Right.
> >
> > > >
> > > > The example is good, but I suggest breakdown each of the commands separated
> > > > by ':' and document those as well.
> > >
> > > I don't know how to explain it in more detail, maybe need to be
> > > familiar with kprobe event and trigger in advance ;-)
> >
> > That's not a strong argument IMO.
> >
> > Shouldn't it be super easy to add the following to the documentation
> > since you already mentioned it in the commit log? Or am I missing
> > something?
> >
> > Syntax:
> >         objtrace:add:obj[,offset][:type][:count][if <filter>]
>
> I'am so sorry, I misunderstood you, I thought it needed to be
> explained every word like this, e.g.
> objtrace:
>     ...
> add:
>     ...
> ...
>
> Thanks,  I will add the above syntax in the next version.
>

Yeah no problem, I am also OK with that being a follow-up patch
instead of the series if it matches with Steven's review timing
better.

Thanks,

 - Joel



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux