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>] [day] [month] [year] [list]
Message-ID: <20110314035041.GA12965@tsunami.ccur.com>
Date:	Sun, 13 Mar 2011 23:50:41 -0400
From:	Joe Korty <joe.korty@...r.com>
To:	paulmck@...ux.vnet.ibm.com
Cc:	fweisbec@...il.com, peterz@...radead.org, laijs@...fujitsu.com,
	mathieu.desnoyers@...icios.com, dhowells@...hat.com,
	loic.minier@...aro.org, dhaval.giani@...il.com, tglx@...utronix.de,
	josh@...htriplett.org, houston.jim@...cast.net,
	andi@...stfloor.org, linux-kernel@...r.kernel.org
Subject: [PATCH 5/9] jrcu: factor out preempt_count_cpu

jrcu: make preempt_count_cpu() nonexistant if jrcu
nonexistant.

preempt_count_cpu()'s existance introduces a (very small)
bit of overhead in the context switch path, so don't
compile it in unless some kernel feature that uses it is
also compiled in.

Currently, jrcu is its only user.

Signed-off-by: Joe Korty <joe.korty@...r.com>

Index: b/kernel/sched.c
===================================================================
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -2657,6 +2657,8 @@ void sched_fork(struct task_struct *p, i
 	put_cpu();
 }
 
+#ifdef CONFIG_PREEMPT_COUNT_CPU
+
 /*
  * Fetch the preempt count of some cpu's current task.  Must be called
  * with interrupts blocked.  Stale return value.
@@ -2671,6 +2673,7 @@ int preempt_count_cpu(int cpu)
 	smp_rmb(); /* stop data prefetch until program ctr gets here */
 	return task_thread_info(cpu_curr(cpu))->preempt_count;
 }
+#endif
 
 /*
  * wake_up_new_task - wake up a newly created task for the first time.
@@ -4009,7 +4012,9 @@ need_resched_nonpreemptible:
 
 		rq->nr_switches++;
 		rq->curr = next;
-		smp_wmb(); /* for preempt_count_cpu() */
+#ifdef CONFIG_PREEMPT_COUNT_CPU
+		smp_wmb();
+#endif
 		++*switch_count;
 
 		context_switch(rq, prev, next); /* unlocks the rq */
@@ -8225,7 +8230,9 @@ struct task_struct *curr_task(int cpu)
 void set_curr_task(int cpu, struct task_struct *p)
 {
 	cpu_curr(cpu) = p;
-	smp_wmb(); /* for preempt_count_cpu() */
+#ifdef CONFIG_PREEMPT_COUNT_CPU
+	smp_wmb();
+#endif
 }
 
 #endif
Index: b/include/linux/preempt.h
===================================================================
--- a/include/linux/preempt.h
+++ b/include/linux/preempt.h
@@ -22,7 +22,9 @@
 #define dec_preempt_count() sub_preempt_count(1)
 
 #define preempt_count()	(current_thread_info()->preempt_count)
+#ifdef CONFIG_PREEMPT_COUNT_CPU
 extern int preempt_count_cpu(int cpu);
+#endif
 
 #ifdef CONFIG_PREEMPT
 
Index: b/init/Kconfig
===================================================================
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -388,6 +388,7 @@ config JRCU
 	bool "A tiny single-CPU RCU for small SMP systems"
 	depends on PREEMPT
 	depends on SMP
+	select PREEMPT_COUNT_CPU
 	help
 	  This option selects a minimal-footprint RCU suitable for small SMP
 	  systems -- that is, those with fewer than 16 or perhaps 32, and
@@ -433,6 +434,16 @@ 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 PREEMPT_COUNT_CPU
+	# bool "Let one CPU look at another CPUs preemption count"
+	bool
+	default n
+	help
+	  If Y then the preempt_count_cpu() function will be compiled into
+	  the kernel.  Its existance impacts kernel performance slightly,
+	  so this option should be selected only if other kernel features
+	  that use preempt_count_cpu() are also selected.
+
 config RCU_TRACE
 	bool "Enable tracing for RCU"
 	help
--
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