[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aBoWEydkftHO_q1N@redhat.com>
Date: Tue, 6 May 2025 16:01:45 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: Jiri Olsa <olsajiri@...il.com>
Cc: Peter Zijlstra <peterz@...radead.org>,
Andrii Nakryiko <andrii@...nel.org>, bpf@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org,
x86@...nel.org, Song Liu <songliubraving@...com>,
Yonghong Song <yhs@...com>,
John Fastabend <john.fastabend@...il.com>,
Hao Luo <haoluo@...gle.com>, Steven Rostedt <rostedt@...dmis.org>,
Masami Hiramatsu <mhiramat@...nel.org>,
Alan Maguire <alan.maguire@...cle.com>,
David Laight <David.Laight@...lab.com>,
Thomas Weißschuh <thomas@...ch.de>,
Ingo Molnar <mingo@...nel.org>
Subject: Re: [PATCH perf/core 03/22] uprobes: Move ref_ctr_offset update out
of uprobe_write_opcode
I'm on PTO and traveling until May 15 without my working laptop, can't read
the code.
Quite possibly I am wrong, but let me try to recall what this code does...
- So. uprobe_register() succeeds and changes ref_ctr from 0 to 1.
- uprobe_unregister() fails but decrements ref_ctr back to zero. Because the
"Revert back reference counter if instruction update failed" logic doesn't
apply if is_register is true.
Since uprobe_unregister() fails, this uprobe won't be removed. IIRC, we even
have the warning about that.
- another uprobe_register() comes and re-uses the same uprobe. In this case
install_breakpoint() will do nothing, ref_ctr won't be updated (right ?)
- uprobe_unregister() is called again and this time it succeeds. In this case
ref_ctr is changed from 0 to -1. IIRC, we even have some warning for this
case.
No?
Sorry, I can't check my thinking until I return.
Oleg.
On 05/06, Jiri Olsa wrote:
>
> On Mon, Apr 28, 2025 at 12:51:57PM +0200, Jiri Olsa wrote:
> > On Sun, Apr 27, 2025 at 04:13:35PM +0200, Oleg Nesterov wrote:
>
> SNIP
>
> > >
> > > -------------------------------------------------------------------------------
> > > OTOH, I think that the current logic is not really correct too,
> > >
> > > /* Revert back reference counter if instruction update failed. */
> > > if (ret < 0 && is_register && ref_ctr_updated)
> > > update_ref_ctr(uprobe, mm, -1);
> > >
> > > I think that "Revert back reference counter" logic should not depend on
> > > is_register. Otherwise we can have the unbalanced update_ref_ctr(-1) if
> > > uprobe_unregister() fails, then another uprobe_register() comes at the
> > > same address, and after that uprobe_unregister() succeeds.
> >
> > sounds good to me
>
> actualy after closer look, I don't see how this code could be triggered
> in the first place.. any hint on how to hit such case? like:
>
> - ref_ctr_offset is updated
>
> - we fail somehow
>
> - "if (ret < 0 && ref_ctr_updated)" is true on the way out
>
> thanks,
> jirka
>
Powered by blists - more mailing lists