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/23] context_tracking: Optimize main APIs off case with static key
Date: Thu,  1 Aug 2013 02:31:25 +0200	[thread overview]
Message-ID: <1375317100-20651-9-git-send-email-fweisbec@gmail.com> (raw)
In-Reply-To: <1375317100-20651-1-git-send-email-fweisbec@gmail.com>

Optimize user and exception entry/exit APIs with static
keys. This minimize the overhead for those who enable
CONFIG_NO_HZ_FULL without always using it. Having no range
passed to nohz_full= should result in the probes to be nopped
(at least we hope so...).

If this proves not be enough in the long term, we'll need
to bring an exception slow path by re-routing the exception
handlers.

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 |   27 ++++++++++++++++++++++-----
 kernel/context_tracking.c        |   12 ++++++------
 2 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/include/linux/context_tracking.h b/include/linux/context_tracking.h
index f9356eb..e5ec0c9 100644
--- a/include/linux/context_tracking.h
+++ b/include/linux/context_tracking.h
@@ -38,23 +38,40 @@ static inline bool context_tracking_active(void)
 
 extern void context_tracking_cpu_set(int cpu);
 
-extern void user_enter(void);
-extern void user_exit(void);
+extern void context_tracking_user_enter(void);
+extern void context_tracking_user_exit(void);
+
+static inline void user_enter(void)
+{
+	if (static_key_false(&context_tracking_enabled))
+		context_tracking_user_enter();
+
+}
+static inline void user_exit(void)
+{
+	if (static_key_false(&context_tracking_enabled))
+		context_tracking_user_exit();
+}
 
 static inline enum ctx_state exception_enter(void)
 {
 	enum ctx_state prev_ctx;
 
+	if (!static_key_false(&context_tracking_enabled))
+		return 0;
+
 	prev_ctx = this_cpu_read(context_tracking.state);
-	user_exit();
+	context_tracking_user_exit();
 
 	return prev_ctx;
 }
 
 static inline void exception_exit(enum ctx_state prev_ctx)
 {
-	if (prev_ctx == IN_USER)
-		user_enter();
+	if (static_key_false(&context_tracking_enabled)) {
+		if (prev_ctx == IN_USER)
+			context_tracking_user_enter();
+	}
 }
 
 extern void context_tracking_task_switch(struct task_struct *prev,
diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c
index f07505c..657f668 100644
--- a/kernel/context_tracking.c
+++ b/kernel/context_tracking.c
@@ -33,15 +33,15 @@ void context_tracking_cpu_set(int cpu)
 }
 
 /**
- * user_enter - Inform the context tracking that the CPU is going to
- *              enter userspace mode.
+ * context_tracking_user_enter - Inform the context tracking that the CPU is going to
+ *                               enter userspace mode.
  *
  * This function must be called right before we switch from the kernel
  * to userspace, when it's guaranteed the remaining kernel instructions
  * to execute won't use any RCU read side critical section because this
  * function sets RCU in extended quiescent state.
  */
-void user_enter(void)
+void context_tracking_user_enter(void)
 {
 	unsigned long flags;
 
@@ -131,8 +131,8 @@ EXPORT_SYMBOL_GPL(preempt_schedule_context);
 #endif /* CONFIG_PREEMPT */
 
 /**
- * user_exit - Inform the context tracking that the CPU is
- *             exiting userspace mode and entering the kernel.
+ * context_tracking_user_exit - Inform the context tracking that the CPU is
+ *                              exiting userspace mode and entering the kernel.
  *
  * This function must be called after we entered the kernel from userspace
  * before any use of RCU read side critical section. This potentially include
@@ -141,7 +141,7 @@ EXPORT_SYMBOL_GPL(preempt_schedule_context);
  * This call supports re-entrancy. This way it can be called from any exception
  * handler without needing to know if we came from userspace or not.
  */
-void user_exit(void)
+void context_tracking_user_exit(void)
 {
 	unsigned long flags;
 
-- 
1.7.5.4


  parent reply	other threads:[~2013-08-01  0:32 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-01  0:31 [GIT PULL] nohz patches for 3.12 preview v3 Frederic Weisbecker
2013-08-01  0:31 ` [PATCH 01/23] sched: Consolidate open coded preemptible() checks Frederic Weisbecker
2013-08-01  0:31 ` [PATCH 02/23] context_tracing: Fix guest accounting with native vtime Frederic Weisbecker
2013-08-01  0:31 ` [PATCH 03/23] vtime: Update a few comments Frederic Weisbecker
2013-08-01  0:31 ` [PATCH 04/23] context_tracking: Fix runtime CPU off-case Frederic Weisbecker
2013-08-01  0:31 ` [PATCH 05/23] nohz: Only enable context tracking on full dynticks CPUs Frederic Weisbecker
2013-08-01  0:31 ` [PATCH 06/23] context_tracking: Remove full dynticks' hacky dependency on wide context tracking Frederic Weisbecker
2013-08-01  0:31 ` [PATCH 07/23] context_tracking: Ground setup for static key use Frederic Weisbecker
2013-08-01  0:31 ` Frederic Weisbecker [this message]
2013-08-01  0:31 ` [PATCH 09/23] context_tracking: Optimize guest APIs off case with static key Frederic Weisbecker
2013-08-01  0:31 ` [PATCH 10/23] context_tracking: Optimize context switch off case with static keys Frederic Weisbecker
2013-08-01  0:31 ` [PATCH 11/23] context_tracking: User/kernel broundary cross trace events Frederic Weisbecker
2013-08-01  0:31 ` [PATCH 12/23] vtime: Remove a few unneeded generic vtime state checks Frederic Weisbecker
2013-08-01  0:31 ` [PATCH 13/23] vtime: Fix racy cputime delta update Frederic Weisbecker
2013-08-01  0:31 ` [PATCH 14/23] context_tracking: Split low level state headers Frederic Weisbecker
2013-08-01  0:31 ` [PATCH 15/23] hardirq: Split preempt count mask definitions Frederic Weisbecker
2013-08-01  0:31 ` [PATCH 16/23] m68k: hardirq_count() only need preempt_mask.h Frederic Weisbecker
2013-08-01  0:31 ` [PATCH 17/23] vtime: Describe overriden functions in dedicated arch headers Frederic Weisbecker
2013-08-01  0:31 ` [PATCH 18/23] vtime: Optimize full dynticks accounting off case with static keys Frederic Weisbecker
2013-08-01  0:31 ` [PATCH 19/23] vtime: Always scale generic vtime accounting results Frederic Weisbecker
2013-08-01  0:31 ` [PATCH 20/23] vtime: Always debug check snapshot source _before_ updating it Frederic Weisbecker
2013-08-01  0:31 ` [PATCH 21/23] nohz: Rename a few state variables Frederic Weisbecker
2013-08-01  0:31 ` [PATCH 22/23] nohz: Optimize full dynticks state checks with static keys Frederic Weisbecker
2013-08-01  0:31 ` [PATCH 23/23] nohz: Optimize full dynticks's sched hooks " Frederic Weisbecker
2013-08-01  8:29 ` [GIT PULL] nohz patches for 3.12 preview v3 Peter Zijlstra
2013-08-03 15:46   ` 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=1375317100-20651-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

all inboxes | Powered by JetHome®