Skip to content

Commit 0fef924

Browse files
paulmckrcuurezki
authored andcommitted
rcutorture: Use symbols for SRCU reader flavors
This commit converts rcutorture.c values for the reader_flavor module parameter from hexadecimal to the SRCU_READ_FLAVOR_* C-preprocessor macros. The actual modprobe or kernel-boot-parameter values for read_flavor must still be entered in hexadecimal. Link: https://lore.kernel.org/all/c48c9dca-fe07-4833-acaa-28c827e5a79e@amd.com/ Suggested-by: Neeraj Upadhyay <Neeraj.Upadhyay@amd.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
1 parent 223f16b commit 0fef924

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

include/linux/srcu.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ int init_srcu_struct(struct srcu_struct *ssp);
4343
#define __SRCU_DEP_MAP_INIT(srcu_name)
4444
#endif /* #else #ifdef CONFIG_DEBUG_LOCK_ALLOC */
4545

46+
/* Values for SRCU Tree srcu_data ->srcu_reader_flavor, but also used by rcutorture. */
47+
#define SRCU_READ_FLAVOR_NORMAL 0x1 // srcu_read_lock().
48+
#define SRCU_READ_FLAVOR_NMI 0x2 // srcu_read_lock_nmisafe().
49+
#define SRCU_READ_FLAVOR_LITE 0x4 // srcu_read_lock_lite().
50+
#define SRCU_READ_FLAVOR_ALL 0x7 // All of the above.
51+
4652
#ifdef CONFIG_TINY_SRCU
4753
#include <linux/srcutiny.h>
4854
#elif defined(CONFIG_TREE_SRCU)

include/linux/srcutree.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ struct srcu_data {
2626
atomic_long_t srcu_lock_count[2]; /* Locks per CPU. */
2727
atomic_long_t srcu_unlock_count[2]; /* Unlocks per CPU. */
2828
int srcu_reader_flavor; /* Reader flavor for srcu_struct structure? */
29+
/* Values: SRCU_READ_FLAVOR_.* */
2930

3031
/* Update-side state. */
3132
spinlock_t __private lock ____cacheline_internodealigned_in_smp;
@@ -43,11 +44,6 @@ struct srcu_data {
4344
struct srcu_struct *ssp;
4445
};
4546

46-
/* Values for ->srcu_reader_flavor. */
47-
#define SRCU_READ_FLAVOR_NORMAL 0x1 // srcu_read_lock().
48-
#define SRCU_READ_FLAVOR_NMI 0x2 // srcu_read_lock_nmisafe().
49-
#define SRCU_READ_FLAVOR_LITE 0x4 // srcu_read_lock_lite().
50-
5147
/*
5248
* Node in SRCU combining tree, similar in function to rcu_data.
5349
*/

kernel/rcu/rcutorture.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ torture_param(int, preempt_duration, 0, "Preemption duration (ms), zero to disab
121121
torture_param(int, preempt_interval, MSEC_PER_SEC, "Interval between preemptions (ms)");
122122
torture_param(int, read_exit_delay, 13, "Delay between read-then-exit episodes (s)");
123123
torture_param(int, read_exit_burst, 16, "# of read-then-exit bursts per episode, zero to disable");
124-
torture_param(int, reader_flavor, 0x1, "Reader flavors to use, one per bit.");
124+
torture_param(int, reader_flavor, SRCU_READ_FLAVOR_NORMAL, "Reader flavors to use, one per bit.");
125125
torture_param(int, shuffle_interval, 3, "Number of seconds between shuffles");
126126
torture_param(int, shutdown_secs, 0, "Shutdown time (s), <= zero to disable.");
127127
torture_param(int, stall_cpu, 0, "Stall duration (s), zero to disable.");
@@ -679,17 +679,17 @@ static int srcu_torture_read_lock(void)
679679
int idx;
680680
int ret = 0;
681681

682-
if ((reader_flavor & 0x1) || !(reader_flavor & 0x7)) {
682+
if ((reader_flavor & SRCU_READ_FLAVOR_NORMAL) || !(reader_flavor & SRCU_READ_FLAVOR_ALL)) {
683683
idx = srcu_read_lock(srcu_ctlp);
684684
WARN_ON_ONCE(idx & ~0x1);
685685
ret += idx;
686686
}
687-
if (reader_flavor & 0x2) {
687+
if (reader_flavor & SRCU_READ_FLAVOR_NMI) {
688688
idx = srcu_read_lock_nmisafe(srcu_ctlp);
689689
WARN_ON_ONCE(idx & ~0x1);
690690
ret += idx << 1;
691691
}
692-
if (reader_flavor & 0x4) {
692+
if (reader_flavor & SRCU_READ_FLAVOR_LITE) {
693693
idx = srcu_read_lock_lite(srcu_ctlp);
694694
WARN_ON_ONCE(idx & ~0x1);
695695
ret += idx << 2;
@@ -719,11 +719,11 @@ srcu_read_delay(struct torture_random_state *rrsp, struct rt_read_seg *rtrsp)
719719
static void srcu_torture_read_unlock(int idx)
720720
{
721721
WARN_ON_ONCE((reader_flavor && (idx & ~reader_flavor)) || (!reader_flavor && (idx & ~0x1)));
722-
if (reader_flavor & 0x4)
722+
if (reader_flavor & SRCU_READ_FLAVOR_LITE)
723723
srcu_read_unlock_lite(srcu_ctlp, (idx & 0x4) >> 2);
724-
if (reader_flavor & 0x2)
724+
if (reader_flavor & SRCU_READ_FLAVOR_NMI)
725725
srcu_read_unlock_nmisafe(srcu_ctlp, (idx & 0x2) >> 1);
726-
if ((reader_flavor & 0x1) || !(reader_flavor & 0x7))
726+
if ((reader_flavor & SRCU_READ_FLAVOR_NORMAL) || !(reader_flavor & SRCU_READ_FLAVOR_ALL))
727727
srcu_read_unlock(srcu_ctlp, idx & 0x1);
728728
}
729729

0 commit comments

Comments
 (0)