Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1205460 > unrolled thread

Re: [tip:x86/asm] x86/asm/entry/64: Migrate error and IRQ exit work to C and remove old assembly code

Started byFrederic Weisbecker <fweisbec@gmail.com>
First post2015-08-12 00:20 +0200
Last post2015-08-12 15:20 +0200
Articles 6 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [tip:x86/asm] x86/asm/entry/64: Migrate error and IRQ exit work  to C and remove old assembly code Frederic Weisbecker <fweisbec@gmail.com> - 2015-08-12 00:20 +0200
    Re: [tip:x86/asm] x86/asm/entry/64: Migrate error and IRQ exit work  to C and remove old assembly code Andy Lutomirski <luto@amacapital.net> - 2015-08-12 00:30 +0200
      Re: [tip:x86/asm] x86/asm/entry/64: Migrate error and IRQ exit work  to C and remove old assembly code Frederic Weisbecker <fweisbec@gmail.com> - 2015-08-12 00:50 +0200
        Re: [tip:x86/asm] x86/asm/entry/64: Migrate error and IRQ exit work  to C and remove old assembly code Andy Lutomirski <luto@amacapital.net> - 2015-08-12 01:10 +0200
          Re: [tip:x86/asm] x86/asm/entry/64: Migrate error and IRQ exit work  to C and remove old assembly code "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> - 2015-08-12 03:10 +0200
          Re: [tip:x86/asm] x86/asm/entry/64: Migrate error and IRQ exit work  to C and remove old assembly code Frederic Weisbecker <fweisbec@gmail.com> - 2015-08-12 15:20 +0200

#1205460 — Re: [tip:x86/asm] x86/asm/entry/64: Migrate error and IRQ exit work to C and remove old assembly code

FromFrederic Weisbecker <fweisbec@gmail.com>
Date2015-08-12 00:20 +0200
SubjectRe: [tip:x86/asm] x86/asm/entry/64: Migrate error and IRQ exit work to C and remove old assembly code
Message-ID<pWq3M-1AD-9@gated-at.bofh.it>
On Tue, Jul 07, 2015 at 03:53:29AM -0700, tip-bot for Andy Lutomirski wrote:
> Commit-ID:  02bc7768fe447ae305e924b931fa629073a4a1b9
> Gitweb:     http://git.kernel.org/tip/02bc7768fe447ae305e924b931fa629073a4a1b9
> Author:     Andy Lutomirski <luto@kernel.org>
> AuthorDate: Fri, 3 Jul 2015 12:44:31 -0700
> Committer:  Ingo Molnar <mingo@kernel.org>
> CommitDate: Tue, 7 Jul 2015 10:59:08 +0200
> 
> x86/asm/entry/64: Migrate error and IRQ exit work to C and remove old assembly code
> 
> Signed-off-by: Andy Lutomirski <luto@kernel.org>
> Cc: Andy Lutomirski <luto@amacapital.net>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Brian Gerst <brgerst@gmail.com>
> Cc: Denys Vlasenko <dvlasenk@redhat.com>
> Cc: Denys Vlasenko <vda.linux@googlemail.com>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: H. Peter Anvin <hpa@zytor.com>
> Cc: Kees Cook <keescook@chromium.org>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: Oleg Nesterov <oleg@redhat.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Rik van Riel <riel@redhat.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: paulmck@linux.vnet.ibm.com
> Link: http://lkml.kernel.org/r/60e90901eee611e59e958bfdbbe39969b4f88fe5.1435952415.git.luto@kernel.org
> Signed-off-by: Ingo Molnar <mingo@kernel.org>
> ---
>  arch/x86/entry/entry_64.S        | 64 +++++++++++-----------------------------
>  arch/x86/entry/entry_64_compat.S |  5 ++++
>  2 files changed, 23 insertions(+), 46 deletions(-)
> 
> diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
> index 83eb63d..168ee26 100644
> --- a/arch/x86/entry/entry_64.S
> +++ b/arch/x86/entry/entry_64.S
> @@ -508,7 +508,16 @@ END(irq_entries_start)
>  
>  	testb	$3, CS(%rsp)
>  	jz	1f
> +
> +	/*
> +	 * IRQ from user mode.  Switch to kernel gsbase and inform context
> +	 * tracking that we're in kernel mode.
> +	 */
>  	SWAPGS
> +#ifdef CONFIG_CONTEXT_TRACKING
> +	call enter_from_user_mode
> +#endif

There have been a lot of patches going there lately so I couldn't follow
everything and since you just started a discussion on context tracking, I
just had a look on the latest change.

So it seems we're now calling user_exit() on IRQ entry. This is not something
we want. We already have everything we need with rcu_irq_enter() and
vtime_account_irq_enter(). user_exit() brings a lot of overhead here that we
don't need. Plus this is called unconditionally since CONFIG_CONTEXT_TRACKING=y
on most distros now.

We really want the context tracking code to be called on syscall slow path only
(and exceptions with static keys but an exception slow path would be desired as well).
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1205463

FromAndy Lutomirski <luto@amacapital.net>
Date2015-08-12 00:30 +0200
Message-ID<pWqds-1LO-3@gated-at.bofh.it>
In reply to#1205460
On Tue, Aug 11, 2015 at 3:18 PM, Frederic Weisbecker <fweisbec@gmail.com> wrote:
> On Tue, Jul 07, 2015 at 03:53:29AM -0700, tip-bot for Andy Lutomirski wrote:
>> Commit-ID:  02bc7768fe447ae305e924b931fa629073a4a1b9
>> Gitweb:     http://git.kernel.org/tip/02bc7768fe447ae305e924b931fa629073a4a1b9
>> Author:     Andy Lutomirski <luto@kernel.org>
>> AuthorDate: Fri, 3 Jul 2015 12:44:31 -0700
>> Committer:  Ingo Molnar <mingo@kernel.org>
>> CommitDate: Tue, 7 Jul 2015 10:59:08 +0200
>>
>> x86/asm/entry/64: Migrate error and IRQ exit work to C and remove old assembly code
>>
>> Signed-off-by: Andy Lutomirski <luto@kernel.org>
>> Cc: Andy Lutomirski <luto@amacapital.net>
>> Cc: Borislav Petkov <bp@alien8.de>
>> Cc: Brian Gerst <brgerst@gmail.com>
>> Cc: Denys Vlasenko <dvlasenk@redhat.com>
>> Cc: Denys Vlasenko <vda.linux@googlemail.com>
>> Cc: Frederic Weisbecker <fweisbec@gmail.com>
>> Cc: H. Peter Anvin <hpa@zytor.com>
>> Cc: Kees Cook <keescook@chromium.org>
>> Cc: Linus Torvalds <torvalds@linux-foundation.org>
>> Cc: Oleg Nesterov <oleg@redhat.com>
>> Cc: Peter Zijlstra <peterz@infradead.org>
>> Cc: Rik van Riel <riel@redhat.com>
>> Cc: Thomas Gleixner <tglx@linutronix.de>
>> Cc: paulmck@linux.vnet.ibm.com
>> Link: http://lkml.kernel.org/r/60e90901eee611e59e958bfdbbe39969b4f88fe5.1435952415.git.luto@kernel.org
>> Signed-off-by: Ingo Molnar <mingo@kernel.org>
>> ---
>>  arch/x86/entry/entry_64.S        | 64 +++++++++++-----------------------------
>>  arch/x86/entry/entry_64_compat.S |  5 ++++
>>  2 files changed, 23 insertions(+), 46 deletions(-)
>>
>> diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
>> index 83eb63d..168ee26 100644
>> --- a/arch/x86/entry/entry_64.S
>> +++ b/arch/x86/entry/entry_64.S
>> @@ -508,7 +508,16 @@ END(irq_entries_start)
>>
>>       testb   $3, CS(%rsp)
>>       jz      1f
>> +
>> +     /*
>> +      * IRQ from user mode.  Switch to kernel gsbase and inform context
>> +      * tracking that we're in kernel mode.
>> +      */
>>       SWAPGS
>> +#ifdef CONFIG_CONTEXT_TRACKING
>> +     call enter_from_user_mode
>> +#endif
>
> There have been a lot of patches going there lately so I couldn't follow
> everything and since you just started a discussion on context tracking, I
> just had a look on the latest change.
>
> So it seems we're now calling user_exit() on IRQ entry. This is not something
> we want. We already have everything we need with rcu_irq_enter() and
> vtime_account_irq_enter(). user_exit() brings a lot of overhead here that we
> don't need. Plus this is called unconditionally since CONFIG_CONTEXT_TRACKING=y
> on most distros now.
>
> We really want the context tracking code to be called on syscall slow path only
> (and exceptions with static keys but an exception slow path would be desired as well).

Can you explain to me what context tracking does that rcu_irq_enter
and vtime_account_irq_enter don't do that's expensive?  Frankly, I'd
rather drop everything except the context tracking callback.

We also need this for the deletion of exception_enter from the trap
entries to be correct.

Like I said in the other thread, there are too many hooks for arch
code to juggle.  Grumble.

--Andy
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1205472

FromFrederic Weisbecker <fweisbec@gmail.com>
Date2015-08-12 00:50 +0200
Message-ID<pWqwN-28O-7@gated-at.bofh.it>
In reply to#1205463
On Tue, Aug 11, 2015 at 03:25:04PM -0700, Andy Lutomirski wrote:
> Can you explain to me what context tracking does that rcu_irq_enter
> and vtime_account_irq_enter don't do that's expensive?  Frankly, I'd
> rather drop everything except the context tracking callback.

Irqs have their own hooks in the generic code. irq_enter() and irq_exit().
And those take care of RCU and time accounting already. So arch code really
doesn't need to care about that.

context tracking exists for the sole purpose of tracking states that don't
have generic hooks. Those are syscalls and exceptions.

Besides, rcu_user_exit() is more costly than rcu_irq_enter() which have been
designed for the very purpose of providing a fast RCU tracking for non sleepable
code (which needs rcu_user_exit()).

> 
> We also need this for the deletion of exception_enter from the trap
> entries to be correct.

I'm not sure we can really delete exception_enter(). See my other email.

> Like I said in the other thread, there are too many hooks for arch
> code to juggle.  Grumble.

Well, archs don't need to care about irq hooks. They only need to track
syscalls and exception.

I've been thinking about pushing down syscalls and exceptions to generic
handlers. It might work for syscalls btw. But many exceptions have only
arch handlers, or significant amount of work is done on the arch level
which might make use of RCU (eg: breakpoint handlers on x86).
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1205494

FromAndy Lutomirski <luto@amacapital.net>
Date2015-08-12 01:10 +0200
Message-ID<pWqQb-2KZ-39@gated-at.bofh.it>
In reply to#1205472
On Tue, Aug 11, 2015 at 3:49 PM, Frederic Weisbecker <fweisbec@gmail.com> wrote:
> On Tue, Aug 11, 2015 at 03:25:04PM -0700, Andy Lutomirski wrote:
>> Can you explain to me what context tracking does that rcu_irq_enter
>> and vtime_account_irq_enter don't do that's expensive?  Frankly, I'd
>> rather drop everything except the context tracking callback.
>
> Irqs have their own hooks in the generic code. irq_enter() and irq_exit().
> And those take care of RCU and time accounting already. So arch code really
> doesn't need to care about that.

I'd love to have irq_enter_from_user and irq_enter_from_kernel instead.

>
> context tracking exists for the sole purpose of tracking states that don't
> have generic hooks. Those are syscalls and exceptions.
>
> Besides, rcu_user_exit() is more costly than rcu_irq_enter() which have been
> designed for the very purpose of providing a fast RCU tracking for non sleepable
> code (which needs rcu_user_exit()).
>

So rcu_user_exit is slower because it's okay to sleep after calling it?

Would it be possible to defer the overhead until we actually try to
sleep rather than doing it on entry?  (I have no idea what's going on
under the hood.)

Anyway, irq_enter_from_user would solve this problem completely.

>
> I've been thinking about pushing down syscalls and exceptions to generic
> handlers. It might work for syscalls btw. But many exceptions have only
> arch handlers, or significant amount of work is done on the arch level
> which might make use of RCU (eg: breakpoint handlers on x86).

I'm trying to port the meat of the x86 syscall code to C.  Maybe the
result will generalize.  The exit code is already in C (in -tip).

--Andy

-- 
Andy Lutomirski
AMA Capital Management, LLC
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1205529

From"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Date2015-08-12 03:10 +0200
Message-ID<pWsIi-5r3-9@gated-at.bofh.it>
In reply to#1205494
On Tue, Aug 11, 2015 at 03:59:37PM -0700, Andy Lutomirski wrote:
> On Tue, Aug 11, 2015 at 3:49 PM, Frederic Weisbecker <fweisbec@gmail.com> wrote:
> > On Tue, Aug 11, 2015 at 03:25:04PM -0700, Andy Lutomirski wrote:
> >> Can you explain to me what context tracking does that rcu_irq_enter
> >> and vtime_account_irq_enter don't do that's expensive?  Frankly, I'd
> >> rather drop everything except the context tracking callback.
> >
> > Irqs have their own hooks in the generic code. irq_enter() and irq_exit().
> > And those take care of RCU and time accounting already. So arch code really
> > doesn't need to care about that.
> 
> I'd love to have irq_enter_from_user and irq_enter_from_kernel instead.

RCU would need to know about irq_enter_from_user(), but could blithely
ignore irq_enter_from_kernel().  Unless irq_enter_from_kernel() is called
from the idle loop, in which case RCU would need to know.  All that aside,
the overhead of rcu_irq_enter() when called from non-idle kernel mode
should be relatively small.  So just telling RCU about all the interrupts
is actually not a bad strategy.

> > context tracking exists for the sole purpose of tracking states that don't
> > have generic hooks. Those are syscalls and exceptions.
> >
> > Besides, rcu_user_exit() is more costly than rcu_irq_enter() which have been
> > designed for the very purpose of providing a fast RCU tracking for non sleepable
> > code (which needs rcu_user_exit()).
> 
> So rcu_user_exit is slower because it's okay to sleep after calling it?
> 
> Would it be possible to defer the overhead until we actually try to
> sleep rather than doing it on entry?  (I have no idea what's going on
> under the hood.)

Nor do I, at least not until someone tells me what .config they are
using.  NO_HZ_FULL, NO_HZ_FULL_SYSIDLE, and RCU_FAST_NO_HZ make a
difference in this case.

> Anyway, irq_enter_from_user would solve this problem completely.
> 
> >
> > I've been thinking about pushing down syscalls and exceptions to generic
> > handlers. It might work for syscalls btw. But many exceptions have only
> > arch handlers, or significant amount of work is done on the arch level
> > which might make use of RCU (eg: breakpoint handlers on x86).
> 
> I'm trying to port the meat of the x86 syscall code to C.  Maybe the
> result will generalize.  The exit code is already in C (in -tip).

That does sound like a good thing!

							Thanx, Paul

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1206072

FromFrederic Weisbecker <fweisbec@gmail.com>
Date2015-08-12 15:20 +0200
Message-ID<pWE6K-5sr-19@gated-at.bofh.it>
In reply to#1205494
On Tue, Aug 11, 2015 at 03:59:37PM -0700, Andy Lutomirski wrote:
> On Tue, Aug 11, 2015 at 3:49 PM, Frederic Weisbecker <fweisbec@gmail.com> wrote:
> > On Tue, Aug 11, 2015 at 03:25:04PM -0700, Andy Lutomirski wrote:
> >> Can you explain to me what context tracking does that rcu_irq_enter
> >> and vtime_account_irq_enter don't do that's expensive?  Frankly, I'd
> >> rather drop everything except the context tracking callback.
> >
> > Irqs have their own hooks in the generic code. irq_enter() and irq_exit().
> > And those take care of RCU and time accounting already. So arch code really
> > doesn't need to care about that.
> 
> I'd love to have irq_enter_from_user and irq_enter_from_kernel instead.

I don't get why we need that. Vtime internals already keeps track of where we
are. Again mixing up hard and soft tracking is asking for troubles.

> 
> >
> > context tracking exists for the sole purpose of tracking states that don't
> > have generic hooks. Those are syscalls and exceptions.
> >
> > Besides, rcu_user_exit() is more costly than rcu_irq_enter() which have been
> > designed for the very purpose of providing a fast RCU tracking for non sleepable
> > code (which needs rcu_user_exit()).
> >
> 
> So rcu_user_exit is slower because it's okay to sleep after calling it?
> 
> Would it be possible to defer the overhead until we actually try to
> sleep rather than doing it on entry?  (I have no idea what's going on
> under the hood.)

That's a question for Paul.

> Anyway, irq_enter_from_user would solve this problem completely.

How?

> >
> > I've been thinking about pushing down syscalls and exceptions to generic
> > handlers. It might work for syscalls btw. But many exceptions have only
> > arch handlers, or significant amount of work is done on the arch level
> > which might make use of RCU (eg: breakpoint handlers on x86).
> 
> I'm trying to port the meat of the x86 syscall code to C.  Maybe the
> result will generalize.  The exit code is already in C (in -tip).

But please don't change such semantics along the way, it really doesn't help
to review the x86 low level changes if it's mixed up with fundamental context
tracking changes.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web