lkml.org 
[lkml]   [2009]   [Apr]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [GIT RFC] percpu: use dynamic percpu allocator as the default percpu allocator
On Wed, Apr 08, 2009 at 01:18:23PM -0700, Tejun Heo wrote:
> > #define DEFINE_PER_CPU_SECTION(type, name, section) \
> > __attribute__((__section__(".garbage"), __unused__)) \
> > char __dummy__##name; \
> > __attribute__((__section__(PER_CPU_BASE_SECTION section))) \
> > __weak __typeof__(type) per_cpu__##name
>
> Nice. I think .discard would suit better for the dummy variable tho
> (x86 discards the section and it seems to be more common name with
> ldscript using /DISCARD/ identifier for things to throw away). Also,

Indeed, .discard sounds better.

> it seems like if two different files happen to use static percpu
> variables with the same name, they would end up sharing it, right?
> That looks a tad bit dangerous.

True. One of possible solutions is to add another dummy variable,
like this:

#define DEFINE_PER_CPU_SECTION(type, name, section) \
__attribute__((__section__(".discard"), __unused__)) \
char __dummy__##name; \
+ __attribute__((__section__(".discard"))) \
+ char __per_cpu_multiple_def__##name; \
__attribute__((__section__(PER_CPU_BASE_SECTION section))) \
__weak __typeof__(type) per_cpu__##name

so in that situation we'll get a link failure.

Ivan.


\
 
 \ /
  Last update: 2009-04-09 11:55    [W:0.158 / U:0.140 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site