Skip to content

Commit c8db27d

Browse files
chaikenpaulmckrcu
authored andcommitted
rcu: Move kthread_prio bounds-check to a separate function
Move the bounds-check of the kthread_prio cmdline parameter to a new function in order to faciliate a different callsite. Signed-off-by: Alison Chaiken <achaiken@aurora.tech> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
1 parent 4b4399b commit c8db27d

1 file changed

Lines changed: 23 additions & 16 deletions

File tree

kernel/rcu/tree.c

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4440,26 +4440,10 @@ static int rcu_pm_notify(struct notifier_block *self,
44404440
static int __init rcu_spawn_gp_kthread(void)
44414441
{
44424442
unsigned long flags;
4443-
int kthread_prio_in = kthread_prio;
44444443
struct rcu_node *rnp;
44454444
struct sched_param sp;
44464445
struct task_struct *t;
44474446

4448-
/* Force priority into range. */
4449-
if (IS_ENABLED(CONFIG_RCU_BOOST) && kthread_prio < 2
4450-
&& IS_BUILTIN(CONFIG_RCU_TORTURE_TEST))
4451-
kthread_prio = 2;
4452-
else if (IS_ENABLED(CONFIG_RCU_BOOST) && kthread_prio < 1)
4453-
kthread_prio = 1;
4454-
else if (kthread_prio < 0)
4455-
kthread_prio = 0;
4456-
else if (kthread_prio > 99)
4457-
kthread_prio = 99;
4458-
4459-
if (kthread_prio != kthread_prio_in)
4460-
pr_alert("rcu_spawn_gp_kthread(): Limited prio to %d from %d\n",
4461-
kthread_prio, kthread_prio_in);
4462-
44634447
rcu_scheduler_fully_active = 1;
44644448
t = kthread_create(rcu_gp_kthread, NULL, "%s", rcu_state.name);
44654449
if (WARN_ONCE(IS_ERR(t), "%s: Could not start grace-period kthread, OOM is now expected behavior\n", __func__))
@@ -4584,6 +4568,28 @@ static void __init rcu_init_one(void)
45844568
}
45854569
}
45864570

4571+
/*
4572+
* Force priority from the kernel command-line into range.
4573+
*/
4574+
static void __init sanitize_kthread_prio(void)
4575+
{
4576+
int kthread_prio_in = kthread_prio;
4577+
4578+
if (IS_ENABLED(CONFIG_RCU_BOOST) && kthread_prio < 2
4579+
&& IS_BUILTIN(CONFIG_RCU_TORTURE_TEST))
4580+
kthread_prio = 2;
4581+
else if (IS_ENABLED(CONFIG_RCU_BOOST) && kthread_prio < 1)
4582+
kthread_prio = 1;
4583+
else if (kthread_prio < 0)
4584+
kthread_prio = 0;
4585+
else if (kthread_prio > 99)
4586+
kthread_prio = 99;
4587+
4588+
if (kthread_prio != kthread_prio_in)
4589+
pr_alert("%s: Limited prio to %d from %d\n",
4590+
__func__, kthread_prio, kthread_prio_in);
4591+
}
4592+
45874593
/*
45884594
* Compute the rcu_node tree geometry from kernel parameters. This cannot
45894595
* replace the definitions in tree.h because those are needed to size
@@ -4744,6 +4750,7 @@ void __init rcu_init(void)
47444750

47454751
kfree_rcu_batch_init();
47464752
rcu_bootup_announce();
4753+
sanitize_kthread_prio();
47474754
rcu_init_geometry();
47484755
rcu_init_one();
47494756
if (dump_tree)

0 commit comments

Comments
 (0)