From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796495328; b=pt0wiQhLfglnLCrZAv7bKgDlDYkyb27LheslCEDZnFH1EzGPy87Q0YdVVk5f92HyKX+7 mCFD9zFHSTEUTI/rQHaH/bgSZ7R3BHKCBu0wsVWeMv56u3NiRzwUo55UzFJkzBUPI2ii0 Yy1cNsFOEVdII0XgFoUorZyt2B0TRX0IZ0CjFSjEONSO08owCNTrL6jifMLw9pJH+o96v 6oUWOJhPyalgxjltiUcoNEwnt62Ielc4wWO5wLMpxjRXWup9DdhkpkJlzI40s5bFyQpXx ebGTfQlDTQM+wAkYlpyf5/Lrl8fsGPhsistR5Ws7NLCfs810FZS9EXT6LneYKNaZtsw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796495328; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=M8fCY17ZaIPrdpWgOMgTQCK8gxs/iP7Vzwv6N/euEeM=; b=MecVq6Sq9QxjM1M+TAlwXQVBX4kbINUxVm1OjJW52js0hJseUKTaFaUx0ifyP7L1KBBH I8/S7A60gA9Jkx7O0pPR/uMpfrM85oXHOyWDPA0+xGaqzsq7K6ZSvO6g4irGWGVSTDm5N l1FxonemolM7m2tYBU26Hnc217LkM5zr3ZgHL9BRLozd6049bxfdIUoMaiw/WSN0VNLEE 8uW4hAYi1hBsfbWpmdx0OPAoJxEbxkX8ND9BRU+X46r1hxe2q9oGhosfC/X9jG/FXAj8+ Ajl0PE9SkoBignD/bIAdWGUnIB3ucjZSyRvsWCbFu+toB+Zi8PiPISgmu5XX5v0KMEQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=H8g+JIGX; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1D99606A31F for ; Sat, 5 Dec 2026 18:28:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=H8g+JIGX Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4EBC51F0092B; Sat, 5 Dec 2026 18:28:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796495328; bh=M8fCY17ZaIPrdpWgOMgTQCK8gxs/iP7Vzwv6N/euEeM=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=H8g+JIGXUJr9FK3Gjaugd/RekLdV2Mjv9HNsvlEWDl0AWeyRo5U2BtfqIVIrVfKox QbjNa5fvDvfNLRyXIQgebi3uKKkc7pXngu2A5HJ2lbprFYz55JyaGjn+qACnLgjn+G k/0dtEqqu++fdSasVLA3xGp2teL8j7tDrQWU22d8z307SfKOojyvWhrG1ARqHenNIu jrnboLQYjwkG2LcEj2/NapkLsJokHPwyCr2B1bMlzicARy4RZxTD/834Dtf9a9TAty LW9/pAsrCpbM0ksYqCu8+9zhzbJbOzV08RnPKz3rE/eaulIuLQi9+37jMPXUhBxsvQ /60yXqqNjPQjA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v5 1/4] rcu-tasks: Make the exit window an SRCU read-side critical section Reply-To: sashiko-reviews@lists.linux.dev To: "Binoy Ravindran" , "Paul E. McKenney" , "Frederic Weisbecker" , "Neeraj Upadhyay" , "Joel Fernandes" , "Josh Triplett" , "Boqun Feng" , "Uladzislau Rezki" , "Steven Rostedt" , "Mathieu Desnoyers" , "Lai Jiangshan" , Zqiang , "Josh Poimboeuf" , "Miroslav Benes" , "Petr Mladek" , "Joe Lawrence" , "Song Liu" , "Ingo Molnar" , "Jiri Kosina" , "Ingo Molnar" , "Peter Zijlstra" , "Juri Lelli" , "Vincent Guittot" , "Dietmar Eggemann" , "Ben Segall" , "Mel Gorman" , "Valentin Schneider" , "K Prateek Nayak" Cc: live-patching@vger.kernel.org, "Yafang Shao" , "Jaidev Shastri" In-Reply-To: <20261205-klp-series-v3-v5-1-3d60c8ea9316@vt.edu> References: <20261205-klp-series-v3-v5-0-3d60c8ea9316@vt.edu> <20261205-klp-series-v3-v5-1-3d60c8ea9316@vt.edu> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 18:28:46 +0000 X-Mailing-List: live-patching@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Low] rcu-tasks: exit SRCU wait APIs undefined if TASKS_RCU_GENERIC && !TASKS_RCU - [Low] rcu-tasks: duplicate rcu_tasks_exit_srcu_idx field bloats task_struct - [Low] rcu-tasks: new exit wait APIs lack locking and exit-tail documentation -- commit 609ca5b3cbc8a384c9da27d490a20f664c23f2de Author: Binoy Ravindran rcu-tasks: Make the exit window an SRCU read-side critical section This commit wraps the do_exit() window between exit_tasks_rcu_start() and exit_tasks_rcu_finish() in a new tasks_rcu_exit_srcu read-side critical section and adds blocking and polled wait helpers for callers that need to wait for exiting tasks to leave that window. > diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h > index 3f74ae6d6e1f2..4442fbe9e9ac8 100644 > --- a/include/linux/rcupdate.h > +++ b/include/linux/rcupdate.h > @@ -204,6 +204,9 @@ void rcu_tasks_rude_torture_stats_print(char *tt, cha= r *tf); > #define rcu_note_voluntary_context_switch(t) rcu_tasks_qs(t, false) > void exit_tasks_rcu_start(void); > void exit_tasks_rcu_finish(void); > +void synchronize_rcu_tasks_exit(void); > +unsigned long start_poll_synchronize_rcu_tasks_exit(void); > +bool poll_state_synchronize_rcu_tasks_exit(unsigned long cookie); > #else /* #ifdef CONFIG_TASKS_RCU_GENERIC */ > #define rcu_tasks_classic_qs(t, preempt) do { } while (0) > #define rcu_tasks_qs(t, preempt) do { } while (0) > @@ -212,6 +215,9 @@ void exit_tasks_rcu_finish(void); > #define synchronize_rcu_tasks synchronize_rcu > static inline void exit_tasks_rcu_start(void) { } > static inline void exit_tasks_rcu_finish(void) { } > +static inline void synchronize_rcu_tasks_exit(void) { } > +static inline unsigned long start_poll_synchronize_rcu_tasks_exit(void) = { return 0; } > +static inline bool poll_state_synchronize_rcu_tasks_exit(unsigned long c= ookie) { return true; } > #endif /* #else #ifdef CONFIG_TASKS_RCU_GENERIC */ [Severity: Low] Can calling these three helpers fail to link when CONFIG_TASKS_RCU_GENERIC is enabled without CONFIG_TASKS_RCU? CONFIG_TASKS_RCU_GENERIC is enabled whenever CONFIG_TASKS_RUDE_RCU is set, so these declarations are exposed as external symbols even when CONFIG_TASKS_RCU is disabled. In kernel/rcu/tasks.h, however, they are only defined under #ifdef CONFIG_TASKS_RCU, with no stubs in the #else branch. Commit "livepatch: Select TASKS_RCU" later in this series avoids the link error for livepatch, but the guard mismatch remains. Guarding the declarations and stubs with #ifdef CONFIG_TASKS_RCU (or adding matching definitions in kernel/rcu/tasks.h) would keep all configs linkable. > diff --git a/include/linux/sched.h b/include/linux/sched.h > index e4f6323d78555..0fe18976d1b40 100644 > --- a/include/linux/sched.h > +++ b/include/linux/sched.h > @@ -963,6 +963,7 @@ struct task_struct { > struct list_head rcu_tasks_holdout_list; > int rcu_tasks_exit_cpu; > struct list_head rcu_tasks_exit_list; > + int rcu_tasks_exit_srcu_idx; > #endif /* #ifdef CONFIG_TASKS_RCU */ [Severity: Low] Could this reuse the existing u8 rcu_tasks_idx field in the same #ifdef CONFIG_TASKS_RCU block instead of adding rcu_tasks_exit_srcu_idx? rcu_tasks_idx has had no remaining users since commit 6b70399f9ef3 ("rcu-tasks: Maintain lists to eliminate RCU-tasks/do_exit() deadlocks"), and __srcu_read_lock() only returns 0 or 1. Appending an int after rcu_tasks_exit_list needlessly grows struct task_struct by 8 bytes (with padding) on 64-bit builds without CONFIG_TASKS_TRACE_RCU and CONFIG_TRIVIAL_PREEMPT_RCU. > diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h > index fcac7361ec51e..57a16d7c33122 100644 > --- a/kernel/rcu/tasks.h > +++ b/kernel/rcu/tasks.h > @@ -1288,6 +1288,32 @@ void rcu_tasks_get_gp_data(int *flags, unsigned lo= ng *gp_seq) > } > EXPORT_SYMBOL_GPL(rcu_tasks_get_gp_data); > =20 > +/* > + * Tasks between exit_tasks_rcu_start() and exit_tasks_rcu_finish() are > + * no longer on the task list, but they still run kernel code. This SRCU > + * domain lets other subsystems wait for every task in that window to > + * leave it. > + */ > +DEFINE_STATIC_SRCU(tasks_rcu_exit_srcu); > + > +/* Wait for all tasks currently in the exit window to leave it. */ > +void synchronize_rcu_tasks_exit(void) > +{ > + synchronize_srcu(&tasks_rcu_exit_srcu); > +} > + > +/* Start waiting for the tasks in the exit window, without blocking. */ > +unsigned long start_poll_synchronize_rcu_tasks_exit(void) > +{ > + return start_poll_synchronize_srcu(&tasks_rcu_exit_srcu); > +} > + > +/* Have all tasks that were in the exit window at @cookie left it? */ > +bool poll_state_synchronize_rcu_tasks_exit(unsigned long cookie) > +{ > + return poll_state_synchronize_srcu(&tasks_rcu_exit_srcu, cookie); > +} [Severity: Low] Should these new public helpers carry kernel-doc covering their calling contexts, locking constraints, and exit-tail semantics, like synchronize_rcu_tasks()? exit_tasks_rcu_start() calls __srcu_read_lock() directly to bypass lockdep (do_exit() checks debug_check_no_locks_held() inside the window). Holding any lock acquired in late do_exit() across synchronize_rcu_tasks_exit() will deadlock silently, as in commit 1612160b9127 ("rcu-tasks: Eliminate deadlocks involving do_exit() and RCU tasks"). In addition, exit_tasks_rcu_finish() runs inside the final preempt_disable() section before lockdep_free_task() and do_task_dead(), so completing this SRCU grace period alone does not guarantee exiting tasks are off the CPU; callers needing that still require a follow-up CPU synchronization step. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205-klp-series= -v3-v5-0-3d60c8ea9316@vt.edu?part=3D1