public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Oleg Nesterov <oleg@redhat.com>,
	andrii@kernel.org, mhiramat@kernel.org, jolsa@kernel.org,
	rostedt@goodmis.org, linux-kernel@vger.kernel.org,
	linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v2 5/5] uprobes: make uprobe_register() return struct uprobe *
Date: Wed, 31 Jul 2024 18:56:14 +0200	[thread overview]
Message-ID: <20240731165614.GI33588@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <CAEf4Bza1_njsVUad8so9EFxy8VmJsTfzaaAahBYFtOqdF1HAjA@mail.gmail.com>

On Wed, Jul 31, 2024 at 09:18:00AM -0700, Andrii Nakryiko wrote:
> On Mon, Jul 29, 2024 at 6:45 AM Oleg Nesterov <oleg@redhat.com> wrote:
> >
> > This way uprobe_unregister() and uprobe_apply() can use "struct uprobe *"
> > rather than inode + offset. This simplifies the code and allows to avoid
> > the unnecessary find_uprobe() + put_uprobe() in these functions.
> >
> > TODO: uprobe_unregister() still needs get_uprobe/put_uprobe to ensure that
> > this uprobe can't be freed before up_write(&uprobe->register_rwsem).
> >
> > Signed-off-by: Oleg Nesterov <oleg@redhat.com>
> > Acked-by: Andrii Nakryiko <andrii@kernel.org>
> > ---
> >  include/linux/uprobes.h     | 15 +++++-----
> >  kernel/events/uprobes.c     | 56 +++++++++++++++----------------------
> >  kernel/trace/bpf_trace.c    | 25 ++++++++---------
> >  kernel/trace/trace_uprobe.c | 26 ++++++++---------
> >  4 files changed, 55 insertions(+), 67 deletions(-)
> >
> 
> You'll need something like below to not break our bpf_testmod. And
> please send pull patch sets, not individually updated patches, it's a
> PITA to deal with. Thanks!

Do I stuff this on top of Oleg's patch or do you want me to fold it in
one of them?

> commit 9f739a9997ab833394196459fa7e6dd4d13dd48b (HEAD -> uprobes-oleg-cleanups)
> Author: Andrii Nakryiko <andrii@kernel.org>
> Date:   Wed Jul 31 09:15:46 2024 -0700
> 
>     uprobes: fix bpf_testmod after uprobe_register/uprobe_unregister API change
> 
>     Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
> 
> diff --git a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
> b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
> index 5f152afdec2f..73a6b041bcce 100644
> --- a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
> +++ b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
> @@ -431,6 +431,7 @@ uprobe_ret_handler(struct uprobe_consumer *self,
> unsigned long func,
>  }
> 
>  struct testmod_uprobe {
> +       struct uprobe *uprobe;
>         struct path path;
>         loff_t offset;
>         struct uprobe_consumer consumer;
> @@ -458,12 +459,14 @@ static int testmod_register_uprobe(loff_t offset)
>         if (err)
>                 goto out;
> 
> -       err = uprobe_register(d_real_inode(uprobe.path.dentry),
> -                             offset, 0, &uprobe.consumer);
> -       if (err)
> +       uprobe.uprobe = uprobe_register(d_real_inode(uprobe.path.dentry),
> +                                       offset, 0, &uprobe.consumer);
> +       if (IS_ERR(uprobe.uprobe)) {
>                 path_put(&uprobe.path);
> -       else
> +               uprobe.uprobe = NULL;
> +       } else {
>                 uprobe.offset = offset;
> +       }
> 
>  out:
>         mutex_unlock(&testmod_uprobe_mutex);
> @@ -474,10 +477,10 @@ static void testmod_unregister_uprobe(void)
>  {
>         mutex_lock(&testmod_uprobe_mutex);
> 
> -       if (uprobe.offset) {
> -               uprobe_unregister(d_real_inode(uprobe.path.dentry),
> -                                 uprobe.offset, &uprobe.consumer);
> +       if (uprobe.uprobe) {
> +               uprobe_unregister(uprobe.uprobe, &uprobe.consumer);
>                 uprobe.offset = 0;
> +               uprobe.uprobe = NULL;
>         }
> 
>         mutex_unlock(&testmod_uprobe_mutex);
> 
> 
> [...]

  reply	other threads:[~2024-07-31 16:56 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-29 13:44 [PATCH v2 0/5] uprobes: misc cleanups/simplifications Oleg Nesterov
2024-07-29 13:45 ` [PATCH v2 1/5] uprobes: document the usage of mm->mmap_lock Oleg Nesterov
2024-07-29 13:45 ` [PATCH v2 2/5] uprobes: is_trap_at_addr: don't use get_user_pages_remote() Oleg Nesterov
2024-07-29 13:45 ` [PATCH v2 3/5] uprobes: simplify error handling for alloc_uprobe() Oleg Nesterov
2024-07-29 13:45 ` [PATCH v2 4/5] uprobes: kill uprobe_register_refctr() Oleg Nesterov
2024-07-31  5:37   ` Masami Hiramatsu
2024-07-31  7:56     ` Oleg Nesterov
2024-07-31  8:10   ` [PATCH v3 " Oleg Nesterov
2024-07-29 13:45 ` [PATCH v2 5/5] uprobes: make uprobe_register() return struct uprobe * Oleg Nesterov
2024-07-31  5:39   ` Masami Hiramatsu
2024-07-31  7:44     ` Oleg Nesterov
2024-07-31 16:18   ` Andrii Nakryiko
2024-07-31 16:56     ` Peter Zijlstra [this message]
2024-07-31 17:01       ` Andrii Nakryiko
2024-07-31 17:05         ` Peter Zijlstra
2024-07-31 17:12           ` Andrii Nakryiko
2024-07-31 17:24             ` Oleg Nesterov
2024-07-31 17:17           ` Oleg Nesterov
2024-08-01 13:10             ` Peter Zijlstra
2024-08-01 11:32     ` Jiri Olsa
2024-08-01 12:00       ` Oleg Nesterov
2024-08-01 12:15         ` Jiri Olsa
2024-08-01 12:26           ` Oleg Nesterov
2024-08-01 13:07             ` Jiri Olsa
2024-07-30  7:42 ` [PATCH v2 0/5] uprobes: misc cleanups/simplifications Jiri Olsa

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=20240731165614.GI33588@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=oleg@redhat.com \
    --cc=rostedt@goodmis.org \
    /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