Re: [PATCH][RFC] kprobes: Add user entry-handler in kretprobes



Abhishek Sagar wrote:
On Nov 13, 2007 12:09 AM, Abhishek Sagar <sagar.abhishek@xxxxxxxxx> wrote:
Whoops...sry for the repeated email..emailer trouble.

Expecting this one to makes it to the list. Summary again:

This patch introduces a provision to specify a user-defined callback
to run at function entry to complement the return handler in
kretprobes. Currently, whenever a kretprobe is registered, a user can
specify a callback (return-handler) to be run each time the target
function returns. This is also not guaranteed and is limited by the
number of concurrently pending return instances of the target function
in the current process's context.

This patch will now allow registration of another user defined handler
which is guaranteed to run each time the current return instance is
allocated and the return handler is set-up. Conversely, if the
entry-handler returns an error, it'll cause the current return
instance to be dropped and the return handler will also not run. The
purpose is to provide flexibility to do certain kinds of function
level profiling using kretprobes. By being able to register function
entry and return handlers, kretprobes will now be able to reduce an
extra probe registration (and associated race) for scenarios where an
entry handler is required to capture the function call/entry event
along with the corresponding function exit event.


If I understand your intentions(to capture information on function call/entry and corresponding function exit) cleary, I have few concerns on this.

1) How do you map the entry_handler(which gets executed when a process enters the function) with each instance of return probe handler.
I accept that entry_handler() will execute each time process enters the function, but to calculate time, one needs to know corresponding instance of return probe handler(there should be a map for each return handler).

Let me explain briefly.
Suppose in a SMP system, 4 processes enter the same function at almost sametime(by executing entry_hanlder()) and returns from 4 different locations by executing the return handler. Now how do I match entry_handler() with corresponding instance of return handler for calculating time.

Sometime back, Even I was interested in calculating the function execution time, but I used approach a) .

Now What I think is, there could be 2 solutions to these problem.

a) Collect the entry time and exit time and put it in that kretprobe_instance structure and fetch it before freeing that instance.

b) Or pass ri(kretprobe_instance address to entry_handler) and match it with return probe handler.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: [PATCH][RFC] kprobes: Add user entry-handler in kretprobes
    ... This patch will now allow registration of another user defined handler ... level profiling using kretprobes. ... entry and return handlers, kretprobes will now be able to reduce an ... struct kretprobe { ...
    (Linux-Kernel)
  • Re: [PATCH][RFC] kprobes: Add user entry-handler in kretprobes
    ... have m kretprobe "misses", we may report n calls but only returns. ... allocation should be left to user entry handlers, ... 'ri' can uniquely identify any entry-return handler ... No. Handlers shouldn't be writing to the pt_regs struct unless they ...
    (Linux-Kernel)
  • Re: [PATCH][RFC] kprobes: Add user entry-handler in kretprobes
    ... I see no reason to save a copy of *regs and pass that to the entry ... And if a handler on i386 uses ®s->esp as the value of the ... stack pointer, ... Multiple kretprobe registration on the same function. ...
    (Linux-Kernel)
  • Re: Need to avoid "field X cannot contain a Null value"
    ... make no entry, or undo the entry ... Still in table design, ... I was hoping either someone already had working code or that ... add the next event handler." ...
    (microsoft.public.access.forms)
  • Re: [PATCH][RFC] kprobes: Add user entry-handler in kretprobes
    ... I accept that entry_handler() will execute each time process enters the function, but to calculate time, one needs to know corresponding instance of return probe handler. ... a one-to-one correspondence between the entry and return handlers ... In case someone wants to calculate the entry and exit timestamps of a ... pending return instances to reach the correct return instance. ...
    (Linux-Kernel)