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>
This commit is contained in:
@@ -71,19 +71,21 @@ static struct irq_desc irq_desc_init = {
|
|||||||
|
|
||||||
void init_kstat_irqs(struct irq_desc *desc, int cpu, int nr)
|
void init_kstat_irqs(struct irq_desc *desc, int cpu, int nr)
|
||||||
{
|
{
|
||||||
unsigned long bytes;
|
|
||||||
char *ptr;
|
|
||||||
int node;
|
int node;
|
||||||
|
void *ptr;
|
||||||
/* Compute how many bytes we need per irq and allocate them */
|
|
||||||
bytes = nr * sizeof(unsigned int);
|
|
||||||
|
|
||||||
node = cpu_to_node(cpu);
|
node = cpu_to_node(cpu);
|
||||||
ptr = kzalloc_node(bytes, GFP_ATOMIC, node);
|
ptr = kzalloc_node(nr * sizeof(*desc->kstat_irqs), GFP_ATOMIC, node);
|
||||||
printk(KERN_DEBUG " alloc kstat_irqs on cpu %d node %d\n", cpu, node);
|
|
||||||
|
|
||||||
if (ptr)
|
/*
|
||||||
desc->kstat_irqs = (unsigned int *)ptr;
|
* don't overwite if can not get new one
|
||||||
|
* init_copy_kstat_irqs() could still use old one
|
||||||
|
*/
|
||||||
|
if (ptr) {
|
||||||
|
printk(KERN_DEBUG " alloc kstat_irqs on cpu %d node %d\n",
|
||||||
|
cpu, node);
|
||||||
|
desc->kstat_irqs = ptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_one_irq_desc(int irq, struct irq_desc *desc, int cpu)
|
static void init_one_irq_desc(int irq, struct irq_desc *desc, int cpu)
|
||||||
|
@@ -17,16 +17,11 @@ static void init_copy_kstat_irqs(struct irq_desc *old_desc,
|
|||||||
struct irq_desc *desc,
|
struct irq_desc *desc,
|
||||||
int cpu, int nr)
|
int cpu, int nr)
|
||||||
{
|
{
|
||||||
unsigned long bytes;
|
|
||||||
|
|
||||||
init_kstat_irqs(desc, cpu, nr);
|
init_kstat_irqs(desc, cpu, nr);
|
||||||
|
|
||||||
if (desc->kstat_irqs != old_desc->kstat_irqs) {
|
if (desc->kstat_irqs != old_desc->kstat_irqs)
|
||||||
/* Compute how many bytes we need per irq and allocate them */
|
memcpy(desc->kstat_irqs, old_desc->kstat_irqs,
|
||||||
bytes = nr * sizeof(unsigned int);
|
nr * sizeof(*desc->kstat_irqs));
|
||||||
|
|
||||||
memcpy(desc->kstat_irqs, old_desc->kstat_irqs, bytes);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void free_kstat_irqs(struct irq_desc *old_desc, struct irq_desc *desc)
|
static void free_kstat_irqs(struct irq_desc *old_desc, struct irq_desc *desc)
|
||||||
|
Reference in New Issue
Block a user