From nobody Wed Nov 27 18:46:18 2024 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 330F4210FB; Wed, 9 Oct 2024 01:09:29 +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=1728436170; cv=none; b=oXLMRH/qdpPWINC55itX+3SlSdromOKvb4i4N1U/cJbBeOor/Tp1RcJUF/j0WzDSJ9O04usElQYkRA15iZRGq5yy/H+yOeo1Dx4wA/qBke0Y1tGbLqHpAsj5QAPPsE4XDvTxqeplJFkwuqpMVEOFqwAxv/Gi2DSm8WwiRB2Z1T4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728436170; c=relaxed/simple; bh=1mOKEbciFJb9rPglGELW2LAK6FZ88FFDOt+9NpyFU4I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YgXvO6ww9JGJcQkkCa+B8lVHIF98t/rBm4foJcIqMv4R+lis9n9ZvKe7kxzsXHhmRFLTEVB0lqxEFXu/LgKK7wGz0gytIAKoNHwYzarYyaup66fdgl87XjJphlWW/XpK8HWTXpwD+qTe6zxD6JL5+PM+dGuRhLfihV08eRwWA/4= 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=xlwJzY2z; 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="xlwJzY2z" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1728436167; bh=1mOKEbciFJb9rPglGELW2LAK6FZ88FFDOt+9NpyFU4I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xlwJzY2ztG+s1107HMTyMBhiwDxKDuYNOvWZQgIiDjtayco8PKMmjV5bRs/WQq9tz 4O/m7XDVNH6oRTAxKxg6Y1iZ0wv9l3Nw5D8zvMNVBzwsoISXEiQm5C+viV9/etYuKO 6RnViH25wW4240pH2RSz3CQaUgFrLWRuh+3xlNach45mLuJTJlRD3lzHSa8G/ePGvY ITSAnGRz1bSFQ6eOWeKzIDNn5iyb2l4s535lwoJiZBFe38vuPUOaV/leugAkA08MzN odrr59Ush6PgHzvjN9x2Du4YRwFiLJB0oBcGn1xw75o/+wiBXQ26ISjNbTAHHb14jR WSFAEyz34mTCg== Received: from thinkos.internal.efficios.com (unknown [IPv6:2606:6d00:100:4000:cacb:9855:de1f:ded2]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4XNZY31l2zzS0R; Tue, 8 Oct 2024 21:09:27 -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 v4 5/8] tracing: Allow system call tracepoints to handle page faults Date: Tue, 8 Oct 2024 21:07:15 -0400 Message-Id: <20241009010718.2050182-6-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241009010718.2050182-1-mathieu.desnoyers@efficios.com> References: <20241009010718.2050182-1-mathieu.desnoyers@efficios.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- Changes since v3: - Add comment above __DO_TRACE() which describes the preempt off vs Tasks Trace RCU for syscall=3D0 vs syscall=3D1. --- include/linux/tracepoint.h | 18 ++++++++++++++++-- init/Kconfig | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h index 76e441b39a96..0dc67fad706c 100644 --- a/include/linux/tracepoint.h +++ b/include/linux/tracepoint.h @@ -17,6 +17,7 @@ #include #include #include +#include #include #include =20 @@ -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 @@ -196,6 +198,12 @@ static inline struct tracepoint *tracepoint_ptr_deref(= tracepoint_ptr_t *p) /* * it_func[0] is never NULL because there is at least one element in the a= rray * when the array itself is non NULL. + * + * With @syscall=3D0, the tracepoint callback array dereference is + * protected by disabling preemption. + * With @syscall=3D1, the tracepoint callback array dereference is + * protected by Tasks Trace RCU, which allows probes to handle page + * faults. */ #define __DO_TRACE(name, args, cond, syscall) \ do { \ @@ -204,11 +212,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) =20 /* diff --git a/init/Kconfig b/init/Kconfig index 530a382ee0fe..4ac3d1b48278 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1985,6 +1985,7 @@ config BINDGEN_VERSION_TEXT # config TRACEPOINTS bool + select TASKS_TRACE_RCU =20 source "kernel/Kconfig.kexec" =20 --=20 2.39.2