All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: "Roger Pau Monné" <roger.pau@citrix.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>, Wei Liu <wl@xen.org>,
	Julien Grall <julien.grall@arm.com>,
	Jan Beulich <JBeulich@suse.com>,
	Xen-devel <xen-devel@lists.xenproject.org>,
	Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Subject: Re: [Xen-devel] [PATCH v2 1/2] xen/link: Introduce .bss.percpu.page_aligned
Date: Mon, 29 Jul 2019 10:01:21 +0100	[thread overview]
Message-ID: <bbf67dc5-598d-c816-523f-d848e62840f3@citrix.com> (raw)
In-Reply-To: <20190729085233.x3lees5rcycj7xko@Air-de-Roger>

On 29/07/2019 09:52, Roger Pau Monné wrote:
> On Fri, Jul 26, 2019 at 09:32:21PM +0100, Andrew Cooper wrote:
>> Future changes are going to need to page align some percpu data.
>>
>> This means that the percpu area needs suitably aligning in the BSS so CPU0 has
>> correctly aligned data.  Shuffle the exact link order of items within the BSS
>> to give .bss.percpu.page_aligned appropriate alignment.
>>
>> In addition, we need to be able to specify an alignment attribute to
>> __DEFINE_PER_CPU().  Rework it so the caller passes in all attributes, and
>> adjust DEFINE_PER_CPU{,_READ_MOSTLY}() to match.  This has the added bonus
>> that it is now possible to grep for .bss.percpu and find all the users.
>>
>> Finally, introduce DEFINE_PER_CPU_PAGE_ALIGNED() which uses both section and
>> alignment attributes.
>>
>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
>
>> diff --git a/xen/include/asm-x86/percpu.h b/xen/include/asm-x86/percpu.h
>> index ff34dc7897..5b6cef04c4 100644
>> --- a/xen/include/asm-x86/percpu.h
>> +++ b/xen/include/asm-x86/percpu.h
>> @@ -7,10 +7,8 @@ extern unsigned long __per_cpu_offset[NR_CPUS];
>>  void percpu_init_areas(void);
>>  #endif
>>  
>> -/* Separate out the type, so (int[3], foo) works. */
>> -#define __DEFINE_PER_CPU(type, name, suffix)                    \
>> -    __section(".bss.percpu" #suffix)                            \
>> -    __typeof__(type) per_cpu_##name
>> +#define __DEFINE_PER_CPU(attr, type, name) \
>> +    attr __typeof__(type) per_cpu_ ## name
>>  
>>  /* var is in discarded region: offset to particular copy we want */
>>  #define per_cpu(var, cpu)  \
>> diff --git a/xen/include/xen/percpu.h b/xen/include/xen/percpu.h
>> index aeec5c19d6..71a31cc361 100644
>> --- a/xen/include/xen/percpu.h
>> +++ b/xen/include/xen/percpu.h
>> @@ -9,9 +9,15 @@
>>   * The _##name concatenation is being used here to prevent 'name' from getting
>>   * macro expanded, while still allowing a per-architecture symbol name prefix.
>>   */
>> -#define DEFINE_PER_CPU(type, name) __DEFINE_PER_CPU(type, _##name, )
>> +#define DEFINE_PER_CPU(type, name) \
>> +    __DEFINE_PER_CPU(__section(".bss.percpu"), type, _ ## name)
>> +
>> +#define DEFINE_PER_CPU_PAGE_ALIGNED(type, name) \
>> +    __DEFINE_PER_CPU(__section(".bss.percpu.page_aligned") \
>> +                     __aligned(PAGE_SIZE), type, _ ## name)
>> +
>>  #define DEFINE_PER_CPU_READ_MOSTLY(type, name) \
>> -	__DEFINE_PER_CPU(type, _##name, .read_mostly)
>> +    __DEFINE_PER_CPU(__section(".bss.percpu.read_mostly"), type, _ ## name)
> AFAICT also adding a '_' here will result in variable names with
> per_cpu__foo, which is inline with the previous behaviour, but I'm not
> sure of the point of the double underscore.

Its double, to avoid token expansion.  See the comment in context at the
top of this hunk.

Without it, the schedulers don't compile because cpumask_scratch is both
the name of a percpu variable, and an alias to
&this_cpu(cpumask_scratch).  Omitting the token concatenation here
causes &this_cpu() to be expanded into __DEFINE_PER_CPU().

~Andrew

P.S. Guess who tried to remove this piece of "fun" to begin with...

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2019-07-29  9:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-26 20:32 [Xen-devel] [PATCH v2 0/2] x86/xpti: Don't leak TSS-adjacent percpu data via Meltdown Andrew Cooper
2019-07-26 20:32 ` [Xen-devel] [PATCH v2 1/2] xen/link: Introduce .bss.percpu.page_aligned Andrew Cooper
2019-07-26 21:39   ` Julien Grall
2019-07-29  8:52   ` Roger Pau Monné
2019-07-29  9:01     ` Andrew Cooper [this message]
2019-07-29 13:17   ` Jan Beulich
2019-07-29 15:01     ` Andrew Cooper
2019-07-26 20:32 ` [Xen-devel] [PATCH v2 2/2] x86/xpti: Don't leak TSS-adjacent percpu data via Meltdown Andrew Cooper
2019-07-29  8:53   ` Roger Pau Monné
2019-07-29 13:51   ` Jan Beulich
2019-07-29 15:55     ` Andrew Cooper
2019-07-29 16:02       ` Andrew Cooper
2019-07-29 16:07       ` Jan Beulich

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=bbf67dc5-598d-c816-523f-d848e62840f3@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=julien.grall@arm.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.