x86, entry: Only call user_exit if TIF_NOHZ
authorAndy Lutomirski <luto@amacapital.net>
Fri, 5 Sep 2014 22:13:53 +0000 (15:13 -0700)
committerH. Peter Anvin <hpa@linux.intel.com>
Mon, 8 Sep 2014 21:13:59 +0000 (14:13 -0700)
The RCU context tracking code requires that arch code call
user_exit() on any entry into kernel code if TIF_NOHZ is set.  This
patch adds a check for TIF_NOHZ and a comment to the syscall entry
tracing code.

The main purpose of this patch is to make the code easier to follow:
one can read the body of user_exit and of every function it calls
without finding any explanation of why it's called for traced
syscalls but not for untraced syscalls.  This makes it clear when
user_exit() is necessary.

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Link: http://lkml.kernel.org/r/0b13e0e24ec0307d67ab7a23b58764f6b1270116.1409954077.git.luto@amacapital.net
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
arch/x86/kernel/ptrace.c

index 39296d2..bbf338a 100644 (file)
@@ -1449,7 +1449,12 @@ long syscall_trace_enter(struct pt_regs *regs)
 {
        long ret = 0;
 
-       user_exit();
+       /*
+        * If TIF_NOHZ is set, we are required to call user_exit() before
+        * doing anything that could touch RCU.
+        */
+       if (test_thread_flag(TIF_NOHZ))
+               user_exit();
 
        /*
         * If we stepped into a sysenter/syscall insn, it trapped in