diff options
author | Yinghai Lu <yinghai@kernel.org> | 2009-02-08 19:18:03 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-02-09 03:02:34 -0500 |
commit | 005bf0e6fa0e9543933fe2e36322af649df7cacb (patch) | |
tree | b14afa63f043d8c1fcf705b2d60262d873ec8f3f /kernel | |
parent | 0f3c2a89c1451cdf6328f99977bd9decd4f708e1 (diff) |
irq: optimize init_kstat_irqs/init_copy_kstat_irqs
Simplify and make init_kstat_irqs etc more type proof, suggested by
Andrew.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/irq/handle.c | 20 | ||||
-rw-r--r-- | kernel/irq/numa_migrate.c | 11 |
2 files changed, 14 insertions, 17 deletions
diff --git a/kernel/irq/handle.c b/kernel/irq/handle.c index 1b473e7569aa..49d642b62c64 100644 --- a/kernel/irq/handle.c +++ b/kernel/irq/handle.c | |||
@@ -71,19 +71,21 @@ static struct irq_desc irq_desc_init = { | |||
71 | 71 | ||
72 | void init_kstat_irqs(struct irq_desc *desc, int cpu, int nr) | 72 | void init_kstat_irqs(struct irq_desc *desc, int cpu, int nr) |
73 | { | 73 | { |
74 | unsigned long bytes; | ||
75 | char *ptr; | ||
76 | int node; | 74 | int node; |
77 | 75 | void *ptr; | |
78 | /* Compute how many bytes we need per irq and allocate them */ | ||
79 | bytes = nr * sizeof(unsigned int); | ||
80 | 76 | ||
81 | node = cpu_to_node(cpu); | 77 | node = cpu_to_node(cpu); |
82 | ptr = kzalloc_node(bytes, GFP_ATOMIC, node); | 78 | ptr = kzalloc_node(nr * sizeof(*desc->kstat_irqs), GFP_ATOMIC, node); |
83 | printk(KERN_DEBUG " alloc kstat_irqs on cpu %d node %d\n", cpu, node); | ||
84 | 79 | ||
85 | if (ptr) | 80 | /* |
86 | desc->kstat_irqs = (unsigned int *)ptr; | 81 | * don't overwite if can not get new one |
82 | * init_copy_kstat_irqs() could still use old one | ||
83 | */ | ||
84 | if (ptr) { | ||
85 | printk(KERN_DEBUG " alloc kstat_irqs on cpu %d node %d\n", | ||
86 | cpu, node); | ||
87 | desc->kstat_irqs = ptr; | ||
88 | } | ||
87 | } | 89 | } |
88 | 90 | ||
89 | static void init_one_irq_desc(int irq, struct irq_desc *desc, int cpu) | 91 | static void init_one_irq_desc(int irq, struct irq_desc *desc, int cpu) |
diff --git a/kernel/irq/numa_migrate.c b/kernel/irq/numa_migrate.c index ecf765c6a77a..c500cfe422b6 100644 --- a/kernel/irq/numa_migrate.c +++ b/kernel/irq/numa_migrate.c | |||
@@ -17,16 +17,11 @@ static void init_copy_kstat_irqs(struct irq_desc *old_desc, | |||
17 | struct irq_desc *desc, | 17 | struct irq_desc *desc, |
18 | int cpu, int nr) | 18 | int cpu, int nr) |
19 | { | 19 | { |
20 | unsigned long bytes; | ||
21 | |||
22 | init_kstat_irqs(desc, cpu, nr); | 20 | init_kstat_irqs(desc, cpu, nr); |
23 | 21 | ||
24 | if (desc->kstat_irqs != old_desc->kstat_irqs) { | 22 | if (desc->kstat_irqs != old_desc->kstat_irqs) |
25 | /* Compute how many bytes we need per irq and allocate them */ | 23 | memcpy(desc->kstat_irqs, old_desc->kstat_irqs, |
26 | bytes = nr * sizeof(unsigned int); | 24 | nr * sizeof(*desc->kstat_irqs)); |
27 | |||
28 | memcpy(desc->kstat_irqs, old_desc->kstat_irqs, bytes); | ||
29 | } | ||
30 | } | 25 | } |
31 | 26 | ||
32 | static void free_kstat_irqs(struct irq_desc *old_desc, struct irq_desc *desc) | 27 | static void free_kstat_irqs(struct irq_desc *old_desc, struct irq_desc *desc) |