Skip to content

Commit ef017be

Browse files
hdellerjkkm
authored andcommitted
parisc: Replace NR_CPUS in parisc code
parisc: Replace most arrays sized by NR_CPUS with percpu variables. Signed-off-by: Helge Deller <deller@gmx.de> Signed-off-by: Kyle McMartin <kyle@mcmartin.ca>
1 parent 7f2347a commit ef017be

8 files changed

Lines changed: 64 additions & 59 deletions

File tree

‎arch/parisc/include/asm/processor.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <asm/ptrace.h>
1818
#include <asm/types.h>
1919
#include <asm/system.h>
20+
#include <asm/percpu.h>
2021
#endif /* __ASSEMBLY__ */
2122

2223
#define KERNEL_STACK_SIZE (4*PAGE_SIZE)
@@ -109,8 +110,7 @@ struct cpuinfo_parisc {
109110
};
110111

111112
extern struct system_cpuinfo_parisc boot_cpu_data;
112-
extern struct cpuinfo_parisc cpu_data[NR_CPUS];
113-
#define current_cpu_data cpu_data[smp_processor_id()]
113+
DECLARE_PER_CPU(struct cpuinfo_parisc, cpu_data);
114114

115115
#define CPU_HVERSION ((boot_cpu_data.hversion >> 4) & 0x0FFF)
116116

‎arch/parisc/kernel/irq.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ unsigned long txn_affinity_addr(unsigned int irq, int cpu)
298298
irq_desc[irq].affinity = cpumask_of_cpu(cpu);
299299
#endif
300300

301-
return cpu_data[cpu].txn_addr;
301+
return per_cpu(cpu_data, cpu).txn_addr;
302302
}
303303

304304

@@ -309,8 +309,9 @@ unsigned long txn_alloc_addr(unsigned int virt_irq)
309309
next_cpu++; /* assign to "next" CPU we want this bugger on */
310310

311311
/* validate entry */
312-
while ((next_cpu < NR_CPUS) && (!cpu_data[next_cpu].txn_addr ||
313-
!cpu_online(next_cpu)))
312+
while ((next_cpu < NR_CPUS) &&
313+
(!per_cpu(cpu_data, next_cpu).txn_addr ||
314+
!cpu_online(next_cpu)))
314315
next_cpu++;
315316

316317
if (next_cpu >= NR_CPUS)
@@ -359,7 +360,7 @@ void do_cpu_irq_mask(struct pt_regs *regs)
359360
printk(KERN_DEBUG "redirecting irq %d from CPU %d to %d\n",
360361
irq, smp_processor_id(), cpu);
361362
gsc_writel(irq + CPU_IRQ_BASE,
362-
cpu_data[cpu].hpa);
363+
per_cpu(cpu_data, cpu).hpa);
363364
goto set_out;
364365
}
365366
#endif

‎arch/parisc/kernel/perf.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,9 +541,9 @@ static int __init perf_init(void)
541541
spin_lock_init(&perf_lock);
542542

543543
/* TODO: this only lets us access the first cpu.. what to do for SMP? */
544-
cpu_device = cpu_data[0].dev;
544+
cpu_device = per_cpu(cpu_data, 0).dev;
545545
printk("Performance monitoring counters enabled for %s\n",
546-
cpu_data[0].dev->name);
546+
per_cpu(cpu_data, 0).dev->name);
547547

548548
return 0;
549549
}

‎arch/parisc/kernel/processor.c‎

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Initial setup-routines for HP 9000 based hardware.
44
*
55
* Copyright (C) 1991, 1992, 1995 Linus Torvalds
6-
* Modifications for PA-RISC (C) 1999 Helge Deller <deller@gmx.de>
6+
* Modifications for PA-RISC (C) 1999-2008 Helge Deller <deller@gmx.de>
77
* Modifications copyright 1999 SuSE GmbH (Philipp Rumpf)
88
* Modifications copyright 2000 Martin K. Petersen <mkp@mkp.net>
99
* Modifications copyright 2000 Philipp Rumpf <prumpf@tux.org>
@@ -46,7 +46,7 @@
4646
struct system_cpuinfo_parisc boot_cpu_data __read_mostly;
4747
EXPORT_SYMBOL(boot_cpu_data);
4848

49-
struct cpuinfo_parisc cpu_data[NR_CPUS] __read_mostly;
49+
DEFINE_PER_CPU(struct cpuinfo_parisc, cpu_data);
5050

5151
extern int update_cr16_clocksource(void); /* from time.c */
5252

@@ -68,6 +68,23 @@ extern int update_cr16_clocksource(void); /* from time.c */
6868
** The initialization of OS data structures is the same (done below).
6969
*/
7070

71+
/**
72+
* init_cpu_profiler - enable/setup per cpu profiling hooks.
73+
* @cpunum: The processor instance.
74+
*
75+
* FIXME: doesn't do much yet...
76+
*/
77+
static void __cpuinit
78+
init_percpu_prof(unsigned long cpunum)
79+
{
80+
struct cpuinfo_parisc *p;
81+
82+
p = &per_cpu(cpu_data, cpunum);
83+
p->prof_counter = 1;
84+
p->prof_multiplier = 1;
85+
}
86+
87+
7188
/**
7289
* processor_probe - Determine if processor driver should claim this device.
7390
* @dev: The device which has been found.
@@ -147,7 +164,7 @@ static int __cpuinit processor_probe(struct parisc_device *dev)
147164
}
148165
#endif
149166

150-
p = &cpu_data[cpuid];
167+
p = &per_cpu(cpu_data, cpuid);
151168
boot_cpu_data.cpu_count++;
152169

153170
/* initialize counters - CPU 0 gets it_value set in time_init() */
@@ -162,12 +179,9 @@ static int __cpuinit processor_probe(struct parisc_device *dev)
162179
#ifdef CONFIG_SMP
163180
/*
164181
** FIXME: review if any other initialization is clobbered
165-
** for boot_cpu by the above memset().
182+
** for boot_cpu by the above memset().
166183
*/
167-
168-
/* stolen from init_percpu_prof() */
169-
cpu_data[cpuid].prof_counter = 1;
170-
cpu_data[cpuid].prof_multiplier = 1;
184+
init_percpu_prof(cpuid);
171185
#endif
172186

173187
/*
@@ -261,19 +275,6 @@ void __init collect_boot_cpu_data(void)
261275
}
262276

263277

264-
/**
265-
* init_cpu_profiler - enable/setup per cpu profiling hooks.
266-
* @cpunum: The processor instance.
267-
*
268-
* FIXME: doesn't do much yet...
269-
*/
270-
static inline void __init
271-
init_percpu_prof(int cpunum)
272-
{
273-
cpu_data[cpunum].prof_counter = 1;
274-
cpu_data[cpunum].prof_multiplier = 1;
275-
}
276-
277278

278279
/**
279280
* init_per_cpu - Handle individual processor initializations.
@@ -293,7 +294,7 @@ init_percpu_prof(int cpunum)
293294
*
294295
* o Enable CPU profiling hooks.
295296
*/
296-
int __init init_per_cpu(int cpunum)
297+
int __cpuinit init_per_cpu(int cpunum)
297298
{
298299
int ret;
299300
struct pdc_coproc_cfg coproc_cfg;
@@ -307,8 +308,8 @@ int __init init_per_cpu(int cpunum)
307308
/* FWIW, FP rev/model is a more accurate way to determine
308309
** CPU type. CPU rev/model has some ambiguous cases.
309310
*/
310-
cpu_data[cpunum].fp_rev = coproc_cfg.revision;
311-
cpu_data[cpunum].fp_model = coproc_cfg.model;
311+
per_cpu(cpu_data, cpunum).fp_rev = coproc_cfg.revision;
312+
per_cpu(cpu_data, cpunum).fp_model = coproc_cfg.model;
312313

313314
printk(KERN_INFO "FP[%d] enabled: Rev %ld Model %ld\n",
314315
cpunum, coproc_cfg.revision, coproc_cfg.model);
@@ -344,16 +345,17 @@ int __init init_per_cpu(int cpunum)
344345
int
345346
show_cpuinfo (struct seq_file *m, void *v)
346347
{
347-
int n;
348+
unsigned long cpu;
348349

349-
for(n=0; n<boot_cpu_data.cpu_count; n++) {
350+
for_each_online_cpu(cpu) {
351+
const struct cpuinfo_parisc *cpuinfo = &per_cpu(cpu_data, cpu);
350352
#ifdef CONFIG_SMP
351-
if (0 == cpu_data[n].hpa)
353+
if (0 == cpuinfo->hpa)
352354
continue;
353355
#endif
354-
seq_printf(m, "processor\t: %d\n"
356+
seq_printf(m, "processor\t: %lu\n"
355357
"cpu family\t: PA-RISC %s\n",
356-
n, boot_cpu_data.family_name);
358+
cpu, boot_cpu_data.family_name);
357359

358360
seq_printf(m, "cpu\t\t: %s\n", boot_cpu_data.cpu_name );
359361

@@ -365,8 +367,8 @@ show_cpuinfo (struct seq_file *m, void *v)
365367
seq_printf(m, "model\t\t: %s\n"
366368
"model name\t: %s\n",
367369
boot_cpu_data.pdc.sys_model_name,
368-
cpu_data[n].dev ?
369-
cpu_data[n].dev->name : "Unknown" );
370+
cpuinfo->dev ?
371+
cpuinfo->dev->name : "Unknown");
370372

371373
seq_printf(m, "hversion\t: 0x%08x\n"
372374
"sversion\t: 0x%08x\n",
@@ -377,8 +379,8 @@ show_cpuinfo (struct seq_file *m, void *v)
377379
show_cache_info(m);
378380

379381
seq_printf(m, "bogomips\t: %lu.%02lu\n",
380-
cpu_data[n].loops_per_jiffy / (500000 / HZ),
381-
(cpu_data[n].loops_per_jiffy / (5000 / HZ)) % 100);
382+
cpuinfo->loops_per_jiffy / (500000 / HZ),
383+
(cpuinfo->loops_per_jiffy / (5000 / HZ)) % 100);
382384

383385
seq_printf(m, "software id\t: %ld\n\n",
384386
boot_cpu_data.pdc.model.sw_id);

‎arch/parisc/kernel/setup.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ static int __init parisc_init(void)
316316

317317
processor_init();
318318
printk(KERN_INFO "CPU(s): %d x %s at %d.%06d MHz\n",
319-
boot_cpu_data.cpu_count,
319+
num_present_cpus(),
320320
boot_cpu_data.cpu_name,
321321
boot_cpu_data.cpu_hz / 1000000,
322322
boot_cpu_data.cpu_hz % 1000000 );
@@ -382,8 +382,8 @@ void start_parisc(void)
382382
if (ret >= 0 && coproc_cfg.ccr_functional) {
383383
mtctl(coproc_cfg.ccr_functional, 10);
384384

385-
cpu_data[cpunum].fp_rev = coproc_cfg.revision;
386-
cpu_data[cpunum].fp_model = coproc_cfg.model;
385+
per_cpu(cpu_data, cpunum).fp_rev = coproc_cfg.revision;
386+
per_cpu(cpu_data, cpunum).fp_model = coproc_cfg.model;
387387

388388
asm volatile ("fstd %fr0,8(%sp)");
389389
} else {

‎arch/parisc/kernel/smp.c‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,17 @@ static int smp_debug_lvl = 0;
5656
if (lvl >= smp_debug_lvl) \
5757
printk(printargs);
5858
#else
59-
#define smp_debug(lvl, ...)
59+
#define smp_debug(lvl, ...) do { } while(0)
6060
#endif /* DEBUG_SMP */
6161

6262
DEFINE_SPINLOCK(smp_lock);
6363

6464
volatile struct task_struct *smp_init_current_idle_task;
6565

66-
static volatile int cpu_now_booting __read_mostly = 0; /* track which CPU is booting */
66+
/* track which CPU is booting */
67+
static volatile int cpu_now_booting __cpuinitdata;
6768

68-
static int parisc_max_cpus __read_mostly = 1;
69+
static int parisc_max_cpus __cpuinitdata = 1;
6970

7071
DEFINE_PER_CPU(spinlock_t, ipi_lock) = SPIN_LOCK_UNLOCKED;
7172

@@ -123,7 +124,7 @@ irqreturn_t
123124
ipi_interrupt(int irq, void *dev_id)
124125
{
125126
int this_cpu = smp_processor_id();
126-
struct cpuinfo_parisc *p = &cpu_data[this_cpu];
127+
struct cpuinfo_parisc *p = &per_cpu(cpu_data, this_cpu);
127128
unsigned long ops;
128129
unsigned long flags;
129130

@@ -202,13 +203,13 @@ ipi_interrupt(int irq, void *dev_id)
202203
static inline void
203204
ipi_send(int cpu, enum ipi_message_type op)
204205
{
205-
struct cpuinfo_parisc *p = &cpu_data[cpu];
206+
struct cpuinfo_parisc *p = &per_cpu(cpu_data, cpu);
206207
spinlock_t *lock = &per_cpu(ipi_lock, cpu);
207208
unsigned long flags;
208209

209210
spin_lock_irqsave(lock, flags);
210211
p->pending_ipi |= 1 << op;
211-
gsc_writel(IPI_IRQ - CPU_IRQ_BASE, cpu_data[cpu].hpa);
212+
gsc_writel(IPI_IRQ - CPU_IRQ_BASE, p->hpa);
212213
spin_unlock_irqrestore(lock, flags);
213214
}
214215

@@ -341,6 +342,7 @@ void __init smp_callin(void)
341342
*/
342343
int __cpuinit smp_boot_one_cpu(int cpuid)
343344
{
345+
const struct cpuinfo_parisc *p = &per_cpu(cpu_data, cpuid);
344346
struct task_struct *idle;
345347
long timeout;
346348

@@ -372,7 +374,7 @@ int __cpuinit smp_boot_one_cpu(int cpuid)
372374
smp_init_current_idle_task = idle ;
373375
mb();
374376

375-
printk("Releasing cpu %d now, hpa=%lx\n", cpuid, cpu_data[cpuid].hpa);
377+
printk(KERN_INFO "Releasing cpu %d now, hpa=%lx\n", cpuid, p->hpa);
376378

377379
/*
378380
** This gets PDC to release the CPU from a very tight loop.
@@ -383,7 +385,7 @@ int __cpuinit smp_boot_one_cpu(int cpuid)
383385
** EIR{0}). MEM_RENDEZ is valid only when it is nonzero and the
384386
** contents of memory are valid."
385387
*/
386-
gsc_writel(TIMER_IRQ - CPU_IRQ_BASE, cpu_data[cpuid].hpa);
388+
gsc_writel(TIMER_IRQ - CPU_IRQ_BASE, p->hpa);
387389
mb();
388390

389391
/*
@@ -415,12 +417,12 @@ int __cpuinit smp_boot_one_cpu(int cpuid)
415417
return 0;
416418
}
417419

418-
void __devinit smp_prepare_boot_cpu(void)
420+
void __init smp_prepare_boot_cpu(void)
419421
{
420-
int bootstrap_processor=cpu_data[0].cpuid; /* CPU ID of BSP */
422+
int bootstrap_processor = per_cpu(cpu_data, 0).cpuid;
421423

422424
/* Setup BSP mappings */
423-
printk("SMP: bootstrap CPU ID is %d\n",bootstrap_processor);
425+
printk(KERN_INFO "SMP: bootstrap CPU ID is %d\n", bootstrap_processor);
424426

425427
cpu_set(bootstrap_processor, cpu_online_map);
426428
cpu_set(bootstrap_processor, cpu_present_map);

‎arch/parisc/kernel/time.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ irqreturn_t timer_interrupt(int irq, void *dev_id)
6060
unsigned long cycles_elapsed, ticks_elapsed;
6161
unsigned long cycles_remainder;
6262
unsigned int cpu = smp_processor_id();
63-
struct cpuinfo_parisc *cpuinfo = &cpu_data[cpu];
63+
struct cpuinfo_parisc *cpuinfo = &per_cpu(cpu_data, cpu);
6464

6565
/* gcc can optimize for "read-only" case with a local clocktick */
6666
unsigned long cpt = clocktick;
@@ -213,7 +213,7 @@ void __init start_cpu_itimer(void)
213213

214214
mtctl(next_tick, 16); /* kick off Interval Timer (CR16) */
215215

216-
cpu_data[cpu].it_value = next_tick;
216+
per_cpu(cpu_data, cpu).it_value = next_tick;
217217
}
218218

219219
struct platform_device rtc_parisc_dev = {

‎arch/parisc/kernel/topology.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
#include <linux/cpu.h>
2323
#include <linux/cache.h>
2424

25-
static struct cpu cpu_devices[NR_CPUS] __read_mostly;
25+
static DEFINE_PER_CPU(struct cpu, cpu_devices);
2626

2727
static int __init topology_init(void)
2828
{
2929
int num;
3030

3131
for_each_present_cpu(num) {
32-
register_cpu(&cpu_devices[num], num);
32+
register_cpu(&per_cpu(cpu_devices, num), num);
3333
}
3434
return 0;
3535
}

0 commit comments

Comments
 (0)