Skip to content

Commit 25246fc

Browse files
committed
rcu-tasks: Allow standalone use of TASKS_{TRACE_,}RCU
This commit allows TASKS_TRACE_RCU to be used independently of TASKS_RCU and vice versa. [ paulmck: Fix conditional compilation per kbuild test robot feedback. ] Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 7e0669c commit 25246fc

File tree

1 file changed

+30
-24
lines changed

1 file changed

+30
-24
lines changed

kernel/rcu/tasks.h

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -244,27 +244,6 @@ static void __init rcu_spawn_tasks_kthread_generic(struct rcu_tasks *rtp)
244244
smp_mb(); /* Ensure others see full kthread. */
245245
}
246246

247-
/* Do the srcu_read_lock() for the above synchronize_srcu(). */
248-
void exit_tasks_rcu_start(void) __acquires(&tasks_rcu_exit_srcu)
249-
{
250-
preempt_disable();
251-
current->rcu_tasks_idx = __srcu_read_lock(&tasks_rcu_exit_srcu);
252-
preempt_enable();
253-
}
254-
255-
static void exit_tasks_rcu_finish_trace(struct task_struct *t);
256-
257-
/* Do the srcu_read_unlock() for the above synchronize_srcu(). */
258-
void exit_tasks_rcu_finish(void) __releases(&tasks_rcu_exit_srcu)
259-
{
260-
struct task_struct *t = current;
261-
262-
preempt_disable();
263-
__srcu_read_unlock(&tasks_rcu_exit_srcu, t->rcu_tasks_idx);
264-
preempt_enable();
265-
exit_tasks_rcu_finish_trace(t);
266-
}
267-
268247
#ifndef CONFIG_TINY_RCU
269248

270249
/*
@@ -303,7 +282,9 @@ static void show_rcu_tasks_generic_gp_kthread(struct rcu_tasks *rtp, char *s)
303282
s);
304283
}
305284

306-
#ifdef CONFIG_TASKS_RCU
285+
static void exit_tasks_rcu_finish_trace(struct task_struct *t);
286+
287+
#if defined(CONFIG_TASKS_RCU) || defined(CONFIG_TASKS_TRACE_RCU)
307288

308289
////////////////////////////////////////////////////////////////////////
309290
//
@@ -374,6 +355,10 @@ static void rcu_tasks_wait_gp(struct rcu_tasks *rtp)
374355
rtp->postgp_func(rtp);
375356
}
376357

358+
#endif /* #if defined(CONFIG_TASKS_RCU) || defined(CONFIG_TASKS_TRACE_RCU) */
359+
360+
#ifdef CONFIG_TASKS_RCU
361+
377362
////////////////////////////////////////////////////////////////////////
378363
//
379364
// Simple variant of RCU whose quiescent states are voluntary context
@@ -577,8 +562,29 @@ static void show_rcu_tasks_classic_gp_kthread(void)
577562
show_rcu_tasks_generic_gp_kthread(&rcu_tasks, "");
578563
}
579564

565+
/* Do the srcu_read_lock() for the above synchronize_srcu(). */
566+
void exit_tasks_rcu_start(void) __acquires(&tasks_rcu_exit_srcu)
567+
{
568+
preempt_disable();
569+
current->rcu_tasks_idx = __srcu_read_lock(&tasks_rcu_exit_srcu);
570+
preempt_enable();
571+
}
572+
573+
/* Do the srcu_read_unlock() for the above synchronize_srcu(). */
574+
void exit_tasks_rcu_finish(void) __releases(&tasks_rcu_exit_srcu)
575+
{
576+
struct task_struct *t = current;
577+
578+
preempt_disable();
579+
__srcu_read_unlock(&tasks_rcu_exit_srcu, t->rcu_tasks_idx);
580+
preempt_enable();
581+
exit_tasks_rcu_finish_trace(t);
582+
}
583+
580584
#else /* #ifdef CONFIG_TASKS_RCU */
581585
static void show_rcu_tasks_classic_gp_kthread(void) { }
586+
void exit_tasks_rcu_start(void) { }
587+
void exit_tasks_rcu_finish(void) { exit_tasks_rcu_finish_trace(current); }
582588
#endif /* #else #ifdef CONFIG_TASKS_RCU */
583589

584590
#ifdef CONFIG_TASKS_RUDE_RCU
@@ -1075,7 +1081,7 @@ static void rcu_tasks_trace_postgp(struct rcu_tasks *rtp)
10751081
}
10761082

10771083
/* Report any needed quiescent state for this exiting task. */
1078-
void exit_tasks_rcu_finish_trace(struct task_struct *t)
1084+
static void exit_tasks_rcu_finish_trace(struct task_struct *t)
10791085
{
10801086
WRITE_ONCE(t->trc_reader_checked, true);
10811087
WARN_ON_ONCE(t->trc_reader_nesting);
@@ -1170,7 +1176,7 @@ static void show_rcu_tasks_trace_gp_kthread(void)
11701176
}
11711177

11721178
#else /* #ifdef CONFIG_TASKS_TRACE_RCU */
1173-
void exit_tasks_rcu_finish_trace(struct task_struct *t) { }
1179+
static void exit_tasks_rcu_finish_trace(struct task_struct *t) { }
11741180
static inline void show_rcu_tasks_trace_gp_kthread(void) {}
11751181
#endif /* #else #ifdef CONFIG_TASKS_TRACE_RCU */
11761182

0 commit comments

Comments
 (0)