From: Borislav Petkov <bp@alien8.de>
To: Andy Lutomirski <luto@amacapital.net>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
"Frédéric Weisbecker" <fweisbec@gmail.com>,
"Oleg Nesterov" <oleg@redhat.com>,
"kvm list" <kvm@vger.kernel.org>
Subject: Re: [PATCH 3/3] x86_64,entry: Remove the syscall exit audit and schedule optimizations
Date: Fri, 9 Jan 2015 16:53:35 +0100 [thread overview]
Message-ID: <20150109155334.GE13637@pd.tnic> (raw)
In-Reply-To: <1072a16a8d4ad1b11b8062f76e3236b9771b0fb6.1415403984.git.luto@amacapital.net>
On Fri, Nov 07, 2014 at 03:58:19PM -0800, Andy Lutomirski wrote:
> We used to optimize rescheduling and audit on syscall exit. Now that
> the full slow path is reasonably fast, remove these optimizations.
>
> This adds something like 10ns to the previously optimized paths on my
> computer, presumably due mostly to SAVE_REST / RESTORE_REST.
>
> I think that we should eventually replace both the syscall and
> non-paranoid interrupt exit slow paths with a pair of C functions
> along the lines of the syscall entry hooks.
>
> Signed-off-by: Andy Lutomirski <luto@amacapital.net>
> ---
> arch/x86/kernel/entry_64.S | 52 +++++-----------------------------------------
> 1 file changed, 5 insertions(+), 47 deletions(-)
>
> diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
> index a5afdf0f7fa4..222dc5c45ac3 100644
> --- a/arch/x86/kernel/entry_64.S
> +++ b/arch/x86/kernel/entry_64.S
> @@ -427,15 +427,12 @@ system_call_fastpath:
> * Has incomplete stack frame and undefined top of stack.
> */
> ret_from_sys_call:
> - movl $_TIF_ALLWORK_MASK,%edi
> - /* edi: flagmask */
> -sysret_check:
> + testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
> + jnz int_ret_from_sys_call_fixup /* Go the the slow path */
> +
> LOCKDEP_SYS_EXIT
> DISABLE_INTERRUPTS(CLBR_NONE)
> TRACE_IRQS_OFF
> - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
> - andl %edi,%edx
> - jnz sysret_careful
> CFI_REMEMBER_STATE
> /*
> * sysretq will re-enable interrupts:
> @@ -449,49 +446,10 @@ sysret_check:
> USERGS_SYSRET64
>
> CFI_RESTORE_STATE
> - /* Handle reschedules */
> - /* edx: work, edi: workmask */
> -sysret_careful:
> - bt $TIF_NEED_RESCHED,%edx
> - jnc sysret_signal
> - TRACE_IRQS_ON
> - ENABLE_INTERRUPTS(CLBR_NONE)
> - pushq_cfi %rdi
> - SCHEDULE_USER
> - popq_cfi %rdi
> - jmp sysret_check
>
> - /* Handle a signal */
> -sysret_signal:
> - TRACE_IRQS_ON
> - ENABLE_INTERRUPTS(CLBR_NONE)
> -#ifdef CONFIG_AUDITSYSCALL
> - bt $TIF_SYSCALL_AUDIT,%edx
> - jc sysret_audit
> -#endif
> - /*
> - * We have a signal, or exit tracing or single-step.
> - * These all wind up with the iret return path anyway,
> - * so just join that path right now.
> - */
> +int_ret_from_sys_call_fixup:
> FIXUP_TOP_OF_STACK %r11, -ARGOFFSET
> - jmp int_check_syscall_exit_work
> -
> -#ifdef CONFIG_AUDITSYSCALL
> - /*
> - * Return fast path for syscall audit. Call __audit_syscall_exit()
> - * directly and then jump back to the fast path with TIF_SYSCALL_AUDIT
> - * masked off.
> - */
> -sysret_audit:
> - movq RAX-ARGOFFSET(%rsp),%rsi /* second arg, syscall return value */
> - cmpq $-MAX_ERRNO,%rsi /* is it < -MAX_ERRNO? */
> - setbe %al /* 1 if so, 0 if not */
> - movzbl %al,%edi /* zero-extend that into %edi */
> - call __audit_syscall_exit
> - movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
> - jmp sysret_check
> -#endif /* CONFIG_AUDITSYSCALL */
> + jmp int_ret_from_sys_call
Ok, dumb question: what is replacing that audit functionality now?
Or are we remaining with the single path down syscall_trace_leave()?
AFAICT, the intention is to direct everything to int_ret_from_sys_call
after the syscall has been done so that paths can get simplified. Which
is a good thing, AFAICT.
Acked-by: Borislav Petkov <bp@suse.de>
--
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--
next prev parent reply other threads:[~2015-01-09 15:53 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-07 23:58 [PATCH 0/3] x86_64,entry: Rearrange the syscall exit optimizations Andy Lutomirski
2014-11-07 23:58 ` [PATCH 1/3] x86_64,entry: Fix RCX for traced syscalls Andy Lutomirski
2015-01-05 12:59 ` Borislav Petkov
2015-01-05 20:31 ` Andy Lutomirski
2015-01-06 15:34 ` Borislav Petkov
2015-01-06 18:43 ` Andy Lutomirski
2015-01-06 19:00 ` Borislav Petkov
2015-01-07 15:55 ` Borislav Petkov
2014-11-07 23:58 ` [PATCH 2/3] x86_64,entry: Use sysret to return to userspace when possible Andy Lutomirski
2015-01-08 12:29 ` Borislav Petkov
2015-01-08 13:57 ` Borislav Petkov
2015-01-10 21:05 ` Andy Lutomirski
2015-01-09 10:40 ` Borislav Petkov
2014-11-07 23:58 ` [PATCH 3/3] x86_64,entry: Remove the syscall exit audit and schedule optimizations Andy Lutomirski
2015-01-09 15:53 ` Borislav Petkov [this message]
2015-01-09 16:08 ` Andy Lutomirski
2014-12-04 1:42 ` [PATCH 0/3] x86_64,entry: Rearrange the syscall exit optimizations Andy Lutomirski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150109155334.GE13637@pd.tnic \
--to=bp@alien8.de \
--cc=fweisbec@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=oleg@redhat.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).