From: Ingo Molnar <mingo@kernel.org>
To: Richard Henderson <rth@twiddle.net>
Cc: linux-kernel@vger.kernel.org, x86@kernel.org,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@linutronix.de>,
Andy Lutomirski <luto@kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] x86: Use named address spaces in asm/percpu.h
Date: Wed, 3 Feb 2016 08:38:10 +0100 [thread overview]
Message-ID: <20160203073809.GA32476@gmail.com> (raw)
In-Reply-To: <1454483253-11246-1-git-send-email-rth@twiddle.net>
* Richard Henderson <rth@twiddle.net> wrote:
> GCC 6 adds support for __seg_fs and __seg_gs as named address spaces,
> producing the obvious segment overrides for objects so marked.
>
> Exposing the memory reference allows slightly better code generation
> in some cases (and in others, merely affects the scheduling). E.g.:
>
> [1]
> - mov %gs:0x0(%rip),%eax
> - R_X86_64_PC32 context_tracking+0x4
> - cmp $0x1,%eax
> + cmpl $0x1,%gs:0x0(%rip)
> + R_X86_64_PC32 context_tracking+0x3
>
> [2]
> - mov %gs:0x0(%rip),%ebx
> - R_X86_64_PC32 cpu_number-0x4
> - movslq %ebx,%rax
> + movslq %gs:0x0(%rip),%rax
> + R_X86_64_PC32 cpu_number-0x4
>
> [3]
> - mov %gs:0x0(%rip),%rdx
> - R_X86_64_PC32 cpu_info+0x20
> - test $0x1000000,%edx
> + testb $0x1,%gs:0x0(%rip)
> + R_X86_64_PC32 cpu_info+0x22
>
> [4]
> - mov $0x0,%rax
> - R_X86_64_32S __uv_hub_info
> - mov %rax,%rcx
> - add %gs:0x0(%rip),%rcx
> - R_X86_64_PC32 this_cpu_off-0x4
> - movzbl 0x15(%rcx),%ecx
> ...
> - mov %rax,%rdx
> - add %gs:0x0(%rip),%rdx
> - R_X86_64_PC32 this_cpu_off-0x4
> - or (%rdx),%rcx
> + mov %gs:0x0(%rip),%r9
> + R_X86_64_PC32 this_cpu_off-0x4
> + mov $0x0,%rax
> + R_X86_64_32S __uv_hub_info
> ...
> + movzbl 0x15(%rax,%r9,1),%ecx
> ...
> + or (%rax,%r9,1),%rdx
>
> The final vmlinux text size is reduced by about 5k for a standard
> Fedora configure.
Very nice!
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Signed-off-by: Richard Henderson <rth@twiddle.net>
> ---
> arch/x86/include/asm/percpu.h | 145 +++++++++++++++++++++++++-----------------
> 1 file changed, 86 insertions(+), 59 deletions(-)
I have a small request: since this depends on a very new compiler feature, and to
make this easier to revert (even just for testing), could you split it into two
patches: the first patch introduces the __percpu_addrspace machinery, the second
one activates it by defining it?
The second patch will be easy to bisect to and will be easy to revert even many
releases down the road, as GCC6 is tested more widely. We could also add a CONFIG_
switch for this - but that might be overkill.
> +#ifdef __percpu_addrspace
> +/* Produce an address-space lvalue for VAR. */
> +#define __percpu_as(VAR) \
> + (*(typeof(VAR) __kernel __force __percpu_addrspace *)(uintptr_t)&(VAR))
> +
> +/* We cannot allow __my_cpu_offset to recurse through this_cpu_read, as
> + this will change based on CONFIG_X86_64, with which games are played
> + in 32-bit compatibility files. */
Small nit: please use the customary (multi-line) comment style:
/*
* Comment .....
* ...... goes here.
*/
Thanks,
Ingo
prev parent reply other threads:[~2016-02-03 7:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-03 7:07 [PATCH] x86: Use named address spaces in asm/percpu.h Richard Henderson
2016-02-03 7:38 ` Ingo Molnar [this message]
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=20160203073809.GA32476@gmail.com \
--to=mingo@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=rth@twiddle.net \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--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).