[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <172285896306.2215.17089314186188760223.tip-bot2@tip-bot2>
Date: Mon, 05 Aug 2024 11:56:03 -0000
From: "tip-bot2 for Oleg Nesterov" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Oleg Nesterov <oleg@...hat.com>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>, Jiri Olsa <jolsa@...nel.org>,
Andrii Nakryiko <andrii@...nel.org>,
"Masami Hiramatsu (Google)" <mhiramat@...nel.org>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: perf/core] uprobes: change uprobe_register() to use
uprobe_unregister() instead of __uprobe_unregister()
The following commit has been merged into the perf/core branch of tip:
Commit-ID: bb18c5de1c288050ef8bd4af4ca16896ad4cd3fc
Gitweb: https://git.kernel.org/tip/bb18c5de1c288050ef8bd4af4ca16896ad4cd3fc
Author: Oleg Nesterov <oleg@...hat.com>
AuthorDate: Thu, 01 Aug 2024 15:27:39 +02:00
Committer: Peter Zijlstra <peterz@...radead.org>
CommitterDate: Fri, 02 Aug 2024 11:30:32 +02:00
uprobes: change uprobe_register() to use uprobe_unregister() instead of __uprobe_unregister()
If register_for_each_vma() fails uprobe_register() can safely drop
uprobe->register_rwsem and use uprobe_unregister(). There is no worry
about the races with another register/unregister, consumer_add() was
already called so this case doesn't differ from _unregister() right
after the successful _register().
Yes this means the extra up_write() + down_write(), but this is the
slow and unlikely case anyway.
Signed-off-by: Oleg Nesterov <oleg@...hat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Reviewed-by: Jiri Olsa <jolsa@...nel.org>
Acked-by: Andrii Nakryiko <andrii@...nel.org>
Acked-by: "Masami Hiramatsu (Google)" <mhiramat@...nel.org>
Link: https://lore.kernel.org/r/20240801132739.GA8809@redhat.com
---
kernel/events/uprobes.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index b33f139..eacf287 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -1174,16 +1174,18 @@ struct uprobe *uprobe_register(struct inode *inode,
if (likely(uprobe_is_active(uprobe))) {
consumer_add(uprobe, uc);
ret = register_for_each_vma(uprobe, uc);
- if (ret)
- __uprobe_unregister(uprobe, uc);
}
up_write(&uprobe->register_rwsem);
put_uprobe(uprobe);
- if (unlikely(ret == -EAGAIN))
- goto retry;
+ if (ret) {
+ if (unlikely(ret == -EAGAIN))
+ goto retry;
+ uprobe_unregister(uprobe, uc);
+ return ERR_PTR(ret);
+ }
- return ret ? ERR_PTR(ret) : uprobe;
+ return uprobe;
}
EXPORT_SYMBOL_GPL(uprobe_register);
Powered by blists - more mailing lists