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


Groups > linux.kernel > #1731221 > unrolled thread

Re: [RFC 17/17] x86/traps: Use a new on_thread_stack() helper to clean up an assertion

Started byJosh Poimboeuf <jpoimboe@redhat.com>
First post2017-09-12 22:20 +0200
Last post2017-09-12 22:30 +0200
Articles 2 — 2 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: [RFC 17/17] x86/traps: Use a new on_thread_stack() helper to  clean up an assertion Josh Poimboeuf <jpoimboe@redhat.com> - 2017-09-12 22:20 +0200
    Re: [RFC 17/17] x86/traps: Use a new on_thread_stack() helper to  clean up an assertion Andrew Cooper <andrew.cooper3@citrix.com> - 2017-09-12 22:30 +0200

#1731221 — Re: [RFC 17/17] x86/traps: Use a new on_thread_stack() helper to clean up an assertion

FromJosh Poimboeuf <jpoimboe@redhat.com>
Date2017-09-12 22:20 +0200
SubjectRe: [RFC 17/17] x86/traps: Use a new on_thread_stack() helper to clean up an assertion
Message-ID<uoZP5-5Ys-31@gated-at.bofh.it>
On Wed, Sep 06, 2017 at 02:37:02PM -0700, Andy Lutomirski wrote:
> Signed-off-by: Andy Lutomirski <luto@kernel.org>
> ---
>  arch/x86/include/asm/processor.h   | 17 +++++++++++++++++
>  arch/x86/include/asm/thread_info.h | 11 -----------
>  arch/x86/kernel/traps.c            |  3 +--
>  3 files changed, 18 insertions(+), 13 deletions(-)
> 
> diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
> index 4c137472f530..b6f8dc11c222 100644
> --- a/arch/x86/include/asm/processor.h
> +++ b/arch/x86/include/asm/processor.h
> @@ -534,6 +534,23 @@ static inline unsigned long current_top_of_stack(void)
>  #endif
>  }
>  
> +static inline unsigned long current_stack_pointer(void)
> +{
> +	unsigned long sp;
> +#ifdef CONFIG_X86_64
> +	asm("mov %%rsp,%0" : "=g" (sp));
> +#else
> +	asm("mov %%esp,%0" : "=g" (sp));
> +#endif
> +	return sp;
> +}

I know you're just moving the function, but this function could also be
cleaned up by using _ASM_SP and getting rid of the ifdef.

-- 
Josh

[toc] | [next] | [standalone]


#1731223

FromAndrew Cooper <andrew.cooper3@citrix.com>
Date2017-09-12 22:30 +0200
Message-ID<uoZYK-633-9@gated-at.bofh.it>
In reply to#1731221
On 12/09/2017 21:11, Josh Poimboeuf wrote:
> On Wed, Sep 06, 2017 at 02:37:02PM -0700, Andy Lutomirski wrote:
>> Signed-off-by: Andy Lutomirski <luto@kernel.org>
>> ---
>>  arch/x86/include/asm/processor.h   | 17 +++++++++++++++++
>>  arch/x86/include/asm/thread_info.h | 11 -----------
>>  arch/x86/kernel/traps.c            |  3 +--
>>  3 files changed, 18 insertions(+), 13 deletions(-)
>>
>> diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
>> index 4c137472f530..b6f8dc11c222 100644
>> --- a/arch/x86/include/asm/processor.h
>> +++ b/arch/x86/include/asm/processor.h
>> @@ -534,6 +534,23 @@ static inline unsigned long current_top_of_stack(void)
>>  #endif
>>  }
>>  
>> +static inline unsigned long current_stack_pointer(void)
>> +{
>> +	unsigned long sp;
>> +#ifdef CONFIG_X86_64
>> +	asm("mov %%rsp,%0" : "=g" (sp));
>> +#else
>> +	asm("mov %%esp,%0" : "=g" (sp));
>> +#endif
>> +	return sp;
>> +}
> I know you're just moving the function, but this function could also be
> cleaned up by using _ASM_SP and getting rid of the ifdef.
>

For GCC, there is a rather more efficient way of doing this, which
allows the compiler much more flexibility than forcing the use of a mov
instruction.

http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=xen/include/asm-x86/current.h;h=89849929ebf98e9ba04659f59b5521982a718b2d;hb=HEAD#l47

I don't know how much you care in Linux, but in Xen it makes a massive
code-volume difference, as that construct is the core of current
(because we can't use %fs/%gs).

~Andrew

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web