Thread (57 messages) flat view 57 messages, 5 authors, 2024-09-10

Re: [PATCH v2] tracing/uprobe: Add missing PID filter for uretprobe

From: Jiri Olsa <hidden>
Date: 2024-08-27 14:41:56
Also in: bpf

On Tue, Aug 27, 2024 at 04:26:08PM +0200, Oleg Nesterov wrote:
On 08/27, Jiri Olsa wrote:
quoted
On Tue, Aug 27, 2024 at 12:40:52PM +0200, Oleg Nesterov wrote:
quoted
 static bool
 uprobe_multi_link_filter(struct uprobe_consumer *con, struct mm_struct *mm)
 {
 	struct bpf_uprobe *uprobe;
+	struct task_struct *task, *t;
+	bool ret = false;

 	uprobe = container_of(con, struct bpf_uprobe, consumer);
-	return uprobe->link->task->mm == mm;
+	task = uprobe->link->task;
+
+	rcu_read_lock();
+	for_each_thread(task, t) {
+		struct mm_struct *mm = READ_ONCE(t->mm);
+		if (mm) {
+			ret = t->mm == mm;
+			break;
+		}
+	}
+	rcu_read_unlock();
that seems expensive if there's many threads
many threads with ->mm == NULL? In the likely case for_each_thread()
stops after the first t->mm check.
aah the mm will be the same.. right, nice

thanks,
jirka
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help