Skip to content

Commit 21871d7

Browse files
clrkwllmspaulmck
authored andcommitted
rcu: Unify boost and kthread priorities
Rename CONFIG_RCU_BOOST_PRIO to CONFIG_RCU_KTHREAD_PRIO and use this value for both the per-CPU kthreads (rcuc/N) and the rcu boosting threads (rcub/n). Also, create the module_parameter rcutree.kthread_prio to be used on the kernel command line at boot to set a new value (rcutree.kthread_prio=N). Signed-off-by: Clark Williams <clark.williams@gmail.com> [ paulmck: Ported to rcu/dev, applied Paul Bolle and Peter Zijlstra feedback. ] Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
1 parent e0775ce commit 21871d7

5 files changed

Lines changed: 32 additions & 24 deletions

File tree

‎Documentation/kernel-parameters.txt‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2922,6 +2922,13 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
29222922
quiescent states. Units are jiffies, minimum
29232923
value is one, and maximum value is HZ.
29242924

2925+
rcutree.kthread_prio= [KNL,BOOT]
2926+
Set the SCHED_FIFO priority of the RCU
2927+
per-CPU kthreads (rcuc/N). This value is also
2928+
used for the priority of the RCU boost threads
2929+
(rcub/N). Valid values are 1-99 and the default
2930+
is 1 (the least-favored priority).
2931+
29252932
rcutree.rcu_nocb_leader_stride= [KNL]
29262933
Set the number of NOCB kthread groups, which
29272934
defaults to the square root of the number of

‎init/Kconfig‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -672,30 +672,31 @@ config RCU_BOOST
672672
Say Y here if you are working with real-time apps or heavy loads
673673
Say N here if you are unsure.
674674

675-
config RCU_BOOST_PRIO
676-
int "Real-time priority to boost RCU readers to"
675+
config RCU_KTHREAD_PRIO
676+
int "Real-time priority to use for RCU worker threads"
677677
range 1 99
678678
depends on RCU_BOOST
679679
default 1
680680
help
681-
This option specifies the real-time priority to which long-term
682-
preempted RCU readers are to be boosted. If you are working
683-
with a real-time application that has one or more CPU-bound
684-
threads running at a real-time priority level, you should set
685-
RCU_BOOST_PRIO to a priority higher then the highest-priority
686-
real-time CPU-bound thread. The default RCU_BOOST_PRIO value
687-
of 1 is appropriate in the common case, which is real-time
681+
This option specifies the SCHED_FIFO priority value that will be
682+
assigned to the rcuc/n and rcub/n threads and is also the value
683+
used for RCU_BOOST (if enabled). If you are working with a
684+
real-time application that has one or more CPU-bound threads
685+
running at a real-time priority level, you should set
686+
RCU_KTHREAD_PRIO to a priority higher than the highest-priority
687+
real-time CPU-bound application thread. The default RCU_KTHREAD_PRIO
688+
value of 1 is appropriate in the common case, which is real-time
688689
applications that do not have any CPU-bound threads.
689690

690691
Some real-time applications might not have a single real-time
691692
thread that saturates a given CPU, but instead might have
692693
multiple real-time threads that, taken together, fully utilize
693-
that CPU. In this case, you should set RCU_BOOST_PRIO to
694+
that CPU. In this case, you should set RCU_KTHREAD_PRIO to
694695
a priority higher than the lowest-priority thread that is
695696
conspiring to prevent the CPU from running any non-real-time
696697
tasks. For example, if one thread at priority 10 and another
697698
thread at priority 5 are between themselves fully consuming
698-
the CPU time on a given CPU, then RCU_BOOST_PRIO should be
699+
the CPU time on a given CPU, then RCU_KTHREAD_PRIO should be
699700
set to priority 6 or higher.
700701

701702
Specify the real-time priority, or take the default if unsure.

‎kernel/rcu/tree_plugin.h‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@
3030
#include <linux/smpboot.h>
3131
#include "../time/tick-internal.h"
3232

33-
#define RCU_KTHREAD_PRIO 1
34-
3533
#ifdef CONFIG_RCU_BOOST
3634

3735
#include "../locking/rtmutex_common.h"
38-
#define RCU_BOOST_PRIO CONFIG_RCU_BOOST_PRIO
36+
37+
/* rcuc/rcub kthread realtime priority */
38+
static int kthread_prio = CONFIG_RCU_KTHREAD_PRIO;
39+
module_param(kthread_prio, int, 0644);
3940

4041
/*
4142
* Control variables for per-CPU and per-rcu_node kthreads. These
@@ -46,11 +47,7 @@ DEFINE_PER_CPU(unsigned int, rcu_cpu_kthread_status);
4647
DEFINE_PER_CPU(unsigned int, rcu_cpu_kthread_loops);
4748
DEFINE_PER_CPU(char, rcu_cpu_has_work);
4849

49-
#else /* #ifdef CONFIG_RCU_BOOST */
50-
51-
#define RCU_BOOST_PRIO RCU_KTHREAD_PRIO
52-
53-
#endif /* #else #ifdef CONFIG_RCU_BOOST */
50+
#endif /* #ifdef CONFIG_RCU_BOOST */
5451

5552
#ifdef CONFIG_RCU_NOCB_CPU
5653
static cpumask_var_t rcu_nocb_mask; /* CPUs to have callbacks offloaded. */
@@ -98,6 +95,9 @@ static void __init rcu_bootup_announce_oddness(void)
9895
pr_info("\tBoot-time adjustment of leaf fanout to %d.\n", rcu_fanout_leaf);
9996
if (nr_cpu_ids != NR_CPUS)
10097
pr_info("\tRCU restricting CPUs from NR_CPUS=%d to nr_cpu_ids=%d.\n", NR_CPUS, nr_cpu_ids);
98+
#ifdef CONFIG_RCU_BOOST
99+
pr_info("\tRCU kthread priority: %d.\n", kthread_prio);
100+
#endif
101101
}
102102

103103
#ifdef CONFIG_TREE_PREEMPT_RCU
@@ -1339,7 +1339,7 @@ static int rcu_spawn_one_boost_kthread(struct rcu_state *rsp,
13391339
smp_mb__after_unlock_lock();
13401340
rnp->boost_kthread_task = t;
13411341
raw_spin_unlock_irqrestore(&rnp->lock, flags);
1342-
sp.sched_priority = RCU_BOOST_PRIO;
1342+
sp.sched_priority = kthread_prio;
13431343
sched_setscheduler_nocheck(t, SCHED_FIFO, &sp);
13441344
wake_up_process(t); /* get to TASK_INTERRUPTIBLE quickly. */
13451345
return 0;
@@ -1356,7 +1356,7 @@ static void rcu_cpu_kthread_setup(unsigned int cpu)
13561356
{
13571357
struct sched_param sp;
13581358

1359-
sp.sched_priority = RCU_KTHREAD_PRIO;
1359+
sp.sched_priority = kthread_prio;
13601360
sched_setscheduler_nocheck(current, SCHED_FIFO, &sp);
13611361
}
13621362

‎tools/testing/selftests/rcutorture/configs/rcu/TREE03‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ CONFIG_DEBUG_LOCK_ALLOC=n
1717
CONFIG_RCU_CPU_STALL_INFO=n
1818
CONFIG_RCU_CPU_STALL_VERBOSE=n
1919
CONFIG_RCU_BOOST=y
20-
CONFIG_RCU_BOOST_PRIO=2
20+
CONFIG_RCU_KTHREAD_PRIO=2
2121
CONFIG_DEBUG_OBJECTS_RCU_HEAD=n

‎tools/testing/selftests/rcutorture/doc/TREE_RCU-kconfig.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ CONFIG_PREEMPT -- Do half. (First three and #8.)
1515
CONFIG_PROVE_LOCKING -- Do all but two, covering CONFIG_PROVE_RCU and not.
1616
CONFIG_PROVE_RCU -- Do all but one under CONFIG_PROVE_LOCKING.
1717
CONFIG_RCU_BOOST -- one of TREE_PREEMPT_RCU.
18-
CONFIG_RCU_BOOST_PRIO -- set to 2 for _BOOST testing.
19-
CONFIG_RCU_CPU_STALL_INFO -- do one with and without _VERBOSE.
18+
CONFIG_RCU_KTHREAD_PRIO -- set to 2 for _BOOST testing.
19+
CONFIG_RCU_CPU_STALL_INFO -- Do one.
2020
CONFIG_RCU_CPU_STALL_VERBOSE -- do one with and without _INFO.
2121
CONFIG_RCU_FANOUT -- Cover hierarchy as currently, but overlap with others.
2222
CONFIG_RCU_FANOUT_EXACT -- Do one.

0 commit comments

Comments
 (0)