mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Anton Arapov <anton@redhat.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Josh Stone <jistone@redhat.com>, Frank Eigler <fche@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@elte.hu>,
	Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
	adrian.m.negreanu@intel.com, Torsten.Polle@gmx.de
Subject: Re: [PATCH 5/7] uretprobes: return probe exit, invoke handlers
Date: Mon, 25 Mar 2013 16:49:40 +0100	[thread overview]
Message-ID: <20130325154940.GA2178@bandura.brq.redhat.com> (raw)
In-Reply-To: <20130324162817.GD17037@redhat.com>

On Sun, Mar 24, 2013 at 05:28:17PM +0100, Oleg Nesterov wrote:
> On 03/22, Anton Arapov wrote:
> >
> > +static void handle_uretprobe(struct xol_area *area, struct pt_regs *regs)
> > +{
> > +	struct uprobe_task *utask;
> > +	struct return_instance *ri, *tmp;
> > +	unsigned long prev_ret_vaddr;
> > +
> > +	utask = get_utask();
> > +	if (!utask)
> > +		return;
> > +
> > +	ri = utask->return_instances;
> > +	if (!ri)
> > +		return;
> Hmm. I am wondering what should the caller (handle_swbp) do in this
> case...
Not sure as well... Will look into it.

> > +
> > +	instruction_pointer_set(regs, ri->orig_ret_vaddr);
> > +
> > +	while (ri) {
> > +		if (ri->uprobe->consumers)
> > +			handler_uretprobe_chain(ri->uprobe, regs);
> I'd suggest to either remove this check or move it into
> handler_uretprobe_chain().
> 
> > +
> > +		put_uprobe(ri->uprobe);
> > +		tmp = ri;
> > +		prev_ret_vaddr = tmp->orig_ret_vaddr;
> For what? It seems that prev_ret_vaddr should be simply killed.
Both above are leftovers I've overlooked before git-send... :(

> > +		ri = ri->next;
> > +		kfree(tmp);
> Another case when you do put_uprobe/kfree using the different vars...
> Once again, the code is correct but imho a bit confusing.
I agree will change it and align with the code in uprobe_free_utask()

> > +		if (!ri || ri->dirty == false) {
> > +			/*
> > +			 * This is the first return uprobe (chronologically)
> > +			 * pushed for this particular instance of the probed
> > +			 * function.
> > +			 */
> > +			utask->return_instances = ri;
> > +			return;
> > +		}
> 
> Else? we simply return without updating ->return_instances which
> points to the freed element(s) ? OK, this must not be possible but
> this is not obvious...
> 
> And the fact you check "ri != NULL" twice doesn't look very nice.
> We already checked ri != NULL before while(ri), we have to do this
> anyway for instruction_pointer_set(). Perhaps do/whild or even
> for (;;) + break would be more clean. But this is minor.
> 
> 
> I am not sure the logic is correct. OK. suppose that
> ->return_instances = NULL.
> 
> The task hits the rp breakoint. After that
> 
> 	return_instances -> { .dirty = false }
> 
> The task hits the same breakoint before return (tail call), now
> we have
> 
> 	return_instances -> { .dirty = true } -> { .dirty = false }
> 
> Then it returns and handle_uretprobe() should unwind the whole stack.
> But, it seems, the main loop will stop after the 1st iteration?
> 
> Ignoring the fact you need put_uprobe/kfree, it seems that we should
> do something like this,
> 
> 	do {
> 		handler_uretprobe_chain(...);
> 
> 		if (!ri->dirty)	// not chained
> 			break;
> 
> 		ri = ri->next;		
> 	} while (ri);
> 
> 	utask->return_instances = ri;
> No?

Oleg, Do you mean 

 	do {
 		handler_uretprobe_chain(...);

        ri = ri->next;		

 		if (!ri->dirty)	// not chained
 			break;
  	} while (ri);
 
 	utask->return_instances = ri;

otherwise we stuck with the first instance in stack.
...and perhaps for(;;) would be 'more beautiful' here?


> 
> > @@ -1631,11 +1681,19 @@ static void handle_swbp(struct pt_regs *regs)
> >  {
> >  	struct uprobe *uprobe;
> >  	unsigned long bp_vaddr;
> > +	struct xol_area *area;
> >  	int uninitialized_var(is_swbp);
> >  
> >  	bp_vaddr = uprobe_get_swbp_addr(regs);
> > -	uprobe = find_active_uprobe(bp_vaddr, &is_swbp);
> > +	area = get_xol_area();
> 
> Why?
> No, we do not want this heavy and potentially unnecessary get_xol_area(),
>
> > +	if (area) {
> 
> Just check uprobes_state.xol_area != NULL instead. If it is NULL
> we simply should not call handle_uretprobe().
> 
> Or perhaps get_trampoline_vaddr() should simply return -1 if
> ->xol_area == NULL.

right.

> 
> > +		if (bp_vaddr == get_trampoline_vaddr(area)) {
> 
> I just noticed get_trampoline_vaddr() takes an argument... It should
> not, I think.
> 

  Yes, at this place we must have *area allocated. And I agree with
your arguments, I will remove *area argument from
get_trampoline_vaddr() and handle_uretprobe() it makes sense to me as
well.

Anton

> Oleg.
> 

  parent reply	other threads:[~2013-03-25 15:50 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-22 13:08 [PATCH 0/7] uretprobes: return probes implementation Anton Arapov
2013-03-22 13:08 ` [PATCH 1/7] uretprobes: preparation patch Anton Arapov
2013-03-23 17:42   ` Oleg Nesterov
2013-03-22 13:08 ` [PATCH 2/7] uretprobes: extract fill_page() and trampoline implementation Anton Arapov
2013-03-24 14:41   ` Oleg Nesterov
2013-03-24 18:20     ` [PATCH 0/5] kmap cleanups for uretprobes (Was: extract fill_page() and trampoline implementation) Oleg Nesterov
2013-03-24 18:21       ` [PATCH 1/5] uprobes: Turn copy_opcode() into copy_from_page() Oleg Nesterov
2013-03-25 10:30         ` Anton Arapov
2013-03-26 11:59         ` Srikar Dronamraju
2013-03-24 18:21       ` [PATCH 2/5] uprobes: Change __copy_insn() to use copy_from_page() Oleg Nesterov
2013-03-25 10:31         ` Anton Arapov
2013-03-26 12:00         ` Srikar Dronamraju
2013-03-24 18:21       ` [PATCH 3/5] uprobes: Kill the unnecesary filp != NULL check in __copy_insn() Oleg Nesterov
2013-03-25 10:31         ` Anton Arapov
2013-03-26 12:00         ` Srikar Dronamraju
2013-03-24 18:21       ` [PATCH 4/5] uprobes: Introduce copy_to_page() Oleg Nesterov
2013-03-25 10:31         ` Anton Arapov
2013-03-26 12:02         ` Srikar Dronamraju
2013-03-24 18:21       ` [PATCH 5/5] uprobes: Change write_opcode() to use copy_*page() Oleg Nesterov
2013-03-25 10:31         ` Anton Arapov
2013-03-26 11:59         ` Srikar Dronamraju
2013-03-25 10:30       ` [PATCH 0/5] kmap cleanups for uretprobes (Was: extract fill_page() and trampoline implementation) Anton Arapov
2013-03-25 11:58     ` [PATCH 2/7] uretprobes: extract fill_page() and trampoline implementation Oleg Nesterov
2013-03-22 13:09 ` [PATCH 3/7] uretprobes/x86: hijack return address Anton Arapov
2013-03-24 14:59   ` Oleg Nesterov
2013-03-22 13:09 ` [PATCH 4/7] uretprobes: return probe entry, prepare_uretprobe() Anton Arapov
2013-03-22 15:02   ` Oleg Nesterov
2013-03-26 12:26     ` Anton Arapov
2013-03-26 14:34       ` Oleg Nesterov
2013-03-23 17:46   ` Oleg Nesterov
2013-03-24 15:26   ` Oleg Nesterov
2013-03-25 15:51     ` Anton Arapov
2013-03-26  8:45     ` Anton Arapov
2013-03-26  8:50       ` Anton Arapov
2013-03-22 13:09 ` [PATCH 5/7] uretprobes: return probe exit, invoke handlers Anton Arapov
2013-03-24 16:28   ` Oleg Nesterov
2013-03-25 12:31     ` Oleg Nesterov
2013-03-25 15:49     ` Anton Arapov [this message]
2013-03-25 16:38       ` Oleg Nesterov
2013-03-26  8:36         ` Anton Arapov
2013-03-22 13:09 ` [PATCH 6/7] uretprobes: limit the depth of return probe nestedness Anton Arapov
2013-03-24 16:54   ` Oleg Nesterov
2013-03-22 13:09 ` [PATCH 7/7] uretprobes: implemented, thus remove -ENOSYS Anton Arapov
2013-03-22 13:13   ` Anton Arapov
2013-03-22 13:09 ` [PATCH 7/7] uretprobes: remove -ENOSYS as return probes implemented Anton Arapov
2013-03-22 15:10 ` [PATCH 0/7] uretprobes: return probes implementation Oleg Nesterov
2013-03-22 21:40   ` Josh Stone
2013-03-23  6:43     ` Anton Arapov
2013-03-23 18:04       ` Oleg Nesterov
2013-03-23 17:56     ` Oleg Nesterov

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=20130325154940.GA2178@bandura.brq.redhat.com \
    --to=anton@redhat.com \
    --cc=Torsten.Polle@gmx.de \
    --cc=adrian.m.negreanu@intel.com \
    --cc=ananth@in.ibm.com \
    --cc=fche@redhat.com \
    --cc=jistone@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=srikar@linux.vnet.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®