2020-02-25 23:31:52

by Thomas Gleixner

[permalink] [raw]
Subject: [patch 6/8] x86/entry: Move irq tracing to syscall_slow_exit_work

which removes the ASM IRQ tracepoints.

Signed-off-by: Thomas Gleixner <[email protected]>
---
arch/x86/entry/common.c | 2 ++
arch/x86/entry/entry_32.S | 3 ++-
arch/x86/entry/entry_64.S | 3 ---
3 files changed, 4 insertions(+), 4 deletions(-)

--- a/arch/x86/entry/common.c
+++ b/arch/x86/entry/common.c
@@ -299,6 +299,8 @@ static void syscall_slow_exit_work(struc

local_irq_disable();
__prepare_exit_to_usermode(regs);
+ /* Return to user space enables interrupts */
+ trace_hardirqs_on();
}
NOKPROBE_SYMBOL(syscall_return_slowpath);

--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -812,7 +812,7 @@ SYM_CODE_START(ret_from_fork)
movl %esp, %eax
call syscall_return_slowpath
STACKLEAK_ERASE
- jmp restore_all
+ jmp restore_all_switch_stack

/* kernel thread */
1: movl %edi, %eax
@@ -1077,6 +1077,7 @@ SYM_FUNC_START(entry_INT80_32)

restore_all:
TRACE_IRQS_IRET
+restore_all_switch_stack:
SWITCH_TO_ENTRY_STACK
CHECK_AND_APPLY_ESPFIX
.Lrestore_nocheck:
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -172,8 +172,6 @@ SYM_INNER_LABEL(entry_SYSCALL_64_after_h
movq %rsp, %rsi
call do_syscall_64 /* returns with IRQs disabled */

- TRACE_IRQS_ON /* return enables interrupts */
-
/*
* Try to use SYSRET instead of IRET if we're returning to
* a completely clean 64-bit userspace context. If we're not,
@@ -340,7 +338,6 @@ SYM_CODE_START(ret_from_fork)
UNWIND_HINT_REGS
movq %rsp, %rdi
call syscall_return_slowpath /* returns with IRQs disabled */
- TRACE_IRQS_ON /* user mode is traced as IRQS on */
jmp swapgs_restore_regs_and_return_to_usermode

1:


2020-02-26 05:49:20

by Andy Lutomirski

[permalink] [raw]
Subject: Re: [patch 6/8] x86/entry: Move irq tracing to syscall_slow_exit_work

On 2/25/20 2:08 PM, Thomas Gleixner wrote:
> which removes the ASM IRQ tracepoints.

It's still after we re-enter rcuidle. Is tracing actually okay?

I always had the impression that tracing was okay in rcuidle mode
because the tracing code was smart enough to do the right thing, but
your patch 3/8 changelog says:

Anything before enter_from_user_mode() is not safe to be traced or probed.


--Andy

2020-02-27 16:13:29

by Alexandre Chartre

[permalink] [raw]
Subject: Re: [patch 6/8] x86/entry: Move irq tracing to syscall_slow_exit_work


On 2/25/20 11:08 PM, Thomas Gleixner wrote:
> which removes the ASM IRQ tracepoints.

This moves irq tracing to syscall_return_slowpath, not syscall_slow_exit_work,
right?

alex.


> Signed-off-by: Thomas Gleixner <[email protected]>
> ---
> arch/x86/entry/common.c | 2 ++
> arch/x86/entry/entry_32.S | 3 ++-
> arch/x86/entry/entry_64.S | 3 ---
> 3 files changed, 4 insertions(+), 4 deletions(-)
>
> --- a/arch/x86/entry/common.c
> +++ b/arch/x86/entry/common.c
> @@ -299,6 +299,8 @@ static void syscall_slow_exit_work(struc
>
> local_irq_disable();
> __prepare_exit_to_usermode(regs);
> + /* Return to user space enables interrupts */
> + trace_hardirqs_on();
> }
> NOKPROBE_SYMBOL(syscall_return_slowpath);
>
> --- a/arch/x86/entry/entry_32.S
> +++ b/arch/x86/entry/entry_32.S
> @@ -812,7 +812,7 @@ SYM_CODE_START(ret_from_fork)
> movl %esp, %eax
> call syscall_return_slowpath
> STACKLEAK_ERASE
> - jmp restore_all
> + jmp restore_all_switch_stack
>
> /* kernel thread */
> 1: movl %edi, %eax
> @@ -1077,6 +1077,7 @@ SYM_FUNC_START(entry_INT80_32)
>
> restore_all:
> TRACE_IRQS_IRET
> +restore_all_switch_stack:
> SWITCH_TO_ENTRY_STACK
> CHECK_AND_APPLY_ESPFIX
> .Lrestore_nocheck:
> --- a/arch/x86/entry/entry_64.S
> +++ b/arch/x86/entry/entry_64.S
> @@ -172,8 +172,6 @@ SYM_INNER_LABEL(entry_SYSCALL_64_after_h
> movq %rsp, %rsi
> call do_syscall_64 /* returns with IRQs disabled */
>
> - TRACE_IRQS_ON /* return enables interrupts */
> -
> /*
> * Try to use SYSRET instead of IRET if we're returning to
> * a completely clean 64-bit userspace context. If we're not,
> @@ -340,7 +338,6 @@ SYM_CODE_START(ret_from_fork)
> UNWIND_HINT_REGS
> movq %rsp, %rdi
> call syscall_return_slowpath /* returns with IRQs disabled */
> - TRACE_IRQS_ON /* user mode is traced as IRQS on */
> jmp swapgs_restore_regs_and_return_to_usermode
>
> 1:
>