Skip to contentSkip to conversation

per-cpu data...

DISCUSSION Rusty Russell 3 participants 4 messages Jul 12, 2002 – Jul 25, 2002

lore
Share & tools
lore
#0 lore raw

IIUC, __per_cpu_data is insufficient for Alpha as stands, to use thread-specific gcc tricks (__thread prepended to the decl, even though they had a perfectly good __attribute__ extension already).

So, I guess we're stuck with something like:

DECLARE_PER_CPU(int x);

If we're going to do this, we can also mangle the name as well to avoid accidental "direct" accesses:

eg:

	#define DECLARE_PER_CPU(var) 
		var##__percpu __attribute__((section(".percpu")))

	/* If not SMP: */
	#define per_cpu(var) var##__percpu

(From my reading, ## on "int x" and "__per_cpu" is well-defined).

Thoughts?
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

#1 lore raw
Quoted 2 lines · Rusty Russell

(__thread prepended to the decl, even
though they had a perfectly good __attribute__ extension already).

Sorry, not our extension. I just copied it.

Quoted 1 line

(From my reading, ## on "int x" and "__per_cpu" is well-defined).

Yep.

Quoted 1 line

Thoughts?

Seems ok, though you really ought to differentiate between DECLARE and DEFINE. Otherwise I can see getting screwed again.

r~

#2 lore raw
In reply to Rusty Russell
Quoted 1 line · Rusty Russell

(From my reading, ## on "int x" and "__per_cpu" is well-defined).

  DECLARE_PER_CPU (int x[3]);

doesn't work, although you can always do

  typedef int three_ints_t[3];
  DECLARE_PER_CPU (three_ints_t x);

I encountered the same thing while doing a user-space `MAKE_THREAD_SPECIFIC' macro. The solution I went for looks like this:

  #define DECLARE_PER_CPU(type, name) \
    __attribute__ ((__section (".percpu"))) __typeof__ (type) name##__per_cpu

enjoy,
-- Jamie

#3 lore raw

In message <[email protected]> you write:

Quoted 7 lines
Quoted 1 line · Rusty Russell

(From my reading, ## on "int x" and "__per_cpu" is well-defined).

  DECLARE_PER_CPU (int x[3]);

doesn't work, although you can always do

Quoted 8 lines
  typedef int three_ints_t[3];
  DECLARE_PER_CPU (three_ints_t x);

I encountered the same thing while doing a user-space `MAKE_THREAD_SPECIFIC' macro. The solution I went for looks like this:

  #define DECLARE_PER_CPU(type, name) \
    __attribute__ ((__section (".percpu"))) __typeof__ (type) name##__per_cpu

Hmmm.... Yeah, might as well go the whole way.

Thanks!
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.