[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.64.0708131153190.4382@localhost.localdomain>
Date: Mon, 13 Aug 2007 11:54:42 -0400 (EDT)
From: "Robert P. J. Day" <rpjday@...dspring.com>
To: Mariusz Kozlowski <m.kozlowski@...land.pl>
cc: surya.prabhakar@...ro.com, mingo@...hat.com,
yaku@...1.kbnes.nec.co.jp, kisimoto@...1.kbnes.nec.co.jp,
zab@...hat.com, Linux Kernel <linux-kernel@...r.kernel.org>
Subject: Re: [KJ] replacing kmalloc with kzalloc in io_apic.c
On Mon, 13 Aug 2007, Mariusz Kozlowski wrote:
> > Hi,
> > Replacing kmalloc with kzalloc and cleaning up memset in
> > arch/i386/kernel/io_apic.c
> >
> >
> > Signed-off-by: Surya Prabhakar <surya.prabhakar@...ro.com>
> > ---
> >
> > diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c
> > index 4b8a8da..1329615 100644
> > --- a/arch/i386/kernel/io_apic.c
> > +++ b/arch/i386/kernel/io_apic.c
> > @@ -690,14 +690,12 @@ static int __init balanced_irq_init(void)
> > physical_balance = 1;
> >
> > for_each_online_cpu(i) {
> > - irq_cpu_data[i].irq_delta = kmalloc(sizeof(unsigned long) * NR_IRQS,
> > GFP_KERNEL); - irq_cpu_data[i].last_irq = kmalloc(sizeof(unsigned long) *
> > NR_IRQS, GFP_KERNEL); + irq_cpu_data[i].irq_delta =
> > kzalloc(sizeof(unsigned long) * NR_IRQS, GFP_KERNEL);
> > + irq_cpu_data[i].last_irq = kzalloc(sizeof(unsigned long) * NR_IRQS,
> > GFP_KERNEL); if (irq_cpu_data[i].irq_delta == NULL ||
> > irq_cpu_data[i].last_irq == NULL) { printk(KERN_ERR "balanced_irq_init: out
> > of memory");
> > goto failed;
> > }
> > - memset(irq_cpu_data[i].irq_delta,0,sizeof(unsigned long) * NR_IRQS);
> > - memset(irq_cpu_data[i].last_irq,0,sizeof(unsigned long) * NR_IRQS);
> > }
> >
> > printk(KERN_INFO "Starting balanced_irq\n");
>
> How about using kcalloc here?
>
> i.e.
> ...
> ... = kcalloc(NR_IRQS, sizeof(unsigned long), GFP_KERNEL);
> ...
from my days submitting numerous patches of this type, i can recall
that in cases like the above, it's a judgment call -- use kzalloc to
get the zeroing, or use kcalloc to get the array-flavoured behaviour.
what a shame you can't have both at the same time.
rday
--
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA
http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists