[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240801132744.GA8814@redhat.com>
Date: Thu, 1 Aug 2024 15:27:44 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: andrii@...nel.org, mhiramat@...nel.org, peterz@...radead.org
Cc: jolsa@...nel.org, rostedt@...dmis.org, linux-kernel@...r.kernel.org,
linux-trace-kernel@...r.kernel.org
Subject: [PATCH v4 8/9] uprobes: fold __uprobe_unregister() into
uprobe_unregister()
Fold __uprobe_unregister() into its single caller, uprobe_unregister().
A separate patch to simplify the next change.
Signed-off-by: Oleg Nesterov <oleg@...hat.com>
Acked-by: Andrii Nakryiko <andrii@...nel.org>
Acked-by: Masami Hiramatsu (Google) <mhiramat@...nel.org>
Reviewed-by: Jiri Olsa <jolsa@...nel.org>
---
kernel/events/uprobes.c | 25 ++++++++++---------------
1 file changed, 10 insertions(+), 15 deletions(-)
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 5ea0aabe8774..c06e1a5f1783 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -1085,20 +1085,6 @@ register_for_each_vma(struct uprobe *uprobe, struct uprobe_consumer *new)
return err;
}
-static void
-__uprobe_unregister(struct uprobe *uprobe, struct uprobe_consumer *uc)
-{
- int err;
-
- if (WARN_ON(!consumer_del(uprobe, uc)))
- return;
-
- err = register_for_each_vma(uprobe, NULL);
- /* TODO : cant unregister? schedule a worker thread */
- if (!uprobe->consumers && !err)
- delete_uprobe(uprobe);
-}
-
/**
* uprobe_unregister - unregister an already registered probe.
* @uprobe: uprobe to remove
@@ -1106,9 +1092,18 @@ __uprobe_unregister(struct uprobe *uprobe, struct uprobe_consumer *uc)
*/
void uprobe_unregister(struct uprobe *uprobe, struct uprobe_consumer *uc)
{
+ int err;
+
get_uprobe(uprobe);
down_write(&uprobe->register_rwsem);
- __uprobe_unregister(uprobe, uc);
+ if (WARN_ON(!consumer_del(uprobe, uc)))
+ err = -ENOENT;
+ else
+ err = register_for_each_vma(uprobe, NULL);
+
+ /* TODO : cant unregister? schedule a worker thread */
+ if (!err && !uprobe->consumers)
+ delete_uprobe(uprobe);
up_write(&uprobe->register_rwsem);
put_uprobe(uprobe);
}
--
2.25.1.362.g51ebf55
Powered by blists - more mailing lists