Skip to content

Commit 23a80d4

Browse files
committed
Merge tag 'rcu.release.v6.8' of https://github.com/neeraju/linux
Pull RCU updates from Neeraj Upadhyay: - Documentation and comment updates - RCU torture, locktorture updates that include cleanups; nolibc init build support for mips, ppc and rv64; testing of mid stall duration scenario and fixing fqs task creation conditions - Misc fixes, most notably restricting usage of RCU CPU stall notifiers, to confine their usage primarily to debug kernels - RCU tasks minor fixes - lockdep annotation fix for NMI-safe accesses, callback advancing/acceleration cleanup and documentation improvements * tag 'rcu.release.v6.8' of https://github.com/neeraju/linux: rcu: Force quiescent states only for ongoing grace period doc: Clarify historical disclaimers in memory-barriers.txt doc: Mention address and data dependencies in rcu_dereference.rst doc: Clarify RCU Tasks reader/updater checklist rculist.h: docs: Fix wrong function summary Documentation: RCU: Remove repeated word in comments srcu: Use try-lock lockdep annotation for NMI-safe access. srcu: Explain why callbacks invocations can't run concurrently srcu: No need to advance/accelerate if no callback enqueued srcu: Remove superfluous callbacks advancing from srcu_gp_start() rcu: Remove unused macros from rcupdate.h rcu: Restrict access to RCU CPU stall notifiers rcu-tasks: Mark RCU Tasks accesses to current->rcu_tasks_idle_cpu rcutorture: Add fqs_holdoff check before fqs_task is created rcutorture: Add mid-sized stall to TREE07 rcutorture: add nolibc init support for mips, ppc and rv64 locktorture: Increase Hamming distance between call_rcu_chain and rcu_call_chains
2 parents 3881433 + 7dfb03d commit 23a80d4

File tree

20 files changed

+151
-67
lines changed

20 files changed

+151
-67
lines changed

Documentation/RCU/checklist.rst

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,22 @@ over a rather long period of time, but improvements are always welcome!
241241
srcu_struct. The rules for the expedited RCU grace-period-wait
242242
primitives are the same as for their non-expedited counterparts.
243243

244-
If the updater uses call_rcu_tasks() or synchronize_rcu_tasks(),
245-
then the readers must refrain from executing voluntary
246-
context switches, that is, from blocking. If the updater uses
247-
call_rcu_tasks_trace() or synchronize_rcu_tasks_trace(), then
248-
the corresponding readers must use rcu_read_lock_trace() and
249-
rcu_read_unlock_trace(). If an updater uses call_rcu_tasks_rude()
250-
or synchronize_rcu_tasks_rude(), then the corresponding readers
251-
must use anything that disables preemption, for example,
252-
preempt_disable() and preempt_enable().
244+
Similarly, it is necessary to correctly use the RCU Tasks flavors:
245+
246+
a. If the updater uses synchronize_rcu_tasks() or
247+
call_rcu_tasks(), then the readers must refrain from
248+
executing voluntary context switches, that is, from
249+
blocking.
250+
251+
b. If the updater uses call_rcu_tasks_trace()
252+
or synchronize_rcu_tasks_trace(), then the
253+
corresponding readers must use rcu_read_lock_trace()
254+
and rcu_read_unlock_trace().
255+
256+
c. If an updater uses call_rcu_tasks_rude() or
257+
synchronize_rcu_tasks_rude(), then the corresponding
258+
readers must use anything that disables preemption,
259+
for example, preempt_disable() and preempt_enable().
253260

254261
Mixing things up will result in confusion and broken kernels, and
255262
has even resulted in an exploitable security issue. Therefore,

Documentation/RCU/rcu_dereference.rst

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,26 @@
33
PROPER CARE AND FEEDING OF RETURN VALUES FROM rcu_dereference()
44
===============================================================
55

6-
Most of the time, you can use values from rcu_dereference() or one of
7-
the similar primitives without worries. Dereferencing (prefix "*"),
8-
field selection ("->"), assignment ("="), address-of ("&"), addition and
9-
subtraction of constants, and casts all work quite naturally and safely.
10-
11-
It is nevertheless possible to get into trouble with other operations.
12-
Follow these rules to keep your RCU code working properly:
6+
Proper care and feeding of address and data dependencies is critically
7+
important to correct use of things like RCU. To this end, the pointers
8+
returned from the rcu_dereference() family of primitives carry address and
9+
data dependencies. These dependencies extend from the rcu_dereference()
10+
macro's load of the pointer to the later use of that pointer to compute
11+
either the address of a later memory access (representing an address
12+
dependency) or the value written by a later memory access (representing
13+
a data dependency).
14+
15+
Most of the time, these dependencies are preserved, permitting you to
16+
freely use values from rcu_dereference(). For example, dereferencing
17+
(prefix "*"), field selection ("->"), assignment ("="), address-of
18+
("&"), casts, and addition or subtraction of constants all work quite
19+
naturally and safely. However, because current compilers do not take
20+
either address or data dependencies into account it is still possible
21+
to get into trouble.
22+
23+
Follow these rules to preserve the address and data dependencies emanating
24+
from your calls to rcu_dereference() and friends, thus keeping your RCU
25+
readers working properly:
1326

1427
- You must use one of the rcu_dereference() family of primitives
1528
to load an RCU-protected pointer, otherwise CONFIG_PROVE_RCU

Documentation/RCU/torture.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ argument.
185185
Not all changes require that all scenarios be run. For example, a change
186186
to Tree SRCU might run only the SRCU-N and SRCU-P scenarios using the
187187
--configs argument to kvm.sh as follows: "--configs 'SRCU-N SRCU-P'".
188-
Large systems can run multiple copies of of the full set of scenarios,
188+
Large systems can run multiple copies of the full set of scenarios,
189189
for example, a system with 448 hardware threads can run five instances
190190
of the full set concurrently. To make this happen::
191191

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5313,6 +5313,12 @@
53135313
Dump ftrace buffer after reporting RCU CPU
53145314
stall warning.
53155315

5316+
rcupdate.rcu_cpu_stall_notifiers= [KNL]
5317+
Provide RCU CPU stall notifiers, but see the
5318+
warnings in the RCU_CPU_STALL_NOTIFIER Kconfig
5319+
option's help text. TL;DR: You almost certainly
5320+
do not want rcupdate.rcu_cpu_stall_notifiers.
5321+
53165322
rcupdate.rcu_cpu_stall_suppress= [KNL]
53175323
Suppress RCU CPU stall warning messages.
53185324

Documentation/memory-barriers.txt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,11 @@ Memory barriers come in four basic varieties:
396396

397397

398398
(2) Address-dependency barriers (historical).
399-
[!] This section is marked as HISTORICAL: For more up-to-date
400-
information, including how compiler transformations related to pointer
401-
comparisons can sometimes cause problems, see
402-
Documentation/RCU/rcu_dereference.rst.
399+
[!] This section is marked as HISTORICAL: it covers the long-obsolete
400+
smp_read_barrier_depends() macro, the semantics of which are now
401+
implicit in all marked accesses. For more up-to-date information,
402+
including how compiler transformations can sometimes break address
403+
dependencies, see Documentation/RCU/rcu_dereference.rst.
403404

404405
An address-dependency barrier is a weaker form of read barrier. In the
405406
case where two loads are performed such that the second depends on the
@@ -560,9 +561,11 @@ There are certain things that the Linux kernel memory barriers do not guarantee:
560561

561562
ADDRESS-DEPENDENCY BARRIERS (HISTORICAL)
562563
----------------------------------------
563-
[!] This section is marked as HISTORICAL: For more up-to-date information,
564-
including how compiler transformations related to pointer comparisons can
565-
sometimes cause problems, see Documentation/RCU/rcu_dereference.rst.
564+
[!] This section is marked as HISTORICAL: it covers the long-obsolete
565+
smp_read_barrier_depends() macro, the semantics of which are now implicit
566+
in all marked accesses. For more up-to-date information, including
567+
how compiler transformations can sometimes break address dependencies,
568+
see Documentation/RCU/rcu_dereference.rst.
566569

567570
As of v4.15 of the Linux kernel, an smp_mb() was added to READ_ONCE() for
568571
DEC Alpha, which means that about the only people who need to pay attention

include/linux/rcu_notifier.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@
1313
#define RCU_STALL_NOTIFY_NORM 1
1414
#define RCU_STALL_NOTIFY_EXP 2
1515

16-
#ifdef CONFIG_RCU_STALL_COMMON
16+
#if defined(CONFIG_RCU_STALL_COMMON) && defined(CONFIG_RCU_CPU_STALL_NOTIFIER)
1717

1818
#include <linux/notifier.h>
1919
#include <linux/types.h>
2020

2121
int rcu_stall_chain_notifier_register(struct notifier_block *n);
2222
int rcu_stall_chain_notifier_unregister(struct notifier_block *n);
2323

24-
#else // #ifdef CONFIG_RCU_STALL_COMMON
24+
#else // #if defined(CONFIG_RCU_STALL_COMMON) && defined(CONFIG_RCU_CPU_STALL_NOTIFIER)
2525

2626
// No RCU CPU stall warnings in Tiny RCU.
2727
static inline int rcu_stall_chain_notifier_register(struct notifier_block *n) { return -EEXIST; }
2828
static inline int rcu_stall_chain_notifier_unregister(struct notifier_block *n) { return -ENOENT; }
2929

30-
#endif // #else // #ifdef CONFIG_RCU_STALL_COMMON
30+
#endif // #else // #if defined(CONFIG_RCU_STALL_COMMON) && defined(CONFIG_RCU_CPU_STALL_NOTIFIER)
3131

3232
#endif /* __LINUX_RCU_NOTIFIER_H */

include/linux/rculist.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ static inline void list_splice_tail_init_rcu(struct list_head *list,
355355
})
356356

357357
/**
358-
* list_next_or_null_rcu - get the first element from a list
358+
* list_next_or_null_rcu - get the next element from a list
359359
* @head: the head for the list.
360360
* @ptr: the list head to take the next element from.
361361
* @type: the type of the struct this is embedded in.

include/linux/rcupdate.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@
3434

3535
#define ULONG_CMP_GE(a, b) (ULONG_MAX / 2 >= (a) - (b))
3636
#define ULONG_CMP_LT(a, b) (ULONG_MAX / 2 < (a) - (b))
37-
#define ulong2long(a) (*(long *)(&(a)))
38-
#define USHORT_CMP_GE(a, b) (USHRT_MAX / 2 >= (unsigned short)((a) - (b)))
39-
#define USHORT_CMP_LT(a, b) (USHRT_MAX / 2 < (unsigned short)((a) - (b)))
4037

4138
/* Exported common interfaces */
4239
void call_rcu(struct rcu_head *head, rcu_callback_t func);
@@ -301,6 +298,11 @@ static inline void rcu_lock_acquire(struct lockdep_map *map)
301298
lock_acquire(map, 0, 0, 2, 0, NULL, _THIS_IP_);
302299
}
303300

301+
static inline void rcu_try_lock_acquire(struct lockdep_map *map)
302+
{
303+
lock_acquire(map, 0, 1, 2, 0, NULL, _THIS_IP_);
304+
}
305+
304306
static inline void rcu_lock_release(struct lockdep_map *map)
305307
{
306308
lock_release(map, _THIS_IP_);
@@ -315,6 +317,7 @@ int rcu_read_lock_any_held(void);
315317
#else /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */
316318

317319
# define rcu_lock_acquire(a) do { } while (0)
320+
# define rcu_try_lock_acquire(a) do { } while (0)
318321
# define rcu_lock_release(a) do { } while (0)
319322

320323
static inline int rcu_read_lock_held(void)

include/linux/srcu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ static inline int srcu_read_lock_nmisafe(struct srcu_struct *ssp) __acquires(ssp
229229

230230
srcu_check_nmi_safety(ssp, true);
231231
retval = __srcu_read_lock_nmisafe(ssp);
232-
rcu_lock_acquire(&ssp->dep_map);
232+
rcu_try_lock_acquire(&ssp->dep_map);
233233
return retval;
234234
}
235235

kernel/locking/locktorture.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ struct call_rcu_chain {
124124
struct rcu_head crc_rh;
125125
bool crc_stop;
126126
};
127-
struct call_rcu_chain *call_rcu_chain;
127+
struct call_rcu_chain *call_rcu_chain_list;
128128

129129
/* Forward reference. */
130130
static void lock_torture_cleanup(void);
@@ -1074,12 +1074,12 @@ static int call_rcu_chain_init(void)
10741074

10751075
if (call_rcu_chains <= 0)
10761076
return 0;
1077-
call_rcu_chain = kcalloc(call_rcu_chains, sizeof(*call_rcu_chain), GFP_KERNEL);
1078-
if (!call_rcu_chain)
1077+
call_rcu_chain_list = kcalloc(call_rcu_chains, sizeof(*call_rcu_chain_list), GFP_KERNEL);
1078+
if (!call_rcu_chain_list)
10791079
return -ENOMEM;
10801080
for (i = 0; i < call_rcu_chains; i++) {
1081-
call_rcu_chain[i].crc_stop = false;
1082-
call_rcu(&call_rcu_chain[i].crc_rh, call_rcu_chain_cb);
1081+
call_rcu_chain_list[i].crc_stop = false;
1082+
call_rcu(&call_rcu_chain_list[i].crc_rh, call_rcu_chain_cb);
10831083
}
10841084
return 0;
10851085
}
@@ -1089,13 +1089,13 @@ static void call_rcu_chain_cleanup(void)
10891089
{
10901090
int i;
10911091

1092-
if (!call_rcu_chain)
1092+
if (!call_rcu_chain_list)
10931093
return;
10941094
for (i = 0; i < call_rcu_chains; i++)
1095-
smp_store_release(&call_rcu_chain[i].crc_stop, true);
1095+
smp_store_release(&call_rcu_chain_list[i].crc_stop, true);
10961096
rcu_barrier();
1097-
kfree(call_rcu_chain);
1098-
call_rcu_chain = NULL;
1097+
kfree(call_rcu_chain_list);
1098+
call_rcu_chain_list = NULL;
10991099
}
11001100

11011101
static void lock_torture_cleanup(void)

0 commit comments

Comments
 (0)