From: Peter Zijlstra <peterz@infradead.org>
To: Kirill Tkhai <ktkhai@parallels.com>
Cc: linux-kernel@vger.kernel.org,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
luto@amacapital.net
Subject: Re: [RFC] sched, x86: Prevent resched interrupts if task in kernel mode and !CONFIG_PREEMPT
Date: Fri, 23 Jan 2015 17:07:46 +0100 [thread overview]
Message-ID: <20150123160746.GD23123@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1422028412.6345.6.camel@tkhai>
On Fri, Jan 23, 2015 at 06:53:32PM +0300, Kirill Tkhai wrote:
> It's useless to send reschedule interrupts in such situations. The earliest
> point, where schedule() call is possible, is sysret_careful(). But in that
> function we directly test TIF_NEED_RESCHED.
>
> So it's possible to get rid of that type of interrupts.
>
> How about this idea? Is set_bit() cheap on x86 machines?
So you set TIF_POLLING_NRFLAG on syscall entry and clear it again on
exit? Thereby we avoid the IPI, because the exit path already checks for
TIF_NEED_RESCHED.
Should work I suppose, but I'm not too familiar with all that entry.S
muck. Andy might know and appreciate this.
> ---
> arch/x86/kernel/entry_64.S | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
> index c653dc4..a046ba8 100644
> --- a/arch/x86/kernel/entry_64.S
> +++ b/arch/x86/kernel/entry_64.S
> @@ -409,6 +409,13 @@ GLOBAL(system_call_after_swapgs)
> movq_cfi rax,(ORIG_RAX-ARGOFFSET)
> movq %rcx,RIP-ARGOFFSET(%rsp)
> CFI_REL_OFFSET rip,RIP-ARGOFFSET
> +#if !defined(CONFIG_PREEMPT) || !defined(SMP)
> + /*
> + * Tell resched_curr() do not send useless interrupts to us.
> + * Kernel isn't preemptible till sysret_careful() anyway.
> + */
> + LOCK ; bts $TIF_POLLING_NRFLAG,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
> +#endif
> testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
> jnz tracesys
> system_call_fastpath:
> @@ -427,6 +434,9 @@ GLOBAL(system_call_after_swapgs)
> * Has incomplete stack frame and undefined top of stack.
> */
> ret_from_sys_call:
> +#if !defined(CONFIG_PREEMPT) || !defined(SMP)
> + LOCK ; btr $TIF_POLLING_NRFLAG,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
> +#endif
> movl $_TIF_ALLWORK_MASK,%edi
> /* edi: flagmask */
> sysret_check:
>
>
>
next prev parent reply other threads:[~2015-01-23 16:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-23 15:53 [RFC] sched, x86: Prevent resched interrupts if task in kernel mode and !CONFIG_PREEMPT Kirill Tkhai
2015-01-23 16:07 ` Peter Zijlstra [this message]
2015-01-23 16:24 ` Andy Lutomirski
2015-01-23 17:09 ` Kirill Tkhai
2015-01-24 2:36 ` Andy Lutomirski
2015-01-26 11:58 ` Kirill Tkhai
2015-02-03 17:14 ` Kirill Tkhai
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=20150123160746.GD23123@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=hpa@zytor.com \
--cc=ktkhai@parallels.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
/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