This is the mail archive of the
systemtap@sources.redhat.com
mailing list for the systemtap project.
Re: [Fwd: Re: [PATCH] Return probe]
- From: Prasanna S Panchamukhi <prasanna at in dot ibm dot com>
- To: Hien Nguyen <hien at us dot ibm dot com>
- Cc: jkenisto at us dot ibm dot com, Vara Prasad <varap at us dot ibm dot com>, SystemTAP <systemtap at sources dot redhat dot com>
- Date: Tue, 19 Apr 2005 18:48:55 +0530
- Subject: Re: [Fwd: Re: [PATCH] Return probe]
- References: <425C30F1.5080900@us.ibm.com> <20050413140945.GA21330@in.ibm.com> <425D6756.3040305@us.ibm.com> <20050414122006.GA22259@in.ibm.com> <425F1F90.1010405@us.ibm.com>
- Reply-to: prasanna at in dot ibm dot com
Hi Jim, Hien,
Please see my comments below.
>+/*
>+ * This function is called from do_exit or do_execv when task tk's stack is
>+ * about to be recycled. Recycle any function-return probe instances
>+ * associated with this task. These represent probed functions that have
>+ * been called but may never return.
>+ */
>+void kprobe_flush_task(struct task_struct *tk)
>+{
>+ unsigned long flags = 0;
>+ struct kretprobe_instance *ri;
>+ struct task_struct *tsk;
>+ struct hlist_head *head;
>+ struct hlist_node *node;
>+
>+ if (!arch_supports_kretprobes) {
>+ return;
>+ }
>+ spin_lock_irqsave(&kprobe_lock, flags);
>+ head = &kretprobe_inst_table[hash_ptr(tk, RPROBE_HASH_BITS)];
>+ hlist_for_each_entry(ri, node, head, hlist) {
>+ tsk = arch_get_kprobe_task(ri->stack_addr);
>+ if (tsk == tk) {
>+ /* Put the original return address back into stack */
>+ *((unsigned long *)(ri->stack_addr)) = (unsigned long) ri->ret_addr;
>+ hlist_del_rcu(&ri->hlist);
>+ recycle_kretprobe_instance(ri);
>+ }
>+ }
>+ spin_unlock_irqrestore(&kprobe_lock, flags);
>+}
>+
The current implementation modifies the return address on the stack, hence the
above routine called for every do_exit, do_execv. How much performance impact
will this cause?
>+
>+ rp_tmp = kmalloc(sizeof(struct kretprobe), GFP_KERNEL);
>+ BUG_ON(rp_tmp == NULL);
>+
>+ spin_lock_irqsave(&kprobe_lock, flags);
>+ old_p = get_kprobe(rp->kp.addr);
>+ if (old_p && (old_p->pre_handler == aggr_pre_handler)) {
>+ list_del(&rp->kp.list);
>+ if (list_empty(&old_p->list)) {
>+ remove_kprobe(old_p, flags);
>+ kfree(old_p);
>+ }
>+ } else if (old_p == &rp->kp) {
>+ remove_kprobe(&rp->kp, flags);
>+ }
The patch by Ananth provides multiple probes feature at a given address and
handles all the above cases. Can you pls check if the above checks can be
removed and use multiple probes interface.
Thanks
Prasanna
--
Prasanna S Panchamukhi
Linux Technology Center
India Software Labs, IBM Bangalore
Ph: 91-80-25044636
<prasanna@in.ibm.com>