2014-10-03 04:51:22

by Sasha Levin

[permalink] [raw]
Subject: Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers

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 <[email protected]>
> AuthorDate: Sun, 21 Sep 2014 20:41:53 +0200
> Committer: Ingo Molnar <[email protected]>
> 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 <[email protected]>
> Reviewed-by: Andy Lutomirski <[email protected]>
> Cc: Denys Vlasenko <[email protected]>
> Cc: Peter Zijlstra <[email protected]>
> Cc: Linus Torvalds <[email protected]>
> Link: http://lkml.kernel.org/r/[email protected]
> Signed-off-by: Ingo Molnar <[email protected]>
> ---

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


2014-10-03 13:40:02

by Chuck Ebbert

[permalink] [raw]
Subject: Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers

On Fri, 03 Oct 2014 00:50:13 -0400
Sasha Levin <[email protected]> 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 <[email protected]>
> > AuthorDate: Sun, 21 Sep 2014 20:41:53 +0200
> > Committer: Ingo Molnar <[email protected]>
> > 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 <[email protected]>
> > Reviewed-by: Andy Lutomirski <[email protected]>
> > Cc: Denys Vlasenko <[email protected]>
> > Cc: Peter Zijlstra <[email protected]>
> > Cc: Linus Torvalds <[email protected]>
> > Link: http://lkml.kernel.org/r/[email protected]
> > Signed-off-by: Ingo Molnar <[email protected]>
> > ---
>
> 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...

2014-10-03 21:19:37

by Oleg Nesterov

[permalink] [raw]
Subject: Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers

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 <[email protected]>
> > AuthorDate: Sun, 21 Sep 2014 20:41:53 +0200
> > Committer: Ingo Molnar <[email protected]>
> > 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 <[email protected]>
> > Reviewed-by: Andy Lutomirski <[email protected]>
> > Cc: Denys Vlasenko <[email protected]>
> > Cc: Peter Zijlstra <[email protected]>
> > Cc: Linus Torvalds <[email protected]>
> > Link: http://lkml.kernel.org/r/[email protected]
> > Signed-off-by: Ingo Molnar <[email protected]>
> > ---
>
> 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.

2014-10-03 21:57:49

by Andy Lutomirski

[permalink] [raw]
Subject: Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers

On Fri, Oct 3, 2014 at 2:41 PM, Oleg Nesterov <[email protected]> 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

2014-10-03 22:48:22

by Chuck Ebbert

[permalink] [raw]
Subject: Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers

On Fri, 3 Oct 2014 23:41:24 +0200
Oleg Nesterov <[email protected]> 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.

2014-10-03 22:53:35

by Andy Lutomirski

[permalink] [raw]
Subject: Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers

On Fri, Oct 3, 2014 at 3:48 PM, Chuck Ebbert <[email protected]> wrote:
> On Fri, 3 Oct 2014 23:41:24 +0200
> Oleg Nesterov <[email protected]> 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

2014-10-03 23:14:47

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers

Yes, it is.

On October 3, 2014 3:53:08 PM PDT, Andy Lutomirski <[email protected]> wrote:
>On Fri, Oct 3, 2014 at 3:48 PM, Chuck Ebbert <[email protected]>
>wrote:
>> On Fri, 3 Oct 2014 23:41:24 +0200
>> Oleg Nesterov <[email protected]> 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.

2014-10-03 23:30:01

by Oleg Nesterov

[permalink] [raw]
Subject: Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers

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 <[email protected]>
> > AuthorDate: Sun, 21 Sep 2014 20:41:53 +0200
> > Committer: Ingo Molnar <[email protected]>
> > 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 <[email protected]>
> > Reviewed-by: Andy Lutomirski <[email protected]>
> > Cc: Denys Vlasenko <[email protected]>
> > Cc: Peter Zijlstra <[email protected]>
> > Cc: Linus Torvalds <[email protected]>
> > Link: http://lkml.kernel.org/r/[email protected]
> > Signed-off-by: Ingo Molnar <[email protected]>
> > ---
>
> 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 */

2014-10-03 23:40:37

by Oleg Nesterov

[permalink] [raw]
Subject: Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers

On 10/03, Chuck Ebbert wrote:
>
> On Fri, 3 Oct 2014 23:41:24 +0200
> Oleg Nesterov <[email protected]> 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.

2014-10-03 23:48:22

by Linus Torvalds

[permalink] [raw]
Subject: Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers

On Fri, Oct 3, 2014 at 2:56 PM, Andy Lutomirski <[email protected]> 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

2014-10-03 23:56:12

by Oleg Nesterov

[permalink] [raw]
Subject: Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers

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.

2014-10-04 00:01:48

by Linus Torvalds

[permalink] [raw]
Subject: Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers

On Fri, Oct 3, 2014 at 4:26 PM, Oleg Nesterov <[email protected]> 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

2014-10-04 00:11:40

by Linus Torvalds

[permalink] [raw]
Subject: Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers

On Fri, Oct 3, 2014 at 5:01 PM, Linus Torvalds
<[email protected]> 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

2014-10-04 00:19:03

by Oleg Nesterov

[permalink] [raw]
Subject: Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers

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.

2014-10-04 00:22:50

by Oleg Nesterov

[permalink] [raw]
Subject: Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers

On 10/03, Linus Torvalds wrote:
>
> On Fri, Oct 3, 2014 at 4:26 PM, Oleg Nesterov <[email protected]> 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.

2014-10-04 00:36:32

by Oleg Nesterov

[permalink] [raw]
Subject: Re: [tip:x86/asm] x86: Speed up ___preempt_schedule*() by using THUNK helpers

On 10/03, Linus Torvalds wrote:
>
> On Fri, Oct 3, 2014 at 5:01 PM, Linus Torvalds
> <[email protected]> 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.

2014-10-05 20:26:35

by Oleg Nesterov

[permalink] [raw]
Subject: [PATCH 0/1] stop the unbound recursion in preempt_schedule_context()

On 10/04, Oleg Nesterov wrote:
>
> On 10/03, Linus Torvalds wrote:
> >
> > On Fri, Oct 3, 2014 at 5:01 PM, Linus Torvalds
> > <[email protected]> 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.

2014-10-05 20:26:51

by Oleg Nesterov

[permalink] [raw]
Subject: [PATCH 1/1] 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 <[email protected]>
Signed-off-by: Oleg Nesterov <[email protected]>
---
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

2014-10-05 23:57:12

by Oleg Nesterov

[permalink] [raw]
Subject: Re: [PATCH 0/1] stop the unbound recursion in preempt_schedule_context()

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);

Subject: [tip:sched/core] sched: stop the unbound recursion in preempt_schedule_context()

Commit-ID: 009f60e2763568cdcd75bd1cf360c7c7165e2e60
Gitweb: http://git.kernel.org/tip/009f60e2763568cdcd75bd1cf360c7c7165e2e60
Author: Oleg Nesterov <[email protected]>
AuthorDate: Sun, 5 Oct 2014 22:23:22 +0200
Committer: Ingo Molnar <[email protected]>
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 <[email protected]>
Signed-off-by: Oleg Nesterov <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Alexander Graf <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Christoph Lameter <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
Cc: Steven Rostedt <[email protected]>
Cc: Peter Anvin <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Denys Vlasenko <[email protected]>
Cc: Chuck Ebbert <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
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 */

/*