From patchwork Fri Oct 4 14:58:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 13822533 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5BFC1AA79B; Fri, 4 Oct 2024 15:00:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=167.114.26.122 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728054028; cv=none; b=ptOaUggtYw3zaIkeLT/HUA7no+Fkzx3l4h2G4ZL7/cAaDf5ZWIW5xe78woiaR2mgH5wZmVeE2vb1SBqR/ZX5dL+d08P0AXYW8HY8NT3zXpk8oLWbO6guCYfVF5JhP+BAo3jSVpcbp0zQGIavON7E29xPXSSaU/xUhOUlxmm/FqQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728054028; c=relaxed/simple; bh=q9fuqUVszf04BYf81tv1tIWkcRZj+Rh78Bl7h//T8fM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BJc1/flGWpg5a4VDYjT87w5HX5YrqeU4Yhz01Mupng1MZlqUVFTFaHJF+dKJJkPAp504jll9Dy06UlVIatM1nAwjsXI+/UPprwC1CZL/8C0qHMGS/5S3n7rf7UhAJv2DTOyj9TJOI2FpLm+15rYyxdP5girOMFxBdjCB6vmIlMA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=efficios.com; spf=pass smtp.mailfrom=efficios.com; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b=dvBKmKwj; arc=none smtp.client-ip=167.114.26.122 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=efficios.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=efficios.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b="dvBKmKwj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1728054025; bh=q9fuqUVszf04BYf81tv1tIWkcRZj+Rh78Bl7h//T8fM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dvBKmKwj6F/Ch+gyeqBp/6a6DNOv5mNlzi8uoysTYqB8IAAiJ1gQx564FALMMzQUL ytGYuqoZ6ox8zftVgzdcaCy9WV5GpPad/KynXbJPFDRTFFv3jE70kqPFSnWHGakx9f d0IDpdQL64kdyZ4ePNDvXIJfyD8m8xgqfhGxF2Ld71KeyTBWm+MpZhNGh1yj/wK9dL ig56oqimpI6XC8ngVCyzH0tb6VoR/c50G2Ze18GAqY9hi/1wKZ5xFjKOwB3ZevDNfa x5SXYltfvyqJ+P8QsPkZfc3AU/qIbndVNu4GdaW5WjbQRA6ahrHSyQkKydVjMznsvc vzYv3TpZljW0Q== Received: from thinkos.internal.efficios.com (96-127-217-162.qc.cable.ebox.net [96.127.217.162]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4XKsD86QnhzLN5; Fri, 4 Oct 2024 11:00:24 -0400 (EDT) From: Mathieu Desnoyers To: Steven Rostedt , Masami Hiramatsu Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , Peter Zijlstra , Alexei Starovoitov , Yonghong Song , "Paul E . McKenney" , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Namhyung Kim , Andrii Nakryiko , bpf@vger.kernel.org, Joel Fernandes , linux-trace-kernel@vger.kernel.org, Michael Jeanson Subject: [PATCH v3 5/8] tracing: Allow system call tracepoints to handle page faults Date: Fri, 4 Oct 2024 10:58:15 -0400 Message-Id: <20241004145818.1726671-6-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241004145818.1726671-1-mathieu.desnoyers@efficios.com> References: <20241004145818.1726671-1-mathieu.desnoyers@efficios.com> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use Tasks Trace RCU to protect iteration of system call enter/exit tracepoint probes to allow those probes to handle page faults. In preparation for this change, all tracers registering to system call enter/exit tracepoints should expect those to be called with preemption enabled. This allows tracers to fault-in userspace system call arguments such as path strings within their probe callbacks. Signed-off-by: Mathieu Desnoyers Cc: Michael Jeanson Cc: Steven Rostedt Cc: Masami Hiramatsu Cc: Peter Zijlstra Cc: Alexei Starovoitov Cc: Yonghong Song Cc: Paul E. McKenney Cc: Ingo Molnar Cc: Arnaldo Carvalho de Melo Cc: Mark Rutland Cc: Alexander Shishkin Cc: Namhyung Kim Cc: Andrii Nakryiko Cc: bpf@vger.kernel.org Cc: Joel Fernandes --- include/linux/tracepoint.h | 12 ++++++++++-- init/Kconfig | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h index 014790495ad8..cefd44b7c91f 100644 --- a/include/linux/tracepoint.h +++ b/include/linux/tracepoint.h @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -107,6 +108,7 @@ void for_each_tracepoint_in_module(struct module *mod, #ifdef CONFIG_TRACEPOINTS static inline void tracepoint_synchronize_unregister(void) { + synchronize_rcu_tasks_trace(); synchronize_rcu(); } #else @@ -204,11 +206,17 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p) if (!(cond)) \ return; \ \ - preempt_disable_notrace(); \ + if (syscall) \ + rcu_read_lock_trace(); \ + else \ + preempt_disable_notrace(); \ \ __DO_TRACE_CALL(name, TP_ARGS(args)); \ \ - preempt_enable_notrace(); \ + if (syscall) \ + rcu_read_unlock_trace(); \ + else \ + preempt_enable_notrace(); \ } while (0) /* diff --git a/init/Kconfig b/init/Kconfig index fbd0cb06a50a..eedd0064fb36 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1984,6 +1984,7 @@ config BINDGEN_VERSION_TEXT # config TRACEPOINTS bool + select TASKS_TRACE_RCU source "kernel/Kconfig.kexec"