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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 07 Jul 2011 22:36:14 +0200
From:	Peter Zijlstra <a.p.zijlstra@...llo.nl>
To:	Jason Baron <jbaron@...hat.com>
Cc:	Ingo Molnar <mingo@...e.hu>, Paul Turner <pjt@...gle.com>,
	linux-kernel@...r.kernel.org,
	Bharata B Rao <bharata@...ux.vnet.ibm.com>,
	Dhaval Giani <dhaval.giani@...il.com>,
	Balbir Singh <balbir@...ux.vnet.ibm.com>,
	Vaidyanathan Srinivasan <svaidy@...ux.vnet.ibm.com>,
	Srivatsa Vaddagiri <vatsa@...ibm.com>,
	Kamalesh Babulal <kamalesh@...ux.vnet.ibm.com>,
	Hidetoshi Seto <seto.hidetoshi@...fujitsu.com>,
	Pavel Emelyanov <xemul@...nvz.org>,
	Hu Tao <hutao@...fujitsu.com>, Mike Galbraith <efault@....de>
Subject: jump_label defaults (was Re: [patch 00/17] CFS Bandwidth Control
 v7.1)

[resend because I somehow managed to wreck the lkml address]

On Thu, 2011-07-07 at 14:15 -0400, Jason Baron wrote:
> We don't have to wait until jump_label_init() to make it take effect.
> 
> We could introduce something like: static_branch_default_false(&foo),
> and static_branch_default_true(&foo), which are set at compile time. I
> was waiting for a real world example before introducing it, but if this
> would solve your issue,  we can look at it. 

Hrm,. I can't seem to make that work, damn CPP for not being recursive.

The thing in question is the below patch, I'd need something like:

sed -ie 's/1)/true)' -e 's/0)/false)/' kernel/sched_features.h

#define SCHED_FEAT(name, enabled)	\
	#define static_branch_##name static_branch_default_##enabled
#include "sched_features.h"
#undef SCHED_FEAT

so that I can then do:

#define sched_feat(x)	\
	static_branch_##x(&sched_feat_keys[__SCHED_FEAT_##x]))

Otherwise there's no way to get the default thing related to x.

Also, it still needs an initializer for jump_label_key to get in the
correct state.

---
Subject: sched: Use jump_labels for sched_feat
From: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Date: Wed Jul 06 14:20:14 CEST 2011

static_branch() is disabled by default, but more sched_feat are enabled
by default, so invert the logic. Fixup the few stragglers on
late_initcall().

Signed-off-by: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Link: http://lkml.kernel.org/n/tip-10afjk8n3eu30jytrhdpaluc@git.kernel.org
---
 kernel/sched.c |   33 ++++++++++++++++++++++++++-------
 1 file changed, 26 insertions(+), 7 deletions(-)

Index: linux-2.6/kernel/sched.c
===================================================================
--- linux-2.6.orig/kernel/sched.c
+++ linux-2.6/kernel/sched.c
@@ -71,6 +71,7 @@
 #include <linux/ctype.h>
 #include <linux/ftrace.h>
 #include <linux/slab.h>
+#include <linux/jump_label.h>
 
 #include <asm/tlb.h>
 #include <asm/irq_regs.h>
@@ -691,6 +692,7 @@ int runqueue_is_locked(int cpu)
 
 enum {
 #include "sched_features.h"
+	__SCHED_FEAT_NR
 };
 
 #undef SCHED_FEAT
@@ -710,16 +712,17 @@ const_debug unsigned int sysctl_sched_fe
 
 static __read_mostly char *sched_feat_names[] = {
 #include "sched_features.h"
-	NULL
 };
 
 #undef SCHED_FEAT
 
+static struct jump_label_key sched_feat_keys[__SCHED_FEAT_NR];
+
 static int sched_feat_show(struct seq_file *m, void *v)
 {
 	int i;
 
-	for (i = 0; sched_feat_names[i]; i++) {
+	for (i = 0; i < __SCHED_FEAT_NR; i++) {
 		if (!(sysctl_sched_features & (1UL << i)))
 			seq_puts(m, "NO_");
 		seq_printf(m, "%s ", sched_feat_names[i]);
@@ -752,17 +755,22 @@ sched_feat_write(struct file *filp, cons
 		cmp += 3;
 	}
 
-	for (i = 0; sched_feat_names[i]; i++) {
+	for (i = 0; i < __SCHED_FEAT_NR; i++) {
 		if (strcmp(cmp, sched_feat_names[i]) == 0) {
-			if (neg)
+			if (neg) {
 				sysctl_sched_features &= ~(1UL << i);
-			else
+				if (!jump_label_enabled(&sched_feat_keys[i]))
+					jump_label_inc(&sched_feat_keys[i]);
+			} else {
 				sysctl_sched_features |= (1UL << i);
+				if (jump_label_enabled(&sched_feat_keys[i]))
+					jump_label_dec(&sched_feat_keys[i]);
+			}
 			break;
 		}
 	}
 
-	if (!sched_feat_names[i])
+	if (i == __SCHED_FEAT_NR)
 		return -EINVAL;
 
 	*ppos += cnt;
@@ -785,6 +793,13 @@ static const struct file_operations sche
 
 static __init int sched_init_debug(void)
 {
+	int i;
+
+	for (i = 0; i < __SCHED_FEAT_NR; i++) {
+		if (!(sysctl_sched_features & (1UL << i)))
+			jump_label_inc(&sched_feat_keys[i]);
+	}
+
 	debugfs_create_file("sched_features", 0644, NULL, NULL,
 			&sched_feat_fops);
 
@@ -792,10 +807,14 @@ static __init int sched_init_debug(void)
 }
 late_initcall(sched_init_debug);
 
-#endif
+#define sched_feat(x) (!static_branch(&sched_feat_keys[__SCHED_FEAT_##x]))
+
+#else /* CONFIG_SCHED_DEBUG */
 
 #define sched_feat(x) (sysctl_sched_features & (1UL << __SCHED_FEAT_##x))
 
+#endif /* CONFIG_SCHED_DEBUG */
+
 /*
  * Number of tasks to iterate in a single balance run.
  * Limited because this is done with IRQs disabled.


--
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