mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Ingo Molnar <mingo@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Borislav Petkov <bp@alien8.de>,
	Li Zhong <zhong@linux.vnet.ibm.com>,
	Mike Galbraith <efault@gmx.de>, Kevin Hilman <khilman@linaro.org>
Subject: [PATCH 08/18] context_tracking: Ground setup for static key use
Date: Wed, 17 Jul 2013 18:44:21 +0200	[thread overview]
Message-ID: <1374079471-3129-9-git-send-email-fweisbec@gmail.com> (raw)
In-Reply-To: <1374079471-3129-1-git-send-email-fweisbec@gmail.com>

Prepare for using a static key in the context tracking subsystem.
This will help optimizing the off case on its many users:

* user_enter, user_exit, exception_enter, exception_exit, guest_enter,
  guest_exit, vtime_*()

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Li Zhong <zhong@linux.vnet.ibm.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Kevin Hilman <khilman@linaro.org>
---
 include/linux/context_tracking.h |    2 ++
 kernel/context_tracking.c        |   26 ++++++++++++++++++++------
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/include/linux/context_tracking.h b/include/linux/context_tracking.h
index 2c2b73aa..0007ab4 100644
--- a/include/linux/context_tracking.h
+++ b/include/linux/context_tracking.h
@@ -4,6 +4,7 @@
 #include <linux/sched.h>
 #include <linux/percpu.h>
 #include <linux/vtime.h>
+#include <linux/static_key.h>
 #include <asm/ptrace.h>
 
 struct context_tracking {
@@ -22,6 +23,7 @@ struct context_tracking {
 
 
 #ifdef CONFIG_CONTEXT_TRACKING
+extern struct static_key context_tracking_enabled;
 DECLARE_PER_CPU(struct context_tracking, context_tracking);
 
 static inline bool context_tracking_in_user(void)
diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c
index 72bcb25..f07505c 100644
--- a/kernel/context_tracking.c
+++ b/kernel/context_tracking.c
@@ -20,15 +20,16 @@
 #include <linux/hardirq.h>
 #include <linux/export.h>
 
-DEFINE_PER_CPU(struct context_tracking, context_tracking) = {
-#ifdef CONFIG_CONTEXT_TRACKING_FORCE
-	.active = true,
-#endif
-};
+struct static_key context_tracking_enabled = STATIC_KEY_INIT_FALSE;
+
+DEFINE_PER_CPU(struct context_tracking, context_tracking);
 
 void context_tracking_cpu_set(int cpu)
 {
-	per_cpu(context_tracking.active, cpu) = true;
+	if (!per_cpu(context_tracking.active, cpu)) {
+		per_cpu(context_tracking.active, cpu) = true;
+		static_key_slow_inc(&context_tracking_enabled);
+	}
 }
 
 /**
@@ -202,3 +203,16 @@ void context_tracking_task_switch(struct task_struct *prev,
 	clear_tsk_thread_flag(prev, TIF_NOHZ);
 	set_tsk_thread_flag(next, TIF_NOHZ);
 }
+
+#ifdef CONFIG_CONTEXT_TRACKING_FORCE
+static int __init context_tracking_init(void)
+{
+	int cpu;
+
+	for_each_possible_cpu(cpu)
+		context_tracking_cpu_set(cpu);
+
+	return 0;
+}
+early_initcall(context_tracking_init);
+#endif
-- 
1.7.5.4


  parent reply	other threads:[~2013-07-17 16:44 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-17 16:44 [PATCH 00/18] nohz patches for 3.12 preview Frederic Weisbecker
2013-07-17 16:44 ` [PATCH 01/18] nohz: Do not warn about unstable tsc unless user uses nohz_full Frederic Weisbecker
2013-07-17 16:44 ` [PATCH 02/18] nohz: fix compile warning in tick_nohz_init() Frederic Weisbecker
2013-07-17 16:44 ` [PATCH 03/18] sched: Consolidate open coded preemptible() checks Frederic Weisbecker
2013-07-17 16:44 ` [PATCH 04/18] context_tracing: Fix guest accounting with native vtime Frederic Weisbecker
2013-07-17 16:44 ` [PATCH 05/18] vtime: Update a few comments Frederic Weisbecker
2013-07-17 17:57   ` Steven Rostedt
2013-07-18 21:30     ` Frederic Weisbecker
2013-07-17 16:44 ` [PATCH 06/18] context_tracking: Fix runtime CPU off-case Frederic Weisbecker
2013-07-17 16:44 ` [PATCH 07/18] nohz: Selectively enable context tracking on full dynticks CPUs Frederic Weisbecker
2013-07-17 18:27   ` Steven Rostedt
2013-07-18 22:13     ` Frederic Weisbecker
2013-07-18 22:51       ` Steven Rostedt
2013-07-19 14:19         ` Frederic Weisbecker
2013-07-17 16:44 ` Frederic Weisbecker [this message]
2013-07-17 16:44 ` [PATCH 09/18] context_tracking: Optimize main APIs off case with static key Frederic Weisbecker
2013-07-17 16:44 ` [PATCH 10/18] context_tracking: Optimize context switch off case with static keys Frederic Weisbecker
2013-07-17 16:44 ` [PATCH 11/18] context_tracking: User/kernel broundary cross trace events Frederic Weisbecker
2013-07-17 16:44 ` [PATCH 12/18] vtime: Remove a few unneeded generic vtime state checks Frederic Weisbecker
2013-07-17 16:44 ` [PATCH 13/18] vtime: Fix racy cputime delta update Frederic Weisbecker
2013-07-17 16:44 ` [PATCH 14/18] context_tracking: Split low level state headers Frederic Weisbecker
2013-07-17 16:44 ` [PATCH 15/18] vtime: Describe overriden functions in dedicated arch headers Frederic Weisbecker
2013-07-17 16:44 ` [PATCH 16/18] vtime: Optimize full dynticks accounting off case with static keys Frederic Weisbecker
2013-07-17 16:44 ` [PATCH 17/18] vtime: Always scale generic vtime accounting results Frederic Weisbecker
2013-07-17 16:44 ` [PATCH 18/18] vtime: Always debug check snapshot source _before_ updating it Frederic Weisbecker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1374079471-3129-9-git-send-email-fweisbec@gmail.com \
    --to=fweisbec@gmail.com \
    --cc=bp@alien8.de \
    --cc=efault@gmx.de \
    --cc=khilman@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=zhong@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome