Skip to contentSkip to conversation

jrcu: tuneable priority

PATCH New Joe Korty 1 participant 1 message Mar 24, 2011

lore
Share & tools
lore

Joe Korty

author
#0 lore raw

PATCH 12/24 jrcu: tuneable priority

jrcu: make daemon priority a tuneable.

kernel/jrcu.c +33 -5
Index: b/kernel/jrcu.c
===================================================================
@@ -504,20 +504,42 @@ void __init rcu_scheduler_starting(void)
 #include <linux/param.h>
 #include <linux/kthread.h>
 
+static int rcu_priority;
+static struct task_struct *rcu_daemon;
+
+static int jrcu_set_priority(int priority)
+{
+	struct sched_param param;
+
+	if (priority == 0) {
+		set_user_nice(current, -19);
+		return 0;
+	}
+
+	if (priority < 0)
+		param.sched_priority = MAX_USER_RT_PRIO + priority;
+	else
+		param.sched_priority = priority;
+
+	sched_setscheduler_nocheck(current, SCHED_RR, &param);
+	return param.sched_priority;
+}
+
 static int jrcud_func(void *arg)
 {
-	set_user_nice(current, -19);
 	current->flags |= PF_NOFREEZE;
-
-	pr_info("JRCU: daemon started. Will operate at ~%d Hz.\n", RCU_HZ);
+	rcu_priority = jrcu_set_priority(CONFIG_JRCU_DAEMON_PRIO);
 	rcu_timer_stop();
 
+	pr_info("JRCU: daemon started. Will operate at ~%d Hz.\n", rcu_hz);
+
 	while (!kthread_should_stop()) {
 		usleep_range(rcu_hz_period_us, rcu_hz_period_us + rcu_hz_delta_us);
 		rcu_delimit_batches();
 	}
 
 	pr_info("JRCU: daemon exiting\n");
+	rcu_daemon = NULL;
 	rcu_timer_restart();
 	return 0;
 }
@@ -531,6 +553,7 @@ static __init int jrcud_start(void)
 		pr_warn("JRCU: daemon not started\n");
 		return -ENODEV;
 	}
+	rcu_daemon = p;
 	return 0;
 }
 late_initcall(jrcud_start);
@@ -552,8 +575,13 @@ static int rcu_debugfs_show(struct seq_f
 	msecs = div_s64(sched_clock() - rcu_timestamp, NSEC_PER_MSEC);
 	raw_local_irq_enable();
 
-	seq_printf(m, "%14u: hz\n",
-		rcu_hz);
+	seq_printf(m, "%14u: hz\n", rcu_hz);
+#ifdef CONFIG_JRCU_DAEMON
+	if (rcu_daemon)
+		seq_printf(m, "%14u: daemon priority\n", rcu_priority);
+	else
+		seq_printf(m, "%14s: daemon priority\n", "none, no daemon");
+#endif
 	seq_printf(m, "%14u: #passes seen\n",
 		rcu_stats.npasses);
 	seq_printf(m, "%14u: #batches seen\n",
init/Kconfig +11 -0
Index: b/init/Kconfig
===================================================================
@@ -434,6 +434,17 @@ config JRCU_DAEMON
 	  Required. The context switch when leaving the daemon is needed
 	  to get the CPU to reliably participate in end-of-batch processing.
 
+config JRCU_DAEMON_PRIO
+	int "JRCU Daemon priority"
+	depends on JRCU_DAEMON
+	default 0
+	help
+	  The JRCU daemon priority. If 0 then the daemon runs SCHED_OTHER.
+	  If >0 then the daemon runs SCHED_RR and its priority will be
+	  the value selected.  If <0 then SCHED_RR is again selected, but
+	  now its priority will be the biased downwards from the maximum
+	  possible Posix priority.
+
 config JRCU_LAZY
 	bool "Should JRCU be lazy recognizing end-of-batch"
 	depends on JRCU