]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
rcu-tasks: Provide rcu_trace_implies_rcu_gp()
authorPaul E. McKenney <paulmck@kernel.org>
Tue, 12 Mar 2024 00:44:34 +0000 (17:44 -0700)
committerSasha Levin <sashal@kernel.org>
Tue, 26 Mar 2024 22:21:45 +0000 (18:21 -0400)
[ Upstream commit e6c86c513f440bec5f1046539c7e3c6c653842da ]

As an accident of implementation, an RCU Tasks Trace grace period also
acts as an RCU grace period.  However, this could change at any time.
This commit therefore creates an rcu_trace_implies_rcu_gp() that currently
returns true to codify this accident.  Code relying on this accident
must call this function to verify that this accident is still happening.

Reported-by: Hou Tao <houtao@huaweicloud.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Martin KaFai Lau <martin.lau@linux.dev>
Link: https://lore.kernel.org/r/20221014113946.965131-2-houtao@huaweicloud.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Stable-dep-of: 876673364161 ("bpf: Defer the free of inner map when necessary")
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 10108826191ab30388e8ae9d54505a628f78a7ec)
Signed-off-by: Robert Kolchmeyer <rkolchmeyer@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/linux/rcupdate.h
kernel/rcu/tasks.h

index 8716a170635183830ccfc270b03ffa90eb7ed0f3..0122c03da24af64587d1cbc0867cf018668c639a 100644 (file)
@@ -201,6 +201,18 @@ static inline void exit_tasks_rcu_stop(void) { }
 static inline void exit_tasks_rcu_finish(void) { }
 #endif /* #else #ifdef CONFIG_TASKS_RCU_GENERIC */
 
+/**
+ * rcu_trace_implies_rcu_gp - does an RCU Tasks Trace grace period imply an RCU grace period?
+ *
+ * As an accident of implementation, an RCU Tasks Trace grace period also
+ * acts as an RCU grace period.  However, this could change at any time.
+ * Code relying on this accident must call this function to verify that
+ * this accident is still happening.
+ *
+ * You have been warned!
+ */
+static inline bool rcu_trace_implies_rcu_gp(void) { return true; }
+
 /**
  * cond_resched_tasks_rcu_qs - Report potential quiescent states to RCU
  *
index c5624ab0580c5e95ed481e86580ee895dde96813..105fdc2bb004cfc65872d3ca5c6e86dd5b8bb94e 100644 (file)
@@ -1015,6 +1015,8 @@ static void rcu_tasks_trace_postscan(struct list_head *hop)
 
        // Wait for late-stage exiting tasks to finish exiting.
        // These might have passed the call to exit_tasks_rcu_finish().
+
+       // If you remove the following line, update rcu_trace_implies_rcu_gp()!!!
        synchronize_rcu();
        // Any tasks that exit after this point will set ->trc_reader_checked.
 }