linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] x86: reimplement ___preempt_schedule*() using THUNK helpers
@ 2014-09-21 18:41 Oleg Nesterov
  2014-09-21 18:41 ` [PATCH v3 1/2] " Oleg Nesterov
  2014-09-21 18:42 ` [PATCH v3 2/2] x86, lib/Makefile: remove the unnecessary "+= thunk_64.o" Oleg Nesterov
  0 siblings, 2 replies; 25+ messages in thread
From: Oleg Nesterov @ 2014-09-21 18:41 UTC (permalink / raw)
  To: H. Peter Anvin, Ingo Molnar
  Cc: Andi Kleen, Andy Lutomirski, Denys Vlasenko, Peter Zijlstra, x86,
	linux-kernel

Peter, Ingo, please consider for inclusion.

Changes:

	v3: added the acks from Andy, otherwise unchanged

	v2: fix the naming in thunk_32.S (thanks Denys!)

And it seems that the patch below (on top of 1/2) also makes sense...

Oleg.

 arch/x86/kernel/Makefile  |    2 --
 arch/x86/kernel/preempt.S |   25 -------------------------
 arch/x86/lib/Makefile     |    2 +-
 arch/x86/lib/thunk_32.S   |   20 ++++++++++++++++----
 arch/x86/lib/thunk_64.S   |    7 +++++++
 5 files changed, 24 insertions(+), 32 deletions(-)


--- x/arch/x86/include/asm/irqflags.h
+++ x/arch/x86/include/asm/irqflags.h
@@ -166,8 +166,9 @@ static inline int arch_irqs_disabled(voi
 
 #else
 
-#ifdef CONFIG_X86_64
 #define ARCH_LOCKDEP_SYS_EXIT		call lockdep_sys_exit_thunk
+
+#ifdef CONFIG_X86_64
 #define ARCH_LOCKDEP_SYS_EXIT_IRQ	\
 	TRACE_IRQS_ON; \
 	sti; \
@@ -176,17 +177,7 @@ static inline int arch_irqs_disabled(voi
 	RESTORE_REST; \
 	cli; \
 	TRACE_IRQS_OFF;
-
 #else
-#define ARCH_LOCKDEP_SYS_EXIT			\
-	pushl %eax;				\
-	pushl %ecx;				\
-	pushl %edx;				\
-	call lockdep_sys_exit;			\
-	popl %edx;				\
-	popl %ecx;				\
-	popl %eax;
-
 #define ARCH_LOCKDEP_SYS_EXIT_IRQ
 #endif
 
--- x/arch/x86/lib/thunk_32.S
+++ x/arch/x86/lib/thunk_32.S
@@ -33,6 +33,10 @@
 	THUNK trace_hardirqs_off_thunk,trace_hardirqs_off_caller,1
 #endif
 
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
+	THUNK lockdep_sys_exit_thunk,lockdep_sys_exit
+#endif
+
 #ifdef CONFIG_PREEMPT
 	THUNK ___preempt_schedule, preempt_schedule
 #ifdef CONFIG_CONTEXT_TRACKING


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH v3 1/2] x86: reimplement ___preempt_schedule*() using THUNK helpers
  2014-09-21 18:41 [PATCH v3 0/2] x86: reimplement ___preempt_schedule*() using THUNK helpers Oleg Nesterov
@ 2014-09-21 18:41 ` Oleg Nesterov
  2014-09-24 15:02   ` [tip:x86/asm] x86: Speed up ___preempt_schedule*() by " tip-bot for Oleg Nesterov
  2014-09-21 18:42 ` [PATCH v3 2/2] x86, lib/Makefile: remove the unnecessary "+= thunk_64.o" Oleg Nesterov
  1 sibling, 1 reply; 25+ messages in thread
From: Oleg Nesterov @ 2014-09-21 18:41 UTC (permalink / raw)
  To: H. Peter Anvin, Ingo Molnar
  Cc: Andi Kleen, Andy Lutomirski, Denys Vlasenko, Peter Zijlstra, x86,
	linux-kernel

___preempt_schedule() does SAVE_ALL/RESTORE_ALL but this is suboptimal,
we do not need to save/restore the callee-saved register. And we already
have arch/x86/lib/thunk_*.S which implements the similar asm wrappers,
so it makes sense to redefine ___preempt_schedule() as "THUNK ..." and
remove preempt.S altogether.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Andy Lutomirski <luto@amacapital.net>
---
 arch/x86/kernel/Makefile  |    2 --
 arch/x86/kernel/preempt.S |   25 -------------------------
 arch/x86/lib/thunk_32.S   |   20 ++++++++++++++++----
 arch/x86/lib/thunk_64.S   |    7 +++++++
 4 files changed, 23 insertions(+), 31 deletions(-)
 delete mode 100644 arch/x86/kernel/preempt.S

diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index b5ea75c..58cf60b 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -39,8 +39,6 @@ obj-y			+= tsc.o tsc_msr.o io_delay.o rtc.o
 obj-y			+= pci-iommu_table.o
 obj-y			+= resource.o
 
-obj-$(CONFIG_PREEMPT)	+= preempt.o
-
 obj-y				+= process.o
 obj-y				+= i387.o xsave.o
 obj-y				+= ptrace.o
diff --git a/arch/x86/kernel/preempt.S b/arch/x86/kernel/preempt.S
deleted file mode 100644
index ca7f0d5..0000000
--- a/arch/x86/kernel/preempt.S
+++ /dev/null
@@ -1,25 +0,0 @@
-
-#include <linux/linkage.h>
-#include <asm/dwarf2.h>
-#include <asm/asm.h>
-#include <asm/calling.h>
-
-ENTRY(___preempt_schedule)
-	CFI_STARTPROC
-	SAVE_ALL
-	call preempt_schedule
-	RESTORE_ALL
-	ret
-	CFI_ENDPROC
-
-#ifdef CONFIG_CONTEXT_TRACKING
-
-ENTRY(___preempt_schedule_context)
-	CFI_STARTPROC
-	SAVE_ALL
-	call preempt_schedule_context
-	RESTORE_ALL
-	ret
-	CFI_ENDPROC
-
-#endif
diff --git a/arch/x86/lib/thunk_32.S b/arch/x86/lib/thunk_32.S
index 28f85c9..e9acf5f 100644
--- a/arch/x86/lib/thunk_32.S
+++ b/arch/x86/lib/thunk_32.S
@@ -7,16 +7,19 @@
 	#include <linux/linkage.h>
 	#include <asm/asm.h>
 
-#ifdef CONFIG_TRACE_IRQFLAGS
 	/* put return address in eax (arg1) */
-	.macro thunk_ra name,func
+	.macro THUNK name, func, put_ret_addr_in_eax=0
 	.globl \name
 \name:
 	pushl %eax
 	pushl %ecx
 	pushl %edx
+
+	.if \put_ret_addr_in_eax
 	/* Place EIP in the arg1 */
 	movl 3*4(%esp), %eax
+	.endif
+
 	call \func
 	popl %edx
 	popl %ecx
@@ -25,6 +28,15 @@
 	_ASM_NOKPROBE(\name)
 	.endm
 
-	thunk_ra trace_hardirqs_on_thunk,trace_hardirqs_on_caller
-	thunk_ra trace_hardirqs_off_thunk,trace_hardirqs_off_caller
+#ifdef CONFIG_TRACE_IRQFLAGS
+	THUNK trace_hardirqs_on_thunk,trace_hardirqs_on_caller,1
+	THUNK trace_hardirqs_off_thunk,trace_hardirqs_off_caller,1
+#endif
+
+#ifdef CONFIG_PREEMPT
+	THUNK ___preempt_schedule, preempt_schedule
+#ifdef CONFIG_CONTEXT_TRACKING
+	THUNK ___preempt_schedule_context, preempt_schedule_context
 #endif
+#endif
+
diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
index 92d9fea..b30b5eb 100644
--- a/arch/x86/lib/thunk_64.S
+++ b/arch/x86/lib/thunk_64.S
@@ -38,6 +38,13 @@
 	THUNK lockdep_sys_exit_thunk,lockdep_sys_exit
 #endif
 
+#ifdef CONFIG_PREEMPT
+	THUNK ___preempt_schedule, preempt_schedule
+#ifdef CONFIG_CONTEXT_TRACKING
+	THUNK ___preempt_schedule_context, preempt_schedule_context
+#endif
+#endif
+
 	/* SAVE_ARGS below is used only for the .cfi directives it contains. */
 	CFI_STARTPROC
 	SAVE_ARGS
-- 
1.5.5.1



^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 2/2] x86, lib/Makefile: remove the unnecessary "+= thunk_64.o"
  2014-09-21 18:41 [PATCH v3 0/2] x86: reimplement ___preempt_schedule*() using THUNK helpers Oleg Nesterov
  2014-09-21 18:41 ` [PATCH v3 1/2] " Oleg Nesterov
@ 2014-09-21 18:42 ` Oleg Nesterov
  2014-09-24 15:02   ` [tip:x86/asm] x86/lib/Makefile: Remove " tip-bot for Oleg Nesterov
  1 sibling, 1 reply; 25+ messages in thread
From: Oleg Nesterov @ 2014-09-21 18:42 UTC (permalink / raw)
  To: H. Peter Anvin, Ingo Molnar
  Cc: Andi Kleen, Andy Lutomirski, Denys Vlasenko, Peter Zijlstra, x86,
	linux-kernel

Trivial. We have "lib-y += thunk_$(BITS).o" at the start, no need
to add thunk_64.o if !CONFIG_X86_32.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Andy Lutomirski <luto@amacapital.net>
---
 arch/x86/lib/Makefile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile
index 4d4f96a..66127b9 100644
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -39,7 +39,7 @@ endif
 else
         obj-y += iomap_copy_64.o
         lib-y += csum-partial_64.o csum-copy_64.o csum-wrappers_64.o
-        lib-y += thunk_64.o clear_page_64.o copy_page_64.o
+        lib-y += clear_page_64.o copy_page_64.o
         lib-y += memmove_64.o memset_64.o
         lib-y += copy_user_64.o copy_user_nocache_64.o
 	lib-y += cmpxchg16b_emu.o
-- 
1.5.5.1



^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers
  2014-09-21 18:41 ` [PATCH v3 1/2] " Oleg Nesterov
@ 2014-09-24 15:02   ` tip-bot for Oleg Nesterov
  2014-10-03  4:50     ` Sasha Levin
  0 siblings, 1 reply; 25+ messages in thread
From: tip-bot for Oleg Nesterov @ 2014-09-24 15:02 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, torvalds, peterz, luto, dvlasenk, tglx, oleg

Commit-ID:  0ad6e3c5199be12c9745da8f8b9e3c9f8066c235
Gitweb:     http://git.kernel.org/tip/0ad6e3c5199be12c9745da8f8b9e3c9f8066c235
Author:     Oleg Nesterov <oleg@redhat.com>
AuthorDate: Sun, 21 Sep 2014 20:41:53 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 24 Sep 2014 15:15:38 +0200

x86: Speed up ___preempt_schedule*() by using THUNK helpers

___preempt_schedule() does SAVE_ALL/RESTORE_ALL but this is
suboptimal, we do not need to save/restore the callee-saved
register. And we already have arch/x86/lib/thunk_*.S which
implements the similar asm wrappers, so it makes sense to
redefine ___preempt_schedule() as "THUNK ..." and remove
preempt.S altogether.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Andy Lutomirski <luto@amacapital.net>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/20140921184153.GA23727@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/Makefile  |  2 --
 arch/x86/kernel/preempt.S | 25 -------------------------
 arch/x86/lib/thunk_32.S   | 20 ++++++++++++++++----
 arch/x86/lib/thunk_64.S   |  7 +++++++
 4 files changed, 23 insertions(+), 31 deletions(-)

diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index ada2e2d..8f1e774 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -39,8 +39,6 @@ obj-y			+= tsc.o tsc_msr.o io_delay.o rtc.o
 obj-y			+= pci-iommu_table.o
 obj-y			+= resource.o
 
-obj-$(CONFIG_PREEMPT)	+= preempt.o
-
 obj-y				+= process.o
 obj-y				+= i387.o xsave.o
 obj-y				+= ptrace.o
diff --git a/arch/x86/kernel/preempt.S b/arch/x86/kernel/preempt.S
deleted file mode 100644
index ca7f0d5..0000000
--- a/arch/x86/kernel/preempt.S
+++ /dev/null
@@ -1,25 +0,0 @@
-
-#include <linux/linkage.h>
-#include <asm/dwarf2.h>
-#include <asm/asm.h>
-#include <asm/calling.h>
-
-ENTRY(___preempt_schedule)
-	CFI_STARTPROC
-	SAVE_ALL
-	call preempt_schedule
-	RESTORE_ALL
-	ret
-	CFI_ENDPROC
-
-#ifdef CONFIG_CONTEXT_TRACKING
-
-ENTRY(___preempt_schedule_context)
-	CFI_STARTPROC
-	SAVE_ALL
-	call preempt_schedule_context
-	RESTORE_ALL
-	ret
-	CFI_ENDPROC
-
-#endif
diff --git a/arch/x86/lib/thunk_32.S b/arch/x86/lib/thunk_32.S
index 28f85c91..e9acf5f 100644
--- a/arch/x86/lib/thunk_32.S
+++ b/arch/x86/lib/thunk_32.S
@@ -7,16 +7,19 @@
 	#include <linux/linkage.h>
 	#include <asm/asm.h>
 
-#ifdef CONFIG_TRACE_IRQFLAGS
 	/* put return address in eax (arg1) */
-	.macro thunk_ra name,func
+	.macro THUNK name, func, put_ret_addr_in_eax=0
 	.globl \name
 \name:
 	pushl %eax
 	pushl %ecx
 	pushl %edx
+
+	.if \put_ret_addr_in_eax
 	/* Place EIP in the arg1 */
 	movl 3*4(%esp), %eax
+	.endif
+
 	call \func
 	popl %edx
 	popl %ecx
@@ -25,6 +28,15 @@
 	_ASM_NOKPROBE(\name)
 	.endm
 
-	thunk_ra trace_hardirqs_on_thunk,trace_hardirqs_on_caller
-	thunk_ra trace_hardirqs_off_thunk,trace_hardirqs_off_caller
+#ifdef CONFIG_TRACE_IRQFLAGS
+	THUNK trace_hardirqs_on_thunk,trace_hardirqs_on_caller,1
+	THUNK trace_hardirqs_off_thunk,trace_hardirqs_off_caller,1
+#endif
+
+#ifdef CONFIG_PREEMPT
+	THUNK ___preempt_schedule, preempt_schedule
+#ifdef CONFIG_CONTEXT_TRACKING
+	THUNK ___preempt_schedule_context, preempt_schedule_context
 #endif
+#endif
+
diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
index 92d9fea..b30b5eb 100644
--- a/arch/x86/lib/thunk_64.S
+++ b/arch/x86/lib/thunk_64.S
@@ -38,6 +38,13 @@
 	THUNK lockdep_sys_exit_thunk,lockdep_sys_exit
 #endif
 
+#ifdef CONFIG_PREEMPT
+	THUNK ___preempt_schedule, preempt_schedule
+#ifdef CONFIG_CONTEXT_TRACKING
+	THUNK ___preempt_schedule_context, preempt_schedule_context
+#endif
+#endif
+
 	/* SAVE_ARGS below is used only for the .cfi directives it contains. */
 	CFI_STARTPROC
 	SAVE_ARGS

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [tip:x86/asm] x86/lib/Makefile: Remove the unnecessary "+= thunk_64.o"
  2014-09-21 18:42 ` [PATCH v3 2/2] x86, lib/Makefile: remove the unnecessary "+= thunk_64.o" Oleg Nesterov
@ 2014-09-24 15:02   ` tip-bot for Oleg Nesterov
  0 siblings, 0 replies; 25+ messages in thread
From: tip-bot for Oleg Nesterov @ 2014-09-24 15:02 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, torvalds, peterz, luto, dvlasenk, tglx, oleg

Commit-ID:  212be3b2320bcf33eff648bc4e1f0edbf4d90acf
Gitweb:     http://git.kernel.org/tip/212be3b2320bcf33eff648bc4e1f0edbf4d90acf
Author:     Oleg Nesterov <oleg@redhat.com>
AuthorDate: Sun, 21 Sep 2014 20:42:32 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 24 Sep 2014 15:15:39 +0200

x86/lib/Makefile: Remove the unnecessary "+= thunk_64.o"

Trivial. We have "lib-y += thunk_$(BITS).o" at the start, no
need to add thunk_64.o if !CONFIG_X86_32.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Andy Lutomirski <luto@amacapital.net>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/20140921184232.GB23727@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/lib/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile
index 4d4f96a..66127b9 100644
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -39,7 +39,7 @@ endif
 else
         obj-y += iomap_copy_64.o
         lib-y += csum-partial_64.o csum-copy_64.o csum-wrappers_64.o
-        lib-y += thunk_64.o clear_page_64.o copy_page_64.o
+        lib-y += clear_page_64.o copy_page_64.o
         lib-y += memmove_64.o memset_64.o
         lib-y += copy_user_64.o copy_user_nocache_64.o
 	lib-y += cmpxchg16b_emu.o

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers
  2014-09-24 15:02   ` [tip:x86/asm] x86: Speed up ___preempt_schedule*() by " tip-bot for Oleg Nesterov
@ 2014-10-03  4:50     ` Sasha Levin
  2014-10-03 13:39       ` Chuck Ebbert
                         ` (2 more replies)
  0 siblings, 3 replies; 25+ messages in thread
From: Sasha Levin @ 2014-10-03  4:50 UTC (permalink / raw)
  To: oleg; +Cc: mingo, hpa, linux-kernel, torvalds, peterz, luto, dvlasenk, tglx

On 09/24/2014 11:02 AM, tip-bot for Oleg Nesterov wrote:
> Commit-ID:  0ad6e3c5199be12c9745da8f8b9e3c9f8066c235
> Gitweb:     http://git.kernel.org/tip/0ad6e3c5199be12c9745da8f8b9e3c9f8066c235
> Author:     Oleg Nesterov <oleg@redhat.com>
> AuthorDate: Sun, 21 Sep 2014 20:41:53 +0200
> Committer:  Ingo Molnar <mingo@kernel.org>
> CommitDate: Wed, 24 Sep 2014 15:15:38 +0200
> 
> x86: Speed up ___preempt_schedule*() by using THUNK helpers
> 
> ___preempt_schedule() does SAVE_ALL/RESTORE_ALL but this is
> suboptimal, we do not need to save/restore the callee-saved
> register. And we already have arch/x86/lib/thunk_*.S which
> implements the similar asm wrappers, so it makes sense to
> redefine ___preempt_schedule() as "THUNK ..." and remove
> preempt.S altogether.
> 
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>
> Reviewed-by: Andy Lutomirski <luto@amacapital.net>
> Cc: Denys Vlasenko <dvlasenk@redhat.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Link: http://lkml.kernel.org/r/20140921184153.GA23727@redhat.com
> Signed-off-by: Ingo Molnar <mingo@kernel.org>
> ---

Hi Oleg,

I *think* that this patch is causing the following trace (arch/x86/lib/thunk_64.S:44
is new code introduced by this patch):


[  921.908530] kernel BUG at kernel/sched/core.c:2702!
[  921.909159] invalid opcode: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC
[  921.910084] Dumping ftrace buffer:
[  921.910626]    (ftrace buffer empty)
[  921.911178] Modules linked in:
[  921.915690] CPU: 18 PID: 9489 Comm: trinity-c195 Not tainted 3.17.0-rc7-next-20141002-sasha-00031-gbdb4244 #1273
[  921.917016] task: ffff8802bd748000 ti: ffff8802bda3c000 task.ti: ffff8802bda3c000
[  921.917752] RIP: __schedule (kernel/sched/core.c:2702 kernel/sched/core.c:2808)
[  921.917752] RSP: 0018:ffff8802bda3c360  EFLAGS: 00010297
[  921.917752] RAX: ffff8802bda3c000 RBX: ffff8808501e2a00 RCX: 0000000000000001
[  921.917752] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000286
[  921.917752] RBP: ffff8802bda3c3c0 R08: 000000000001aa50 R09: 0000000000000000
[  921.917752] R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000012
[  921.917752] R13: ffff8808501e2a00 R14: 0000000000000002 R15: ffff8802bda3c428
[  921.917752] FS:  00007f5475cc2700(0000) GS:ffff880850000000(0000) knlGS:0000000000000000
[  921.917752] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
[  921.917752] CR2: 00007f5475abe60c CR3: 00000002bebab000 CR4: 00000000000006a0
[  921.917752] DR0: 00000000006f0000 DR1: 0000000000000000 DR2: 0000000000000000
[  921.917752] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000600
[  921.917752] Stack:
[  921.917752]  000000000001aa50 ffff8802bd748000 ffff8802bda3ffd8 00000000001e2a00
[  921.917752]  00000000001e2a00 ffff8802bd748000 ffff8802bda3c3a0 00000000001e2a00
[  921.917752]  ffff8802bd748000 000000000001a9ea 0000000000000002 ffff8802bda3c428
[  921.917752] Call Trace:
[  921.917752] schedule_user (kernel/sched/core.c:2894 include/linux/jump_label.h:114 include/linux/context_tracking_state.h:27 include/linux/context_tracking.h:20 kernel/sched/core.c:2909)
[  921.917752] int_careful (arch/x86/kernel/entry_64.S:560)
[  921.917752] ? retint_careful (arch/x86/kernel/entry_64.S:889)
[  921.917752] ? preempt_schedule (./arch/x86/include/asm/preempt.h:80 (discriminator 1) kernel/sched/core.c:2943 (discriminator 1))
[  921.917752] ? preempt_schedule_context (./arch/x86/include/asm/preempt.h:75 kernel/context_tracking.c:143)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  921.917752] ? __schedule (kernel/sched/core.c:2900)
[  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  921.917752] ? ftrace_ops_control_func (kernel/trace/ftrace.c:4780)
[  921.917752] ? ftrace_call (arch/x86/kernel/mcount_64.S:56)
[  921.917752] ? retint_careful (arch/x86/kernel/entry_64.S:886)
[  921.917752] ? __this_cpu_preempt_check (lib/smp_processor_id.c:63)
[  921.917752] ? schedule_user (kernel/sched/core.c:2900)
[  921.917752] ? schedule_user (kernel/sched/core.c:2900)
[  921.917752] ? retint_careful (arch/x86/kernel/entry_64.S:889)
[ 921.917752] Code: 48 c7 c2 50 2d 72 97 be 72 00 00 00 48 c7 c7 eb 26 73 97 c6 05 37 b3 ac 02 01 e8 d4 06 c6 fc e9 0d fb ff ff 0f 1f 80 00 00 00 00 <0f> 0b 66 0f 1f 44 00 00 48 8b 45 c8 48 8b 00 48 83 f8 40 0f 84
All code
========
   0:	48 c7 c2 50 2d 72 97 	mov    $0xffffffff97722d50,%rdx
   7:	be 72 00 00 00       	mov    $0x72,%esi
   c:	48 c7 c7 eb 26 73 97 	mov    $0xffffffff977326eb,%rdi
  13:	c6 05 37 b3 ac 02 01 	movb   $0x1,0x2acb337(%rip)        # 0x2acb351
  1a:	e8 d4 06 c6 fc       	callq  0xfffffffffcc606f3
  1f:	e9 0d fb ff ff       	jmpq   0xfffffffffffffb31
  24:	0f 1f 80 00 00 00 00 	nopl   0x0(%rax)
  2b:*	0f 0b                	ud2    		<-- trapping instruction
  2d:	66 0f 1f 44 00 00    	nopw   0x0(%rax,%rax,1)
  33:	48 8b 45 c8          	mov    -0x38(%rbp),%rax
  37:	48 8b 00             	mov    (%rax),%rax
  3a:	48 83 f8 40          	cmp    $0x40,%rax
  3e:	0f                   	.byte 0xf
  3f:	84 00                	test   %al,(%rax)

Code starting with the faulting instruction
===========================================
   0:	0f 0b                	ud2
   2:	66 0f 1f 44 00 00    	nopw   0x0(%rax,%rax,1)
   8:	48 8b 45 c8          	mov    -0x38(%rbp),%rax
   c:	48 8b 00             	mov    (%rax),%rax
   f:	48 83 f8 40          	cmp    $0x40,%rax
  13:	0f                   	.byte 0xf
  14:	84 00                	test   %al,(%rax)
[  921.917752] RIP __schedule (kernel/sched/core.c:2702 kernel/sched/core.c:2808)
[  921.917752]  RSP <ffff8802bda3c360>
[  922.457643] BUG: unable to handle kernel paging request at fffffffc310ead68
[  922.458855] IP: cpuacct_charge (kernel/sched/cpuacct.c:247)
[  922.467627] PGD 17e23067 PUD 0
[  922.467627] Thread overran stack, or stack corrupted
[  922.467627] Oops: 0000 [#2] PREEMPT SMP DEBUG_PAGEALLOC
[  922.467627] Dumping ftrace buffer:
[  922.467627]    (ftrace buffer empty)
[  922.467627] Modules linked in:
[  922.467627] CPU: 18 PID: 9489 Comm: trinity-c195 Tainted: G      D        3.17.0-rc7-next-20141002-sasha-00031-gbdb4244 #1273
[  922.467627] task: ffff8802bd748000 ti: ffff8802bda3c000 task.ti: ffff8802bda3c000
[  922.467627] RIP: cpuacct_charge (kernel/sched/cpuacct.c:247)
[  922.467627] RSP: 0018:ffff880850003d28  EFLAGS: 00010046
[  922.467627] RAX: 000000000000f128 RBX: 00000000932539cd RCX: ffffffff932539cd
[  922.467627] RDX: ffffffff97ea5500 RSI: 0000000000000000 RDI: 0000000000000086
[  922.467627] RBP: ffff880850003d58 R08: 0000000000000000 R09: 0000000000000001
[  922.467627] R10: 0000000000000000 R11: 0000000000009a86 R12: 00000000128d0aa7
[  922.467627] R13: ffff8802bd748000 R14: ffffffff98afaa40 R15: 0000000000000400
[  922.467627] FS:  00007f5475cc2700(0000) GS:ffff880850000000(0000) knlGS:0000000000000000
[  922.467627] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
[  922.467627] CR2: fffffffc310ead68 CR3: 00000002bebab000 CR4: 00000000000006a0
[  922.467627] DR0: 00000000006f0000 DR1: 0000000000000000 DR2: 0000000000000000
[  922.467627] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000600
[  922.467627] Stack:
[  922.467627]  ffffffff931bdb35 ffffffff931bdb35 ffff8802bd748068 ffff88084f106f90
[  922.467627]  00000000128d0aa7 ffff8802bd748000 ffff880850003d98 ffffffff931a7b86
[  922.467627]  000000000001aa9a ffff8802bd748068 ffff88084f106f90 0000000000000000
[  922.467627] Call Trace:
[  922.467627]  <IRQ>
[  922.467627] ? cpuacct_charge (kernel/sched/cpuacct.c:236)
[  922.467627] ? cpuacct_charge (kernel/sched/cpuacct.c:236)
[  922.467627] update_curr (kernel/sched/stats.h:259 kernel/sched/fair.c:723)
[  922.467627] task_tick_fair (kernel/sched/fair.c:2526 (discriminator 2) kernel/sched/fair.c:7512 (discriminator 2))
[  922.467627] scheduler_tick (kernel/sched/core.c:2564)
[  922.467627] update_process_times (kernel/time/timer.c:1391)
[  922.467627] tick_sched_handle.isra.14 (kernel/time/tick-sched.c:152)
[  922.467627] tick_sched_timer (kernel/time/tick-sched.c:1117)
[  922.467627] __run_hrtimer (kernel/time/hrtimer.c:1218 (discriminator 3))
[  922.467627] ? tick_sched_do_timer (kernel/time/tick-sched.c:1101)
[  922.467627] hrtimer_interrupt (kernel/time/hrtimer.c:1307)
[  922.467627] local_apic_timer_interrupt (arch/x86/kernel/apic/apic.c:921)
[  922.467627] smp_apic_timer_interrupt (./arch/x86/include/asm/apic.h:660 arch/x86/kernel/apic/apic.c:945)
[  922.467627] apic_timer_interrupt (arch/x86/kernel/entry_64.S:999)
[  922.467627]  <EOI>
[  922.467627] ? oops_end (./arch/x86/include/asm/paravirt.h:809 arch/x86/kernel/dumpstack.c:240)
[  922.467627] die (arch/x86/kernel/dumpstack.c:313)
[  922.467627] do_trap (arch/x86/kernel/traps.c:132 arch/x86/kernel/traps.c:178)
[  922.467627] do_error_trap (arch/x86/kernel/traps.c:216 include/linux/jump_label.h:114 include/linux/context_tracking_state.h:27 include/linux/context_tracking.h:45 arch/x86/kernel/traps.c:220)
[  922.467627] ? __schedule (kernel/sched/core.c:2702 kernel/sched/core.c:2808)
[  922.467627] ? error_sti (arch/x86/kernel/entry_64.S:1398)
[  922.467627] ? __this_cpu_preempt_check (lib/smp_processor_id.c:63)
[  922.467627] do_invalid_op (arch/x86/kernel/traps.c:232)
[  922.467627] invalid_op (arch/x86/kernel/entry_64.S:1125)
[  922.467627] ? __schedule (kernel/sched/core.c:2702 kernel/sched/core.c:2808)
[  922.467627] schedule_user (kernel/sched/core.c:2894 include/linux/jump_label.h:114 include/linux/context_tracking_state.h:27 include/linux/context_tracking.h:20 kernel/sched/core.c:2909)
[  922.467627] int_careful (arch/x86/kernel/entry_64.S:560)
[  922.467627] ? retint_careful (arch/x86/kernel/entry_64.S:889)
[  922.467627] ? preempt_schedule (./arch/x86/include/asm/preempt.h:80 (discriminator 1) kernel/sched/core.c:2943 (discriminator 1))
[  922.467627] ? preempt_schedule_context (./arch/x86/include/asm/preempt.h:75 kernel/context_tracking.c:143)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? preempt_schedule_context (kernel/context_tracking.c:145)
[  922.467627] ? __schedule (kernel/sched/core.c:2900)
[  922.467627] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
[  922.467627] ? ftrace_ops_control_func (kernel/trace/ftrace.c:4780)
[  922.467627] ? ftrace_call (arch/x86/kernel/mcount_64.S:56)
[  922.467627] ? retint_careful (arch/x86/kernel/entry_64.S:886)
[  922.467627] ? __this_cpu_preempt_check (lib/smp_processor_id.c:63)
[  922.467627] ? schedule_user (kernel/sched/core.c:2900)
[  922.467627] ? schedule_user (kernel/sched/core.c:2900)
[  922.467627] ? retint_careful (arch/x86/kernel/entry_64.S:889)
[ 922.467627] Code: 00 00 00 4d 8b b5 e8 18 00 00 e8 b5 55 02 00 85 c0 74 09 80 3d e4 1c e7 05 00 74 68 49 8b 56 60 48 63 cb 90 48 8b 82 e0 00 00 00 <48> 03 04 cd 00 df e4 97 4c 01 20 48 8b 52 48 48 85 d2 75 e5 e8
All code
========
   0:	00 00                	add    %al,(%rax)
   2:	00 4d 8b             	add    %cl,-0x75(%rbp)
   5:	b5 e8                	mov    $0xe8,%ch
   7:	18 00                	sbb    %al,(%rax)
   9:	00 e8                	add    %ch,%al
   b:	b5 55                	mov    $0x55,%ch
   d:	02 00                	add    (%rax),%al
   f:	85 c0                	test   %eax,%eax
  11:	74 09                	je     0x1c
  13:	80 3d e4 1c e7 05 00 	cmpb   $0x0,0x5e71ce4(%rip)        # 0x5e71cfe
  1a:	74 68                	je     0x84
  1c:	49 8b 56 60          	mov    0x60(%r14),%rdx
  20:	48 63 cb             	movslq %ebx,%rcx
  23:	90                   	nop
  24:	48 8b 82 e0 00 00 00 	mov    0xe0(%rdx),%rax
  2b:*	48 03 04 cd 00 df e4 	add    -0x681b2100(,%rcx,8),%rax		<-- trapping instruction
  32:	97
  33:	4c 01 20             	add    %r12,(%rax)
  36:	48 8b 52 48          	mov    0x48(%rdx),%rdx
  3a:	48 85 d2             	test   %rdx,%rdx
  3d:	75 e5                	jne    0x24
  3f:	e8                   	.byte 0xe8
	...

Code starting with the faulting instruction
===========================================
   0:	48 03 04 cd 00 df e4 	add    -0x681b2100(,%rcx,8),%rax
   7:	97
   8:	4c 01 20             	add    %r12,(%rax)
   b:	48 8b 52 48          	mov    0x48(%rdx),%rdx
   f:	48 85 d2             	test   %rdx,%rdx
  12:	75 e5                	jne    0xfffffffffffffff9
  14:	e8                   	.byte 0xe8
	...
[  922.467627] RIP cpuacct_charge (kernel/sched/cpuacct.c:247)
[  922.467627]  RSP <ffff880850003d28>
[  922.467627] CR2: fffffffc310ead68


Thanks,
Sasha

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers
  2014-10-03  4:50     ` Sasha Levin
@ 2014-10-03 13:39       ` Chuck Ebbert
  2014-10-03 21:41         ` Oleg Nesterov
  2014-10-03 21:16       ` Oleg Nesterov
  2014-10-03 23:26       ` Oleg Nesterov
  2 siblings, 1 reply; 25+ messages in thread
From: Chuck Ebbert @ 2014-10-03 13:39 UTC (permalink / raw)
  To: Sasha Levin
  Cc: oleg, mingo, hpa, linux-kernel, torvalds, peterz, luto, dvlasenk, tglx

On Fri, 03 Oct 2014 00:50:13 -0400
Sasha Levin <sasha.levin@oracle.com> wrote:

> On 09/24/2014 11:02 AM, tip-bot for Oleg Nesterov wrote:
> > Commit-ID:  0ad6e3c5199be12c9745da8f8b9e3c9f8066c235
> > Gitweb:     http://git.kernel.org/tip/0ad6e3c5199be12c9745da8f8b9e3c9f8066c235
> > Author:     Oleg Nesterov <oleg@redhat.com>
> > AuthorDate: Sun, 21 Sep 2014 20:41:53 +0200
> > Committer:  Ingo Molnar <mingo@kernel.org>
> > CommitDate: Wed, 24 Sep 2014 15:15:38 +0200
> > 
> > x86: Speed up ___preempt_schedule*() by using THUNK helpers
> > 
> > ___preempt_schedule() does SAVE_ALL/RESTORE_ALL but this is
> > suboptimal, we do not need to save/restore the callee-saved
> > register. And we already have arch/x86/lib/thunk_*.S which
> > implements the similar asm wrappers, so it makes sense to
> > redefine ___preempt_schedule() as "THUNK ..." and remove
> > preempt.S altogether.
> > 
> > Signed-off-by: Oleg Nesterov <oleg@redhat.com>
> > Reviewed-by: Andy Lutomirski <luto@amacapital.net>
> > Cc: Denys Vlasenko <dvlasenk@redhat.com>
> > Cc: Peter Zijlstra <peterz@infradead.org>
> > Cc: Linus Torvalds <torvalds@linux-foundation.org>
> > Link: http://lkml.kernel.org/r/20140921184153.GA23727@redhat.com
> > Signed-off-by: Ingo Molnar <mingo@kernel.org>
> > ---
> 
> Hi Oleg,
> 
> I *think* that this patch is causing the following trace (arch/x86/lib/thunk_64.S:44
> is new code introduced by this patch):
> 
> 
> [  921.908530] kernel BUG at kernel/sched/core.c:2702!
> [  921.909159] invalid opcode: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC
> [  921.910084] Dumping ftrace buffer:
> [  921.910626]    (ftrace buffer empty)
> [  921.911178] Modules linked in:
> [  921.915690] CPU: 18 PID: 9489 Comm: trinity-c195 Not tainted 3.17.0-rc7-next-20141002-sasha-00031-gbdb4244 #1273
> [  921.917016] task: ffff8802bd748000 ti: ffff8802bda3c000 task.ti: ffff8802bda3c000
> [  921.917752] RIP: __schedule (kernel/sched/core.c:2702 kernel/sched/core.c:2808)
> [  921.917752] RSP: 0018:ffff8802bda3c360  EFLAGS: 00010297
> [  921.917752] RAX: ffff8802bda3c000 RBX: ffff8808501e2a00 RCX: 0000000000000001
> [  921.917752] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000286
> [  921.917752] RBP: ffff8802bda3c3c0 R08: 000000000001aa50 R09: 0000000000000000
> [  921.917752] R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000012
> [  921.917752] R13: ffff8808501e2a00 R14: 0000000000000002 R15: ffff8802bda3c428
> [  921.917752] FS:  00007f5475cc2700(0000) GS:ffff880850000000(0000) knlGS:0000000000000000
> [  921.917752] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
> [  921.917752] CR2: 00007f5475abe60c CR3: 00000002bebab000 CR4: 00000000000006a0
> [  921.917752] DR0: 00000000006f0000 DR1: 0000000000000000 DR2: 0000000000000000
> [  921.917752] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000600
> [  921.917752] Stack:
> [  921.917752]  000000000001aa50 ffff8802bd748000 ffff8802bda3ffd8 00000000001e2a00
> [  921.917752]  00000000001e2a00 ffff8802bd748000 ffff8802bda3c3a0 00000000001e2a00
> [  921.917752]  ffff8802bd748000 000000000001a9ea 0000000000000002 ffff8802bda3c428
> [  921.917752] Call Trace:
> [  921.917752] schedule_user (kernel/sched/core.c:2894 include/linux/jump_label.h:114 include/linux/context_tracking_state.h:27 include/linux/context_tracking.h:20 kernel/sched/core.c:2909)
> [  921.917752] int_careful (arch/x86/kernel/entry_64.S:560)
> [  921.917752] ? retint_careful (arch/x86/kernel/entry_64.S:889)
> [  921.917752] ? preempt_schedule (./arch/x86/include/asm/preempt.h:80 (discriminator 1) kernel/sched/core.c:2943 (discriminator 1))
> [  921.917752] ? preempt_schedule_context (./arch/x86/include/asm/preempt.h:75 kernel/context_tracking.c:143)
> [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
> [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
> [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
> [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
> [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
> [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
> [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
> [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
> [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
> [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)

<snip lots of repeats of this>

I *think* this is because RBP isn't being saved across task switch
anymore?

Without CONFIG_FRAME_POINTERS that night not be a problem...

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers
  2014-10-03  4:50     ` Sasha Levin
  2014-10-03 13:39       ` Chuck Ebbert
@ 2014-10-03 21:16       ` Oleg Nesterov
  2014-10-03 23:26       ` Oleg Nesterov
  2 siblings, 0 replies; 25+ messages in thread
From: Oleg Nesterov @ 2014-10-03 21:16 UTC (permalink / raw)
  To: Sasha Levin
  Cc: mingo, hpa, linux-kernel, torvalds, peterz, luto, dvlasenk, tglx

Hi Sasha,

On 10/03, Sasha Levin wrote:
>
> On 09/24/2014 11:02 AM, tip-bot for Oleg Nesterov wrote:
> > Commit-ID:  0ad6e3c5199be12c9745da8f8b9e3c9f8066c235
> > Gitweb:     http://git.kernel.org/tip/0ad6e3c5199be12c9745da8f8b9e3c9f8066c235
> > Author:     Oleg Nesterov <oleg@redhat.com>
> > AuthorDate: Sun, 21 Sep 2014 20:41:53 +0200
> > Committer:  Ingo Molnar <mingo@kernel.org>
> > CommitDate: Wed, 24 Sep 2014 15:15:38 +0200
> >
> > x86: Speed up ___preempt_schedule*() by using THUNK helpers
> >
> > ___preempt_schedule() does SAVE_ALL/RESTORE_ALL but this is
> > suboptimal, we do not need to save/restore the callee-saved
> > register. And we already have arch/x86/lib/thunk_*.S which
> > implements the similar asm wrappers, so it makes sense to
> > redefine ___preempt_schedule() as "THUNK ..." and remove
> > preempt.S altogether.
> >
> > Signed-off-by: Oleg Nesterov <oleg@redhat.com>
> > Reviewed-by: Andy Lutomirski <luto@amacapital.net>
> > Cc: Denys Vlasenko <dvlasenk@redhat.com>
> > Cc: Peter Zijlstra <peterz@infradead.org>
> > Cc: Linus Torvalds <torvalds@linux-foundation.org>
> > Link: http://lkml.kernel.org/r/20140921184153.GA23727@redhat.com
> > Signed-off-by: Ingo Molnar <mingo@kernel.org>
> > ---
>
> Hi Oleg,
>
> I *think* that this patch is causing the following trace (arch/x86/lib/thunk_64.S:44
> is new code introduced by this patch):

Not sure, but I'm afraid your guess can be correct...

> [  921.908530] kernel BUG at kernel/sched/core.c:2702!

OK, this is schedule_debug() -> BUG_ON(unlikely(task_stack_end_corrupted(prev)))
in linux-next.

But at first glance this doesn't match the disassembled code... Could you
send me (privately) your kernel/sched/core.c just in case? And .config
please. And, if possible, kernel/sched/core.s

Oleg.


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers
  2014-10-03 13:39       ` Chuck Ebbert
@ 2014-10-03 21:41         ` Oleg Nesterov
  2014-10-03 21:56           ` Andy Lutomirski
  2014-10-03 22:48           ` Chuck Ebbert
  0 siblings, 2 replies; 25+ messages in thread
From: Oleg Nesterov @ 2014-10-03 21:41 UTC (permalink / raw)
  To: Chuck Ebbert
  Cc: Sasha Levin, mingo, hpa, linux-kernel, torvalds, peterz, luto,
	dvlasenk, tglx

On 10/03, Chuck Ebbert wrote:
>
> > [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
> > [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
> > [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
> > [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
> > [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
> > [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
> > [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
> > [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
> > [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
> > [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
>
> <snip lots of repeats of this>
>
> I *think* this is because RBP isn't being saved across task switch
> anymore?
>
> Without CONFIG_FRAME_POINTERS that night not be a problem...

Could you please spell?

I don't even understand "RBP isn't being saved", SAVE_CONTEXT/RESTORE_CONTEXT
do push/pop %rbp?

Thanks,

Oleg.


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers
  2014-10-03 21:41         ` Oleg Nesterov
@ 2014-10-03 21:56           ` Andy Lutomirski
  2014-10-03 23:48             ` Linus Torvalds
  2014-10-03 23:51             ` Oleg Nesterov
  2014-10-03 22:48           ` Chuck Ebbert
  1 sibling, 2 replies; 25+ messages in thread
From: Andy Lutomirski @ 2014-10-03 21:56 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Chuck Ebbert, Sasha Levin, Ingo Molnar, H. Peter Anvin,
	linux-kernel, Linus Torvalds, Peter Zijlstra, Denys Vlasenko,
	Thomas Gleixner

On Fri, Oct 3, 2014 at 2:41 PM, Oleg Nesterov <oleg@redhat.com> wrote:
> On 10/03, Chuck Ebbert wrote:
>>
>> > [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
>> > [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
>> > [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
>> > [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
>> > [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
>> > [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
>> > [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
>> > [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
>> > [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
>> > [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
>>
>> <snip lots of repeats of this>
>>
>> I *think* this is because RBP isn't being saved across task switch
>> anymore?
>>
>> Without CONFIG_FRAME_POINTERS that night not be a problem...
>
> Could you please spell?
>
> I don't even understand "RBP isn't being saved", SAVE_CONTEXT/RESTORE_CONTEXT
> do push/pop %rbp?
>

Is this thing missing a flags or cc clobber:

# define __preempt_schedule() asm ("call ___preempt_schedule")

Also, I'm at a loss as to wtf all this code is doing.

There's preempt_schedule, which appears to be a normal C function.

There's ___preempt_schedule, which is written in assembly and calls
preempt_schedule.

Then there's __preempt_schedule, which is an inline assembler function
that calls ___preempt_schedule.

Is this all just to make the call sequence for preempt_schedule shorter?

--Andy


> Thanks,
>
> Oleg.
>



-- 
Andy Lutomirski
AMA Capital Management, LLC

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers
  2014-10-03 21:41         ` Oleg Nesterov
  2014-10-03 21:56           ` Andy Lutomirski
@ 2014-10-03 22:48           ` Chuck Ebbert
  2014-10-03 22:53             ` Andy Lutomirski
  2014-10-03 23:37             ` Oleg Nesterov
  1 sibling, 2 replies; 25+ messages in thread
From: Chuck Ebbert @ 2014-10-03 22:48 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Sasha Levin, mingo, hpa, linux-kernel, torvalds, peterz, luto,
	dvlasenk, tglx

On Fri, 3 Oct 2014 23:41:24 +0200
Oleg Nesterov <oleg@redhat.com> wrote:

> On 10/03, Chuck Ebbert wrote:
> >
> > > [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
> > > [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
> > > [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
> > > [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
> > > [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
> > > [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
> > > [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
> > > [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
> > > [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
> > > [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
> >
> > <snip lots of repeats of this>
> >
> > I *think* this is because RBP isn't being saved across task switch
> > anymore?
> >
> > Without CONFIG_FRAME_POINTERS that night not be a problem...
> 
> Could you please spell?
> 
> I don't even understand "RBP isn't being saved", SAVE_CONTEXT/RESTORE_CONTEXT
> do push/pop %rbp?
> 

SAVE_ARGS/RESTORE_ARGS, which is what THUNK uses, doesn't push/pop %rbp

Before, SAVE_ALL/RESTORE_ALL were being used around the call to
preempt_schedule(). So from the symptoms I thought this was the problem.

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers
  2014-10-03 22:48           ` Chuck Ebbert
@ 2014-10-03 22:53             ` Andy Lutomirski
  2014-10-03 23:13               ` H. Peter Anvin
  2014-10-03 23:37             ` Oleg Nesterov
  1 sibling, 1 reply; 25+ messages in thread
From: Andy Lutomirski @ 2014-10-03 22:53 UTC (permalink / raw)
  To: Chuck Ebbert
  Cc: Oleg Nesterov, Sasha Levin, Ingo Molnar, H. Peter Anvin,
	linux-kernel, Linus Torvalds, Peter Zijlstra, Denys Vlasenko,
	Thomas Gleixner

On Fri, Oct 3, 2014 at 3:48 PM, Chuck Ebbert <cebbert.lkml@gmail.com> wrote:
> On Fri, 3 Oct 2014 23:41:24 +0200
> Oleg Nesterov <oleg@redhat.com> wrote:
>
>> On 10/03, Chuck Ebbert wrote:
>> >
>> > > [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
>> > > [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
>> > > [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
>> > > [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
>> > > [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
>> > > [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
>> > > [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
>> > > [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
>> > > [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
>> > > [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
>> >
>> > <snip lots of repeats of this>
>> >
>> > I *think* this is because RBP isn't being saved across task switch
>> > anymore?
>> >
>> > Without CONFIG_FRAME_POINTERS that night not be a problem...
>>
>> Could you please spell?
>>
>> I don't even understand "RBP isn't being saved", SAVE_CONTEXT/RESTORE_CONTEXT
>> do push/pop %rbp?
>>
>
> SAVE_ARGS/RESTORE_ARGS, which is what THUNK uses, doesn't push/pop %rbp
>
> Before, SAVE_ALL/RESTORE_ALL were being used around the call to
> preempt_schedule(). So from the symptoms I thought this was the problem.

rbp is callee-saved no matter what, unless my memory of the ABI is
*waaaaay* off.

--Andy

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers
  2014-10-03 22:53             ` Andy Lutomirski
@ 2014-10-03 23:13               ` H. Peter Anvin
  0 siblings, 0 replies; 25+ messages in thread
From: H. Peter Anvin @ 2014-10-03 23:13 UTC (permalink / raw)
  To: Andy Lutomirski, Chuck Ebbert
  Cc: Oleg Nesterov, Sasha Levin, Ingo Molnar, linux-kernel,
	Linus Torvalds, Peter Zijlstra, Denys Vlasenko, Thomas Gleixner

Yes, it is.

On October 3, 2014 3:53:08 PM PDT, Andy Lutomirski <luto@amacapital.net> wrote:
>On Fri, Oct 3, 2014 at 3:48 PM, Chuck Ebbert <cebbert.lkml@gmail.com>
>wrote:
>> On Fri, 3 Oct 2014 23:41:24 +0200
>> Oleg Nesterov <oleg@redhat.com> wrote:
>>
>>> On 10/03, Chuck Ebbert wrote:
>>> >
>>> > > [  921.917752] ? ___preempt_schedule_context
>(arch/x86/lib/thunk_64.S:44)
>>> > > [  921.917752] ? preempt_schedule_context
>(kernel/context_tracking.c:145)
>>> > > [  921.917752] ? ___preempt_schedule_context
>(arch/x86/lib/thunk_64.S:44)
>>> > > [  921.917752] ? preempt_schedule_context
>(kernel/context_tracking.c:145)
>>> > > [  921.917752] ? ___preempt_schedule_context
>(arch/x86/lib/thunk_64.S:44)
>>> > > [  921.917752] ? preempt_schedule_context
>(kernel/context_tracking.c:145)
>>> > > [  921.917752] ? ___preempt_schedule_context
>(arch/x86/lib/thunk_64.S:44)
>>> > > [  921.917752] ? preempt_schedule_context
>(kernel/context_tracking.c:145)
>>> > > [  921.917752] ? ___preempt_schedule_context
>(arch/x86/lib/thunk_64.S:44)
>>> > > [  921.917752] ? preempt_schedule_context
>(kernel/context_tracking.c:145)
>>> >
>>> > <snip lots of repeats of this>
>>> >
>>> > I *think* this is because RBP isn't being saved across task switch
>>> > anymore?
>>> >
>>> > Without CONFIG_FRAME_POINTERS that night not be a problem...
>>>
>>> Could you please spell?
>>>
>>> I don't even understand "RBP isn't being saved",
>SAVE_CONTEXT/RESTORE_CONTEXT
>>> do push/pop %rbp?
>>>
>>
>> SAVE_ARGS/RESTORE_ARGS, which is what THUNK uses, doesn't push/pop
>%rbp
>>
>> Before, SAVE_ALL/RESTORE_ALL were being used around the call to
>> preempt_schedule(). So from the symptoms I thought this was the
>problem.
>
>rbp is callee-saved no matter what, unless my memory of the ABI is
>*waaaaay* off.
>
>--Andy

-- 
Sent from my mobile phone.  Please pardon brevity and lack of formatting.

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers
  2014-10-03  4:50     ` Sasha Levin
  2014-10-03 13:39       ` Chuck Ebbert
  2014-10-03 21:16       ` Oleg Nesterov
@ 2014-10-03 23:26       ` Oleg Nesterov
  2014-10-04  0:01         ` Linus Torvalds
  2 siblings, 1 reply; 25+ messages in thread
From: Oleg Nesterov @ 2014-10-03 23:26 UTC (permalink / raw)
  To: Sasha Levin, Frederic Weisbecker
  Cc: mingo, hpa, linux-kernel, torvalds, peterz, luto, dvlasenk, tglx,
	Chuck Ebbert

On 10/03, Sasha Levin wrote:
>
> On 09/24/2014 11:02 AM, tip-bot for Oleg Nesterov wrote:
> > Commit-ID:  0ad6e3c5199be12c9745da8f8b9e3c9f8066c235
> > Gitweb:     http://git.kernel.org/tip/0ad6e3c5199be12c9745da8f8b9e3c9f8066c235
> > Author:     Oleg Nesterov <oleg@redhat.com>
> > AuthorDate: Sun, 21 Sep 2014 20:41:53 +0200
> > Committer:  Ingo Molnar <mingo@kernel.org>
> > CommitDate: Wed, 24 Sep 2014 15:15:38 +0200
> >
> > x86: Speed up ___preempt_schedule*() by using THUNK helpers
> >
> > ___preempt_schedule() does SAVE_ALL/RESTORE_ALL but this is
> > suboptimal, we do not need to save/restore the callee-saved
> > register. And we already have arch/x86/lib/thunk_*.S which
> > implements the similar asm wrappers, so it makes sense to
> > redefine ___preempt_schedule() as "THUNK ..." and remove
> > preempt.S altogether.
> >
> > Signed-off-by: Oleg Nesterov <oleg@redhat.com>
> > Reviewed-by: Andy Lutomirski <luto@amacapital.net>
> > Cc: Denys Vlasenko <dvlasenk@redhat.com>
> > Cc: Peter Zijlstra <peterz@infradead.org>
> > Cc: Linus Torvalds <torvalds@linux-foundation.org>
> > Link: http://lkml.kernel.org/r/20140921184153.GA23727@redhat.com
> > Signed-off-by: Ingo Molnar <mingo@kernel.org>
> > ---
>
> Hi Oleg,
>
> I *think* that this patch is causing the following trace (arch/x86/lib/thunk_64.S:44
> is new code introduced by this patch):

So far I still do not think (at least I do not understand how) this patch
could introduce the problem. I can be wrong of course...

Let's look at this trace again,

> [  921.908530] kernel BUG at kernel/sched/core.c:2702!

OK, let's assume this is BUG_ON(unlikely(task_stack_end_corrupted(prev)))
in schedule_debug().

> [  921.909159] invalid opcode: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC
> [  921.910084] Dumping ftrace buffer:
> [  921.910626]    (ftrace buffer empty)
> [  921.911178] Modules linked in:
> [  921.915690] CPU: 18 PID: 9489 Comm: trinity-c195 Not tainted 3.17.0-rc7-next-20141002-sasha-00031-gbdb4244 #1273
> [  921.917016] task: ffff8802bd748000 ti: ffff8802bda3c000 task.ti: ffff8802bda3c000
> [  921.917752] RIP: __schedule (kernel/sched/core.c:2702 kernel/sched/core.c:2808)
> [  921.917752] RSP: 0018:ffff8802bda3c360  EFLAGS: 00010297
> [  921.917752] RAX: ffff8802bda3c000 RBX: ffff8808501e2a00 RCX: 0000000000000001
> [  921.917752] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000286
> [  921.917752] RBP: ffff8802bda3c3c0 R08: 000000000001aa50 R09: 0000000000000000
> [  921.917752] R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000012
> [  921.917752] R13: ffff8808501e2a00 R14: 0000000000000002 R15: ffff8802bda3c428
> [  921.917752] FS:  00007f5475cc2700(0000) GS:ffff880850000000(0000) knlGS:0000000000000000
> [  921.917752] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
> [  921.917752] CR2: 00007f5475abe60c CR3: 00000002bebab000 CR4: 00000000000006a0
> [  921.917752] DR0: 00000000006f0000 DR1: 0000000000000000 DR2: 0000000000000000
> [  921.917752] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000600
> [  921.917752] Stack:
> [  921.917752]  000000000001aa50 ffff8802bd748000 ffff8802bda3ffd8 00000000001e2a00
> [  921.917752]  00000000001e2a00 ffff8802bd748000 ffff8802bda3c3a0 00000000001e2a00
> [  921.917752]  ffff8802bd748000 000000000001a9ea 0000000000000002 ffff8802bda3c428
> [  921.917752] Call Trace:
> [  921.917752] schedule_user (kernel/sched/core.c:2894 include/linux/jump_label.h:114 include/linux/context_tracking_state.h:27 include/linux/context_tracking.h:20 kernel/sched/core.c:2909)
> [  921.917752] int_careful (arch/x86/kernel/entry_64.S:560)
> [  921.917752] ? retint_careful (arch/x86/kernel/entry_64.S:889)
> [  921.917752] ? preempt_schedule (./arch/x86/include/asm/preempt.h:80 (discriminator 1) kernel/sched/core.c:2943 (discriminator 1))

...

> [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
> [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
> [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
> [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
> [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
> [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
> [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
> [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)

...

A lOT of repeats of above, so we can run out of stack and in this case
task_stack_end_corrupted() is clear.

> [  921.917752] ? __schedule (kernel/sched/core.c:2900)
> [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
> [  921.917752] ? ftrace_ops_control_func (kernel/trace/ftrace.c:4780)
> [  921.917752] ? ftrace_call (arch/x86/kernel/mcount_64.S:56)
> [  921.917752] ? retint_careful (arch/x86/kernel/entry_64.S:886)
> [  921.917752] ? __this_cpu_preempt_check (lib/smp_processor_id.c:63)
> [  921.917752] ? schedule_user (kernel/sched/core.c:2900)
> [  921.917752] ? schedule_user (kernel/sched/core.c:2900)
> [  921.917752] ? retint_careful (arch/x86/kernel/entry_64.S:889)


And I _think_ that preempt_schedule_context() should be fixed anyway,
although I am not sure there is no something else. It does:


	preempt_disable_notrace();
	prev_ctx = exception_enter();
	preempt_enable_no_resched_notrace();

	preempt_schedule();

	preempt_disable_notrace();
	exception_exit(prev_ctx);
	preempt_enable_notrace();

but exception_exit() is heavy, it is quite possible that TIF_NEED_RESCHED
and thus set_preempt_need_resched() can be set again when we call
preempt_enable_notrace(). And in this case preempt_schedule_context()
will be called recursively.

Frederic, how about the patch below?

In _theory_ this can explain this OOPS unless I am totally confused.

Oleg.

--- x/kernel/context_tracking.c
+++ x/kernel/context_tracking.c
@@ -134,15 +134,17 @@ asmlinkage __visible void __sched notrac
 	 * and the tracer calls preempt_enable_notrace() causing
 	 * an infinite recursion.
 	 */
-	preempt_disable_notrace();
-	prev_ctx = exception_enter();
-	preempt_enable_no_resched_notrace();
-
-	preempt_schedule();
-
-	preempt_disable_notrace();
-	exception_exit(prev_ctx);
-	preempt_enable_notrace();
+	do {
+		preempt_disable_notrace();
+		prev_ctx = exception_enter();
+		preempt_enable_no_resched_notrace();
+
+		preempt_schedule();
+
+		preempt_disable_notrace();
+		exception_exit(prev_ctx);
+		preempt_enable_no_resched_notrace();
+	} while (need_resched());
 }
 EXPORT_SYMBOL_GPL(preempt_schedule_context);
 #endif /* CONFIG_PREEMPT */


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers
  2014-10-03 22:48           ` Chuck Ebbert
  2014-10-03 22:53             ` Andy Lutomirski
@ 2014-10-03 23:37             ` Oleg Nesterov
  1 sibling, 0 replies; 25+ messages in thread
From: Oleg Nesterov @ 2014-10-03 23:37 UTC (permalink / raw)
  To: Chuck Ebbert
  Cc: Sasha Levin, mingo, hpa, linux-kernel, torvalds, peterz, luto,
	dvlasenk, tglx

On 10/03, Chuck Ebbert wrote:
>
> On Fri, 3 Oct 2014 23:41:24 +0200
> Oleg Nesterov <oleg@redhat.com> wrote:
>
> > On 10/03, Chuck Ebbert wrote:
> > >
> > > > [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
> > > > [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
> > > > [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
> > > > [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
> > > > [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
> > > > [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
> > > > [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
> > > > [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
> > > > [  921.917752] ? ___preempt_schedule_context (arch/x86/lib/thunk_64.S:44)
> > > > [  921.917752] ? preempt_schedule_context (kernel/context_tracking.c:145)
> > >
> > > <snip lots of repeats of this>
> > >
> > > I *think* this is because RBP isn't being saved across task switch
> > > anymore?
> > >
> > > Without CONFIG_FRAME_POINTERS that night not be a problem...
> >
> > Could you please spell?
> >
> > I don't even understand "RBP isn't being saved", SAVE_CONTEXT/RESTORE_CONTEXT
> > do push/pop %rbp?
> >
>
> SAVE_ARGS/RESTORE_ARGS, which is what THUNK uses, doesn't push/pop %rbp
>
> Before, SAVE_ALL/RESTORE_ALL were being used around the call to
> preempt_schedule(). So from the symptoms I thought this was the problem.

Ah, thanks, now I understand what you meant. I thought you meant
switch_to().

Yes, I thought about this difference too, but so far I fail to understand
how this can make a difference, according to calling.h it is callee-saved.

Oleg.


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers
  2014-10-03 21:56           ` Andy Lutomirski
@ 2014-10-03 23:48             ` Linus Torvalds
  2014-10-03 23:51             ` Oleg Nesterov
  1 sibling, 0 replies; 25+ messages in thread
From: Linus Torvalds @ 2014-10-03 23:48 UTC (permalink / raw)
  To: Andy Lutomirski
  Cc: Oleg Nesterov, Chuck Ebbert, Sasha Levin, Ingo Molnar,
	H. Peter Anvin, linux-kernel, Peter Zijlstra, Denys Vlasenko,
	Thomas Gleixner

On Fri, Oct 3, 2014 at 2:56 PM, Andy Lutomirski <luto@amacapital.net> wrote:
>
> Is this thing missing a flags or cc clobber:
>
> # define __preempt_schedule() asm ("call ___preempt_schedule")

Yes, it should probably have a cc clobber. Although I think thet gcc
actually assumes all asms clobber flags on x86, so it shouldn't
matter.

> Is this all just to make the call sequence for preempt_schedule shorter?

Not so much the call sequence, but the code around the call - not
havign to spill live registers etc. But yes.

              Linus

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers
  2014-10-03 21:56           ` Andy Lutomirski
  2014-10-03 23:48             ` Linus Torvalds
@ 2014-10-03 23:51             ` Oleg Nesterov
  1 sibling, 0 replies; 25+ messages in thread
From: Oleg Nesterov @ 2014-10-03 23:51 UTC (permalink / raw)
  To: Andy Lutomirski
  Cc: Chuck Ebbert, Sasha Levin, Ingo Molnar, H. Peter Anvin,
	linux-kernel, Linus Torvalds, Peter Zijlstra, Denys Vlasenko,
	Thomas Gleixner

On 10/03, Andy Lutomirski wrote:
>
> Is this thing missing a flags or cc clobber:
>
> # define __preempt_schedule() asm ("call ___preempt_schedule")

Well, calling.h says "rflags is clobbered", so probably yes?


> Also, I'm at a loss as to wtf all this code is doing.
>
> There's preempt_schedule, which appears to be a normal C function.
>
> There's ___preempt_schedule, which is written in assembly and calls
> preempt_schedule.
>
> Then there's __preempt_schedule, which is an inline assembler function
> that calls ___preempt_schedule.
>
> Is this all just to make the call sequence for preempt_schedule shorter?

Yes, please look at 1a338ac32ca630f67df25b4a16436cccc314e997

    sched, x86: Optimize the preempt_schedule() call

    Remove the bloat of the C calling convention out of the
    preempt_enable() sites by creating an ASM wrapper which allows us to
    do an asm("call ___preempt_schedule") instead.

Oleg.


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers
  2014-10-03 23:26       ` Oleg Nesterov
@ 2014-10-04  0:01         ` Linus Torvalds
  2014-10-04  0:11           ` Linus Torvalds
  2014-10-04  0:19           ` [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers Oleg Nesterov
  0 siblings, 2 replies; 25+ messages in thread
From: Linus Torvalds @ 2014-10-04  0:01 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Sasha Levin, Frederic Weisbecker, Ingo Molnar, Peter Anvin,
	Linux Kernel Mailing List, Peter Zijlstra, Andy Lutomirski,
	Denys Vlasenko, Thomas Gleixner, Chuck Ebbert

On Fri, Oct 3, 2014 at 4:26 PM, Oleg Nesterov <oleg@redhat.com> wrote:
>
> And I _think_ that preempt_schedule_context() should be fixed anyway,
> although I am not sure there is no something else. It does:
>
>
>         preempt_disable_notrace();
>         prev_ctx = exception_enter();
>         preempt_enable_no_resched_notrace();
>
>         preempt_schedule();
>
>         preempt_disable_notrace();
>         exception_exit(prev_ctx);
>         preempt_enable_notrace();
>
> but exception_exit() is heavy, it is quite possible that TIF_NEED_RESCHED
> and thus set_preempt_need_resched() can be set again when we call
> preempt_enable_notrace(). And in this case preempt_schedule_context()
> will be called recursively.

Why the hell is it using "preempt_enable_notrace()" in the first
place? Shouldn't it use "preempt_enable_no_resched_notrace()", since
we do *not* want it to schedule, since the whole *point* is that any
scheduling should be called within "exception" context.

> Frederic, how about the patch below?

Why do it multiple times? The whole concept is fundamentally racy
anyway, in it doesn't guarantee that any *new* "need_resched()" would
be reacted to (since they could happen *after* the test), so there's
no point in trying to fix the "race", since it always remains at the
last iteration anyway.  So adding the loop looks like just voodoo
programming, not actually fixing anything.

The real fix would appear to be to use
"preempt_enable_no_resched_notrace()", which your patch did, but
without the loop.

Yes?

             Linus

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers
  2014-10-04  0:01         ` Linus Torvalds
@ 2014-10-04  0:11           ` Linus Torvalds
  2014-10-04  0:33             ` Oleg Nesterov
  2014-10-04  0:19           ` [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers Oleg Nesterov
  1 sibling, 1 reply; 25+ messages in thread
From: Linus Torvalds @ 2014-10-04  0:11 UTC (permalink / raw)
  To: Oleg Nesterov
  Cc: Sasha Levin, Frederic Weisbecker, Ingo Molnar, Peter Anvin,
	Linux Kernel Mailing List, Peter Zijlstra, Andy Lutomirski,
	Denys Vlasenko, Thomas Gleixner, Chuck Ebbert

On Fri, Oct 3, 2014 at 5:01 PM, Linus Torvalds
<torvalds@linux-foundation.org> wrote:
>
> The real fix would appear to be to use
> "preempt_enable_no_resched_notrace()", which your patch did, but
> without the loop.

Actually, the real fix would be to not be stupid, and just make the
code do something like

>        if (likely(!preemptible()))
>                return;
>
>         __preempt_count_add(PREEMPT_ACTIVE);
>         prev_ctx = exception_enter();
>
>         __schedule();
>
>         exception_exit(prev_ctx);
>         __preempt_count_sub(PREEMPT_ACTIVE);

and *not* enable preemption around the scheduling at all. The whole
enable and then re-disable seems entirely broken, and comes from the
code using "preempt_schedule()" which doesn't work while preemption is
disabled. So don't do that then.

No?

               Linus

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers
  2014-10-04  0:01         ` Linus Torvalds
  2014-10-04  0:11           ` Linus Torvalds
@ 2014-10-04  0:19           ` Oleg Nesterov
  1 sibling, 0 replies; 25+ messages in thread
From: Oleg Nesterov @ 2014-10-04  0:19 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Sasha Levin, Frederic Weisbecker, Ingo Molnar, Peter Anvin,
	Linux Kernel Mailing List, Peter Zijlstra, Andy Lutomirski,
	Denys Vlasenko, Thomas Gleixner, Chuck Ebbert

On 10/03, Linus Torvalds wrote:
>
> On Fri, Oct 3, 2014 at 4:26 PM, Oleg Nesterov <oleg@redhat.com> wrote:
> >
> > And I _think_ that preempt_schedule_context() should be fixed anyway,
> > although I am not sure there is no something else. It does:
> >
> >
> >         preempt_disable_notrace();
> >         prev_ctx = exception_enter();
> >         preempt_enable_no_resched_notrace();
> >
> >         preempt_schedule();
> >
> >         preempt_disable_notrace();
> >         exception_exit(prev_ctx);
> >         preempt_enable_notrace();
> >
> > but exception_exit() is heavy, it is quite possible that TIF_NEED_RESCHED
> > and thus set_preempt_need_resched() can be set again when we call
> > preempt_enable_notrace(). And in this case preempt_schedule_context()
> > will be called recursively.
>
> Why the hell is it using "preempt_enable_notrace()" in the first
> place? Shouldn't it use "preempt_enable_no_resched_notrace()",

Yes, this this is the main problem.

> > Frederic, how about the patch below?
>
> Why do it multiple times? The whole concept is fundamentally racy
> anyway, in it doesn't guarantee that any *new* "need_resched()" would
> be reacted to (since they could happen *after* the test),

But in this case we rely on scheduler_ipi() and return-from-irq path?

> The real fix would appear to be to use
> "preempt_enable_no_resched_notrace()", which your patch did, but
> without the loop.

Not sure... preempt_schedule() does the same and afaics for good reason.

But perhaps you are right. I am already sleeping, will try to recheck
tomorrow. And in fact I got lost in preempt.h files... I can't even
understand why __preempt_schedule_context() is only called by
preempt_enable_notrace().

Oleg.


^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers
  2014-10-04  0:11           ` Linus Torvalds
@ 2014-10-04  0:33             ` Oleg Nesterov
  2014-10-05 20:23               ` [PATCH 0/1] stop the unbound recursion in preempt_schedule_context() Oleg Nesterov
  0 siblings, 1 reply; 25+ messages in thread
From: Oleg Nesterov @ 2014-10-04  0:33 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Sasha Levin, Frederic Weisbecker, Ingo Molnar, Peter Anvin,
	Linux Kernel Mailing List, Peter Zijlstra, Andy Lutomirski,
	Denys Vlasenko, Thomas Gleixner, Chuck Ebbert

On 10/03, Linus Torvalds wrote:
>
> On Fri, Oct 3, 2014 at 5:01 PM, Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
> >
> > The real fix would appear to be to use
> > "preempt_enable_no_resched_notrace()", which your patch did, but
> > without the loop.
>
> Actually, the real fix would be to not be stupid, and just make the
> code do something like
>
> >        if (likely(!preemptible()))
> >                return;
> >
> >         __preempt_count_add(PREEMPT_ACTIVE);
> >         prev_ctx = exception_enter();
> >
> >         __schedule();
> >
> >         exception_exit(prev_ctx);
> >         __preempt_count_sub(PREEMPT_ACTIVE);
>
> and *not* enable preemption around the scheduling at all. The whole
> enable and then re-disable seems entirely broken, and comes from the
> code using "preempt_schedule()" which doesn't work while preemption is
> disabled. So don't do that then.

Again, it is too late for me... Most probably I am wrong, but somehow
it seems to me that the real fix should try to kill preempt_schedule_context()
altogether and teach preempt_schedule() to play well with CONTEXT_TRACKING.

Oleg.


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 0/1] stop the unbound recursion in preempt_schedule_context()
  2014-10-04  0:33             ` Oleg Nesterov
@ 2014-10-05 20:23               ` Oleg Nesterov
  2014-10-05 20:23                 ` [PATCH 1/1] " Oleg Nesterov
  2014-10-05 23:53                 ` [PATCH 0/1] " Oleg Nesterov
  0 siblings, 2 replies; 25+ messages in thread
From: Oleg Nesterov @ 2014-10-05 20:23 UTC (permalink / raw)
  To: Linus Torvalds, Frederic Weisbecker, Steven Rostedt
  Cc: Sasha Levin, Ingo Molnar, Peter Anvin, Linux Kernel Mailing List,
	Peter Zijlstra, Andy Lutomirski, Denys Vlasenko, Thomas Gleixner,
	Chuck Ebbert

On 10/04, Oleg Nesterov wrote:
>
> On 10/03, Linus Torvalds wrote:
> >
> > On Fri, Oct 3, 2014 at 5:01 PM, Linus Torvalds
> > <torvalds@linux-foundation.org> wrote:
> > >
> > > The real fix would appear to be to use
> > > "preempt_enable_no_resched_notrace()", which your patch did, but
> > > without the loop.
> >
> > Actually, the real fix would be to not be stupid, and just make the
> > code do something like
> >
> > >        if (likely(!preemptible()))
> > >                return;
> > >
> > >         __preempt_count_add(PREEMPT_ACTIVE);
> > >         prev_ctx = exception_enter();
> > >
> > >         __schedule();
> > >
> > >         exception_exit(prev_ctx);
> > >         __preempt_count_sub(PREEMPT_ACTIVE);
> >
> > and *not* enable preemption around the scheduling at all.

Yes, I think you are right. And I hate to admit that I didn't think about
this simplification. The only complication is that we should move this
function from context_tracking.c to sched/core.c.

However, I still think we need the need_resched() loop, we can't do this
only once.

And in fact the simplest fix could just turn it into

	local_irq_disable();
	preempt_schedule_irq();
	local_irq_enable();

> Again, it is too late for me... Most probably I am wrong, but somehow
> it seems to me that the real fix should try to kill preempt_schedule_context()
> altogether and teach preempt_schedule() to play well with CONTEXT_TRACKING.

Yes, the very fact that

	preempt_enable() != trace_preempt_on() + preempt_enable_notrace()

looks simply wrong imo. And preempt_enable_notrace() has users outside of
the tracing code which can run in IN_USER state. For example, why should
__perf_sw_event() worry about context_tracking.state?

OTOH, if the caller of preempt_enable_notrace() actually needs to take care
of potential IN_USER state, then it probably has other problems. And indeed,
ftrace_ops_control_func() has to check rcu_is_watching() anyway.

IOW, imho 29bb9e5a75 "tracing/context-tracking: Add preempt_schedule_context()
for tracing" was not a right solution. Perhaps the tracing functions can be
changed to switch to IN_KERNEL mode, or at least perhaps we can add the
special preempt_disable_ftrace() helper. But this needs another discussion.

Either way, I do think that preempt_schedule_context() in its current form
must die.

Oleg.


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH 1/1] stop the unbound recursion in preempt_schedule_context()
  2014-10-05 20:23               ` [PATCH 0/1] stop the unbound recursion in preempt_schedule_context() Oleg Nesterov
@ 2014-10-05 20:23                 ` Oleg Nesterov
  2014-10-28 11:03                   ` [tip:sched/core] sched: " tip-bot for Oleg Nesterov
  2014-10-05 23:53                 ` [PATCH 0/1] " Oleg Nesterov
  1 sibling, 1 reply; 25+ messages in thread
From: Oleg Nesterov @ 2014-10-05 20:23 UTC (permalink / raw)
  To: Linus Torvalds, Frederic Weisbecker, Steven Rostedt
  Cc: Sasha Levin, Ingo Molnar, Peter Anvin, Linux Kernel Mailing List,
	Peter Zijlstra, Andy Lutomirski, Denys Vlasenko, Thomas Gleixner,
	Chuck Ebbert

preempt_schedule_context() does preempt_enable_notrace() at the end
and this can call the same function again; exception_exit() is heavy
and it is quite possible that need-resched is true again.

1. Change this code to dec preempt_count() and check need_resched()
   by hand.

2. As Linus suggested, we can use the PREEMPT_ACTIVE bit and avoid
   the enable/disable dance around __schedule(). But in this case
   we need to move into sched/core.c.

3. Cosmetic, but x86 forgets to declare this function. This doesn't
   really matter because it is only called by asm helpers, still it
   make sense to add the declaration into asm/preempt.h to match
   preempt_schedule().

Reported-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
 arch/x86/include/asm/preempt.h |    1 +
 kernel/context_tracking.c      |   40 ---------------------------------------
 kernel/sched/core.c            |   41 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 42 insertions(+), 40 deletions(-)

diff --git a/arch/x86/include/asm/preempt.h b/arch/x86/include/asm/preempt.h
index 7024c12..4008734 100644
--- a/arch/x86/include/asm/preempt.h
+++ b/arch/x86/include/asm/preempt.h
@@ -105,6 +105,7 @@ static __always_inline bool should_resched(void)
 # ifdef CONFIG_CONTEXT_TRACKING
     extern asmlinkage void ___preempt_schedule_context(void);
 #   define __preempt_schedule_context() asm ("call ___preempt_schedule_context")
+    extern asmlinkage void preempt_schedule_context(void);
 # endif
 #endif
 
diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c
index 5664985..937ecdf 100644
--- a/kernel/context_tracking.c
+++ b/kernel/context_tracking.c
@@ -107,46 +107,6 @@ void context_tracking_user_enter(void)
 }
 NOKPROBE_SYMBOL(context_tracking_user_enter);
 
-#ifdef CONFIG_PREEMPT
-/**
- * preempt_schedule_context - preempt_schedule called by tracing
- *
- * The tracing infrastructure uses preempt_enable_notrace to prevent
- * recursion and tracing preempt enabling caused by the tracing
- * infrastructure itself. But as tracing can happen in areas coming
- * from userspace or just about to enter userspace, a preempt enable
- * can occur before user_exit() is called. This will cause the scheduler
- * to be called when the system is still in usermode.
- *
- * To prevent this, the preempt_enable_notrace will use this function
- * instead of preempt_schedule() to exit user context if needed before
- * calling the scheduler.
- */
-asmlinkage __visible void __sched notrace preempt_schedule_context(void)
-{
-	enum ctx_state prev_ctx;
-
-	if (likely(!preemptible()))
-		return;
-
-	/*
-	 * Need to disable preemption in case user_exit() is traced
-	 * and the tracer calls preempt_enable_notrace() causing
-	 * an infinite recursion.
-	 */
-	preempt_disable_notrace();
-	prev_ctx = exception_enter();
-	preempt_enable_no_resched_notrace();
-
-	preempt_schedule();
-
-	preempt_disable_notrace();
-	exception_exit(prev_ctx);
-	preempt_enable_notrace();
-}
-EXPORT_SYMBOL_GPL(preempt_schedule_context);
-#endif /* CONFIG_PREEMPT */
-
 /**
  * context_tracking_user_exit - Inform the context tracking that the CPU is
  *                              exiting userspace mode and entering the kernel.
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 9023f56..86980c5 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2903,6 +2903,47 @@ asmlinkage __visible void __sched notrace preempt_schedule(void)
 }
 NOKPROBE_SYMBOL(preempt_schedule);
 EXPORT_SYMBOL(preempt_schedule);
+
+#ifdef CONFIG_CONTEXT_TRACKING
+/**
+ * preempt_schedule_context - preempt_schedule called by tracing
+ *
+ * The tracing infrastructure uses preempt_enable_notrace to prevent
+ * recursion and tracing preempt enabling caused by the tracing
+ * infrastructure itself. But as tracing can happen in areas coming
+ * from userspace or just about to enter userspace, a preempt enable
+ * can occur before user_exit() is called. This will cause the scheduler
+ * to be called when the system is still in usermode.
+ *
+ * To prevent this, the preempt_enable_notrace will use this function
+ * instead of preempt_schedule() to exit user context if needed before
+ * calling the scheduler.
+ */
+asmlinkage __visible void __sched notrace preempt_schedule_context(void)
+{
+	enum ctx_state prev_ctx;
+
+	if (likely(!preemptible()))
+		return;
+
+	do {
+		__preempt_count_add(PREEMPT_ACTIVE);
+		/*
+		 * Needs preempt disabled in case user_exit() is traced
+		 * and the tracer calls preempt_enable_notrace() causing
+		 * an infinite recursion.
+		 */
+		prev_ctx = exception_enter();
+		__schedule();
+		exception_exit(prev_ctx);
+
+		__preempt_count_sub(PREEMPT_ACTIVE);
+		barrier();
+	} while (need_resched());
+}
+EXPORT_SYMBOL_GPL(preempt_schedule_context);
+#endif /* CONFIG_CONTEXT_TRACKING */
+
 #endif /* CONFIG_PREEMPT */
 
 /*
-- 
1.5.5.1



^ permalink raw reply related	[flat|nested] 25+ messages in thread

* Re: [PATCH 0/1] stop the unbound recursion in preempt_schedule_context()
  2014-10-05 20:23               ` [PATCH 0/1] stop the unbound recursion in preempt_schedule_context() Oleg Nesterov
  2014-10-05 20:23                 ` [PATCH 1/1] " Oleg Nesterov
@ 2014-10-05 23:53                 ` Oleg Nesterov
  1 sibling, 0 replies; 25+ messages in thread
From: Oleg Nesterov @ 2014-10-05 23:53 UTC (permalink / raw)
  To: Linus Torvalds, Frederic Weisbecker, Steven Rostedt
  Cc: Sasha Levin, Ingo Molnar, Peter Anvin, Linux Kernel Mailing List,
	Peter Zijlstra, Andy Lutomirski, Denys Vlasenko, Thomas Gleixner,
	Chuck Ebbert

And, Frederic, this is off-topic but I am just curious...

I can't understand why exception_enter() calls context_tracking_user_exit()
unconditionally (unlike exception_exit), and why enter/exit need to check
context_tracking.state with irqs disabled.

IOW, any reason why the patch below is wrong?

Of course, context_tracking is per-cpu, so

	if (context_tracking_in_user()) {
		local_irq_save(flags);
		...

can be preempted and change the state on another CPU. But this should
be fine because the task must see the same .state on all CPU's or the
whole preempt context-tracking logic is broken?

Oleg.


--- x/include/linux/context_tracking.h
+++ x/include/linux/context_tracking.h
@@ -29,15 +29,14 @@ static inline void user_exit(void)
 
 static inline enum ctx_state exception_enter(void)
 {
-	enum ctx_state prev_ctx;
-
-	if (!context_tracking_is_enabled())
-		return 0;
-
-	prev_ctx = this_cpu_read(context_tracking.state);
-	context_tracking_user_exit();
+	if (context_tracking_is_enabled()) {
+		if (context_tracking_in_user()) {
+			context_tracking_user_exit();
+			return IN_USER;
+		}
+	}
 
-	return prev_ctx;
+	return IN_KERNEL;
 }
 
 static inline void exception_exit(enum ctx_state prev_ctx)
--- x/kernel/context_tracking.c
+++ x/kernel/context_tracking.c
@@ -74,8 +74,8 @@ void context_tracking_user_enter(void)
 	/* Kernel threads aren't supposed to go to userspace */
 	WARN_ON_ONCE(!current->mm);
 
-	local_irq_save(flags);
-	if ( __this_cpu_read(context_tracking.state) != IN_USER) {
+	if (!context_tracking_in_user()) {
+		local_irq_save(flags);
 		if (__this_cpu_read(context_tracking.active)) {
 			trace_user_enter(0);
 			/*
@@ -102,8 +102,8 @@ void context_tracking_user_enter(void)
 		 * is false because we know that CPU is not tickless.
 		 */
 		__this_cpu_write(context_tracking.state, IN_USER);
+		local_irq_restore(flags);
 	}
-	local_irq_restore(flags);
 }
 NOKPROBE_SYMBOL(context_tracking_user_enter);
 
@@ -128,8 +128,8 @@ void context_tracking_user_exit(void)
 	if (in_interrupt())
 		return;
 
-	local_irq_save(flags);
-	if (__this_cpu_read(context_tracking.state) == IN_USER) {
+	if (context_tracking_in_user()) {
+		local_irq_save(flags);
 		if (__this_cpu_read(context_tracking.active)) {
 			/*
 			 * We are going to run code that may use RCU. Inform
@@ -140,8 +140,8 @@ void context_tracking_user_exit(void)
 			trace_user_exit(0);
 		}
 		__this_cpu_write(context_tracking.state, IN_KERNEL);
+		local_irq_restore(flags);
 	}
-	local_irq_restore(flags);
 }
 NOKPROBE_SYMBOL(context_tracking_user_exit);
 


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [tip:sched/core] sched: stop the unbound recursion in preempt_schedule_context()
  2014-10-05 20:23                 ` [PATCH 1/1] " Oleg Nesterov
@ 2014-10-28 11:03                   ` tip-bot for Oleg Nesterov
  0 siblings, 0 replies; 25+ messages in thread
From: tip-bot for Oleg Nesterov @ 2014-10-28 11:03 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hpa, torvalds, akpm, linux-kernel, cebbert.lkml, fweisbec, oleg,
	dvlasenk, mingo, sasha.levin, masami.hiramatsu.pt, agraf, luto,
	peterz, cl, tglx, rostedt

Commit-ID:  009f60e2763568cdcd75bd1cf360c7c7165e2e60
Gitweb:     http://git.kernel.org/tip/009f60e2763568cdcd75bd1cf360c7c7165e2e60
Author:     Oleg Nesterov <oleg@redhat.com>
AuthorDate: Sun, 5 Oct 2014 22:23:22 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 28 Oct 2014 10:46:05 +0100

sched: stop the unbound recursion in preempt_schedule_context()

preempt_schedule_context() does preempt_enable_notrace() at the end
and this can call the same function again; exception_exit() is heavy
and it is quite possible that need-resched is true again.

1. Change this code to dec preempt_count() and check need_resched()
   by hand.

2. As Linus suggested, we can use the PREEMPT_ACTIVE bit and avoid
   the enable/disable dance around __schedule(). But in this case
   we need to move into sched/core.c.

3. Cosmetic, but x86 forgets to declare this function. This doesn't
   really matter because it is only called by asm helpers, still it
   make sense to add the declaration into asm/preempt.h to match
   preempt_schedule().

Reported-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Alexander Graf <agraf@suse.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Christoph Lameter <cl@linux.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Peter Anvin <hpa@zytor.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Chuck Ebbert <cebbert.lkml@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Link: http://lkml.kernel.org/r/20141005202322.GB27962@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/include/asm/preempt.h |  1 +
 kernel/context_tracking.c      | 40 ----------------------------------------
 kernel/sched/core.c            | 41 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 42 insertions(+), 40 deletions(-)

diff --git a/arch/x86/include/asm/preempt.h b/arch/x86/include/asm/preempt.h
index 7024c12..4008734 100644
--- a/arch/x86/include/asm/preempt.h
+++ b/arch/x86/include/asm/preempt.h
@@ -105,6 +105,7 @@ static __always_inline bool should_resched(void)
 # ifdef CONFIG_CONTEXT_TRACKING
     extern asmlinkage void ___preempt_schedule_context(void);
 #   define __preempt_schedule_context() asm ("call ___preempt_schedule_context")
+    extern asmlinkage void preempt_schedule_context(void);
 # endif
 #endif
 
diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c
index 5664985..937ecdf 100644
--- a/kernel/context_tracking.c
+++ b/kernel/context_tracking.c
@@ -107,46 +107,6 @@ void context_tracking_user_enter(void)
 }
 NOKPROBE_SYMBOL(context_tracking_user_enter);
 
-#ifdef CONFIG_PREEMPT
-/**
- * preempt_schedule_context - preempt_schedule called by tracing
- *
- * The tracing infrastructure uses preempt_enable_notrace to prevent
- * recursion and tracing preempt enabling caused by the tracing
- * infrastructure itself. But as tracing can happen in areas coming
- * from userspace or just about to enter userspace, a preempt enable
- * can occur before user_exit() is called. This will cause the scheduler
- * to be called when the system is still in usermode.
- *
- * To prevent this, the preempt_enable_notrace will use this function
- * instead of preempt_schedule() to exit user context if needed before
- * calling the scheduler.
- */
-asmlinkage __visible void __sched notrace preempt_schedule_context(void)
-{
-	enum ctx_state prev_ctx;
-
-	if (likely(!preemptible()))
-		return;
-
-	/*
-	 * Need to disable preemption in case user_exit() is traced
-	 * and the tracer calls preempt_enable_notrace() causing
-	 * an infinite recursion.
-	 */
-	preempt_disable_notrace();
-	prev_ctx = exception_enter();
-	preempt_enable_no_resched_notrace();
-
-	preempt_schedule();
-
-	preempt_disable_notrace();
-	exception_exit(prev_ctx);
-	preempt_enable_notrace();
-}
-EXPORT_SYMBOL_GPL(preempt_schedule_context);
-#endif /* CONFIG_PREEMPT */
-
 /**
  * context_tracking_user_exit - Inform the context tracking that the CPU is
  *                              exiting userspace mode and entering the kernel.
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index dde8adb..240157c 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2951,6 +2951,47 @@ asmlinkage __visible void __sched notrace preempt_schedule(void)
 }
 NOKPROBE_SYMBOL(preempt_schedule);
 EXPORT_SYMBOL(preempt_schedule);
+
+#ifdef CONFIG_CONTEXT_TRACKING
+/**
+ * preempt_schedule_context - preempt_schedule called by tracing
+ *
+ * The tracing infrastructure uses preempt_enable_notrace to prevent
+ * recursion and tracing preempt enabling caused by the tracing
+ * infrastructure itself. But as tracing can happen in areas coming
+ * from userspace or just about to enter userspace, a preempt enable
+ * can occur before user_exit() is called. This will cause the scheduler
+ * to be called when the system is still in usermode.
+ *
+ * To prevent this, the preempt_enable_notrace will use this function
+ * instead of preempt_schedule() to exit user context if needed before
+ * calling the scheduler.
+ */
+asmlinkage __visible void __sched notrace preempt_schedule_context(void)
+{
+	enum ctx_state prev_ctx;
+
+	if (likely(!preemptible()))
+		return;
+
+	do {
+		__preempt_count_add(PREEMPT_ACTIVE);
+		/*
+		 * Needs preempt disabled in case user_exit() is traced
+		 * and the tracer calls preempt_enable_notrace() causing
+		 * an infinite recursion.
+		 */
+		prev_ctx = exception_enter();
+		__schedule();
+		exception_exit(prev_ctx);
+
+		__preempt_count_sub(PREEMPT_ACTIVE);
+		barrier();
+	} while (need_resched());
+}
+EXPORT_SYMBOL_GPL(preempt_schedule_context);
+#endif /* CONFIG_CONTEXT_TRACKING */
+
 #endif /* CONFIG_PREEMPT */
 
 /*

^ permalink raw reply related	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2014-10-28 11:04 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-21 18:41 [PATCH v3 0/2] x86: reimplement ___preempt_schedule*() using THUNK helpers Oleg Nesterov
2014-09-21 18:41 ` [PATCH v3 1/2] " Oleg Nesterov
2014-09-24 15:02   ` [tip:x86/asm] x86: Speed up ___preempt_schedule*() by " tip-bot for Oleg Nesterov
2014-10-03  4:50     ` Sasha Levin
2014-10-03 13:39       ` Chuck Ebbert
2014-10-03 21:41         ` Oleg Nesterov
2014-10-03 21:56           ` Andy Lutomirski
2014-10-03 23:48             ` Linus Torvalds
2014-10-03 23:51             ` Oleg Nesterov
2014-10-03 22:48           ` Chuck Ebbert
2014-10-03 22:53             ` Andy Lutomirski
2014-10-03 23:13               ` H. Peter Anvin
2014-10-03 23:37             ` Oleg Nesterov
2014-10-03 21:16       ` Oleg Nesterov
2014-10-03 23:26       ` Oleg Nesterov
2014-10-04  0:01         ` Linus Torvalds
2014-10-04  0:11           ` Linus Torvalds
2014-10-04  0:33             ` Oleg Nesterov
2014-10-05 20:23               ` [PATCH 0/1] stop the unbound recursion in preempt_schedule_context() Oleg Nesterov
2014-10-05 20:23                 ` [PATCH 1/1] " Oleg Nesterov
2014-10-28 11:03                   ` [tip:sched/core] sched: " tip-bot for Oleg Nesterov
2014-10-05 23:53                 ` [PATCH 0/1] " Oleg Nesterov
2014-10-04  0:19           ` [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers Oleg Nesterov
2014-09-21 18:42 ` [PATCH v3 2/2] x86, lib/Makefile: remove the unnecessary "+= thunk_64.o" Oleg Nesterov
2014-09-24 15:02   ` [tip:x86/asm] x86/lib/Makefile: Remove " tip-bot for Oleg Nesterov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).