Skip to content

Commit 6fedc28

Browse files
committed
Merge tag 'rcu.2021.11.01a' of git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu
Pull RCU updates from Paul McKenney: - Miscellaneous fixes - Torture-test updates for smp_call_function(), most notably improved checking of module parameters. - Tasks-trace RCU updates that fix a number of rare but important race-condition bugs. - Other torture-test updates, most notably better checking of module parameters. In addition, rcutorture may once again be run on CONFIG_PREEMPT_RT kernels. - Torture-test scripting updates, most notably specifying the new CONFIG_KCSAN_STRICT kconfig option rather than maintaining an ever-changing list of individual KCSAN kconfig options. * tag 'rcu.2021.11.01a' of git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu: (46 commits) rcu: Fix rcu_dynticks_curr_cpu_in_eqs() vs noinstr rcu: Always inline rcu_dynticks_task*_{enter,exit}() torture: Make kvm-remote.sh print size of downloaded tarball torture: Allot 1G of memory for scftorture runs tools/rcu: Add an extract-stall script scftorture: Warn on individual scf_torture_init() error conditions scftorture: Count reschedule IPIs scftorture: Account for weight_resched when checking for all zeroes scftorture: Shut down if nonsensical arguments given scftorture: Allow zero weight to exclude an smp_call_function*() category rcu: Avoid unneeded function call in rcu_read_unlock() rcu-tasks: Update comments to cond_resched_tasks_rcu_qs() rcu-tasks: Fix IPI failure handling in trc_wait_for_one_reader rcu-tasks: Fix read-side primitives comment for call_rcu_tasks_trace rcu-tasks: Clarify read side section info for rcu_tasks_rude GP primitives rcu-tasks: Correct comparisons for CPU numbers in show_stalled_task_trace rcu-tasks: Correct firstreport usage in check_all_holdout_tasks_trace rcu-tasks: Fix s/rcu_add_holdout/trc_add_holdout/ typo in comment rcu-tasks: Move RTGS_WAIT_CBS to beginning of rcu_tasks_kthread() loop rcu-tasks: Fix s/instruction/instructions/ typo in comment ...
2 parents 79ef0c0 + dd1277d commit 6fedc28

File tree

22 files changed

+273
-200
lines changed

22 files changed

+273
-200
lines changed

Documentation/RCU/Design/Memory-Ordering/Tree-RCU-Memory-Ordering.rst

Lines changed: 32 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -202,49 +202,44 @@ newly arrived RCU callbacks against future grace periods:
202202
1 static void rcu_prepare_for_idle(void)
203203
2 {
204204
3 bool needwake;
205-
4 struct rcu_data *rdp;
206-
5 struct rcu_dynticks *rdtp = this_cpu_ptr(&rcu_dynticks);
207-
6 struct rcu_node *rnp;
208-
7 struct rcu_state *rsp;
209-
8 int tne;
210-
9
211-
10 if (IS_ENABLED(CONFIG_RCU_NOCB_CPU_ALL) ||
212-
11 rcu_is_nocb_cpu(smp_processor_id()))
213-
12 return;
205+
4 struct rcu_data *rdp = this_cpu_ptr(&rcu_data);
206+
5 struct rcu_node *rnp;
207+
6 int tne;
208+
7
209+
8 lockdep_assert_irqs_disabled();
210+
9 if (rcu_rdp_is_offloaded(rdp))
211+
10 return;
212+
11
213+
12 /* Handle nohz enablement switches conservatively. */
214214
13 tne = READ_ONCE(tick_nohz_active);
215-
14 if (tne != rdtp->tick_nohz_enabled_snap) {
216-
15 if (rcu_cpu_has_callbacks(NULL))
217-
16 invoke_rcu_core();
218-
17 rdtp->tick_nohz_enabled_snap = tne;
215+
14 if (tne != rdp->tick_nohz_enabled_snap) {
216+
15 if (!rcu_segcblist_empty(&rdp->cblist))
217+
16 invoke_rcu_core(); /* force nohz to see update. */
218+
17 rdp->tick_nohz_enabled_snap = tne;
219219
18 return;
220-
19 }
220+
19 }
221221
20 if (!tne)
222222
21 return;
223-
22 if (rdtp->all_lazy &&
224-
23 rdtp->nonlazy_posted != rdtp->nonlazy_posted_snap) {
225-
24 rdtp->all_lazy = false;
226-
25 rdtp->nonlazy_posted_snap = rdtp->nonlazy_posted;
227-
26 invoke_rcu_core();
228-
27 return;
229-
28 }
230-
29 if (rdtp->last_accelerate == jiffies)
231-
30 return;
232-
31 rdtp->last_accelerate = jiffies;
233-
32 for_each_rcu_flavor(rsp) {
234-
33 rdp = this_cpu_ptr(rsp->rda);
235-
34 if (rcu_segcblist_pend_cbs(&rdp->cblist))
236-
35 continue;
237-
36 rnp = rdp->mynode;
238-
37 raw_spin_lock_rcu_node(rnp);
239-
38 needwake = rcu_accelerate_cbs(rsp, rnp, rdp);
240-
39 raw_spin_unlock_rcu_node(rnp);
241-
40 if (needwake)
242-
41 rcu_gp_kthread_wake(rsp);
243-
42 }
244-
43 }
223+
22
224+
23 /*
225+
24 * If we have not yet accelerated this jiffy, accelerate all
226+
25 * callbacks on this CPU.
227+
26 */
228+
27 if (rdp->last_accelerate == jiffies)
229+
28 return;
230+
29 rdp->last_accelerate = jiffies;
231+
30 if (rcu_segcblist_pend_cbs(&rdp->cblist)) {
232+
31 rnp = rdp->mynode;
233+
32 raw_spin_lock_rcu_node(rnp); /* irqs already disabled. */
234+
33 needwake = rcu_accelerate_cbs(rnp, rdp);
235+
34 raw_spin_unlock_rcu_node(rnp); /* irqs remain disabled. */
236+
35 if (needwake)
237+
36 rcu_gp_kthread_wake();
238+
37 }
239+
38 }
245240

246241
But the only part of ``rcu_prepare_for_idle()`` that really matters for
247-
this discussion are lines 37–39. We will therefore abbreviate this
242+
this discussion are lines 32–34. We will therefore abbreviate this
248243
function as follows:
249244

250245
.. kernel-figure:: rcu_node-lock.svg

Documentation/RCU/stallwarn.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ warnings:
9696
the ``rcu_.*timer wakeup didn't happen for`` console-log message,
9797
which will include additional debugging information.
9898

99+
- A low-level kernel issue that either fails to invoke one of the
100+
variants of rcu_user_enter(), rcu_user_exit(), rcu_idle_enter(),
101+
rcu_idle_exit(), rcu_irq_enter(), or rcu_irq_exit() on the one
102+
hand, or that invokes one of them too many times on the other.
103+
Historically, the most frequent issue has been an omission
104+
of either irq_enter() or irq_exit(), which in turn invoke
105+
rcu_irq_enter() or rcu_irq_exit(), respectively. Building your
106+
kernel with CONFIG_RCU_EQS_DEBUG=y can help track down these types
107+
of issues, which sometimes arise in architecture-specific code.
108+
99109
- A bug in the RCU implementation.
100110

101111
- A hardware failure. This is quite unlikely, but has occurred

arch/sh/configs/sdk7786_defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ CONFIG_BSD_PROCESS_ACCT=y
55
CONFIG_BSD_PROCESS_ACCT_V3=y
66
CONFIG_AUDIT=y
77
CONFIG_AUDITSYSCALL=y
8-
CONFIG_TREE_PREEMPT_RCU=y
98
CONFIG_RCU_TRACE=y
109
CONFIG_IKCONFIG=y
1110
CONFIG_IKCONFIG_PROC=y

arch/xtensa/configs/nommu_kc705_defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ CONFIG_DEBUG_SPINLOCK=y
119119
CONFIG_DEBUG_MUTEXES=y
120120
CONFIG_DEBUG_ATOMIC_SLEEP=y
121121
CONFIG_STACKTRACE=y
122-
# CONFIG_RCU_CPU_STALL_INFO is not set
123122
CONFIG_RCU_TRACE=y
124123
# CONFIG_FTRACE is not set
125124
# CONFIG_LD_NO_RELAX is not set

include/linux/rcupdate.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ static inline void __rcu_read_lock(void)
7171
static inline void __rcu_read_unlock(void)
7272
{
7373
preempt_enable();
74-
rcu_read_unlock_strict();
74+
if (IS_ENABLED(CONFIG_RCU_STRICT_GRACE_PERIOD))
75+
rcu_read_unlock_strict();
7576
}
7677

7778
static inline int rcu_preempt_depth(void)

include/linux/rcupdate_trace.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static inline int rcu_read_lock_trace_held(void)
3131

3232
#ifdef CONFIG_TASKS_TRACE_RCU
3333

34-
void rcu_read_unlock_trace_special(struct task_struct *t, int nesting);
34+
void rcu_read_unlock_trace_special(struct task_struct *t);
3535

3636
/**
3737
* rcu_read_lock_trace - mark beginning of RCU-trace read-side critical section
@@ -80,7 +80,8 @@ static inline void rcu_read_unlock_trace(void)
8080
WRITE_ONCE(t->trc_reader_nesting, nesting);
8181
return; // We assume shallow reader nesting.
8282
}
83-
rcu_read_unlock_trace_special(t, nesting);
83+
WARN_ON_ONCE(nesting != 0);
84+
rcu_read_unlock_trace_special(t);
8485
}
8586

8687
void call_rcu_tasks_trace(struct rcu_head *rhp, rcu_callback_t func);

include/linux/torture.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ do { \
4747
} while (0)
4848
void verbose_torout_sleep(void);
4949

50+
#define torture_init_error(firsterr) \
51+
({ \
52+
int ___firsterr = (firsterr); \
53+
\
54+
WARN_ONCE(!IS_MODULE(CONFIG_RCU_TORTURE_TEST) && ___firsterr < 0, "Torture-test initialization failed with error code %d\n", ___firsterr); \
55+
___firsterr < 0; \
56+
})
57+
5058
/* Definitions for online/offline exerciser. */
5159
#ifdef CONFIG_HOTPLUG_CPU
5260
int torture_num_online_cpus(void);

kernel/locking/locktorture.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,23 +1022,23 @@ static int __init lock_torture_init(void)
10221022
if (onoff_interval > 0) {
10231023
firsterr = torture_onoff_init(onoff_holdoff * HZ,
10241024
onoff_interval * HZ, NULL);
1025-
if (firsterr)
1025+
if (torture_init_error(firsterr))
10261026
goto unwind;
10271027
}
10281028
if (shuffle_interval > 0) {
10291029
firsterr = torture_shuffle_init(shuffle_interval);
1030-
if (firsterr)
1030+
if (torture_init_error(firsterr))
10311031
goto unwind;
10321032
}
10331033
if (shutdown_secs > 0) {
10341034
firsterr = torture_shutdown_init(shutdown_secs,
10351035
lock_torture_cleanup);
1036-
if (firsterr)
1036+
if (torture_init_error(firsterr))
10371037
goto unwind;
10381038
}
10391039
if (stutter > 0) {
10401040
firsterr = torture_stutter_init(stutter, stutter);
1041-
if (firsterr)
1041+
if (torture_init_error(firsterr))
10421042
goto unwind;
10431043
}
10441044

@@ -1082,7 +1082,7 @@ static int __init lock_torture_init(void)
10821082
/* Create writer. */
10831083
firsterr = torture_create_kthread(lock_torture_writer, &cxt.lwsa[i],
10841084
writer_tasks[i]);
1085-
if (firsterr)
1085+
if (torture_init_error(firsterr))
10861086
goto unwind;
10871087

10881088
create_reader:
@@ -1091,13 +1091,13 @@ static int __init lock_torture_init(void)
10911091
/* Create reader. */
10921092
firsterr = torture_create_kthread(lock_torture_reader, &cxt.lrsa[j],
10931093
reader_tasks[j]);
1094-
if (firsterr)
1094+
if (torture_init_error(firsterr))
10951095
goto unwind;
10961096
}
10971097
if (stat_interval > 0) {
10981098
firsterr = torture_create_kthread(lock_torture_stats, NULL,
10991099
stats_task);
1100-
if (firsterr)
1100+
if (torture_init_error(firsterr))
11011101
goto unwind;
11021102
}
11031103
torture_init_end();

kernel/rcu/rcuscale.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ kfree_scale_init(void)
758758
init_waitqueue_head(&shutdown_wq);
759759
firsterr = torture_create_kthread(kfree_scale_shutdown, NULL,
760760
shutdown_task);
761-
if (firsterr)
761+
if (torture_init_error(firsterr))
762762
goto unwind;
763763
schedule_timeout_uninterruptible(1);
764764
}
@@ -775,7 +775,7 @@ kfree_scale_init(void)
775775
for (i = 0; i < kfree_nrealthreads; i++) {
776776
firsterr = torture_create_kthread(kfree_scale_thread, (void *)i,
777777
kfree_reader_tasks[i]);
778-
if (firsterr)
778+
if (torture_init_error(firsterr))
779779
goto unwind;
780780
}
781781

@@ -838,7 +838,7 @@ rcu_scale_init(void)
838838
init_waitqueue_head(&shutdown_wq);
839839
firsterr = torture_create_kthread(rcu_scale_shutdown, NULL,
840840
shutdown_task);
841-
if (firsterr)
841+
if (torture_init_error(firsterr))
842842
goto unwind;
843843
schedule_timeout_uninterruptible(1);
844844
}
@@ -852,7 +852,7 @@ rcu_scale_init(void)
852852
for (i = 0; i < nrealreaders; i++) {
853853
firsterr = torture_create_kthread(rcu_scale_reader, (void *)i,
854854
reader_tasks[i]);
855-
if (firsterr)
855+
if (torture_init_error(firsterr))
856856
goto unwind;
857857
}
858858
while (atomic_read(&n_rcu_scale_reader_started) < nrealreaders)
@@ -879,7 +879,7 @@ rcu_scale_init(void)
879879
}
880880
firsterr = torture_create_kthread(rcu_scale_writer, (void *)i,
881881
writer_tasks[i]);
882-
if (firsterr)
882+
if (torture_init_error(firsterr))
883883
goto unwind;
884884
}
885885
torture_init_end();

0 commit comments

Comments
 (0)