Skip to contentSkip to conversation

per_cpu data question

DISCUSSION Rusty Russell 1 participant 1 message Aug 30, 2002 1 message not in the archive Per-CPU memory allocator

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

In message <[email protected]> you write:

Quoted 8 lines

Hi Rusty,

I can't do this -

        struct rcu_data *rdata;
        rdata = &get_cpu_var(rcu_data);

Has this been deliberately made illegal ?

No, I suck. Lvalues continue to haunt me. This works for me.

BTW, I prefer to have bug reports cc'd to linux-kernel, so the results are archived. Plus, public humiliation is good for the soul.

include/linux/percpu.h +2 -1
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.32/include/linux/percpu.h working-2.5.32-percpu/include/linux/percpu.h
@@ -3,7 +3,8 @@
 #include <linux/spinlock.h> /* For preempt_disable() */
 #include <asm/percpu.h>
 
-#define get_cpu_var(var) ({ preempt_disable(); __get_cpu_var(var); })
+/* Must be an lvalue. */
+#define get_cpu_var(var) (*({ preempt_disable(); &__get_cpu_var(var); }))
 #define put_cpu_var(var) preempt_enable()
 
 #endif /* __LINUX_PERCPU_H */

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