Skip to content

Commit d38c8fe

Browse files
committed
Merge branches 'doc.2022.06.21a', 'fixes.2022.07.19a', 'nocb.2022.07.19a', 'poll.2022.07.21a', 'rcu-tasks.2022.06.21a' and 'torture.2022.06.21a' into HEAD
doc.2022.06.21a: Documentation updates. fixes.2022.07.19a: Miscellaneous fixes. nocb.2022.07.19a: Callback-offload updates. poll.2022.07.21a: Polled grace-period updates. rcu-tasks.2022.06.21a: Tasks RCU updates. torture.2022.06.21a: Torture-test updates.
6 parents 89f7f29 + a03ae49 + 0578e14 + 28787e0 + e72ee5e + 7bf336f commit d38c8fe

28 files changed

Lines changed: 1218 additions & 479 deletions

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3659,6 +3659,9 @@
36593659
just as if they had also been called out in the
36603660
rcu_nocbs= boot parameter.
36613661

3662+
Note that this argument takes precedence over
3663+
the CONFIG_RCU_NOCB_CPU_DEFAULT_ALL option.
3664+
36623665
noiotrap [SH] Disables trapped I/O port accesses.
36633666

36643667
noirqdebug [X86-32] Disables the code which attempts to detect and
@@ -4557,6 +4560,9 @@
45574560
no-callback mode from boot but the mode may be
45584561
toggled at runtime via cpusets.
45594562

4563+
Note that this argument takes precedence over
4564+
the CONFIG_RCU_NOCB_CPU_DEFAULT_ALL option.
4565+
45604566
rcu_nocb_poll [KNL]
45614567
Rather than requiring that offloaded CPUs
45624568
(specified by rcu_nocbs= above) explicitly
@@ -5799,6 +5805,24 @@
57995805
expediting. Set to zero to disable automatic
58005806
expediting.
58015807

5808+
srcutree.srcu_max_nodelay [KNL]
5809+
Specifies the number of no-delay instances
5810+
per jiffy for which the SRCU grace period
5811+
worker thread will be rescheduled with zero
5812+
delay. Beyond this limit, worker thread will
5813+
be rescheduled with a sleep delay of one jiffy.
5814+
5815+
srcutree.srcu_max_nodelay_phase [KNL]
5816+
Specifies the per-grace-period phase, number of
5817+
non-sleeping polls of readers. Beyond this limit,
5818+
grace period worker thread will be rescheduled
5819+
with a sleep delay of one jiffy, between each
5820+
rescan of the readers, for a grace period phase.
5821+
5822+
srcutree.srcu_retry_check_delay [KNL]
5823+
Specifies number of microseconds of non-sleeping
5824+
delay between each non-sleeping poll of readers.
5825+
58025826
srcutree.small_contention_lim [KNL]
58035827
Specifies the number of update-side contention
58045828
events per jiffy will be tolerated before

include/linux/rcupdate.h

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ void call_rcu(struct rcu_head *head, rcu_callback_t func);
4141
void rcu_barrier_tasks(void);
4242
void rcu_barrier_tasks_rude(void);
4343
void synchronize_rcu(void);
44+
unsigned long get_completed_synchronize_rcu(void);
4445

4546
#ifdef CONFIG_PREEMPT_RCU
4647

@@ -169,13 +170,24 @@ void synchronize_rcu_tasks(void);
169170
# endif
170171

171172
# ifdef CONFIG_TASKS_TRACE_RCU
172-
# define rcu_tasks_trace_qs(t) \
173-
do { \
174-
if (!likely(READ_ONCE((t)->trc_reader_checked)) && \
175-
!unlikely(READ_ONCE((t)->trc_reader_nesting))) { \
176-
smp_store_release(&(t)->trc_reader_checked, true); \
177-
smp_mb(); /* Readers partitioned by store. */ \
178-
} \
173+
// Bits for ->trc_reader_special.b.need_qs field.
174+
#define TRC_NEED_QS 0x1 // Task needs a quiescent state.
175+
#define TRC_NEED_QS_CHECKED 0x2 // Task has been checked for needing quiescent state.
176+
177+
u8 rcu_trc_cmpxchg_need_qs(struct task_struct *t, u8 old, u8 new);
178+
void rcu_tasks_trace_qs_blkd(struct task_struct *t);
179+
180+
# define rcu_tasks_trace_qs(t) \
181+
do { \
182+
int ___rttq_nesting = READ_ONCE((t)->trc_reader_nesting); \
183+
\
184+
if (likely(!READ_ONCE((t)->trc_reader_special.b.need_qs)) && \
185+
likely(!___rttq_nesting)) { \
186+
rcu_trc_cmpxchg_need_qs((t), 0, TRC_NEED_QS_CHECKED); \
187+
} else if (___rttq_nesting && ___rttq_nesting != INT_MIN && \
188+
!READ_ONCE((t)->trc_reader_special.b.blocked)) { \
189+
rcu_tasks_trace_qs_blkd(t); \
190+
} \
179191
} while (0)
180192
# else
181193
# define rcu_tasks_trace_qs(t) do { } while (0)
@@ -184,7 +196,7 @@ void synchronize_rcu_tasks(void);
184196
#define rcu_tasks_qs(t, preempt) \
185197
do { \
186198
rcu_tasks_classic_qs((t), (preempt)); \
187-
rcu_tasks_trace_qs((t)); \
199+
rcu_tasks_trace_qs(t); \
188200
} while (0)
189201

190202
# ifdef CONFIG_TASKS_RUDE_RCU

include/linux/rcupdate_trace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static inline void rcu_read_unlock_trace(void)
7575
nesting = READ_ONCE(t->trc_reader_nesting) - 1;
7676
barrier(); // Critical section before disabling.
7777
// Disable IPI-based setting of .need_qs.
78-
WRITE_ONCE(t->trc_reader_nesting, INT_MIN);
78+
WRITE_ONCE(t->trc_reader_nesting, INT_MIN + nesting);
7979
if (likely(!READ_ONCE(t->trc_reader_special.s)) || nesting) {
8080
WRITE_ONCE(t->trc_reader_nesting, nesting);
8181
return; // We assume shallow reader nesting.

include/linux/rcutiny.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ static inline void cond_synchronize_rcu(unsigned long oldstate)
2323
might_sleep();
2424
}
2525

26+
static inline unsigned long start_poll_synchronize_rcu_expedited(void)
27+
{
28+
return start_poll_synchronize_rcu();
29+
}
30+
31+
static inline void cond_synchronize_rcu_expedited(unsigned long oldstate)
32+
{
33+
cond_synchronize_rcu(oldstate);
34+
}
35+
2636
extern void rcu_barrier(void);
2737

2838
static inline void synchronize_rcu_expedited(void)
@@ -38,7 +48,7 @@ static inline void synchronize_rcu_expedited(void)
3848
*/
3949
extern void kvfree(const void *addr);
4050

41-
static inline void kvfree_call_rcu(struct rcu_head *head, rcu_callback_t func)
51+
static inline void __kvfree_call_rcu(struct rcu_head *head, rcu_callback_t func)
4252
{
4353
if (head) {
4454
call_rcu(head, func);
@@ -51,6 +61,15 @@ static inline void kvfree_call_rcu(struct rcu_head *head, rcu_callback_t func)
5161
kvfree((void *) func);
5262
}
5363

64+
#ifdef CONFIG_KASAN_GENERIC
65+
void kvfree_call_rcu(struct rcu_head *head, rcu_callback_t func);
66+
#else
67+
static inline void kvfree_call_rcu(struct rcu_head *head, rcu_callback_t func)
68+
{
69+
__kvfree_call_rcu(head, func);
70+
}
71+
#endif
72+
5473
void rcu_qs(void);
5574

5675
static inline void rcu_softirq_qs(void)

include/linux/rcutree.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ bool rcu_eqs_special_set(int cpu);
4040
void rcu_momentary_dyntick_idle(void);
4141
void kfree_rcu_scheduler_running(void);
4242
bool rcu_gp_might_be_stalled(void);
43+
unsigned long start_poll_synchronize_rcu_expedited(void);
44+
void cond_synchronize_rcu_expedited(unsigned long oldstate);
4345
unsigned long get_state_synchronize_rcu(void);
4446
unsigned long start_poll_synchronize_rcu(void);
4547
bool poll_state_synchronize_rcu(unsigned long oldstate);

include/linux/sched.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,8 +843,9 @@ struct task_struct {
843843
int trc_reader_nesting;
844844
int trc_ipi_to_cpu;
845845
union rcu_special trc_reader_special;
846-
bool trc_reader_checked;
847846
struct list_head trc_holdout_list;
847+
struct list_head trc_blkd_node;
848+
int trc_blkd_cpu;
848849
#endif /* #ifdef CONFIG_TASKS_TRACE_RCU */
849850

850851
struct sched_info sched_info;
@@ -2223,6 +2224,7 @@ static inline void set_task_cpu(struct task_struct *p, unsigned int cpu)
22232224

22242225
extern bool sched_task_on_rq(struct task_struct *p);
22252226
extern unsigned long get_wchan(struct task_struct *p);
2227+
extern struct task_struct *cpu_curr_snapshot(int cpu);
22262228

22272229
/*
22282230
* In order to reduce various lock holder preemption latencies provide an

init/init_task.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ struct task_struct init_task
157157
.trc_reader_nesting = 0,
158158
.trc_reader_special.s = 0,
159159
.trc_holdout_list = LIST_HEAD_INIT(init_task.trc_holdout_list),
160+
.trc_blkd_node = LIST_HEAD_INIT(init_task.trc_blkd_node),
160161
#endif
161162
#ifdef CONFIG_CPUSETS
162163
.mems_allowed_seq = SEQCNT_SPINLOCK_ZERO(init_task.mems_allowed_seq,

kernel/fork.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1814,6 +1814,7 @@ static inline void rcu_copy_process(struct task_struct *p)
18141814
p->trc_reader_nesting = 0;
18151815
p->trc_reader_special.s = 0;
18161816
INIT_LIST_HEAD(&p->trc_holdout_list);
1817+
INIT_LIST_HEAD(&p->trc_blkd_node);
18171818
#endif /* #ifdef CONFIG_TASKS_TRACE_RCU */
18181819
}
18191820

kernel/rcu/Kconfig

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,35 @@ config RCU_NOCB_CPU
262262
Say Y here if you need reduced OS jitter, despite added overhead.
263263
Say N here if you are unsure.
264264

265+
config RCU_NOCB_CPU_DEFAULT_ALL
266+
bool "Offload RCU callback processing from all CPUs by default"
267+
depends on RCU_NOCB_CPU
268+
default n
269+
help
270+
Use this option to offload callback processing from all CPUs
271+
by default, in the absence of the rcu_nocbs or nohz_full boot
272+
parameter. This also avoids the need to use any boot parameters
273+
to achieve the effect of offloading all CPUs on boot.
274+
275+
Say Y here if you want offload all CPUs by default on boot.
276+
Say N here if you are unsure.
277+
278+
config RCU_NOCB_CPU_CB_BOOST
279+
bool "Offload RCU callback from real-time kthread"
280+
depends on RCU_NOCB_CPU && RCU_BOOST
281+
default y if PREEMPT_RT
282+
help
283+
Use this option to invoke offloaded callbacks as SCHED_FIFO
284+
to avoid starvation by heavy SCHED_OTHER background load.
285+
Of course, running as SCHED_FIFO during callback floods will
286+
cause the rcuo[ps] kthreads to monopolize the CPU for hundreds
287+
of milliseconds or more. Therefore, when enabling this option,
288+
it is your responsibility to ensure that latency-sensitive
289+
tasks either run with higher priority or run on some other CPU.
290+
291+
Say Y here if you want to set RT priority for offloading kthreads.
292+
Say N here if you are building a !PREEMPT_RT kernel and are unsure.
293+
265294
config TASKS_TRACE_RCU_READ_MB
266295
bool "Tasks Trace RCU readers use memory barriers in user and idle"
267296
depends on RCU_EXPERT && TASKS_TRACE_RCU

kernel/rcu/Kconfig.debug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ config RCU_EQS_DEBUG
121121

122122
config RCU_STRICT_GRACE_PERIOD
123123
bool "Provide debug RCU implementation with short grace periods"
124-
depends on DEBUG_KERNEL && RCU_EXPERT && NR_CPUS <= 4
124+
depends on DEBUG_KERNEL && RCU_EXPERT && NR_CPUS <= 4 && !TINY_RCU
125125
default n
126126
select PREEMPT_COUNT if PREEMPT=n
127127
help

0 commit comments

Comments
 (0)