From: "Abhishek Sagar" <sagar.abhishek@gmail.com>
To: "Srinivasa Ds" <srinivasa@in.ibm.com>
Cc: linux-kernel@vger.kernel.org, prasanna@in.ibm.com,
davem@davemloft.net, anil.s.keshavamurthy@intel.com,
"Jim Keniston" <jkenisto@us.ibm.com>,
"Ananth N Mavinakayanahalli" <ananth@in.ibm.com>
Subject: Re: [PATCH][RFC] kprobes: Add user entry-handler in kretprobes
Date: Wed, 14 Nov 2007 19:00:44 +0530 [thread overview]
Message-ID: <863e9df20711140530h69df9107g38e293aab278686a@mail.gmail.com> (raw)
In-Reply-To: <473ACCBE.9010308@in.ibm.com>
On Nov 14, 2007 3:53 PM, Srinivasa Ds <srinivasa@in.ibm.com> wrote:
> No, eventhough return instances are chained in an order, order of execution of
> return handler entirely depends on which process returns first
Right...the LIFO chain analogy holds true for return instances for the
same task only. As you've pointed out, kretprobe_instance is the only
thing that can bind corresponding entry and return handlers together,
which has been taken care of.
> So entry_handler() which gets executed last doesn't guarantee
> that its return handler will be executed first(because it took a lot time
> to return).
Only if there are return instances pending belonging to different tasks.
> So only thing to match the entry_handler() with its return_handler() is
> return probe instance(ri)'s address, which user has to take care explicitly
Lets see how entry and return handlers can be matched up in three
different scenarios:-
1. Multiple function entries from various tasks (the one you've just
pointed out).
2. Multiple kretprobe registration on the same function.
3. Nested calls of kretprobe'd function.
In cases 1 and 3, the following information can be used to match
corresponding entry and return handlers inside a user handler (if
needed):
(ri->task, ri->ret_addr)
where ri is struct kretprobe_instance *
This tuple should uniquely identify a return address (right?).
In case 2, entry and return handlers are anyways called in the right
order (taken care of by
trampoline_handler() due to LIFO insertion in ri->hlist).
The fact that ri is passed to both handlers should allow any user
handler to identify each of these cases and take appropriate
synchronization action pertaining to its private data, if needed.
> (Hence I feel sol a) would be nice).
With an entry-handler, any module aiming to profile running time of a
function (say) can simply do the following without being "return
instance" conscious. Note however that I'm not trying to address just
this scenario but trying to provide a general way to use
entry-handlers in kretprobes:
static unsigned long flag = 0; /* use bit 0 as a global flag */
unsigned long long entry, exit;
int my_entry_handler(struct kretprobe_instance *ri, struct pt_regs *regs)
{
if (!test_and_set_bit(0, &flag))
/* this instance claims the first entry to kretprobe'd function */
entry = sched_clock();
/* do other stuff */
return 0; /* right on! */
}
return 1; /* error: no return instance to be allocated for this
function entry */
}
/* will only be called iff flag == 1 */
int my_return_handler(struct kretprobe_instance *ri, struct pt_regs *regs)
{
BUG_ON(!flag);
exit = sched_clock();
set_bit(0, &flag);
}
I think something like this should do the trick for you.
> Thanks
> Srinivasa DS
--
Thanks & Regards
Abhishek Sagar
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
next prev parent reply other threads:[~2007-11-14 13:31 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <47389BEB.1000901@gmail.com>
2007-11-12 18:39 ` Abhishek Sagar
2007-11-13 10:47 ` Abhishek Sagar
2007-11-14 7:57 ` Srinivasa Ds
2007-11-14 8:49 ` Abhishek Sagar
2007-11-14 10:23 ` Srinivasa Ds
2007-11-14 13:30 ` Abhishek Sagar [this message]
2007-11-14 22:51 ` Jim Keniston
2007-11-15 13:16 ` Abhishek Sagar
2007-11-15 21:16 ` Jim Keniston
2007-11-16 17:50 ` Abhishek Sagar
2007-11-17 0:54 ` Jim Keniston
2007-11-17 18:15 ` Abhishek Sagar
2007-11-19 12:26 ` Abhishek Sagar
2007-11-21 5:55 ` Jim Keniston
2007-11-21 10:20 ` Abhishek Sagar
2007-11-27 0:54 ` Jim Keniston
2007-11-15 15:00 ` Abhishek Sagar
2007-11-16 0:07 ` Jim Keniston
2007-11-16 18:53 ` Abhishek Sagar
2007-11-16 23:09 ` Jim Keniston
2007-11-17 17:09 ` Abhishek Sagar
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=863e9df20711140530h69df9107g38e293aab278686a@mail.gmail.com \
--to=sagar.abhishek@gmail.com \
--cc=ananth@in.ibm.com \
--cc=anil.s.keshavamurthy@intel.com \
--cc=davem@davemloft.net \
--cc=jkenisto@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=prasanna@in.ibm.com \
--cc=srinivasa@in.ibm.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
all inboxes | Powered by JetHome®