lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Fri, 27 Nov 2009 15:45:54 +0100
From:	ehrhardt@...ux.vnet.ibm.com
To:	peterz@...radead.org, mingo@...e.hu, linux-kernel@...r.kernel.org
Cc:	ehrhardt@...ux.vnet.ibm.com, Holger.Wolf@...ibm.com,
	epasch@...ibm.com, schwidefsky@...ibm.com
Subject: [PATCH 2/3] sched: make tunable scaling style configurable

From: Christian Ehrhardt <ehrhardt@...ux.vnet.ibm.com>

As scaling now takes place on all kind of cpu add/remove events a user that
configures values via proc should be able to configure if his set values are
still rescaled or kept whatever happens.

As the comments state that log2 was just a second guess that worked the
interface is not just designed for on/off, but to choose a scaling type.
Currently this allows none, log and linear, but more important it allwos us
to keep the interface even if someone has an even better idea how to scale
the values.

Signed-off-by: Christian Ehrhardt <ehrhardt@...ux.vnet.ibm.com>
---

[diffstat]
 include/linux/sched.h |   11 ++++++++++-
 kernel/sched.c        |   15 +++++++++++++++
 kernel/sched_debug.c  |   10 ++++++++++
 kernel/sched_fair.c   |   12 ++++++++++++
 kernel/sysctl.c       |   14 ++++++++++++++
 5 files changed, 61 insertions(+), 1 deletion(-)

[diff]
Index: linux-2.6-git-schedrecalc/include/linux/sched.h
===================================================================
--- linux-2.6-git-schedrecalc.orig/include/linux/sched.h
+++ linux-2.6-git-schedrecalc/include/linux/sched.h
@@ -1899,6 +1899,15 @@ extern unsigned int sysctl_sched_wakeup_
 extern unsigned int sysctl_sched_shares_ratelimit;
 extern unsigned int sysctl_sched_shares_thresh;
 extern unsigned int sysctl_sched_child_runs_first;
+
+enum sched_tunable_scaling
+{
+	SCHED_TUNABLESCALING_NONE,
+	SCHED_TUNABLESCALING_LOG,
+	SCHED_TUNABLESCALING_LINEAR,
+	SCHED_TUNABLESCALING_END,
+};
+extern enum sched_tunable_scaling sysctl_sched_tunable_scaling;
 #ifdef CONFIG_SCHED_DEBUG
 extern unsigned int sysctl_sched_features;
 extern unsigned int sysctl_sched_migration_cost;
@@ -1906,7 +1915,7 @@ extern unsigned int sysctl_sched_nr_migr
 extern unsigned int sysctl_sched_time_avg;
 extern unsigned int sysctl_timer_migration;
 
-int sched_nr_latency_handler(struct ctl_table *table, int write,
+int sched_proc_update_handler(struct ctl_table *table, int write,
 		void __user *buffer, size_t *length,
 		loff_t *ppos);
 #endif
Index: linux-2.6-git-schedrecalc/kernel/sched.c
===================================================================
--- linux-2.6-git-schedrecalc.orig/kernel/sched.c
+++ linux-2.6-git-schedrecalc/kernel/sched.c
@@ -7010,6 +7010,21 @@ static void update_sysctl(void)
 	unsigned int cpus = max(num_online_cpus(), 8U);
 	unsigned int factor = 1 + ilog2(cpus);
 
+	unsigned int factor;
+
+	switch (sysctl_sched_tunable_scaling) {
+		case SCHED_TUNABLESCALING_NONE:
+			factor = 1;
+			break;
+		case SCHED_TUNABLESCALING_LINEAR:
+			factor = cpus;
+			break;
+		case SCHED_TUNABLESCALING_LOG:
+		default:
+			factor = 1 + ilog2(cpus);
+			break;
+	}
+
 #define SET_SYSCTL(name) \
 	sysctl_##name = (factor) * normalized_sysctl_##name
 	SET_SYSCTL(sched_min_granularity);
Index: linux-2.6-git-schedrecalc/kernel/sched_fair.c
===================================================================
--- linux-2.6-git-schedrecalc.orig/kernel/sched_fair.c
+++ linux-2.6-git-schedrecalc/kernel/sched_fair.c
@@ -21,6 +21,7 @@
  */
 
 #include <linux/latencytop.h>
+#include <linux/sched.h>
 
 /*
  * Targeted preemption latency for CPU-bound tasks:
@@ -38,6 +39,17 @@ unsigned int sysctl_sched_latency = 5000
 unsigned int normalized_sysctl_sched_latency = 5000000ULL;
 
 /*
+ * The initial- and re-scaling of tunables is configurable
+ * (default SCHED_TUNABLESCALING_LOG = *(1+ilog(ncpus))
+ *
+ * Options are:
+ * SCHED_TUNABLESCALING_NONE - unscaled, always *1
+ * SCHED_TUNABLESCALING_LOG - scaled logarithmical, *1+ilog(ncpus)
+ * SCHED_TUNABLESCALING_LINEAR - scaled linear, *ncpus
+ */
+enum sched_tunable_scaling sysctl_sched_tunable_scaling = SCHED_TUNABLESCALING_LOG;
+
+/*
  * Minimal preemption granularity for CPU-bound tasks:
  * (default: 1 msec * (1 + ilog(ncpus)), units: nanoseconds)
  */
Index: linux-2.6-git-schedrecalc/kernel/sysctl.c
===================================================================
--- linux-2.6-git-schedrecalc.orig/kernel/sysctl.c
+++ linux-2.6-git-schedrecalc/kernel/sysctl.c
@@ -248,6 +248,8 @@ static int min_sched_granularity_ns = 10
 static int max_sched_granularity_ns = NSEC_PER_SEC;	/* 1 second */
 static int min_wakeup_granularity_ns;			/* 0 usecs */
 static int max_wakeup_granularity_ns = NSEC_PER_SEC;	/* 1 second */
+static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
+static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
 #endif
 
 static struct ctl_table kern_table[] = {
@@ -303,6 +305,18 @@ static struct ctl_table kern_table[] = {
 	},
 	{
 		.ctl_name	= CTL_UNNUMBERED,
+		.procname	= "sched_tunable_scaling",
+		.data		= &sysctl_sched_tunable_scaling,
+		.maxlen		= sizeof(enum sched_tunable_scaling),
+		.mode		= 0644,
+		.proc_handler	= &proc_dointvec_minmax,
+		.strategy	= &sysctl_intvec,
+		.extra1		= &min_sched_tunable_scaling,
+		.extra2		= &max_sched_tunable_scaling,
+	},
+
+	{
+		.ctl_name	= CTL_UNNUMBERED,
 		.procname	= "sched_shares_thresh",
 		.data		= &sysctl_sched_shares_thresh,
 		.maxlen		= sizeof(unsigned int),
Index: linux-2.6-git-schedrecalc/kernel/sched_debug.c
===================================================================
--- linux-2.6-git-schedrecalc.orig/kernel/sched_debug.c
+++ linux-2.6-git-schedrecalc/kernel/sched_debug.c
@@ -305,6 +305,12 @@ static void print_cpu(struct seq_file *m
 	print_rq(m, rq, cpu);
 }
 
+static const char *sched_tunable_scaling_names[] = {
+	"none",
+	"logaritmic",
+	"linear"
+};
+
 static int sched_debug_show(struct seq_file *m, void *v)
 {
 	u64 now = ktime_to_ns(ktime_get());
@@ -330,6 +336,10 @@ static int sched_debug_show(struct seq_f
 #undef PN
 #undef P
 
+	SEQ_printf(m, "  .%-40s: %d (%s)\n", "sysctl_sched_tunable_scaling",
+		sysctl_sched_tunable_scaling,
+		sched_tunable_scaling_names[sysctl_sched_tunable_scaling]);
+
 	for_each_online_cpu(cpu)
 		print_cpu(m, cpu);
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ