initialization of static per-cpu variables

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Linux Kernel Mailing List <linux-kernel@...>
Cc: Rusty Russel <rusty@...>
Date: Wednesday, May 21, 2008 - 2:28 pm

Hi,

I encountered this comment in kernel/softirq.c:

/* Some compilers disobey section attribute on statics when not
   initialized -- RR */
static DEFINE_PER_CPU(struct tasklet_head, tasklet_vec) = { NULL };
static DEFINE_PER_CPU(struct tasklet_head, tasklet_hi_vec) = { NULL };

So I assume it's the combination of static and whatever section
DFINE_PER_CPU puts the variable in which is the problem.

However, there's a LOT of these "static DEFINE_PER_CPU" without any
initializer in the rest of the code, e.g.:

$ g 'static DEFINE_PER_CPU' kernel/sched.c
static DEFINE_PER_CPU(struct sched_entity, init_sched_entity);
static DEFINE_PER_CPU(struct cfs_rq, init_cfs_rq) ____cacheline_aligned_in_smp;
static DEFINE_PER_CPU(struct sched_rt_entity, init_sched_rt_entity);
static DEFINE_PER_CPU(struct rt_rq, init_rt_rq) ____cacheline_aligned_in_smp;
static DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues);
static DEFINE_PER_CPU(unsigned long long, time_offset);
static DEFINE_PER_CPU(unsigned long long, prev_cpu_time);
static DEFINE_PER_CPU(spinlock_t, aggregate_lock);
static DEFINE_PER_CPU(struct sched_domain, cpu_domains);
static DEFINE_PER_CPU(struct sched_group, sched_group_cpus);
static DEFINE_PER_CPU(struct sched_domain, core_domains);
static DEFINE_PER_CPU(struct sched_group, sched_group_core);
static DEFINE_PER_CPU(struct sched_domain, phys_domains);
static DEFINE_PER_CPU(struct sched_group, sched_group_phys);
static DEFINE_PER_CPU(struct sched_domain, node_domains);
static DEFINE_PER_CPU(struct sched_domain, allnodes_domains);
static DEFINE_PER_CPU(struct sched_group, sched_group_allnodes);

The comment seems to be ancient and I don't know who wrote it, so I'm
making a guess that it's Rusty Russel (Cced).

So which do we do, delete the comment (on the grounds that it is
invalid) or fix these other declarations (there's a lot of them)?

Vegard

-- 
"The animistic metaphor of the bug that maliciously sneaked in while
the programmer was not looking is intellectually dishonest as it
disguises that the error is the programmer's own creation."
	-- E. W. Dijkstra, EWD1036
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
initialization of static per-cpu variables, Vegard Nossum, (Wed May 21, 2:28 pm)
Re: initialization of static per-cpu variables, Rusty Russell, (Thu May 22, 4:20 am)
Re: initialization of static per-cpu variables, Adrian Bunk, (Fri May 23, 10:29 am)
Re: initialization of static per-cpu variables, Rusty Russell, (Sun May 25, 6:35 am)
Re: initialization of static per-cpu variables, Adrian Bunk, (Mon Jun 2, 3:59 am)
Re: initialization of static per-cpu variables, Rusty Russell, (Mon Jun 2, 7:11 pm)
Re: initialization of static per-cpu variables, Vegard Nossum, (Fri May 23, 10:43 am)
Re: initialization of static per-cpu variables, David Miller, (Thu May 22, 12:12 pm)