2010-11-01 05:50:57

by Jesper Juhl

[permalink] [raw]
Subject: Re: [PATCH] cgroup: Avoid a memset by using vzalloc

On Sun, 31 Oct 2010, Balbir Singh wrote:

> * MinChan Kim <[email protected]> [2010-10-31 08:34:01]:
>
> > On Sun, Oct 31, 2010 at 6:35 AM, Jesper Juhl <[email protected]> wrote:
> > > Hi,
> > >
> > > We can avoid doing a memset in swap_cgroup_swapon() by using vzalloc().
> > >
> > >
> > > Signed-off-by: Jesper Juhl <[email protected]>
> > Reviewed-by: Minchan Kim <[email protected]>
> >
> > There are so many placed need vzalloc.
> > Thanks, Jesper.
>
> Yes, please check memcontrol.c as well
>
I will shortly, I'm slowly working my way through a mountain of code
checking for this. I'll get to memcontrol.c

>
> Acked-by: Balbir Singh <[email protected]>
>
Thanks.

--
Jesper Juhl <[email protected]> http://www.chaosbits.net/
Plain text mails only, please http://www.expita.com/nomime.html
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html


Subject: Re: [PATCH] cgroup: Avoid a memset by using vzalloc

On Mon, 1 Nov 2010, Jesper Juhl wrote:

> On Sun, 31 Oct 2010, Balbir Singh wrote:

> > > There are so many placed need vzalloc.
> > > Thanks, Jesper.


Could we avoid this painful exercise with a "semantic patch"?

2010-11-03 15:20:35

by Jovi Zhang

[permalink] [raw]
Subject: Re: [PATCH] cgroup: Avoid a memset by using vzalloc

On Wed, Nov 3, 2010 at 10:38 PM, Christoph Lameter <[email protected]> wrote:
> On Mon, 1 Nov 2010, Jesper Juhl wrote:
>
>> On Sun, 31 Oct 2010, Balbir Singh wrote:
>
>> > > There are so many placed need vzalloc.
>> > > Thanks, Jesper.
>
>
> Could we avoid this painful exercise with a "semantic patch"?
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>
Can we make a grep script to walk all files to find vzalloc usage like this?
No need to send patch mail one by one like this.

Subject: Re: [PATCH] cgroup: Avoid a memset by using vzalloc

On Wed, 3 Nov 2010, jovi zhang wrote:

> On Wed, Nov 3, 2010 at 10:38 PM, Christoph Lameter <[email protected]> wrote:
> > Could we avoid this painful exercise with a "semantic patch"?

> Can we make a grep script to walk all files to find vzalloc usage like this?
> No need to send patch mail one by one like this.

Please use spatch. See http://lwn.net/Articles/315686/

2010-11-03 15:48:09

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH] cgroup: Avoid a memset by using vzalloc

On Wed, 2010-11-03 at 23:20 +0800, jovi zhang wrote:
> On Wed, Nov 3, 2010 at 10:38 PM, Christoph Lameter <[email protected]> wrote:
> > On Mon, 1 Nov 2010, Jesper Juhl wrote:
> >
> >> On Sun, 31 Oct 2010, Balbir Singh wrote:
> >
> >> > > There are so many placed need vzalloc.
> >> > > Thanks, Jesper.
> >
> >
> > Could we avoid this painful exercise with a "semantic patch"?

There's an existing cocci kmalloc/memset script.

Perhaps this is good enough?

cp scripts/coccinelle/api/alloc/kzalloc-simple.cocci scripts/coccinelle/api/alloc/vzalloc-simple.cocci
sed -i -e 's/kmalloc/vmalloc/g' -e 's/kzalloc/vzalloc/g' scripts/coccinelle/api/alloc/vzalloc-simple.cocci



Subject: Re: [PATCH] cgroup: Avoid a memset by using vzalloc

On Wed, 3 Nov 2010, Joe Perches wrote:

> On Wed, 2010-11-03 at 23:20 +0800, jovi zhang wrote:
> > On Wed, Nov 3, 2010 at 10:38 PM, Christoph Lameter <[email protected]> wrote:
> > > On Mon, 1 Nov 2010, Jesper Juhl wrote:
> > >
> > >> On Sun, 31 Oct 2010, Balbir Singh wrote:
> > >
> > >> > > There are so many placed need vzalloc.
> > >> > > Thanks, Jesper.
> > >
> > >
> > > Could we avoid this painful exercise with a "semantic patch"?
>
> There's an existing cocci kmalloc/memset script.

I have it in
/usr/share/doc/coccinelle/examples/janitorings/kzalloc-orig.cocci.gz

(Ubuntu coccinelle package)

> Perhaps this is good enough?
>
> cp scripts/coccinelle/api/alloc/kzalloc-simple.cocci scripts/coccinelle/api/alloc/vzalloc-simple.cocci
> sed -i -e 's/kmalloc/vmalloc/g' -e 's/kzalloc/vzalloc/g' scripts/coccinelle/api/alloc/vzalloc-simple.cocci

Not sure if that is the same script but certainly a good start. Try it and
see if it catches all the locations that you know of?

2010-11-03 16:34:39

by Cong Wang

[permalink] [raw]
Subject: Re: [PATCH] cgroup: Avoid a memset by using vzalloc

On Wed, Nov 03, 2010 at 11:20:32PM +0800, jovi zhang wrote:
>On Wed, Nov 3, 2010 at 10:38 PM, Christoph Lameter <[email protected]> wrote:
>> On Mon, 1 Nov 2010, Jesper Juhl wrote:
>>
>>> On Sun, 31 Oct 2010, Balbir Singh wrote:
>>
>>> > > There are so many placed need vzalloc.
>>> > > Thanks, Jesper.
>>
>>
>> Could we avoid this painful exercise with a "semantic patch"?
>>
>Can we make a grep script to walk all files to find vzalloc usage like this?
>No need to send patch mail one by one like this.

No, grep doesn't understand C. :)

--
Live like a child, think like the god.

2010-11-04 21:54:55

by Jesper Juhl

[permalink] [raw]
Subject: Re: [PATCH] cgroup: Avoid a memset by using vzalloc

On Wed, 3 Nov 2010, Christoph Lameter wrote:

> On Wed, 3 Nov 2010, Joe Perches wrote:
>
> > On Wed, 2010-11-03 at 23:20 +0800, jovi zhang wrote:
> > > On Wed, Nov 3, 2010 at 10:38 PM, Christoph Lameter <[email protected]> wrote:
> > > > On Mon, 1 Nov 2010, Jesper Juhl wrote:
> > > >
> > > >> On Sun, 31 Oct 2010, Balbir Singh wrote:
> > > >
> > > >> > > There are so many placed need vzalloc.
> > > >> > > Thanks, Jesper.
> > > >
> > > >
> > > > Could we avoid this painful exercise with a "semantic patch"?
> >
> > There's an existing cocci kmalloc/memset script.
>
> I have it in
> /usr/share/doc/coccinelle/examples/janitorings/kzalloc-orig.cocci.gz
>
> (Ubuntu coccinelle package)
>
> > Perhaps this is good enough?
> >
> > cp scripts/coccinelle/api/alloc/kzalloc-simple.cocci scripts/coccinelle/api/alloc/vzalloc-simple.cocci
> > sed -i -e 's/kmalloc/vmalloc/g' -e 's/kzalloc/vzalloc/g' scripts/coccinelle/api/alloc/vzalloc-simple.cocci
>
> Not sure if that is the same script but certainly a good start. Try it and
> see if it catches all the locations that you know of?
>

I'm aware of coccinelle, but I've never used it and it looks like it'll
take more than just a few hours to learn, so I'm sticking with
bash+egrep+manual inspection for now until I get a bit more time on my
hands to learn coccinelle/spatch.

I assume that not using spatch is not going to be an obstacle to patches
such as this one getting merged...?


--
Jesper Juhl <[email protected]> http://www.chaosbits.net/
Plain text mails only, please http://www.expita.com/nomime.html
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html

2010-11-05 03:08:37

by Joe Perches

[permalink] [raw]
Subject: [PATCH 01/49] arch/ia64: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
arch/ia64/kernel/perfmon.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index 39e534f..3aee09d 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -829,10 +829,9 @@ pfm_rvmalloc(unsigned long size)
unsigned long addr;

size = PAGE_ALIGN(size);
- mem = vmalloc(size);
+ mem = vzalloc(size);
if (mem) {
//printk("perfmon: CPU%d pfm_rvmalloc(%ld)=%p\n", smp_processor_id(), size, mem);
- memset(mem, 0, size);
addr = (unsigned long)mem;
while (size > 0) {
pfm_reserve_page(addr);
--
1.7.3.1.g432b3.dirty

2010-11-05 03:08:58

by Joe Perches

[permalink] [raw]
Subject: [PATCH 28/49] drivers/net/pch_gbe: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
drivers/net/pch_gbe/pch_gbe_main.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/pch_gbe/pch_gbe_main.c b/drivers/net/pch_gbe/pch_gbe_main.c
index 472056b..afb7506 100644
--- a/drivers/net/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/pch_gbe/pch_gbe_main.c
@@ -1523,12 +1523,11 @@ int pch_gbe_setup_tx_resources(struct pch_gbe_adapter *adapter,
int desNo;

size = (int)sizeof(struct pch_gbe_buffer) * tx_ring->count;
- tx_ring->buffer_info = vmalloc(size);
+ tx_ring->buffer_info = vzalloc(size);
if (!tx_ring->buffer_info) {
pr_err("Unable to allocate memory for the buffer infomation\n");
return -ENOMEM;
}
- memset(tx_ring->buffer_info, 0, size);

tx_ring->size = tx_ring->count * (int)sizeof(struct pch_gbe_tx_desc);

@@ -1573,12 +1572,11 @@ int pch_gbe_setup_rx_resources(struct pch_gbe_adapter *adapter,
int desNo;

size = (int)sizeof(struct pch_gbe_buffer) * rx_ring->count;
- rx_ring->buffer_info = vmalloc(size);
+ rx_ring->buffer_info = vzalloc(size);
if (!rx_ring->buffer_info) {
pr_err("Unable to allocate memory for the receive descriptor ring\n");
return -ENOMEM;
}
- memset(rx_ring->buffer_info, 0, size);
rx_ring->size = rx_ring->count * (int)sizeof(struct pch_gbe_rx_desc);
rx_ring->desc = dma_alloc_coherent(&pdev->dev, rx_ring->size,
&rx_ring->dma, GFP_KERNEL);
--
1.7.3.1.g432b3.dirty

2010-11-05 03:09:19

by Joe Perches

[permalink] [raw]
Subject: [PATCH 46/49] net/netfilter: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
net/netfilter/x_tables.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index 8046350..89e8895 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -753,12 +753,11 @@ static int xt_jumpstack_alloc(struct xt_table_info *i)

size = sizeof(void **) * nr_cpu_ids;
if (size > PAGE_SIZE)
- i->jumpstack = vmalloc(size);
+ i->jumpstack = vzalloc(size);
else
- i->jumpstack = kmalloc(size, GFP_KERNEL);
+ i->jumpstack = kzalloc(size, GFP_KERNEL);
if (i->jumpstack == NULL)
return -ENOMEM;
- memset(i->jumpstack, 0, size);

i->stacksize *= xt_jumpstack_multiplier;
size = sizeof(void *) * i->stacksize;
--
1.7.3.1.g432b3.dirty

2010-11-05 03:09:23

by Joe Perches

[permalink] [raw]
Subject: [PATCH 48/49] sound/oss/dev_table.c: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
sound/oss/dev_table.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/sound/oss/dev_table.c b/sound/oss/dev_table.c
index 727bdb9..d8cf3e5 100644
--- a/sound/oss/dev_table.c
+++ b/sound/oss/dev_table.c
@@ -71,7 +71,7 @@ int sound_install_audiodrv(int vers, char *name, struct audio_driver *driver,
if (sound_nblocks >= MAX_MEM_BLOCKS)
sound_nblocks = MAX_MEM_BLOCKS - 1;

- op = (struct audio_operations *) (sound_mem_blocks[sound_nblocks] = vmalloc(sizeof(struct audio_operations)));
+ op = (struct audio_operations *) (sound_mem_blocks[sound_nblocks] = vzalloc(sizeof(struct audio_operations)));
sound_nblocks++;
if (sound_nblocks >= MAX_MEM_BLOCKS)
sound_nblocks = MAX_MEM_BLOCKS - 1;
@@ -81,7 +81,6 @@ int sound_install_audiodrv(int vers, char *name, struct audio_driver *driver,
sound_unload_audiodev(num);
return -(ENOMEM);
}
- memset((char *) op, 0, sizeof(struct audio_operations));
init_waitqueue_head(&op->in_sleeper);
init_waitqueue_head(&op->out_sleeper);
init_waitqueue_head(&op->poll_sleeper);
@@ -128,7 +127,7 @@ int sound_install_mixer(int vers, char *name, struct mixer_operations *driver,
/* FIXME: This leaks a mixer_operations struct every time its called
until you unload sound! */

- op = (struct mixer_operations *) (sound_mem_blocks[sound_nblocks] = vmalloc(sizeof(struct mixer_operations)));
+ op = (struct mixer_operations *) (sound_mem_blocks[sound_nblocks] = vzalloc(sizeof(struct mixer_operations)));
sound_nblocks++;
if (sound_nblocks >= MAX_MEM_BLOCKS)
sound_nblocks = MAX_MEM_BLOCKS - 1;
@@ -137,7 +136,6 @@ int sound_install_mixer(int vers, char *name, struct mixer_operations *driver,
printk(KERN_ERR "Sound: Can't allocate mixer driver for (%s)\n", name);
return -ENOMEM;
}
- memset((char *) op, 0, sizeof(struct mixer_operations));
memcpy((char *) op, (char *) driver, driver_size);

strlcpy(op->name, name, sizeof(op->name));
--
1.7.3.1.g432b3.dirty

2010-11-05 03:09:14

by Joe Perches

[permalink] [raw]
Subject: [PATCH 41/49] fs/xfs: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
fs/xfs/linux-2.6/kmem.h | 7 +------
1 files changed, 1 insertions(+), 6 deletions(-)

diff --git a/fs/xfs/linux-2.6/kmem.h b/fs/xfs/linux-2.6/kmem.h
index f7c8f7a..292eff1 100644
--- a/fs/xfs/linux-2.6/kmem.h
+++ b/fs/xfs/linux-2.6/kmem.h
@@ -61,12 +61,7 @@ extern void kmem_free(const void *);

static inline void *kmem_zalloc_large(size_t size)
{
- void *ptr;
-
- ptr = vmalloc(size);
- if (ptr)
- memset(ptr, 0, size);
- return ptr;
+ return vzalloc(size);
}
static inline void kmem_free_large(void *ptr)
{
--
1.7.3.1.g432b3.dirty

2010-11-05 03:09:22

by Joe Perches

[permalink] [raw]
Subject: [PATCH 47/49] net/rds: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
net/rds/ib_cm.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
index ee369d2..cc6b073 100644
--- a/net/rds/ib_cm.c
+++ b/net/rds/ib_cm.c
@@ -374,23 +374,21 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
goto out;
}

- ic->i_sends = vmalloc_node(ic->i_send_ring.w_nr * sizeof(struct rds_ib_send_work),
+ ic->i_sends = vzalloc_node(ic->i_send_ring.w_nr * sizeof(struct rds_ib_send_work),
ibdev_to_node(dev));
if (!ic->i_sends) {
ret = -ENOMEM;
rdsdebug("send allocation failed\n");
goto out;
}
- memset(ic->i_sends, 0, ic->i_send_ring.w_nr * sizeof(struct rds_ib_send_work));

- ic->i_recvs = vmalloc_node(ic->i_recv_ring.w_nr * sizeof(struct rds_ib_recv_work),
+ ic->i_recvs = vzalloc_node(ic->i_recv_ring.w_nr * sizeof(struct rds_ib_recv_work),
ibdev_to_node(dev));
if (!ic->i_recvs) {
ret = -ENOMEM;
rdsdebug("recv allocation failed\n");
goto out;
}
- memset(ic->i_recvs, 0, ic->i_recv_ring.w_nr * sizeof(struct rds_ib_recv_work));

rds_ib_recv_init_ack(ic);

--
1.7.3.1.g432b3.dirty

2010-11-05 03:09:16

by Joe Perches

[permalink] [raw]
Subject: [PATCH 44/49] mm: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
mm/memcontrol.c | 5 ++---
mm/page_cgroup.c | 3 +--
mm/percpu.c | 8 ++------
mm/swapfile.c | 3 +--
4 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 9a99cfa..90da698 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -4199,14 +4199,13 @@ static struct mem_cgroup *mem_cgroup_alloc(void)

/* Can be very big if MAX_NUMNODES is very big */
if (size < PAGE_SIZE)
- mem = kmalloc(size, GFP_KERNEL);
+ mem = kzalloc(size, GFP_KERNEL);
else
- mem = vmalloc(size);
+ mem = vzalloc(size);

if (!mem)
return NULL;

- memset(mem, 0, size);
mem->stat = alloc_percpu(struct mem_cgroup_stat_cpu);
if (!mem->stat) {
if (size < PAGE_SIZE)
diff --git a/mm/page_cgroup.c b/mm/page_cgroup.c
index 5bffada..34970c7 100644
--- a/mm/page_cgroup.c
+++ b/mm/page_cgroup.c
@@ -450,11 +450,10 @@ int swap_cgroup_swapon(int type, unsigned long max_pages)
length = ((max_pages/SC_PER_PAGE) + 1);
array_size = length * sizeof(void *);

- array = vmalloc(array_size);
+ array = vzalloc(array_size);
if (!array)
goto nomem;

- memset(array, 0, array_size);
ctrl = &swap_cgroup_ctrl[type];
mutex_lock(&swap_cgroup_mutex);
ctrl->length = length;
diff --git a/mm/percpu.c b/mm/percpu.c
index efe8168..9e16d1c 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -293,12 +293,8 @@ static void *pcpu_mem_alloc(size_t size)

if (size <= PAGE_SIZE)
return kzalloc(size, GFP_KERNEL);
- else {
- void *ptr = vmalloc(size);
- if (ptr)
- memset(ptr, 0, size);
- return ptr;
- }
+ else
+ return vzalloc(size);
}

/**
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 67ddaaf..43e6988 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -2044,13 +2044,12 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
goto bad_swap;

/* OK, set up the swap map and apply the bad block list */
- swap_map = vmalloc(maxpages);
+ swap_map = vzalloc(maxpages);
if (!swap_map) {
error = -ENOMEM;
goto bad_swap;
}

- memset(swap_map, 0, maxpages);
nr_good_pages = maxpages - 1; /* omit header page */

for (i = 0; i < swap_header->info.nr_badpages; i++) {
--
1.7.3.1.g432b3.dirty

2010-11-05 03:09:05

by Joe Perches

[permalink] [raw]
Subject: [PATCH 35/49] drivers/staging: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
drivers/staging/comedi/drivers.c | 4 +---
drivers/staging/rtl8192e/r8192E_core.c | 4 +---
drivers/staging/udlfb/udlfb.c | 5 ++---
drivers/staging/xgifb/XGI_main_26.c | 3 +--
drivers/staging/zram/zram_drv.c | 3 +--
5 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index 4a29ed7..ef24a53 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -470,10 +470,8 @@ int comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s,
struct page **pages = NULL;

async->buf_page_list =
- vmalloc(sizeof(struct comedi_buf_page) * n_pages);
+ vzalloc(sizeof(struct comedi_buf_page) * n_pages);
if (async->buf_page_list) {
- memset(async->buf_page_list, 0,
- sizeof(struct comedi_buf_page) * n_pages);
pages = vmalloc(sizeof(struct page *) * n_pages);
}
if (pages) {
diff --git a/drivers/staging/rtl8192e/r8192E_core.c b/drivers/staging/rtl8192e/r8192E_core.c
index a202194..c870014 100644
--- a/drivers/staging/rtl8192e/r8192E_core.c
+++ b/drivers/staging/rtl8192e/r8192E_core.c
@@ -2283,9 +2283,7 @@ static void rtl8192_init_priv_variable(struct net_device* dev)
IMR_TXFOVW | IMR_BcnInt | IMR_TBDOK | IMR_TBDER);

priv->AcmControl = 0;
- priv->pFirmware = (rt_firmware*)vmalloc(sizeof(rt_firmware));
- if (priv->pFirmware)
- memset(priv->pFirmware, 0, sizeof(rt_firmware));
+ priv->pFirmware = vzalloc(sizeof(rt_firmware));

/* rx related queue */
skb_queue_head_init(&priv->rx_queue);
diff --git a/drivers/staging/udlfb/udlfb.c b/drivers/staging/udlfb/udlfb.c
index 5969e84..e228329 100644
--- a/drivers/staging/udlfb/udlfb.c
+++ b/drivers/staging/udlfb/udlfb.c
@@ -1163,14 +1163,13 @@ static int dlfb_realloc_framebuffer(struct dlfb_data *dev, struct fb_info *info)
* But with imperfect damage info we may send pixels over USB
* that were, in fact, unchanged - wasting limited USB bandwidth
*/
- new_back = vmalloc(new_len);
+ new_back = vzalloc(new_len);
if (!new_back)
- dl_info("No shadow/backing buffer allcoated\n");
+ dl_info("No shadow/backing buffer allocated\n");
else {
if (dev->backing_buffer)
vfree(dev->backing_buffer);
dev->backing_buffer = new_back;
- memset(dev->backing_buffer, 0, new_len);
}
}

diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c
index 4f73d09..1ebf1a0 100644
--- a/drivers/staging/xgifb/XGI_main_26.c
+++ b/drivers/staging/xgifb/XGI_main_26.c
@@ -2178,8 +2178,7 @@ static int XGIfb_heap_init(void)

#ifndef AGPOFF
if (XGIfb_queuemode == AGP_CMD_QUEUE) {
- agp_info = vmalloc(sizeof(*agp_info));
- memset((void *)agp_info, 0x00, sizeof(*agp_info));
+ agp_info = vzalloc(sizeof(*agp_info));
agp_copy_info(agp_info);

agp_backend_acquire();
diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c
index 8c3c057..43fd608 100644
--- a/drivers/staging/zram/zram_drv.c
+++ b/drivers/staging/zram/zram_drv.c
@@ -533,7 +533,7 @@ int zram_init_device(struct zram *zram)
}

num_pages = zram->disksize >> PAGE_SHIFT;
- zram->table = vmalloc(num_pages * sizeof(*zram->table));
+ zram->table = vzalloc(num_pages * sizeof(*zram->table));
if (!zram->table) {
pr_err("Error allocating zram address table\n");
/* To prevent accessing table entries during cleanup */
@@ -541,7 +541,6 @@ int zram_init_device(struct zram *zram)
ret = -ENOMEM;
goto fail;
}
- memset(zram->table, 0, num_pages * sizeof(*zram->table));

set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT);

--
1.7.3.1.g432b3.dirty

2010-11-05 03:09:11

by Joe Perches

[permalink] [raw]
Subject: [PATCH 40/49] fs/udf: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
fs/udf/super.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/udf/super.c b/fs/udf/super.c
index 4a5c7c6..6e07d99 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -959,9 +959,9 @@ static struct udf_bitmap *udf_sb_alloc_bitmap(struct super_block *sb, u32 index)
(sizeof(struct buffer_head *) * nr_groups);

if (size <= PAGE_SIZE)
- bitmap = kmalloc(size, GFP_KERNEL);
+ bitmap = kzalloc(size, GFP_KERNEL);
else
- bitmap = vmalloc(size); /* TODO: get rid of vmalloc */
+ bitmap = vzalloc(size); /* TODO: get rid of vmalloc */

if (bitmap == NULL) {
udf_error(sb, __func__,
@@ -970,7 +970,6 @@ static struct udf_bitmap *udf_sb_alloc_bitmap(struct super_block *sb, u32 index)
return NULL;
}

- memset(bitmap, 0x00, size);
bitmap->s_block_bitmap = (struct buffer_head **)(bitmap + 1);
bitmap->s_nr_groups = nr_groups;
return bitmap;
--
1.7.3.1.g432b3.dirty

2010-11-05 03:10:22

by Joe Perches

[permalink] [raw]
Subject: [PATCH 49/49] virt/kvm/kvm_main.c: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
virt/kvm/kvm_main.c | 13 +++----------
1 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 5225052..c2a08e6e 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -604,13 +604,10 @@ int __kvm_set_memory_region(struct kvm *kvm,
/* Allocate if a slot is being created */
#ifndef CONFIG_S390
if (npages && !new.rmap) {
- new.rmap = vmalloc(npages * sizeof(*new.rmap));
-
+ new.rmap = vzalloc(npages * sizeof(*new.rmap));
if (!new.rmap)
goto out_free;

- memset(new.rmap, 0, npages * sizeof(*new.rmap));
-
new.user_alloc = user_alloc;
new.userspace_addr = mem->userspace_addr;
}
@@ -633,14 +630,11 @@ int __kvm_set_memory_region(struct kvm *kvm,
>> KVM_HPAGE_GFN_SHIFT(level));
lpages -= base_gfn >> KVM_HPAGE_GFN_SHIFT(level);

- new.lpage_info[i] = vmalloc(lpages * sizeof(*new.lpage_info[i]));
+ new.lpage_info[i] = vzalloc(lpages * sizeof(*new.lpage_info[i]));

if (!new.lpage_info[i])
goto out_free;

- memset(new.lpage_info[i], 0,
- lpages * sizeof(*new.lpage_info[i]));
-
if (base_gfn & (KVM_PAGES_PER_HPAGE(level) - 1))
new.lpage_info[i][0].write_count = 1;
if ((base_gfn+npages) & (KVM_PAGES_PER_HPAGE(level) - 1))
@@ -663,10 +657,9 @@ skip_lpage:
if ((new.flags & KVM_MEM_LOG_DIRTY_PAGES) && !new.dirty_bitmap) {
unsigned long dirty_bytes = kvm_dirty_bitmap_bytes(&new);

- new.dirty_bitmap = vmalloc(dirty_bytes);
+ new.dirty_bitmap = vzalloc(dirty_bytes);
if (!new.dirty_bitmap)
goto out_free;
- memset(new.dirty_bitmap, 0, dirty_bytes);
/* destroy any largepage mappings for dirty tracking */
if (old.npages)
flush_shadow = 1;
--
1.7.3.1.g432b3.dirty

2010-11-05 03:11:20

by Joe Perches

[permalink] [raw]
Subject: [PATCH 43/49] kernel: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
kernel/profile.c | 6 ++----
kernel/relay.c | 4 +---
2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/kernel/profile.c b/kernel/profile.c
index 66f841b..14c9f87 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -126,11 +126,9 @@ int __ref profile_init(void)
if (prof_buffer)
return 0;

- prof_buffer = vmalloc(buffer_bytes);
- if (prof_buffer) {
- memset(prof_buffer, 0, buffer_bytes);
+ prof_buffer = vzalloc(buffer_bytes);
+ if (prof_buffer)
return 0;
- }

free_cpumask_var(prof_cpu_mask);
return -ENOMEM;
diff --git a/kernel/relay.c b/kernel/relay.c
index c7cf397..11fbe89 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -74,9 +74,7 @@ static struct page **relay_alloc_page_array(unsigned int n_pages)
size_t pa_size = n_pages * sizeof(struct page *);

if (pa_size > PAGE_SIZE) {
- array = vmalloc(pa_size);
- if (array)
- memset(array, 0, pa_size);
+ array = vzalloc(pa_size);
} else {
array = kzalloc(pa_size, GFP_KERNEL);
}
--
1.7.3.1.g432b3.dirty

2010-11-05 03:11:35

by Joe Perches

[permalink] [raw]
Subject: [PATCH 38/49] fs/jffs2: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
fs/jffs2/build.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/fs/jffs2/build.c b/fs/jffs2/build.c
index 85c6be2..3005ec4 100644
--- a/fs/jffs2/build.c
+++ b/fs/jffs2/build.c
@@ -336,14 +336,13 @@ int jffs2_do_mount_fs(struct jffs2_sb_info *c)
size = sizeof(struct jffs2_eraseblock) * c->nr_blocks;
#ifndef __ECOS
if (jffs2_blocks_use_vmalloc(c))
- c->blocks = vmalloc(size);
+ c->blocks = vzalloc(size);
else
#endif
- c->blocks = kmalloc(size, GFP_KERNEL);
+ c->blocks = kzalloc(size, GFP_KERNEL);
if (!c->blocks)
return -ENOMEM;

- memset(c->blocks, 0, size);
for (i=0; i<c->nr_blocks; i++) {
INIT_LIST_HEAD(&c->blocks[i].list);
c->blocks[i].offset = i * c->sector_size;
--
1.7.3.1.g432b3.dirty

2010-11-05 03:11:33

by Joe Perches

[permalink] [raw]
Subject: [PATCH 42/49] include/linux/coda_linux.h: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
include/linux/coda_linux.h | 26 ++++++++++++++++----------
1 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/include/linux/coda_linux.h b/include/linux/coda_linux.h
index 2e914d0..57460f3 100644
--- a/include/linux/coda_linux.h
+++ b/include/linux/coda_linux.h
@@ -55,19 +55,25 @@ unsigned short coda_flags_to_cflags(unsigned short);
void coda_sysctl_init(void);
void coda_sysctl_clean(void);

-#define CODA_ALLOC(ptr, cast, size) do { \
- if (size < PAGE_SIZE) \
- ptr = kmalloc((unsigned long) size, GFP_KERNEL); \
- else \
- ptr = (cast)vmalloc((unsigned long) size); \
- if (!ptr) \
- printk("kernel malloc returns 0 at %s:%d\n", __FILE__, __LINE__); \
- else memset( ptr, 0, size ); \
+#define CODA_ALLOC(ptr, cast, size) \
+do { \
+ if (size < PAGE_SIZE) \
+ ptr = kzalloc((unsigned long) size, GFP_KERNEL); \
+ else \
+ ptr = vzalloc((unsigned long) size); \
+ if (!ptr) \
+ printk(KERN_ERR "kernel malloc returns 0 at %s:%d\n", \
+ __FILE__, __LINE__); \
} while (0)


-#define CODA_FREE(ptr,size) \
- do { if (size < PAGE_SIZE) kfree((ptr)); else vfree((ptr)); } while (0)
+#define CODA_FREE(ptr, size) \
+do { \
+ if (size < PAGE_SIZE) \
+ kfree((ptr)); \
+ else \
+ vfree((ptr)); \
+} while (0)

/* inode to cnode access functions */

--
1.7.3.1.g432b3.dirty

2010-11-05 03:09:09

by Joe Perches

[permalink] [raw]
Subject: [PATCH 39/49] fs/reiserfs: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
fs/reiserfs/journal.c | 9 +++------
fs/reiserfs/resize.c | 4 +---
2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
index 076c8b1..d8a2592 100644
--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -292,14 +292,13 @@ int reiserfs_allocate_list_bitmaps(struct super_block *sb,
for (i = 0; i < JOURNAL_NUM_BITMAPS; i++) {
jb = jb_array + i;
jb->journal_list = NULL;
- jb->bitmaps = vmalloc(mem);
+ jb->bitmaps = vzalloc(mem);
if (!jb->bitmaps) {
reiserfs_warning(sb, "clm-2000", "unable to "
"allocate bitmaps for journal lists");
failed = 1;
break;
}
- memset(jb->bitmaps, 0, mem);
}
if (failed) {
free_list_bitmaps(sb, jb_array);
@@ -354,11 +353,10 @@ static struct reiserfs_journal_cnode *allocate_cnodes(int num_cnodes)
if (num_cnodes <= 0) {
return NULL;
}
- head = vmalloc(num_cnodes * sizeof(struct reiserfs_journal_cnode));
+ head = vzalloc(num_cnodes * sizeof(struct reiserfs_journal_cnode));
if (!head) {
return NULL;
}
- memset(head, 0, num_cnodes * sizeof(struct reiserfs_journal_cnode));
head[0].prev = NULL;
head[0].next = head + 1;
for (i = 1; i < num_cnodes; i++) {
@@ -2703,14 +2701,13 @@ int journal_init(struct super_block *sb, const char *j_dev_name,
* dependency inversion warnings.
*/
reiserfs_write_unlock(sb);
- journal = SB_JOURNAL(sb) = vmalloc(sizeof(struct reiserfs_journal));
+ journal = SB_JOURNAL(sb) = vzalloc(sizeof(struct reiserfs_journal));
if (!journal) {
reiserfs_warning(sb, "journal-1256",
"unable to get memory for journal structure");
reiserfs_write_lock(sb);
return 1;
}
- memset(journal, 0, sizeof(struct reiserfs_journal));
INIT_LIST_HEAD(&journal->j_bitmap_nodes);
INIT_LIST_HEAD(&journal->j_prealloc_list);
INIT_LIST_HEAD(&journal->j_working_list);
diff --git a/fs/reiserfs/resize.c b/fs/reiserfs/resize.c
index b3a94d2..cfb5196 100644
--- a/fs/reiserfs/resize.c
+++ b/fs/reiserfs/resize.c
@@ -111,15 +111,13 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new)
/* allocate additional bitmap blocks, reallocate array of bitmap
* block pointers */
bitmap =
- vmalloc(sizeof(struct reiserfs_bitmap_info) * bmap_nr_new);
+ vzalloc(sizeof(struct reiserfs_bitmap_info) * bmap_nr_new);
if (!bitmap) {
/* Journal bitmaps are still supersized, but the memory isn't
* leaked, so I guess it's ok */
printk("reiserfs_resize: unable to allocate memory.\n");
return -ENOMEM;
}
- memset(bitmap, 0,
- sizeof(struct reiserfs_bitmap_info) * bmap_nr_new);
for (i = 0; i < bmap_nr; i++)
bitmap[i] = old_bitmap[i];

--
1.7.3.1.g432b3.dirty

2010-11-05 03:10:59

by Joe Perches

[permalink] [raw]
Subject: [PATCH 45/49] net/core/pktgen.c: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
net/core/pktgen.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index fbce4b0..ccca6cd 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -3706,13 +3706,12 @@ static int pktgen_add_device(struct pktgen_thread *t, const char *ifname)
return -ENOMEM;

strcpy(pkt_dev->odevname, ifname);
- pkt_dev->flows = vmalloc_node(MAX_CFLOWS * sizeof(struct flow_state),
+ pkt_dev->flows = vzalloc_node(MAX_CFLOWS * sizeof(struct flow_state),
node);
if (pkt_dev->flows == NULL) {
kfree(pkt_dev);
return -ENOMEM;
}
- memset(pkt_dev->flows, 0, MAX_CFLOWS * sizeof(struct flow_state));

pkt_dev->removal_mark = 0;
pkt_dev->min_pkt_size = ETH_ZLEN;
--
1.7.3.1.g432b3.dirty

2010-11-05 03:11:53

by Joe Perches

[permalink] [raw]
Subject: [PATCH 37/49] fs/ext4: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
fs/ext4/super.c | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 40131b7..9ed90f4 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1909,9 +1909,7 @@ static int ext4_fill_flex_info(struct super_block *sb)
size = flex_group_count * sizeof(struct flex_groups);
sbi->s_flex_groups = kzalloc(size, GFP_KERNEL);
if (sbi->s_flex_groups == NULL) {
- sbi->s_flex_groups = vmalloc(size);
- if (sbi->s_flex_groups)
- memset(sbi->s_flex_groups, 0, size);
+ sbi->s_flex_groups = vzalloc(size);
}
if (sbi->s_flex_groups == NULL) {
ext4_msg(sb, KERN_ERR, "not enough memory for "
--
1.7.3.1.g432b3.dirty

2010-11-05 03:12:04

by Joe Perches

[permalink] [raw]
Subject: [PATCH 36/49] drivers/video: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
drivers/video/arcfb.c | 5 ++---
drivers/video/broadsheetfb.c | 4 +---
drivers/video/hecubafb.c | 5 ++---
drivers/video/metronomefb.c | 4 +---
drivers/video/xen-fbfront.c | 3 +--
5 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/video/arcfb.c b/drivers/video/arcfb.c
index 3ec4923..86573e2 100644
--- a/drivers/video/arcfb.c
+++ b/drivers/video/arcfb.c
@@ -515,11 +515,10 @@ static int __devinit arcfb_probe(struct platform_device *dev)

/* We need a flat backing store for the Arc's
less-flat actual paged framebuffer */
- if (!(videomemory = vmalloc(videomemorysize)))
+ videomemory = vmalloc(videomemorysize);
+ if (!videomemory)
return retval;

- memset(videomemory, 0, videomemorysize);
-
info = framebuffer_alloc(sizeof(struct arcfb_par), &dev->dev);
if (!info)
goto err;
diff --git a/drivers/video/broadsheetfb.c b/drivers/video/broadsheetfb.c
index ebda687..377dde3 100644
--- a/drivers/video/broadsheetfb.c
+++ b/drivers/video/broadsheetfb.c
@@ -1101,12 +1101,10 @@ static int __devinit broadsheetfb_probe(struct platform_device *dev)

videomemorysize = roundup((dpyw*dpyh), PAGE_SIZE);

- videomemory = vmalloc(videomemorysize);
+ videomemory = vzalloc(videomemorysize);
if (!videomemory)
goto err_fb_rel;

- memset(videomemory, 0, videomemorysize);
-
info->screen_base = (char *)videomemory;
info->fbops = &broadsheetfb_ops;

diff --git a/drivers/video/hecubafb.c b/drivers/video/hecubafb.c
index c77bcc6..a941e6f 100644
--- a/drivers/video/hecubafb.c
+++ b/drivers/video/hecubafb.c
@@ -231,11 +231,10 @@ static int __devinit hecubafb_probe(struct platform_device *dev)

videomemorysize = (DPY_W*DPY_H)/8;

- if (!(videomemory = vmalloc(videomemorysize)))
+ videomemory = vzalloc(videomemorysize);
+ if (!videomemory)
return retval;

- memset(videomemory, 0, videomemorysize);
-
info = framebuffer_alloc(sizeof(struct hecubafb_par), &dev->dev);
if (!info)
goto err_fballoc;
diff --git a/drivers/video/metronomefb.c b/drivers/video/metronomefb.c
index 63ed3b7..c0c358c 100644
--- a/drivers/video/metronomefb.c
+++ b/drivers/video/metronomefb.c
@@ -628,12 +628,10 @@ static int __devinit metronomefb_probe(struct platform_device *dev)
/* we need to add a spare page because our csum caching scheme walks
* to the end of the page */
videomemorysize = PAGE_SIZE + (fw * fh);
- videomemory = vmalloc(videomemorysize);
+ videomemory = vzalloc(videomemorysize);
if (!videomemory)
goto err_fb_rel;

- memset(videomemory, 0, videomemorysize);
-
info->screen_base = (char __force __iomem *)videomemory;
info->fbops = &metronomefb_ops;

diff --git a/drivers/video/xen-fbfront.c b/drivers/video/xen-fbfront.c
index 428d273..81fcaea 100644
--- a/drivers/video/xen-fbfront.c
+++ b/drivers/video/xen-fbfront.c
@@ -395,10 +395,9 @@ static int __devinit xenfb_probe(struct xenbus_device *dev,
spin_lock_init(&info->dirty_lock);
spin_lock_init(&info->resize_lock);

- info->fb = vmalloc(fb_size);
+ info->fb = vzalloc(fb_size);
if (info->fb == NULL)
goto error_nomem;
- memset(info->fb, 0, fb_size);

info->nr_pages = (fb_size + PAGE_SIZE - 1) >> PAGE_SHIFT;

--
1.7.3.1.g432b3.dirty

2010-11-05 03:12:44

by Joe Perches

[permalink] [raw]
Subject: [PATCH 33/49] drivers/s390: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
drivers/s390/cio/blacklist.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/s390/cio/blacklist.c b/drivers/s390/cio/blacklist.c
index 76058a5..08c6603 100644
--- a/drivers/s390/cio/blacklist.c
+++ b/drivers/s390/cio/blacklist.c
@@ -335,10 +335,9 @@ cio_ignore_write(struct file *file, const char __user *user_buf,
return -EINVAL;
if (user_len > 65536)
user_len = 65536;
- buf = vmalloc (user_len + 1); /* maybe better use the stack? */
+ buf = vzalloc(user_len + 1); /* maybe better use the stack? */
if (buf == NULL)
return -ENOMEM;
- memset(buf, 0, user_len + 1);

if (strncpy_from_user (buf, user_buf, user_len) < 0) {
rc = -EFAULT;
--
1.7.3.1.g432b3.dirty

2010-11-05 03:12:46

by Joe Perches

[permalink] [raw]
Subject: [PATCH 32/49] drivers/net/bnx2.c: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
drivers/net/bnx2.c | 10 ++--------
1 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 062600b..aba4d0f 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -766,13 +766,10 @@ bnx2_alloc_rx_mem(struct bnx2 *bp)
int j;

rxr->rx_buf_ring =
- vmalloc(SW_RXBD_RING_SIZE * bp->rx_max_ring);
+ vzalloc(SW_RXBD_RING_SIZE * bp->rx_max_ring);
if (rxr->rx_buf_ring == NULL)
return -ENOMEM;

- memset(rxr->rx_buf_ring, 0,
- SW_RXBD_RING_SIZE * bp->rx_max_ring);
-
for (j = 0; j < bp->rx_max_ring; j++) {
rxr->rx_desc_ring[j] =
dma_alloc_coherent(&bp->pdev->dev,
@@ -785,13 +782,10 @@ bnx2_alloc_rx_mem(struct bnx2 *bp)
}

if (bp->rx_pg_ring_size) {
- rxr->rx_pg_ring = vmalloc(SW_RXPG_RING_SIZE *
+ rxr->rx_pg_ring = vzalloc(SW_RXPG_RING_SIZE *
bp->rx_max_pg_ring);
if (rxr->rx_pg_ring == NULL)
return -ENOMEM;
-
- memset(rxr->rx_pg_ring, 0, SW_RXPG_RING_SIZE *
- bp->rx_max_pg_ring);
}

for (j = 0; j < bp->rx_max_pg_ring; j++) {
--
1.7.3.1.g432b3.dirty

2010-11-05 03:09:02

by Joe Perches

[permalink] [raw]
Subject: [PATCH 31/49] drivers/net/vxge: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
drivers/net/vxge/vxge-config.c | 37 +++++++++----------------------------
1 files changed, 9 insertions(+), 28 deletions(-)

diff --git a/drivers/net/vxge/vxge-config.c b/drivers/net/vxge/vxge-config.c
index 906a3ca3..0c0a4e4 100644
--- a/drivers/net/vxge/vxge-config.c
+++ b/drivers/net/vxge/vxge-config.c
@@ -776,14 +776,12 @@ vxge_hw_device_initialize(
if (status != VXGE_HW_OK)
goto exit;

- hldev = (struct __vxge_hw_device *)
- vmalloc(sizeof(struct __vxge_hw_device));
+ hldev = vzalloc(sizeof(struct __vxge_hw_device));
if (hldev == NULL) {
status = VXGE_HW_ERR_OUT_OF_MEMORY;
goto exit;
}

- memset(hldev, 0, sizeof(struct __vxge_hw_device));
hldev->magic = VXGE_HW_DEVICE_MAGIC;

vxge_hw_device_debug_set(hldev, VXGE_ERR, VXGE_COMPONENT_ALL);
@@ -1627,15 +1625,12 @@ __vxge_hw_mempool_grow(struct vxge_hw_mempool *mempool, u32 num_allocate,
* allocate new memblock and its private part at once.
* This helps to minimize memory usage a lot. */
mempool->memblocks_priv_arr[i] =
- vmalloc(mempool->items_priv_size * n_items);
+ vzalloc(mempool->items_priv_size * n_items);
if (mempool->memblocks_priv_arr[i] == NULL) {
status = VXGE_HW_ERR_OUT_OF_MEMORY;
goto exit;
}

- memset(mempool->memblocks_priv_arr[i], 0,
- mempool->items_priv_size * n_items);
-
/* allocate DMA-capable memblock */
mempool->memblocks_arr[i] =
__vxge_hw_blockpool_malloc(mempool->devh,
@@ -1707,13 +1702,11 @@ __vxge_hw_mempool_create(
goto exit;
}

- mempool = (struct vxge_hw_mempool *)
- vmalloc(sizeof(struct vxge_hw_mempool));
+ mempool = vzalloc(sizeof(struct vxge_hw_mempool));
if (mempool == NULL) {
status = VXGE_HW_ERR_OUT_OF_MEMORY;
goto exit;
}
- memset(mempool, 0, sizeof(struct vxge_hw_mempool));

mempool->devh = devh;
mempool->memblock_size = memblock_size;
@@ -1733,31 +1726,27 @@ __vxge_hw_mempool_create(

/* allocate array of memblocks */
mempool->memblocks_arr =
- (void **) vmalloc(sizeof(void *) * mempool->memblocks_max);
+ vzalloc(sizeof(void *) * mempool->memblocks_max);
if (mempool->memblocks_arr == NULL) {
__vxge_hw_mempool_destroy(mempool);
status = VXGE_HW_ERR_OUT_OF_MEMORY;
mempool = NULL;
goto exit;
}
- memset(mempool->memblocks_arr, 0,
- sizeof(void *) * mempool->memblocks_max);

/* allocate array of private parts of items per memblocks */
mempool->memblocks_priv_arr =
- (void **) vmalloc(sizeof(void *) * mempool->memblocks_max);
+ vzalloc(sizeof(void *) * mempool->memblocks_max);
if (mempool->memblocks_priv_arr == NULL) {
__vxge_hw_mempool_destroy(mempool);
status = VXGE_HW_ERR_OUT_OF_MEMORY;
mempool = NULL;
goto exit;
}
- memset(mempool->memblocks_priv_arr, 0,
- sizeof(void *) * mempool->memblocks_max);

/* allocate array of memblocks DMA objects */
- mempool->memblocks_dma_arr = (struct vxge_hw_mempool_dma *)
- vmalloc(sizeof(struct vxge_hw_mempool_dma) *
+ mempool->memblocks_dma_arr =
+ vzalloc(sizeof(struct vxge_hw_mempool_dma) *
mempool->memblocks_max);

if (mempool->memblocks_dma_arr == NULL) {
@@ -1766,20 +1755,15 @@ __vxge_hw_mempool_create(
mempool = NULL;
goto exit;
}
- memset(mempool->memblocks_dma_arr, 0,
- sizeof(struct vxge_hw_mempool_dma) *
- mempool->memblocks_max);

/* allocate hash array of items */
- mempool->items_arr =
- (void **) vmalloc(sizeof(void *) * mempool->items_max);
+ mempool->items_arr = vzalloc(sizeof(void *) * mempool->items_max);
if (mempool->items_arr == NULL) {
__vxge_hw_mempool_destroy(mempool);
status = VXGE_HW_ERR_OUT_OF_MEMORY;
mempool = NULL;
goto exit;
}
- memset(mempool->items_arr, 0, sizeof(void *) * mempool->items_max);

/* calculate initial number of memblocks */
memblocks_to_allocate = (mempool->items_initial +
@@ -4242,15 +4226,12 @@ vxge_hw_vpath_open(struct __vxge_hw_device *hldev,
if (status != VXGE_HW_OK)
goto vpath_open_exit1;

- vp = (struct __vxge_hw_vpath_handle *)
- vmalloc(sizeof(struct __vxge_hw_vpath_handle));
+ vp = vzalloc(sizeof(struct __vxge_hw_vpath_handle));
if (vp == NULL) {
status = VXGE_HW_ERR_OUT_OF_MEMORY;
goto vpath_open_exit2;
}

- memset(vp, 0, sizeof(struct __vxge_hw_vpath_handle));
-
vp->vpath = vpath;

if (vpath->vp_config->fifo.enable == VXGE_HW_FIFO_ENABLE) {
--
1.7.3.1.g432b3.dirty

2010-11-05 03:12:27

by Joe Perches

[permalink] [raw]
Subject: [PATCH 34/49] drivers/scsi: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
drivers/scsi/bfa/bfad.c | 3 +--
drivers/scsi/bfa/bfad_debugfs.c | 8 ++------
drivers/scsi/cxgbi/libcxgbi.h | 9 +++------
drivers/scsi/osst.c | 3 +--
drivers/scsi/qla2xxx/qla_attr.c | 3 +--
drivers/scsi/qla2xxx/qla_bsg.c | 3 +--
drivers/scsi/scsi_debug.c | 7 ++-----
7 files changed, 11 insertions(+), 25 deletions(-)

diff --git a/drivers/scsi/bfa/bfad.c b/drivers/scsi/bfa/bfad.c
index 1f93897..10dc5d2 100644
--- a/drivers/scsi/bfa/bfad.c
+++ b/drivers/scsi/bfa/bfad.c
@@ -600,13 +600,12 @@ retry:
meminfo_elem = &hal_meminfo->meminfo[i];
switch (meminfo_elem->mem_type) {
case BFA_MEM_TYPE_KVA:
- kva = vmalloc(meminfo_elem->mem_len);
+ kva = vzalloc(meminfo_elem->mem_len);
if (kva == NULL) {
bfad_hal_mem_release(bfad);
rc = BFA_STATUS_ENOMEM;
goto ext;
}
- memset(kva, 0, meminfo_elem->mem_len);
meminfo_elem->kva = kva;
break;
case BFA_MEM_TYPE_DMA:
diff --git a/drivers/scsi/bfa/bfad_debugfs.c b/drivers/scsi/bfa/bfad_debugfs.c
index 1fedeeb..0f7af51 100644
--- a/drivers/scsi/bfa/bfad_debugfs.c
+++ b/drivers/scsi/bfa/bfad_debugfs.c
@@ -79,7 +79,7 @@ bfad_debugfs_open_fwtrc(struct inode *inode, struct file *file)

fw_debug->buffer_len = sizeof(struct bfa_trc_mod_s);

- fw_debug->debug_buffer = vmalloc(fw_debug->buffer_len);
+ fw_debug->debug_buffer = vzalloc(fw_debug->buffer_len);
if (!fw_debug->debug_buffer) {
kfree(fw_debug);
printk(KERN_INFO "bfad[%d]: Failed to allocate fwtrc buffer\n",
@@ -87,8 +87,6 @@ bfad_debugfs_open_fwtrc(struct inode *inode, struct file *file)
return -ENOMEM;
}

- memset(fw_debug->debug_buffer, 0, fw_debug->buffer_len);
-
spin_lock_irqsave(&bfad->bfad_lock, flags);
rc = bfa_debug_fwtrc(&bfad->bfa,
fw_debug->debug_buffer,
@@ -123,7 +121,7 @@ bfad_debugfs_open_fwsave(struct inode *inode, struct file *file)

fw_debug->buffer_len = sizeof(struct bfa_trc_mod_s);

- fw_debug->debug_buffer = vmalloc(fw_debug->buffer_len);
+ fw_debug->debug_buffer = vzalloc(fw_debug->buffer_len);
if (!fw_debug->debug_buffer) {
kfree(fw_debug);
printk(KERN_INFO "bfad[%d]: Failed to allocate fwsave buffer\n",
@@ -131,8 +129,6 @@ bfad_debugfs_open_fwsave(struct inode *inode, struct file *file)
return -ENOMEM;
}

- memset(fw_debug->debug_buffer, 0, fw_debug->buffer_len);
-
spin_lock_irqsave(&bfad->bfad_lock, flags);
rc = bfa_debug_fwsave(&bfad->bfa,
fw_debug->debug_buffer,
diff --git a/drivers/scsi/cxgbi/libcxgbi.h b/drivers/scsi/cxgbi/libcxgbi.h
index c57d59d..7627e37 100644
--- a/drivers/scsi/cxgbi/libcxgbi.h
+++ b/drivers/scsi/cxgbi/libcxgbi.h
@@ -658,14 +658,11 @@ static inline u32 cxgbi_tag_nonrsvd_bits(struct cxgbi_tag_format *tformat,
return v1 | v2;
}

-static inline void *cxgbi_alloc_big_mem(unsigned int size,
- gfp_t gfp)
+static inline void *cxgbi_alloc_big_mem(unsigned int size, gfp_t gfp)
{
- void *p = kmalloc(size, gfp);
+ void *p = kzalloc(size, gfp);
if (!p)
- p = vmalloc(size);
- if (p)
- memset(p, 0, size);
+ p = vzalloc(size);
return p;
}

diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index 54de1d1..02bc1cc 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -2296,11 +2296,10 @@ static int osst_write_header(struct osst_tape * STp, struct osst_request ** aSRp
if (STp->raw) return 0;

if (STp->header_cache == NULL) {
- if ((STp->header_cache = (os_header_t *)vmalloc(sizeof(os_header_t))) == NULL) {
+ if ((STp->header_cache = vzalloc(sizeof(os_header_t))) == NULL) {
printk(KERN_ERR "%s:E: Failed to allocate header cache\n", name);
return (-ENOMEM);
}
- memset(STp->header_cache, 0, sizeof(os_header_t));
#if DEBUG
printk(OSST_DEB_MSG "%s:D: Allocated and cleared memory for header cache\n", name);
#endif
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index bc8194f..7151b04 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -271,7 +271,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,
ha->optrom_size - start : size;

ha->optrom_state = QLA_SREADING;
- ha->optrom_buffer = vmalloc(ha->optrom_region_size);
+ ha->optrom_buffer = vzalloc(ha->optrom_region_size);
if (ha->optrom_buffer == NULL) {
qla_printk(KERN_WARNING, ha,
"Unable to allocate memory for optrom retrieval "
@@ -291,7 +291,6 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,
"Reading flash region -- 0x%x/0x%x.\n",
ha->optrom_region_start, ha->optrom_region_size));

- memset(ha->optrom_buffer, 0, ha->optrom_region_size);
ha->isp_ops->read_optrom(vha, ha->optrom_buffer,
ha->optrom_region_start, ha->optrom_region_size);
break;
diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c
index 31a4121..27f7f79 100644
--- a/drivers/scsi/qla2xxx/qla_bsg.c
+++ b/drivers/scsi/qla2xxx/qla_bsg.c
@@ -1356,7 +1356,7 @@ qla2x00_optrom_setup(struct fc_bsg_job *bsg_job, struct qla_hw_data *ha,
ha->optrom_state = QLA_SREADING;
}

- ha->optrom_buffer = vmalloc(ha->optrom_region_size);
+ ha->optrom_buffer = vzalloc(ha->optrom_region_size);
if (!ha->optrom_buffer) {
qla_printk(KERN_WARNING, ha,
"Read: Unable to allocate memory for optrom retrieval "
@@ -1366,7 +1366,6 @@ qla2x00_optrom_setup(struct fc_bsg_job *bsg_job, struct qla_hw_data *ha,
return -ENOMEM;
}

- memset(ha->optrom_buffer, 0, ha->optrom_region_size);
return 0;
}

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 2c36bae..e6aaad4 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -3305,12 +3305,11 @@ static int __init scsi_debug_init(void)
(sdebug_sectors_per * sdebug_heads);
}

- fake_storep = vmalloc(sz);
+ fake_storep = vzalloc(sz);
if (NULL == fake_storep) {
printk(KERN_ERR "scsi_debug_init: out of memory, 1\n");
return -ENOMEM;
}
- memset(fake_storep, 0, sz);
if (scsi_debug_num_parts > 0)
sdebug_build_parts(fake_storep, sz);

@@ -3355,7 +3354,7 @@ static int __init scsi_debug_init(void)

map_size = (sdebug_store_sectors / scsi_debug_unmap_granularity);
map_bytes = map_size >> 3;
- map_storep = vmalloc(map_bytes);
+ map_storep = vzalloc(map_bytes);

printk(KERN_INFO "scsi_debug_init: %lu provisioning blocks\n",
map_size);
@@ -3366,8 +3365,6 @@ static int __init scsi_debug_init(void)
goto free_vm;
}

- memset(map_storep, 0x0, map_bytes);
-
/* Map first 1KB for partition table */
if (scsi_debug_num_parts)
map_region(0, 2);
--
1.7.3.1.g432b3.dirty

2010-11-05 03:13:43

by Joe Perches

[permalink] [raw]
Subject: [PATCH 29/49] drivers/net/qlcnic: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
drivers/net/qlcnic/qlcnic_init.c | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/qlcnic/qlcnic_init.c b/drivers/net/qlcnic/qlcnic_init.c
index 0d180c6..c5ea2f4 100644
--- a/drivers/net/qlcnic/qlcnic_init.c
+++ b/drivers/net/qlcnic/qlcnic_init.c
@@ -236,12 +236,11 @@ int qlcnic_alloc_sw_resources(struct qlcnic_adapter *adapter)
tx_ring->num_desc = adapter->num_txd;
tx_ring->txq = netdev_get_tx_queue(netdev, 0);

- cmd_buf_arr = vmalloc(TX_BUFF_RINGSIZE(tx_ring));
+ cmd_buf_arr = vzalloc(TX_BUFF_RINGSIZE(tx_ring));
if (cmd_buf_arr == NULL) {
dev_err(&netdev->dev, "failed to allocate cmd buffer ring\n");
goto err_out;
}
- memset(cmd_buf_arr, 0, TX_BUFF_RINGSIZE(tx_ring));
tx_ring->cmd_buf_arr = cmd_buf_arr;

recv_ctx = &adapter->recv_ctx;
@@ -275,14 +274,12 @@ int qlcnic_alloc_sw_resources(struct qlcnic_adapter *adapter)
rds_ring->dma_size + NET_IP_ALIGN;
break;
}
- rds_ring->rx_buf_arr = (struct qlcnic_rx_buffer *)
- vmalloc(RCV_BUFF_RINGSIZE(rds_ring));
+ rds_ring->rx_buf_arr = vzalloc(RCV_BUFF_RINGSIZE(rds_ring));
if (rds_ring->rx_buf_arr == NULL) {
dev_err(&netdev->dev, "Failed to allocate "
"rx buffer ring %d\n", ring);
goto err_out;
}
- memset(rds_ring->rx_buf_arr, 0, RCV_BUFF_RINGSIZE(rds_ring));
INIT_LIST_HEAD(&rds_ring->free_list);
/*
* Now go through all of them, set reference handles
--
1.7.3.1.g432b3.dirty

2010-11-05 03:13:44

by Joe Perches

[permalink] [raw]
Subject: [PATCH 27/49] drivers/net/netxen: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
drivers/net/netxen/netxen_nic_init.c | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index 95fe552..731077d 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -214,13 +214,12 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter)
tx_ring->num_desc = adapter->num_txd;
tx_ring->txq = netdev_get_tx_queue(netdev, 0);

- cmd_buf_arr = vmalloc(TX_BUFF_RINGSIZE(tx_ring));
+ cmd_buf_arr = vzalloc(TX_BUFF_RINGSIZE(tx_ring));
if (cmd_buf_arr == NULL) {
dev_err(&pdev->dev, "%s: failed to allocate cmd buffer ring\n",
netdev->name);
goto err_out;
}
- memset(cmd_buf_arr, 0, TX_BUFF_RINGSIZE(tx_ring));
tx_ring->cmd_buf_arr = cmd_buf_arr;

recv_ctx = &adapter->recv_ctx;
@@ -279,8 +278,7 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter)
break;

}
- rds_ring->rx_buf_arr = (struct netxen_rx_buffer *)
- vmalloc(RCV_BUFF_RINGSIZE(rds_ring));
+ rds_ring->rx_buf_arr = vzalloc(RCV_BUFF_RINGSIZE(rds_ring));
if (rds_ring->rx_buf_arr == NULL) {
printk(KERN_ERR "%s: Failed to allocate "
"rx buffer ring %d\n",
@@ -288,7 +286,6 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter)
/* free whatever was already allocated */
goto err_out;
}
- memset(rds_ring->rx_buf_arr, 0, RCV_BUFF_RINGSIZE(rds_ring));
INIT_LIST_HEAD(&rds_ring->free_list);
/*
* Now go through all of them, set reference handles
--
1.7.3.1.g432b3.dirty

2010-11-05 03:08:55

by Joe Perches

[permalink] [raw]
Subject: [PATCH 20/49] drivers/net/e1000e: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
drivers/net/e1000e/netdev.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index c4ca162..9922edb 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -2059,10 +2059,9 @@ int e1000e_setup_tx_resources(struct e1000_adapter *adapter)
int err = -ENOMEM, size;

size = sizeof(struct e1000_buffer) * tx_ring->count;
- tx_ring->buffer_info = vmalloc(size);
+ tx_ring->buffer_info = vzalloc(size);
if (!tx_ring->buffer_info)
goto err;
- memset(tx_ring->buffer_info, 0, size);

/* round up to nearest 4K */
tx_ring->size = tx_ring->count * sizeof(struct e1000_tx_desc);
@@ -2095,10 +2094,9 @@ int e1000e_setup_rx_resources(struct e1000_adapter *adapter)
int i, size, desc_len, err = -ENOMEM;

size = sizeof(struct e1000_buffer) * rx_ring->count;
- rx_ring->buffer_info = vmalloc(size);
+ rx_ring->buffer_info = vzalloc(size);
if (!rx_ring->buffer_info)
goto err;
- memset(rx_ring->buffer_info, 0, size);

for (i = 0; i < rx_ring->count; i++) {
buffer_info = &rx_ring->buffer_info[i];
--
1.7.3.1.g432b3.dirty

2010-11-05 03:08:57

by Joe Perches

[permalink] [raw]
Subject: [PATCH 21/49] drivers/net/ehea: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
drivers/net/ehea/ehea_main.c | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index 182b2a7..a84c389 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -1496,12 +1496,10 @@ static int ehea_init_q_skba(struct ehea_q_skb_arr *q_skba, int max_q_entries)
{
int arr_size = sizeof(void *) * max_q_entries;

- q_skba->arr = vmalloc(arr_size);
+ q_skba->arr = vzalloc(arr_size);
if (!q_skba->arr)
return -ENOMEM;

- memset(q_skba->arr, 0, arr_size);
-
q_skba->len = max_q_entries;
q_skba->index = 0;
q_skba->os_skbs = 0;
--
1.7.3.1.g432b3.dirty

2010-11-05 03:13:19

by Joe Perches

[permalink] [raw]
Subject: [PATCH 30/49] drivers/net/sfc: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
drivers/net/sfc/filter.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/net/sfc/filter.c b/drivers/net/sfc/filter.c
index 52cb608..44500b5 100644
--- a/drivers/net/sfc/filter.c
+++ b/drivers/net/sfc/filter.c
@@ -428,10 +428,9 @@ int efx_probe_filters(struct efx_nic *efx)
GFP_KERNEL);
if (!table->used_bitmap)
goto fail;
- table->spec = vmalloc(table->size * sizeof(*table->spec));
+ table->spec = vzalloc(table->size * sizeof(*table->spec));
if (!table->spec)
goto fail;
- memset(table->spec, 0, table->size * sizeof(*table->spec));
}

return 0;
--
1.7.3.1.g432b3.dirty

2010-11-05 03:08:53

by Joe Perches

[permalink] [raw]
Subject: [PATCH 17/49] drivers/net/cxgb3: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
drivers/net/cxgb3/cxgb3_offload.c | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/cxgb3/cxgb3_offload.c b/drivers/net/cxgb3/cxgb3_offload.c
index bcf0753..5e632e2 100644
--- a/drivers/net/cxgb3/cxgb3_offload.c
+++ b/drivers/net/cxgb3/cxgb3_offload.c
@@ -1164,12 +1164,11 @@ static void cxgb_redirect(struct dst_entry *old, struct dst_entry *new)
*/
void *cxgb_alloc_mem(unsigned long size)
{
- void *p = kmalloc(size, GFP_KERNEL);
+ void *p = kzalloc(size, GFP_KERNEL);

if (!p)
- p = vmalloc(size);
- if (p)
- memset(p, 0, size);
+ p = vzalloc(size);
+
return p;
}

--
1.7.3.1.g432b3.dirty

2010-11-05 03:14:19

by Joe Perches

[permalink] [raw]
Subject: [PATCH 26/49] drivers/net/ixgbevf: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
drivers/net/ixgbevf/ixgbevf_main.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ixgbevf/ixgbevf_main.c b/drivers/net/ixgbevf/ixgbevf_main.c
index dc03c96..6aeaf54 100644
--- a/drivers/net/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ixgbevf/ixgbevf_main.c
@@ -2488,10 +2488,9 @@ int ixgbevf_setup_tx_resources(struct ixgbevf_adapter *adapter,
int size;

size = sizeof(struct ixgbevf_tx_buffer) * tx_ring->count;
- tx_ring->tx_buffer_info = vmalloc(size);
+ tx_ring->tx_buffer_info = vzalloc(size);
if (!tx_ring->tx_buffer_info)
goto err;
- memset(tx_ring->tx_buffer_info, 0, size);

/* round up to nearest 4K */
tx_ring->size = tx_ring->count * sizeof(union ixgbe_adv_tx_desc);
@@ -2555,14 +2554,13 @@ int ixgbevf_setup_rx_resources(struct ixgbevf_adapter *adapter,
int size;

size = sizeof(struct ixgbevf_rx_buffer) * rx_ring->count;
- rx_ring->rx_buffer_info = vmalloc(size);
+ rx_ring->rx_buffer_info = vzalloc(size);
if (!rx_ring->rx_buffer_info) {
hw_dbg(&adapter->hw,
"Unable to vmalloc buffer memory for "
"the receive descriptor ring\n");
goto alloc_failed;
}
- memset(rx_ring->rx_buffer_info, 0, size);

/* Round up to nearest 4K */
rx_ring->size = rx_ring->count * sizeof(union ixgbe_adv_rx_desc);
--
1.7.3.1.g432b3.dirty

2010-11-05 03:14:42

by Joe Perches

[permalink] [raw]
Subject: [PATCH 25/49] drivers/net/ixgbe: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
drivers/net/ixgbe/ixgbe_main.c | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index 2bd3eb4..c10d179 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -4970,12 +4970,11 @@ int ixgbe_setup_tx_resources(struct ixgbe_adapter *adapter,
int size;

size = sizeof(struct ixgbe_tx_buffer) * tx_ring->count;
- tx_ring->tx_buffer_info = vmalloc_node(size, tx_ring->numa_node);
+ tx_ring->tx_buffer_info = vzalloc_node(size, tx_ring->numa_node);
if (!tx_ring->tx_buffer_info)
- tx_ring->tx_buffer_info = vmalloc(size);
+ tx_ring->tx_buffer_info = vzalloc(size);
if (!tx_ring->tx_buffer_info)
goto err;
- memset(tx_ring->tx_buffer_info, 0, size);

/* round up to nearest 4K */
tx_ring->size = tx_ring->count * sizeof(union ixgbe_adv_tx_desc);
@@ -5037,15 +5036,14 @@ int ixgbe_setup_rx_resources(struct ixgbe_adapter *adapter,
int size;

size = sizeof(struct ixgbe_rx_buffer) * rx_ring->count;
- rx_ring->rx_buffer_info = vmalloc_node(size, adapter->node);
+ rx_ring->rx_buffer_info = vzalloc_node(size, adapter->node);
if (!rx_ring->rx_buffer_info)
- rx_ring->rx_buffer_info = vmalloc(size);
+ rx_ring->rx_buffer_info = vzalloc(size);
if (!rx_ring->rx_buffer_info) {
e_err(probe, "vmalloc allocation failed for the Rx "
"descriptor ring\n");
goto alloc_failed;
}
- memset(rx_ring->rx_buffer_info, 0, size);

/* Round up to nearest 4K */
rx_ring->size = rx_ring->count * sizeof(union ixgbe_adv_rx_desc);
--
1.7.3.1.g432b3.dirty

2010-11-05 03:14:44

by Joe Perches

[permalink] [raw]
Subject: [PATCH 24/49] drivers/net/ixgb: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
drivers/net/ixgb/ixgb_main.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
index caa8192..211a169 100644
--- a/drivers/net/ixgb/ixgb_main.c
+++ b/drivers/net/ixgb/ixgb_main.c
@@ -669,13 +669,12 @@ ixgb_setup_tx_resources(struct ixgb_adapter *adapter)
int size;

size = sizeof(struct ixgb_buffer) * txdr->count;
- txdr->buffer_info = vmalloc(size);
+ txdr->buffer_info = vzalloc(size);
if (!txdr->buffer_info) {
netif_err(adapter, probe, adapter->netdev,
"Unable to allocate transmit descriptor ring memory\n");
return -ENOMEM;
}
- memset(txdr->buffer_info, 0, size);

/* round up to nearest 4K */

@@ -759,13 +758,12 @@ ixgb_setup_rx_resources(struct ixgb_adapter *adapter)
int size;

size = sizeof(struct ixgb_buffer) * rxdr->count;
- rxdr->buffer_info = vmalloc(size);
+ rxdr->buffer_info = vzalloc(size);
if (!rxdr->buffer_info) {
netif_err(adapter, probe, adapter->netdev,
"Unable to allocate receive descriptor ring\n");
return -ENOMEM;
}
- memset(rxdr->buffer_info, 0, size);

/* Round up to nearest 4K */

--
1.7.3.1.g432b3.dirty

2010-11-05 03:08:50

by Joe Perches

[permalink] [raw]
Subject: [PATCH 15/49] drivers/media: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
drivers/media/dvb/ngene/ngene-core.c | 3 +--
drivers/media/video/mx3_camera.c | 3 +--
drivers/media/video/pwc/pwc-if.c | 3 +--
drivers/media/video/videobuf-dma-sg.c | 3 +--
4 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/media/dvb/ngene/ngene-core.c b/drivers/media/dvb/ngene/ngene-core.c
index 4caeb16..1abc3a0 100644
--- a/drivers/media/dvb/ngene/ngene-core.c
+++ b/drivers/media/dvb/ngene/ngene-core.c
@@ -1537,12 +1537,11 @@ int __devinit ngene_probe(struct pci_dev *pci_dev,
if (pci_enable_device(pci_dev) < 0)
return -ENODEV;

- dev = vmalloc(sizeof(struct ngene));
+ dev = vzalloc(sizeof(struct ngene));
if (dev == NULL) {
stat = -ENOMEM;
goto fail0;
}
- memset(dev, 0, sizeof(struct ngene));

dev->pci_dev = pci_dev;
dev->card_info = (struct ngene_info *)id->driver_data;
diff --git a/drivers/media/video/mx3_camera.c b/drivers/media/video/mx3_camera.c
index 29c5fc3..321c3e5 100644
--- a/drivers/media/video/mx3_camera.c
+++ b/drivers/media/video/mx3_camera.c
@@ -1182,13 +1182,12 @@ static int __devinit mx3_camera_probe(struct platform_device *pdev)
goto egetres;
}

- mx3_cam = vmalloc(sizeof(*mx3_cam));
+ mx3_cam = vzalloc(sizeof(*mx3_cam));
if (!mx3_cam) {
dev_err(&pdev->dev, "Could not allocate mx3 camera object\n");
err = -ENOMEM;
goto ealloc;
}
- memset(mx3_cam, 0, sizeof(*mx3_cam));

mx3_cam->clk = clk_get(&pdev->dev, NULL);
if (IS_ERR(mx3_cam->clk)) {
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index e62beb4..fc5f02e 100644
--- a/drivers/media/video/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -288,14 +288,13 @@ static int pwc_allocate_buffers(struct pwc_device *pdev)
/* create frame buffers, and make circular ring */
for (i = 0; i < default_fbufs; i++) {
if (pdev->fbuf[i].data == NULL) {
- kbuf = vmalloc(PWC_FRAME_SIZE); /* need vmalloc since frame buffer > 128K */
+ kbuf = vzalloc(PWC_FRAME_SIZE); /* need vmalloc since frame buffer > 128K */
if (kbuf == NULL) {
PWC_ERROR("Failed to allocate frame buffer %d.\n", i);
return -ENOMEM;
}
PWC_DEBUG_MEMORY("Allocated frame buffer %d at %p.\n", i, kbuf);
pdev->fbuf[i].data = kbuf;
- memset(kbuf, 0, PWC_FRAME_SIZE);
}
}

diff --git a/drivers/media/video/videobuf-dma-sg.c b/drivers/media/video/videobuf-dma-sg.c
index 20f227e..ab684e8 100644
--- a/drivers/media/video/videobuf-dma-sg.c
+++ b/drivers/media/video/videobuf-dma-sg.c
@@ -69,10 +69,9 @@ static struct scatterlist *videobuf_vmalloc_to_sg(unsigned char *virt,
struct page *pg;
int i;

- sglist = vmalloc(nr_pages * sizeof(*sglist));
+ sglist = vzalloc(nr_pages * sizeof(*sglist));
if (NULL == sglist)
return NULL;
- memset(sglist, 0, nr_pages * sizeof(*sglist));
sg_init_table(sglist, nr_pages);
for (i = 0; i < nr_pages; i++, virt += PAGE_SIZE) {
pg = vmalloc_to_page(virt);
--
1.7.3.1.g432b3.dirty

2010-11-05 03:08:51

by Joe Perches

[permalink] [raw]
Subject: [PATCH 16/49] drivers/mtd: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
drivers/mtd/nand/nandsim.c | 3 +--
drivers/mtd/ubi/vtbl.c | 6 ++----
2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
index a6a73aa..b3d241b 100644
--- a/drivers/mtd/nand/nandsim.c
+++ b/drivers/mtd/nand/nandsim.c
@@ -470,7 +470,7 @@ static int alloc_device(struct nandsim *ns)
err = -EINVAL;
goto err_close;
}
- ns->pages_written = vmalloc(ns->geom.pgnum);
+ ns->pages_written = vzalloc(ns->geom.pgnum);
if (!ns->pages_written) {
NS_ERR("alloc_device: unable to allocate pages written array\n");
err = -ENOMEM;
@@ -483,7 +483,6 @@ static int alloc_device(struct nandsim *ns)
goto err_free;
}
ns->cfile = cfile;
- memset(ns->pages_written, 0, ns->geom.pgnum);
return 0;
}

diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
index fcdb7f6..0b8141f 100644
--- a/drivers/mtd/ubi/vtbl.c
+++ b/drivers/mtd/ubi/vtbl.c
@@ -425,12 +425,11 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi,

/* Read both LEB 0 and LEB 1 into memory */
ubi_rb_for_each_entry(rb, seb, &sv->root, u.rb) {
- leb[seb->lnum] = vmalloc(ubi->vtbl_size);
+ leb[seb->lnum] = vzalloc(ubi->vtbl_size);
if (!leb[seb->lnum]) {
err = -ENOMEM;
goto out_free;
}
- memset(leb[seb->lnum], 0, ubi->vtbl_size);

err = ubi_io_read_data(ubi, leb[seb->lnum], seb->pnum, 0,
ubi->vtbl_size);
@@ -516,10 +515,9 @@ static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi,
int i;
struct ubi_vtbl_record *vtbl;

- vtbl = vmalloc(ubi->vtbl_size);
+ vtbl = vzalloc(ubi->vtbl_size);
if (!vtbl)
return ERR_PTR(-ENOMEM);
- memset(vtbl, 0, ubi->vtbl_size);

for (i = 0; i < ubi->vtbl_slots; i++)
memcpy(&vtbl[i], &empty_vtbl_record, UBI_VTBL_RECORD_SIZE);
--
1.7.3.1.g432b3.dirty

2010-11-05 03:15:19

by Joe Perches

[permalink] [raw]
Subject: [PATCH 23/49] drivers/net/igbvf: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
drivers/net/igbvf/netdev.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/igbvf/netdev.c b/drivers/net/igbvf/netdev.c
index 28af019..08e7459 100644
--- a/drivers/net/igbvf/netdev.c
+++ b/drivers/net/igbvf/netdev.c
@@ -429,10 +429,9 @@ int igbvf_setup_tx_resources(struct igbvf_adapter *adapter,
int size;

size = sizeof(struct igbvf_buffer) * tx_ring->count;
- tx_ring->buffer_info = vmalloc(size);
+ tx_ring->buffer_info = vzalloc(size);
if (!tx_ring->buffer_info)
goto err;
- memset(tx_ring->buffer_info, 0, size);

/* round up to nearest 4K */
tx_ring->size = tx_ring->count * sizeof(union e1000_adv_tx_desc);
@@ -469,10 +468,9 @@ int igbvf_setup_rx_resources(struct igbvf_adapter *adapter,
int size, desc_len;

size = sizeof(struct igbvf_buffer) * rx_ring->count;
- rx_ring->buffer_info = vmalloc(size);
+ rx_ring->buffer_info = vzalloc(size);
if (!rx_ring->buffer_info)
goto err;
- memset(rx_ring->buffer_info, 0, size);

desc_len = sizeof(union e1000_adv_rx_desc);

--
1.7.3.1.g432b3.dirty

2010-11-05 03:15:47

by Joe Perches

[permalink] [raw]
Subject: [PATCH 22/49] drivers/net/igb: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
drivers/net/igb/igb_main.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index 892d196..67ea262 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -2436,10 +2436,9 @@ int igb_setup_tx_resources(struct igb_ring *tx_ring)
int size;

size = sizeof(struct igb_buffer) * tx_ring->count;
- tx_ring->buffer_info = vmalloc(size);
+ tx_ring->buffer_info = vzalloc(size);
if (!tx_ring->buffer_info)
goto err;
- memset(tx_ring->buffer_info, 0, size);

/* round up to nearest 4K */
tx_ring->size = tx_ring->count * sizeof(union e1000_adv_tx_desc);
@@ -2587,10 +2586,9 @@ int igb_setup_rx_resources(struct igb_ring *rx_ring)
int size, desc_len;

size = sizeof(struct igb_buffer) * rx_ring->count;
- rx_ring->buffer_info = vmalloc(size);
+ rx_ring->buffer_info = vzalloc(size);
if (!rx_ring->buffer_info)
goto err;
- memset(rx_ring->buffer_info, 0, size);

desc_len = sizeof(union e1000_adv_rx_desc);

--
1.7.3.1.g432b3.dirty

2010-11-05 03:16:09

by Joe Perches

[permalink] [raw]
Subject: [PATCH 19/49] drivers/net/e1000: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
drivers/net/e1000/e1000_main.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 4686c39..dcb7f82 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -1425,13 +1425,12 @@ static int e1000_setup_tx_resources(struct e1000_adapter *adapter,
int size;

size = sizeof(struct e1000_buffer) * txdr->count;
- txdr->buffer_info = vmalloc(size);
+ txdr->buffer_info = vzalloc(size);
if (!txdr->buffer_info) {
e_err(probe, "Unable to allocate memory for the Tx descriptor "
"ring\n");
return -ENOMEM;
}
- memset(txdr->buffer_info, 0, size);

/* round up to nearest 4K */

@@ -1621,13 +1620,12 @@ static int e1000_setup_rx_resources(struct e1000_adapter *adapter,
int size, desc_len;

size = sizeof(struct e1000_buffer) * rxdr->count;
- rxdr->buffer_info = vmalloc(size);
+ rxdr->buffer_info = vzalloc(size);
if (!rxdr->buffer_info) {
e_err(probe, "Unable to allocate memory for the Rx descriptor "
"ring\n");
return -ENOMEM;
}
- memset(rxdr->buffer_info, 0, size);

desc_len = sizeof(struct e1000_rx_desc);

--
1.7.3.1.g432b3.dirty

2010-11-05 03:16:25

by Joe Perches

[permalink] [raw]
Subject: [PATCH 18/49] drivers/net/cxgb4: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
drivers/net/cxgb4/cxgb4_main.c | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/cxgb4/cxgb4_main.c b/drivers/net/cxgb4/cxgb4_main.c
index f17703f..b7758ce 100644
--- a/drivers/net/cxgb4/cxgb4_main.c
+++ b/drivers/net/cxgb4/cxgb4_main.c
@@ -868,12 +868,11 @@ out: release_firmware(fw);
*/
void *t4_alloc_mem(size_t size)
{
- void *p = kmalloc(size, GFP_KERNEL);
+ void *p = kzalloc(size, GFP_KERNEL);

if (!p)
- p = vmalloc(size);
- if (p)
- memset(p, 0, size);
+ p = vzalloc(size);
+
return p;
}

--
1.7.3.1.g432b3.dirty

2010-11-05 03:08:44

by Joe Perches

[permalink] [raw]
Subject: [PATCH 05/49] arch/x86: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
arch/x86/kernel/microcode_amd.c | 3 +--
arch/x86/kvm/x86.c | 3 +--
arch/x86/mm/pageattr-test.c | 3 +--
3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/microcode_amd.c b/arch/x86/kernel/microcode_amd.c
index e1af7c0..d46e805 100644
--- a/arch/x86/kernel/microcode_amd.c
+++ b/arch/x86/kernel/microcode_amd.c
@@ -183,9 +183,8 @@ get_next_ucode(const u8 *buf, unsigned int size, unsigned int *mc_size)
return NULL;
}

- mc = vmalloc(UCODE_MAX_SIZE);
+ mc = vzalloc(UCODE_MAX_SIZE);
if (mc) {
- memset(mc, 0, UCODE_MAX_SIZE);
if (get_ucode_data(mc, buf + UCODE_CONTAINER_SECTION_HDR,
total_size)) {
vfree(mc);
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 2288ad8..624d4da 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3174,10 +3174,9 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
spin_unlock(&kvm->mmu_lock);

r = -ENOMEM;
- dirty_bitmap = vmalloc(n);
+ dirty_bitmap = vzalloc(n);
if (!dirty_bitmap)
goto out;
- memset(dirty_bitmap, 0, n);

r = -ENOMEM;
slots = kzalloc(sizeof(struct kvm_memslots), GFP_KERNEL);
diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
index e1d1069..b008656 100644
--- a/arch/x86/mm/pageattr-test.c
+++ b/arch/x86/mm/pageattr-test.c
@@ -123,12 +123,11 @@ static int pageattr_test(void)
if (print)
printk(KERN_INFO "CPA self-test:\n");

- bm = vmalloc((max_pfn_mapped + 7) / 8);
+ bm = vzalloc((max_pfn_mapped + 7) / 8);
if (!bm) {
printk(KERN_ERR "CPA Cannot vmalloc bitmap\n");
return -ENOMEM;
}
- memset(bm, 0, (max_pfn_mapped + 7) / 8);

failed += print_split(&sa);
srandom32(100);
--
1.7.3.1.g432b3.dirty

2010-11-05 03:16:49

by Joe Perches

[permalink] [raw]
Subject: [PATCH 14/49] drivers/md: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
drivers/md/dm-log.c | 3 +--
drivers/md/dm-snap-persistent.c | 3 +--
drivers/md/dm-table.c | 4 +---
3 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/md/dm-log.c b/drivers/md/dm-log.c
index 33420e6..8f00e38 100644
--- a/drivers/md/dm-log.c
+++ b/drivers/md/dm-log.c
@@ -487,7 +487,7 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti,
memset(lc->sync_bits, (sync == NOSYNC) ? -1 : 0, bitset_size);
lc->sync_count = (sync == NOSYNC) ? region_count : 0;

- lc->recovering_bits = vmalloc(bitset_size);
+ lc->recovering_bits = vzalloc(bitset_size);
if (!lc->recovering_bits) {
DMWARN("couldn't allocate sync bitset");
vfree(lc->sync_bits);
@@ -499,7 +499,6 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti,
kfree(lc);
return -ENOMEM;
}
- memset(lc->recovering_bits, 0, bitset_size);
lc->sync_search = 0;
log->context = lc;

diff --git a/drivers/md/dm-snap-persistent.c b/drivers/md/dm-snap-persistent.c
index 2129cdb..8eb943f 100644
--- a/drivers/md/dm-snap-persistent.c
+++ b/drivers/md/dm-snap-persistent.c
@@ -174,10 +174,9 @@ static int alloc_area(struct pstore *ps)
if (!ps->area)
goto err_area;

- ps->zero_area = vmalloc(len);
+ ps->zero_area = vzalloc(len);
if (!ps->zero_area)
goto err_zero_area;
- memset(ps->zero_area, 0, len);

ps->header_area = vmalloc(len);
if (!ps->header_area)
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 90267f8..d6a91f7 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -151,9 +151,7 @@ void *dm_vcalloc(unsigned long nmemb, unsigned long elem_size)
return NULL;

size = nmemb * elem_size;
- addr = vmalloc(size);
- if (addr)
- memset(addr, 0, size);
+ addr = vzalloc(size);

return addr;
}
--
1.7.3.1.g432b3.dirty

2010-11-05 03:08:46

by Joe Perches

[permalink] [raw]
Subject: [PATCH 07/49] drivers/atm: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
drivers/atm/idt77252.c | 11 ++++++-----
drivers/atm/lanai.c | 3 +--
2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
index bce5732..8c09e32 100644
--- a/drivers/atm/idt77252.c
+++ b/drivers/atm/idt77252.c
@@ -3459,27 +3459,28 @@ init_card(struct atm_dev *dev)

size = sizeof(struct vc_map *) * card->tct_size;
IPRINTK("%s: allocate %d byte for VC map.\n", card->name, size);
- if (NULL == (card->vcs = vmalloc(size))) {
+ card->vcs = vzalloc(size);
+ if (!card->vcs) {
printk("%s: memory allocation failure.\n", card->name);
deinit_card(card);
return -1;
}
- memset(card->vcs, 0, size);

size = sizeof(struct vc_map *) * card->scd_size;
IPRINTK("%s: allocate %d byte for SCD to VC mapping.\n",
card->name, size);
- if (NULL == (card->scd2vc = vmalloc(size))) {
+ card->scd2vc = vzalloc(size);
+ if (!card->scd2vc) {
printk("%s: memory allocation failure.\n", card->name);
deinit_card(card);
return -1;
}
- memset(card->scd2vc, 0, size);

size = sizeof(struct tst_info) * (card->tst_size - 2);
IPRINTK("%s: allocate %d byte for TST to VC mapping.\n",
card->name, size);
- if (NULL == (card->soft_tst = vmalloc(size))) {
+ card->soft_tst = vmalloc(size);
+ if (!card->soft_tst) {
printk("%s: memory allocation failure.\n", card->name);
deinit_card(card);
return -1;
diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
index cbe15a8..5cec592 100644
--- a/drivers/atm/lanai.c
+++ b/drivers/atm/lanai.c
@@ -1457,10 +1457,9 @@ static int __devinit vcc_table_allocate(struct lanai_dev *lanai)
return (lanai->vccs == NULL) ? -ENOMEM : 0;
#else
int bytes = (lanai->num_vci) * sizeof(struct lanai_vcc *);
- lanai->vccs = (struct lanai_vcc **) vmalloc(bytes);
+ lanai->vccs = vzalloc(bytes);
if (unlikely(lanai->vccs == NULL))
return -ENOMEM;
- memset(lanai->vccs, 0, bytes);
return 0;
#endif
}
--
1.7.3.1.g432b3.dirty

2010-11-05 03:17:19

by Joe Perches

[permalink] [raw]
Subject: [PATCH 12/49] drivers/infiniband: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
drivers/infiniband/hw/amso1100/c2_rnic.c | 5 ++---
drivers/infiniband/hw/ehca/ipz_pt_fn.c | 5 ++---
drivers/infiniband/hw/ipath/ipath_driver.c | 3 +--
drivers/infiniband/hw/ipath/ipath_file_ops.c | 11 +++--------
drivers/infiniband/hw/ipath/ipath_init_chip.c | 5 +----
drivers/infiniband/hw/qib/qib_init.c | 7 ++-----
drivers/infiniband/ulp/ipoib/ipoib_cm.c | 10 +++-------
drivers/infiniband/ulp/ipoib/ipoib_main.c | 3 +--
8 files changed, 15 insertions(+), 34 deletions(-)

diff --git a/drivers/infiniband/hw/amso1100/c2_rnic.c b/drivers/infiniband/hw/amso1100/c2_rnic.c
index 85cfae4..8c81992 100644
--- a/drivers/infiniband/hw/amso1100/c2_rnic.c
+++ b/drivers/infiniband/hw/amso1100/c2_rnic.c
@@ -459,13 +459,12 @@ int __devinit c2_rnic_init(struct c2_dev *c2dev)
IB_DEVICE_MEM_WINDOW);

/* Allocate the qptr_array */
- c2dev->qptr_array = vmalloc(C2_MAX_CQS * sizeof(void *));
+ c2dev->qptr_array = vzalloc(C2_MAX_CQS * sizeof(void *));
if (!c2dev->qptr_array) {
return -ENOMEM;
}

- /* Inialize the qptr_array */
- memset(c2dev->qptr_array, 0, C2_MAX_CQS * sizeof(void *));
+ /* Initialize the qptr_array */
c2dev->qptr_array[0] = (void *) &c2dev->req_vq;
c2dev->qptr_array[1] = (void *) &c2dev->rep_vq;
c2dev->qptr_array[2] = (void *) &c2dev->aeq;
diff --git a/drivers/infiniband/hw/ehca/ipz_pt_fn.c b/drivers/infiniband/hw/ehca/ipz_pt_fn.c
index 1596e30..1898d6e 100644
--- a/drivers/infiniband/hw/ehca/ipz_pt_fn.c
+++ b/drivers/infiniband/hw/ehca/ipz_pt_fn.c
@@ -222,15 +222,14 @@ int ipz_queue_ctor(struct ehca_pd *pd, struct ipz_queue *queue,
queue->small_page = NULL;

/* allocate queue page pointers */
- queue->queue_pages = kmalloc(nr_of_pages * sizeof(void *), GFP_KERNEL);
+ queue->queue_pages = kzalloc(nr_of_pages * sizeof(void *), GFP_KERNEL);
if (!queue->queue_pages) {
- queue->queue_pages = vmalloc(nr_of_pages * sizeof(void *));
+ queue->queue_pages = vzalloc(nr_of_pages * sizeof(void *));
if (!queue->queue_pages) {
ehca_gen_err("Couldn't allocate queue page list");
return 0;
}
}
- memset(queue->queue_pages, 0, nr_of_pages * sizeof(void *));

/* allocate actual queue pages */
if (is_small) {
diff --git a/drivers/infiniband/hw/ipath/ipath_driver.c b/drivers/infiniband/hw/ipath/ipath_driver.c
index 765f0fc..6572b8c 100644
--- a/drivers/infiniband/hw/ipath/ipath_driver.c
+++ b/drivers/infiniband/hw/ipath/ipath_driver.c
@@ -199,12 +199,11 @@ static struct ipath_devdata *ipath_alloc_devdata(struct pci_dev *pdev)
goto bail;
}

- dd = vmalloc(sizeof(*dd));
+ dd = vzalloc(sizeof(*dd));
if (!dd) {
dd = ERR_PTR(-ENOMEM);
goto bail;
}
- memset(dd, 0, sizeof(*dd));
dd->ipath_unit = -1;

spin_lock_irqsave(&ipath_devs_lock, flags);
diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c
index 6078992..ff5c6fa 100644
--- a/drivers/infiniband/hw/ipath/ipath_file_ops.c
+++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c
@@ -1531,7 +1531,7 @@ static int init_subports(struct ipath_devdata *dd,
}

num_subports = uinfo->spu_subport_cnt;
- pd->subport_uregbase = vmalloc(PAGE_SIZE * num_subports);
+ pd->subport_uregbase = vzalloc(PAGE_SIZE * num_subports);
if (!pd->subport_uregbase) {
ret = -ENOMEM;
goto bail;
@@ -1539,13 +1539,13 @@ static int init_subports(struct ipath_devdata *dd,
/* Note: pd->port_rcvhdrq_size isn't initialized yet. */
size = ALIGN(dd->ipath_rcvhdrcnt * dd->ipath_rcvhdrentsize *
sizeof(u32), PAGE_SIZE) * num_subports;
- pd->subport_rcvhdr_base = vmalloc(size);
+ pd->subport_rcvhdr_base = vzalloc(size);
if (!pd->subport_rcvhdr_base) {
ret = -ENOMEM;
goto bail_ureg;
}

- pd->subport_rcvegrbuf = vmalloc(pd->port_rcvegrbuf_chunks *
+ pd->subport_rcvegrbuf = vzalloc(pd->port_rcvegrbuf_chunks *
pd->port_rcvegrbuf_size *
num_subports);
if (!pd->subport_rcvegrbuf) {
@@ -1557,11 +1557,6 @@ static int init_subports(struct ipath_devdata *dd,
pd->port_subport_id = uinfo->spu_subport_id;
pd->active_slaves = 1;
set_bit(IPATH_PORT_MASTER_UNINIT, &pd->port_flag);
- memset(pd->subport_uregbase, 0, PAGE_SIZE * num_subports);
- memset(pd->subport_rcvhdr_base, 0, size);
- memset(pd->subport_rcvegrbuf, 0, pd->port_rcvegrbuf_chunks *
- pd->port_rcvegrbuf_size *
- num_subports);
goto bail;

bail_rhdr:
diff --git a/drivers/infiniband/hw/ipath/ipath_init_chip.c b/drivers/infiniband/hw/ipath/ipath_init_chip.c
index 7769382..fef0f42 100644
--- a/drivers/infiniband/hw/ipath/ipath_init_chip.c
+++ b/drivers/infiniband/hw/ipath/ipath_init_chip.c
@@ -442,7 +442,7 @@ static void init_shadow_tids(struct ipath_devdata *dd)
struct page **pages;
dma_addr_t *addrs;

- pages = vmalloc(dd->ipath_cfgports * dd->ipath_rcvtidcnt *
+ pages = vzalloc(dd->ipath_cfgports * dd->ipath_rcvtidcnt *
sizeof(struct page *));
if (!pages) {
ipath_dev_err(dd, "failed to allocate shadow page * "
@@ -461,9 +461,6 @@ static void init_shadow_tids(struct ipath_devdata *dd)
return;
}

- memset(pages, 0, dd->ipath_cfgports * dd->ipath_rcvtidcnt *
- sizeof(struct page *));
-
dd->ipath_pageshadow = pages;
dd->ipath_physshadow = addrs;
}
diff --git a/drivers/infiniband/hw/qib/qib_init.c b/drivers/infiniband/hw/qib/qib_init.c
index f3b5039..953d285 100644
--- a/drivers/infiniband/hw/qib/qib_init.c
+++ b/drivers/infiniband/hw/qib/qib_init.c
@@ -268,23 +268,20 @@ static void init_shadow_tids(struct qib_devdata *dd)
struct page **pages;
dma_addr_t *addrs;

- pages = vmalloc(dd->cfgctxts * dd->rcvtidcnt * sizeof(struct page *));
+ pages = vzalloc(dd->cfgctxts * dd->rcvtidcnt * sizeof(struct page *));
if (!pages) {
qib_dev_err(dd, "failed to allocate shadow page * "
"array, no expected sends!\n");
goto bail;
}

- addrs = vmalloc(dd->cfgctxts * dd->rcvtidcnt * sizeof(dma_addr_t));
+ addrs = vzalloc(dd->cfgctxts * dd->rcvtidcnt * sizeof(dma_addr_t));
if (!addrs) {
qib_dev_err(dd, "failed to allocate shadow dma handle "
"array, no expected sends!\n");
goto bail_free;
}

- memset(pages, 0, dd->cfgctxts * dd->rcvtidcnt * sizeof(struct page *));
- memset(addrs, 0, dd->cfgctxts * dd->rcvtidcnt * sizeof(dma_addr_t));
-
dd->pageshadow = pages;
dd->physshadow = addrs;
return;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
index bb10041..1e61104 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
@@ -352,15 +352,13 @@ static int ipoib_cm_nonsrq_init_rx(struct net_device *dev, struct ib_cm_id *cm_i
int ret;
int i;

- rx->rx_ring = vmalloc(ipoib_recvq_size * sizeof *rx->rx_ring);
+ rx->rx_ring = vzalloc(ipoib_recvq_size * sizeof *rx->rx_ring);
if (!rx->rx_ring) {
printk(KERN_WARNING "%s: failed to allocate CM non-SRQ ring (%d entries)\n",
priv->ca->name, ipoib_recvq_size);
return -ENOMEM;
}

- memset(rx->rx_ring, 0, ipoib_recvq_size * sizeof *rx->rx_ring);
-
t = kmalloc(sizeof *t, GFP_KERNEL);
if (!t) {
ret = -ENOMEM;
@@ -1097,13 +1095,12 @@ static int ipoib_cm_tx_init(struct ipoib_cm_tx *p, u32 qpn,
struct ipoib_dev_priv *priv = netdev_priv(p->dev);
int ret;

- p->tx_ring = vmalloc(ipoib_sendq_size * sizeof *p->tx_ring);
+ p->tx_ring = vzalloc(ipoib_sendq_size * sizeof *p->tx_ring);
if (!p->tx_ring) {
ipoib_warn(priv, "failed to allocate tx ring\n");
ret = -ENOMEM;
goto err_tx;
}
- memset(p->tx_ring, 0, ipoib_sendq_size * sizeof *p->tx_ring);

p->qp = ipoib_cm_create_tx_qp(p->dev, p);
if (IS_ERR(p->qp)) {
@@ -1520,7 +1517,7 @@ static void ipoib_cm_create_srq(struct net_device *dev, int max_sge)
return;
}

- priv->cm.srq_ring = vmalloc(ipoib_recvq_size * sizeof *priv->cm.srq_ring);
+ priv->cm.srq_ring = vzalloc(ipoib_recvq_size * sizeof *priv->cm.srq_ring);
if (!priv->cm.srq_ring) {
printk(KERN_WARNING "%s: failed to allocate CM SRQ ring (%d entries)\n",
priv->ca->name, ipoib_recvq_size);
@@ -1529,7 +1526,6 @@ static void ipoib_cm_create_srq(struct net_device *dev, int max_sge)
return;
}

- memset(priv->cm.srq_ring, 0, ipoib_recvq_size * sizeof *priv->cm.srq_ring);
}

int ipoib_cm_dev_init(struct net_device *dev)
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 9ff7bc7..65e4e98 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -925,13 +925,12 @@ int ipoib_dev_init(struct net_device *dev, struct ib_device *ca, int port)
goto out;
}

- priv->tx_ring = vmalloc(ipoib_sendq_size * sizeof *priv->tx_ring);
+ priv->tx_ring = vzalloc(ipoib_sendq_size * sizeof *priv->tx_ring);
if (!priv->tx_ring) {
printk(KERN_WARNING "%s: failed to allocate TX ring (%d entries)\n",
ca->name, ipoib_sendq_size);
goto out_rx_ring_cleanup;
}
- memset(priv->tx_ring, 0, ipoib_sendq_size * sizeof *priv->tx_ring);

/* priv->tx_head, tx_tail & tx_outstanding are already 0 */

--
1.7.3.1.g432b3.dirty

2010-11-05 03:16:52

by Joe Perches

[permalink] [raw]
Subject: [PATCH 13/49] drivers/isdn: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
drivers/isdn/i4l/isdn_common.c | 4 ++--
drivers/isdn/mISDN/dsp_core.c | 3 +--
drivers/isdn/mISDN/l1oip_codec.c | 6 ++----
3 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
index 15632bd..2601d5c 100644
--- a/drivers/isdn/i4l/isdn_common.c
+++ b/drivers/isdn/i4l/isdn_common.c
@@ -2315,11 +2315,11 @@ static int __init isdn_init(void)
int i;
char tmprev[50];

- if (!(dev = vmalloc(sizeof(isdn_dev)))) {
+ dev = vzalloc(sizeof(isdn_dev));
+ if (!dev) {
printk(KERN_WARNING "isdn: Could not allocate device-struct.\n");
return -EIO;
}
- memset((char *) dev, 0, sizeof(isdn_dev));
init_timer(&dev->timer);
dev->timer.function = isdn_timer_funct;
spin_lock_init(&dev->lock);
diff --git a/drivers/isdn/mISDN/dsp_core.c b/drivers/isdn/mISDN/dsp_core.c
index 6f5b548..a255de5 100644
--- a/drivers/isdn/mISDN/dsp_core.c
+++ b/drivers/isdn/mISDN/dsp_core.c
@@ -1052,12 +1052,11 @@ dspcreate(struct channel_req *crq)
if (crq->protocol != ISDN_P_B_L2DSP
&& crq->protocol != ISDN_P_B_L2DSPHDLC)
return -EPROTONOSUPPORT;
- ndsp = vmalloc(sizeof(struct dsp));
+ ndsp = vzalloc(sizeof(struct dsp));
if (!ndsp) {
printk(KERN_ERR "%s: vmalloc struct dsp failed\n", __func__);
return -ENOMEM;
}
- memset(ndsp, 0, sizeof(struct dsp));
if (dsp_debug & DEBUG_DSP_CTRL)
printk(KERN_DEBUG "%s: creating new dsp instance\n", __func__);

diff --git a/drivers/isdn/mISDN/l1oip_codec.c b/drivers/isdn/mISDN/l1oip_codec.c
index bbfd1b8..5a89972 100644
--- a/drivers/isdn/mISDN/l1oip_codec.c
+++ b/drivers/isdn/mISDN/l1oip_codec.c
@@ -330,14 +330,12 @@ l1oip_4bit_alloc(int ulaw)
return 0;

/* alloc conversion tables */
- table_com = vmalloc(65536);
- table_dec = vmalloc(512);
+ table_com = vzalloc(65536);
+ table_dec = vzalloc(512);
if (!table_com || !table_dec) {
l1oip_4bit_free();
return -ENOMEM;
}
- memset(table_com, 0, 65536);
- memset(table_dec, 0, 512);
/* generate compression table */
i1 = 0;
while (i1 < 256) {
--
1.7.3.1.g432b3.dirty

2010-11-05 03:08:42

by Joe Perches

[permalink] [raw]
Subject: [PATCH 06/49] crypto: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
crypto/deflate.c | 3 +--
crypto/zlib.c | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/crypto/deflate.c b/crypto/deflate.c
index 463dc85..cbc7a33 100644
--- a/crypto/deflate.c
+++ b/crypto/deflate.c
@@ -48,12 +48,11 @@ static int deflate_comp_init(struct deflate_ctx *ctx)
int ret = 0;
struct z_stream_s *stream = &ctx->comp_stream;

- stream->workspace = vmalloc(zlib_deflate_workspacesize());
+ stream->workspace = vzalloc(zlib_deflate_workspacesize());
if (!stream->workspace) {
ret = -ENOMEM;
goto out;
}
- memset(stream->workspace, 0, zlib_deflate_workspacesize());
ret = zlib_deflateInit2(stream, DEFLATE_DEF_LEVEL, Z_DEFLATED,
-DEFLATE_DEF_WINBITS, DEFLATE_DEF_MEMLEVEL,
Z_DEFAULT_STRATEGY);
diff --git a/crypto/zlib.c b/crypto/zlib.c
index c3015733..739b8fc 100644
--- a/crypto/zlib.c
+++ b/crypto/zlib.c
@@ -95,11 +95,10 @@ static int zlib_compress_setup(struct crypto_pcomp *tfm, void *params,
zlib_comp_exit(ctx);

workspacesize = zlib_deflate_workspacesize();
- stream->workspace = vmalloc(workspacesize);
+ stream->workspace = vzalloc(workspacesize);
if (!stream->workspace)
return -ENOMEM;

- memset(stream->workspace, 0, workspacesize);
ret = zlib_deflateInit2(stream,
tb[ZLIB_COMP_LEVEL]
? nla_get_u32(tb[ZLIB_COMP_LEVEL])
--
1.7.3.1.g432b3.dirty

2010-11-05 03:17:44

by Joe Perches

[permalink] [raw]
Subject: [PATCH 11/49] drivers/hid: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
drivers/hid/hid-core.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 515345b..3fd8e5a 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -652,13 +652,12 @@ int hid_parse_report(struct hid_device *device, __u8 *start,
return -ENOMEM;
device->rsize = size;

- parser = vmalloc(sizeof(struct hid_parser));
+ parser = vzalloc(sizeof(struct hid_parser));
if (!parser) {
ret = -ENOMEM;
goto err;
}

- memset(parser, 0, sizeof(struct hid_parser));
parser->device = device;

end = start + size;
--
1.7.3.1.g432b3.dirty

2010-11-05 03:17:46

by Joe Perches

[permalink] [raw]
Subject: [PATCH 10/49] drivers/gpu: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
drivers/gpu/drm/via/via_dmablit.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/via/via_dmablit.c b/drivers/gpu/drm/via/via_dmablit.c
index 9b5b4d9..3e038a3 100644
--- a/drivers/gpu/drm/via/via_dmablit.c
+++ b/drivers/gpu/drm/via/via_dmablit.c
@@ -235,9 +235,9 @@ via_lock_all_dma_pages(drm_via_sg_info_t *vsg, drm_via_dmablit_t *xfer)
vsg->num_pages = VIA_PFN(xfer->mem_addr + (xfer->num_lines * xfer->mem_stride - 1)) -
first_pfn + 1;

- if (NULL == (vsg->pages = vmalloc(sizeof(struct page *) * vsg->num_pages)))
+ vsg->pages = vzalloc(sizeof(struct page *) * vsg->num_pages);
+ if (NULL == vsg->pages)
return -ENOMEM;
- memset(vsg->pages, 0, sizeof(struct page *) * vsg->num_pages);
down_read(&current->mm->mmap_sem);
ret = get_user_pages(current, current->mm,
(unsigned long)xfer->mem_addr,
--
1.7.3.1.g432b3.dirty

2010-11-05 03:18:10

by Joe Perches

[permalink] [raw]
Subject: [PATCH 09/49] drivers/char: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
drivers/char/agp/backend.c | 3 +--
drivers/char/mspec.c | 5 ++---
2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/char/agp/backend.c b/drivers/char/agp/backend.c
index f27d0d0..4b71647 100644
--- a/drivers/char/agp/backend.c
+++ b/drivers/char/agp/backend.c
@@ -171,7 +171,7 @@ static int agp_backend_initialize(struct agp_bridge_data *bridge)
}
got_gatt = 1;

- bridge->key_list = vmalloc(PAGE_SIZE * 4);
+ bridge->key_list = vzalloc(PAGE_SIZE * 4);
if (bridge->key_list == NULL) {
dev_err(&bridge->dev->dev,
"can't allocate memory for key lists\n");
@@ -181,7 +181,6 @@ static int agp_backend_initialize(struct agp_bridge_data *bridge)
got_keylist = 1;

/* FIXME vmalloc'd memory not guaranteed contiguous */
- memset(bridge->key_list, 0, PAGE_SIZE * 4);

if (bridge->driver->configure()) {
dev_err(&bridge->dev->dev, "error configuring host chipset\n");
diff --git a/drivers/char/mspec.c b/drivers/char/mspec.c
index 966a95b..25d139c 100644
--- a/drivers/char/mspec.c
+++ b/drivers/char/mspec.c
@@ -271,14 +271,13 @@ mspec_mmap(struct file *file, struct vm_area_struct *vma,
pages = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
vdata_size = sizeof(struct vma_data) + pages * sizeof(long);
if (vdata_size <= PAGE_SIZE)
- vdata = kmalloc(vdata_size, GFP_KERNEL);
+ vdata = kzalloc(vdata_size, GFP_KERNEL);
else {
- vdata = vmalloc(vdata_size);
+ vdata = vzalloc(vdata_size);
flags = VMD_VMALLOCED;
}
if (!vdata)
return -ENOMEM;
- memset(vdata, 0, vdata_size);

vdata->vm_start = vma->vm_start;
vdata->vm_end = vma->vm_end;
--
1.7.3.1.g432b3.dirty

2010-11-05 03:18:24

by Joe Perches

[permalink] [raw]
Subject: [PATCH 08/49] drivers/block: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
drivers/block/drbd/drbd_bitmap.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/block/drbd/drbd_bitmap.c b/drivers/block/drbd/drbd_bitmap.c
index fd42832..09e8cfc 100644
--- a/drivers/block/drbd/drbd_bitmap.c
+++ b/drivers/block/drbd/drbd_bitmap.c
@@ -250,15 +250,14 @@ static struct page **bm_realloc_pages(struct drbd_bitmap *b, unsigned long want)
* thread. As we have no disk yet, we are not in the IO path,
* not even the IO path of the peer. */
bytes = sizeof(struct page *)*want;
- new_pages = kmalloc(bytes, GFP_KERNEL);
+ new_pages = kzalloc(bytes, GFP_KERNEL);
if (!new_pages) {
- new_pages = vmalloc(bytes);
+ new_pages = vzalloc(bytes);
if (!new_pages)
return NULL;
vmalloced = 1;
}

- memset(new_pages, 0, bytes);
if (want >= have) {
for (i = 0; i < have; i++)
new_pages[i] = old_pages[i];
--
1.7.3.1.g432b3.dirty

2010-11-05 03:19:04

by Joe Perches

[permalink] [raw]
Subject: [PATCH 02/49] arch/mips: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
arch/mips/sibyte/common/sb_tbprof.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/arch/mips/sibyte/common/sb_tbprof.c b/arch/mips/sibyte/common/sb_tbprof.c
index 87ccdb4..48853ab 100644
--- a/arch/mips/sibyte/common/sb_tbprof.c
+++ b/arch/mips/sibyte/common/sb_tbprof.c
@@ -410,14 +410,13 @@ static int sbprof_tb_open(struct inode *inode, struct file *filp)
return -EBUSY;

memset(&sbp, 0, sizeof(struct sbprof_tb));
- sbp.sbprof_tbbuf = vmalloc(MAX_TBSAMPLE_BYTES);
+ sbp.sbprof_tbbuf = vzalloc(MAX_TBSAMPLE_BYTES);
if (!sbp.sbprof_tbbuf) {
sbp.open = SB_CLOSED;
wmb();
return -ENOMEM;
}

- memset(sbp.sbprof_tbbuf, 0, MAX_TBSAMPLE_BYTES);
init_waitqueue_head(&sbp.tb_sync);
init_waitqueue_head(&sbp.tb_read);
mutex_init(&sbp.lock);
--
1.7.3.1.g432b3.dirty

2010-11-05 03:18:32

by Joe Perches

[permalink] [raw]
Subject: [PATCH 03/49] arch/powerpc: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
arch/powerpc/kvm/book3s.c | 6 ++----
arch/powerpc/platforms/cell/spufs/lscsa_alloc.c | 3 +--
2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c
index e316847..4275463 100644
--- a/arch/powerpc/kvm/book3s.c
+++ b/arch/powerpc/kvm/book3s.c
@@ -1307,13 +1307,11 @@ struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, unsigned int id)
int err = -ENOMEM;
unsigned long p;

- vcpu_book3s = vmalloc(sizeof(struct kvmppc_vcpu_book3s));
+ vcpu_book3s = vzalloc(sizeof(struct kvmppc_vcpu_book3s));
if (!vcpu_book3s)
goto out;

- memset(vcpu_book3s, 0, sizeof(struct kvmppc_vcpu_book3s));
-
- vcpu_book3s->shadow_vcpu = (struct kvmppc_book3s_shadow_vcpu *)
+ vcpu_book3s->shadow_vcpu =
kzalloc(sizeof(*vcpu_book3s->shadow_vcpu), GFP_KERNEL);
if (!vcpu_book3s->shadow_vcpu)
goto free_vcpu;
diff --git a/arch/powerpc/platforms/cell/spufs/lscsa_alloc.c b/arch/powerpc/platforms/cell/spufs/lscsa_alloc.c
index a101abf..3b894f5 100644
--- a/arch/powerpc/platforms/cell/spufs/lscsa_alloc.c
+++ b/arch/powerpc/platforms/cell/spufs/lscsa_alloc.c
@@ -36,10 +36,9 @@ static int spu_alloc_lscsa_std(struct spu_state *csa)
struct spu_lscsa *lscsa;
unsigned char *p;

- lscsa = vmalloc(sizeof(struct spu_lscsa));
+ lscsa = vzalloc(sizeof(struct spu_lscsa));
if (!lscsa)
return -ENOMEM;
- memset(lscsa, 0, sizeof(struct spu_lscsa));
csa->lscsa = lscsa;

/* Set LS pages reserved to allow for user-space mapping. */
--
1.7.3.1.g432b3.dirty

2010-11-05 03:18:28

by Joe Perches

[permalink] [raw]
Subject: [PATCH 04/49] arch/s390: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
arch/s390/hypfs/hypfs_diag.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/arch/s390/hypfs/hypfs_diag.c b/arch/s390/hypfs/hypfs_diag.c
index cd4a81b..1b1acef 100644
--- a/arch/s390/hypfs/hypfs_diag.c
+++ b/arch/s390/hypfs/hypfs_diag.c
@@ -570,12 +570,11 @@ static int dbfs_d204_open(struct inode *inode, struct file *file)
if (!data)
return -ENOMEM;
buf_size = PAGE_SIZE * (diag204_buf_pages + 1) + sizeof(d204->hdr);
- data->base = vmalloc(buf_size);
+ data->base = vzalloc(buf_size);
if (!data->base) {
rc = -ENOMEM;
goto fail_kfree_data;
}
- memset(data->base, 0, buf_size);
d204 = page_align_ptr(data->base + sizeof(d204->hdr))
- sizeof(d204->hdr);
rc = diag204_do_store(&d204->buf, diag204_buf_pages);
--
1.7.3.1.g432b3.dirty

2010-11-05 04:20:54

by Takuya Yoshikawa

[permalink] [raw]
Subject: Re: [PATCH 05/49] arch/x86: Use vzalloc

(2010/11/05 12:07), Joe Perches wrote:

> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 2288ad8..624d4da 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -3174,10 +3174,9 @@ int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
> spin_unlock(&kvm->mmu_lock);
>
> r = -ENOMEM;
> - dirty_bitmap = vmalloc(n);
> + dirty_bitmap = vzalloc(n);

This vmalloc() does not exist already, see kvm.git.

Takuya

> if (!dirty_bitmap)
> goto out;
> - memset(dirty_bitmap, 0, n);
>
> r = -ENOMEM;
> slots = kzalloc(sizeof(struct kvm_memslots), GFP_KERNEL);

2010-11-05 04:23:15

by Takuya Yoshikawa

[permalink] [raw]
Subject: Re: [PATCH 49/49] virt/kvm/kvm_main.c: Use vzalloc

(2010/11/05 12:08), Joe Perches wrote:
> Signed-off-by: Joe Perches<[email protected]>
> ---
> virt/kvm/kvm_main.c | 13 +++----------
> 1 files changed, 3 insertions(+), 10 deletions(-)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c

Already changed to vzalloc(), see kvm.git.

Takuya


> index 5225052..c2a08e6e 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -604,13 +604,10 @@ int __kvm_set_memory_region(struct kvm *kvm,
> /* Allocate if a slot is being created */
> #ifndef CONFIG_S390
> if (npages&& !new.rmap) {
> - new.rmap = vmalloc(npages * sizeof(*new.rmap));
> -
> + new.rmap = vzalloc(npages * sizeof(*new.rmap));
> if (!new.rmap)
> goto out_free;
>
> - memset(new.rmap, 0, npages * sizeof(*new.rmap));
> -
> new.user_alloc = user_alloc;
> new.userspace_addr = mem->userspace_addr;
> }
> @@ -633,14 +630,11 @@ int __kvm_set_memory_region(struct kvm *kvm,
> >> KVM_HPAGE_GFN_SHIFT(level));
> lpages -= base_gfn>> KVM_HPAGE_GFN_SHIFT(level);
>
> - new.lpage_info[i] = vmalloc(lpages * sizeof(*new.lpage_info[i]));
> + new.lpage_info[i] = vzalloc(lpages * sizeof(*new.lpage_info[i]));
>
> if (!new.lpage_info[i])
> goto out_free;
>
> - memset(new.lpage_info[i], 0,
> - lpages * sizeof(*new.lpage_info[i]));
> -
> if (base_gfn& (KVM_PAGES_PER_HPAGE(level) - 1))
> new.lpage_info[i][0].write_count = 1;
> if ((base_gfn+npages)& (KVM_PAGES_PER_HPAGE(level) - 1))
> @@ -663,10 +657,9 @@ skip_lpage:
> if ((new.flags& KVM_MEM_LOG_DIRTY_PAGES)&& !new.dirty_bitmap) {
> unsigned long dirty_bytes = kvm_dirty_bitmap_bytes(&new);
>
> - new.dirty_bitmap = vmalloc(dirty_bytes);
> + new.dirty_bitmap = vzalloc(dirty_bytes);
> if (!new.dirty_bitmap)
> goto out_free;
> - memset(new.dirty_bitmap, 0, dirty_bytes);
> /* destroy any largepage mappings for dirty tracking */
> if (old.npages)
> flush_shadow = 1;

2010-11-05 04:44:15

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 49/49] virt/kvm/kvm_main.c: Use vzalloc

On Fri, 2010-11-05 at 13:25 +0900, Takuya Yoshikawa wrote:
> (2010/11/05 12:08), Joe Perches wrote:
> > Signed-off-by: Joe Perches<[email protected]>
> > ---
> > virt/kvm/kvm_main.c | 13 +++----------
> > 1 files changed, 3 insertions(+), 10 deletions(-)
> >
> > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
>
> Already changed to vzalloc(), see kvm.git.

Thanks. No worries.

fyi: the kvm git isn't in MAINTAINERS.

Perhaps something like this is appropriate
---
MAINTAINERS | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index ec7e4a4..73bfe4f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3443,6 +3443,7 @@ M: Avi Kivity <[email protected]>
M: Marcelo Tosatti <[email protected]>
L: [email protected]
W: http://kvm.qumranet.com
+T: git git://git.kernel.org/pub/scm/virt/kvm/kvm.git
S: Supported
F: Documentation/*/kvm.txt
F: arch/*/kvm/

2010-11-05 05:20:11

by Amit Salecha

[permalink] [raw]
Subject: RE: [PATCH 27/49] drivers/net/netxen: Use vzalloc

> From: Joe Perches [[email protected]]
> Sent: Friday, November 05, 2010 8:37 AM
> To: Jiri Kosina
> Cc: Amit Salecha; [email protected]; [email protected]
> Subject: [PATCH 27/49] drivers/net/netxen: Use vzalloc
>
> Signed-off-by: Joe Perches <[email protected]>
> ---
> drivers/net/netxen/netxen_nic_init.c | 7 ++-----
> files changed, 2 insertions(+), 5 deletions(-)

Thanks.-

2010-11-05 05:27:09

by Dave Young

[permalink] [raw]
Subject: Re: [PATCH 36/49] drivers/video: Use vzalloc

On Fri, Nov 5, 2010 at 11:08 AM, Joe Perches <[email protected]> wrote:
> Signed-off-by: Joe Perches <[email protected]>
> ---
>  drivers/video/arcfb.c        |    5 ++---
>  drivers/video/broadsheetfb.c |    4 +---
>  drivers/video/hecubafb.c     |    5 ++---
>  drivers/video/metronomefb.c  |    4 +---
>  drivers/video/xen-fbfront.c  |    3 +--
>  5 files changed, 7 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/video/arcfb.c b/drivers/video/arcfb.c
> index 3ec4923..86573e2 100644
> --- a/drivers/video/arcfb.c
> +++ b/drivers/video/arcfb.c
> @@ -515,11 +515,10 @@ static int __devinit arcfb_probe(struct platform_device *dev)
>
>        /* We need a flat backing store for the Arc's
>           less-flat actual paged framebuffer */
> -       if (!(videomemory = vmalloc(videomemorysize)))
> +       videomemory = vmalloc(videomemorysize);

typo?

> +       if (!videomemory)
>                return retval;
>
> -       memset(videomemory, 0, videomemorysize);
> -
>        info = framebuffer_alloc(sizeof(struct arcfb_par), &dev->dev);
>        if (!info)
>                goto err;
> diff --git a/drivers/video/broadsheetfb.c b/drivers/video/broadsheetfb.c
> index ebda687..377dde3 100644
> --- a/drivers/video/broadsheetfb.c
> +++ b/drivers/video/broadsheetfb.c
> @@ -1101,12 +1101,10 @@ static int __devinit broadsheetfb_probe(struct platform_device *dev)
>
>        videomemorysize = roundup((dpyw*dpyh), PAGE_SIZE);
>
> -       videomemory = vmalloc(videomemorysize);
> +       videomemory = vzalloc(videomemorysize);
>        if (!videomemory)
>                goto err_fb_rel;
>
> -       memset(videomemory, 0, videomemorysize);
> -
>        info->screen_base = (char *)videomemory;
>        info->fbops = &broadsheetfb_ops;
>
> diff --git a/drivers/video/hecubafb.c b/drivers/video/hecubafb.c
> index c77bcc6..a941e6f 100644
> --- a/drivers/video/hecubafb.c
> +++ b/drivers/video/hecubafb.c
> @@ -231,11 +231,10 @@ static int __devinit hecubafb_probe(struct platform_device *dev)
>
>        videomemorysize = (DPY_W*DPY_H)/8;
>
> -       if (!(videomemory = vmalloc(videomemorysize)))
> +       videomemory = vzalloc(videomemorysize);
> +       if (!videomemory)
>                return retval;
>
> -       memset(videomemory, 0, videomemorysize);
> -
>        info = framebuffer_alloc(sizeof(struct hecubafb_par), &dev->dev);
>        if (!info)
>                goto err_fballoc;
> diff --git a/drivers/video/metronomefb.c b/drivers/video/metronomefb.c
> index 63ed3b7..c0c358c 100644
> --- a/drivers/video/metronomefb.c
> +++ b/drivers/video/metronomefb.c
> @@ -628,12 +628,10 @@ static int __devinit metronomefb_probe(struct platform_device *dev)
>        /* we need to add a spare page because our csum caching scheme walks
>         * to the end of the page */
>        videomemorysize = PAGE_SIZE + (fw * fh);
> -       videomemory = vmalloc(videomemorysize);
> +       videomemory = vzalloc(videomemorysize);
>        if (!videomemory)
>                goto err_fb_rel;
>
> -       memset(videomemory, 0, videomemorysize);
> -
>        info->screen_base = (char __force __iomem *)videomemory;
>        info->fbops = &metronomefb_ops;
>
> diff --git a/drivers/video/xen-fbfront.c b/drivers/video/xen-fbfront.c
> index 428d273..81fcaea 100644
> --- a/drivers/video/xen-fbfront.c
> +++ b/drivers/video/xen-fbfront.c
> @@ -395,10 +395,9 @@ static int __devinit xenfb_probe(struct xenbus_device *dev,
>        spin_lock_init(&info->dirty_lock);
>        spin_lock_init(&info->resize_lock);
>
> -       info->fb = vmalloc(fb_size);
> +       info->fb = vzalloc(fb_size);
>        if (info->fb == NULL)
>                goto error_nomem;
> -       memset(info->fb, 0, fb_size);
>
>        info->nr_pages = (fb_size + PAGE_SIZE - 1) >> PAGE_SHIFT;
>
> --
> 1.7.3.1.g432b3.dirty
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>



--
Regards
dave

2010-11-05 05:31:27

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 36/49] drivers/video: Use vzalloc

On Fri, 2010-11-05 at 13:27 +0800, Dave Young wrote:
> On Fri, Nov 5, 2010 at 11:08 AM, Joe Perches <[email protected]> wrote:
> > diff --git a/drivers/video/arcfb.c b/drivers/video/arcfb.c
> > @@ -515,11 +515,10 @@ static int __devinit arcfb_probe(struct platform_device *dev)
> >
> > /* We need a flat backing store for the Arc's
> > less-flat actual paged framebuffer */
> > - if (!(videomemory = vmalloc(videomemorysize)))
> > + videomemory = vmalloc(videomemorysize);
> typo?

Yes. Thanks for catching that.

2010-11-05 05:31:38

by Joe Perches

[permalink] [raw]
Subject: [PATCH V2 36/49] drivers/video: Use vzalloc

Signed-off-by: Joe Perches <[email protected]>
---
V2 - Fixed vmalloc/vzalloc typo
Thanks to Dave Young for noticing.

drivers/video/arcfb.c | 5 ++---
drivers/video/broadsheetfb.c | 4 +---
drivers/video/hecubafb.c | 5 ++---
drivers/video/metronomefb.c | 4 +---
drivers/video/xen-fbfront.c | 3 +--
5 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/video/arcfb.c b/drivers/video/arcfb.c
index 3ec4923..86573e2 100644
--- a/drivers/video/arcfb.c
+++ b/drivers/video/arcfb.c
@@ -515,11 +515,10 @@ static int __devinit arcfb_probe(struct platform_device *dev)

/* We need a flat backing store for the Arc's
less-flat actual paged framebuffer */
- if (!(videomemory = vmalloc(videomemorysize)))
+ videomemory = vzalloc(videomemorysize);
+ if (!videomemory)
return retval;

- memset(videomemory, 0, videomemorysize);
-
info = framebuffer_alloc(sizeof(struct arcfb_par), &dev->dev);
if (!info)
goto err;
diff --git a/drivers/video/broadsheetfb.c b/drivers/video/broadsheetfb.c
index ebda687..377dde3 100644
--- a/drivers/video/broadsheetfb.c
+++ b/drivers/video/broadsheetfb.c
@@ -1101,12 +1101,10 @@ static int __devinit broadsheetfb_probe(struct platform_device *dev)

videomemorysize = roundup((dpyw*dpyh), PAGE_SIZE);

- videomemory = vmalloc(videomemorysize);
+ videomemory = vzalloc(videomemorysize);
if (!videomemory)
goto err_fb_rel;

- memset(videomemory, 0, videomemorysize);
-
info->screen_base = (char *)videomemory;
info->fbops = &broadsheetfb_ops;

diff --git a/drivers/video/hecubafb.c b/drivers/video/hecubafb.c
index c77bcc6..a941e6f 100644
--- a/drivers/video/hecubafb.c
+++ b/drivers/video/hecubafb.c
@@ -231,11 +231,10 @@ static int __devinit hecubafb_probe(struct platform_device *dev)

videomemorysize = (DPY_W*DPY_H)/8;

- if (!(videomemory = vmalloc(videomemorysize)))
+ videomemory = vzalloc(videomemorysize);
+ if (!videomemory)
return retval;

- memset(videomemory, 0, videomemorysize);
-
info = framebuffer_alloc(sizeof(struct hecubafb_par), &dev->dev);
if (!info)
goto err_fballoc;
diff --git a/drivers/video/metronomefb.c b/drivers/video/metronomefb.c
index 63ed3b7..c0c358c 100644
--- a/drivers/video/metronomefb.c
+++ b/drivers/video/metronomefb.c
@@ -628,12 +628,10 @@ static int __devinit metronomefb_probe(struct platform_device *dev)
/* we need to add a spare page because our csum caching scheme walks
* to the end of the page */
videomemorysize = PAGE_SIZE + (fw * fh);
- videomemory = vmalloc(videomemorysize);
+ videomemory = vzalloc(videomemorysize);
if (!videomemory)
goto err_fb_rel;

- memset(videomemory, 0, videomemorysize);
-
info->screen_base = (char __force __iomem *)videomemory;
info->fbops = &metronomefb_ops;

diff --git a/drivers/video/xen-fbfront.c b/drivers/video/xen-fbfront.c
index 428d273..81fcaea 100644
--- a/drivers/video/xen-fbfront.c
+++ b/drivers/video/xen-fbfront.c
@@ -395,10 +395,9 @@ static int __devinit xenfb_probe(struct xenbus_device *dev,
spin_lock_init(&info->dirty_lock);
spin_lock_init(&info->resize_lock);

- info->fb = vmalloc(fb_size);
+ info->fb = vzalloc(fb_size);
if (info->fb == NULL)
goto error_nomem;
- memset(info->fb, 0, fb_size);

info->nr_pages = (fb_size + PAGE_SIZE - 1) >> PAGE_SHIFT;

--
1.7.3.1.g432b3.dirty

2010-11-05 06:30:50

by Eric Dumazet

[permalink] [raw]
Subject: Re: [PATCH 46/49] net/netfilter: Use vzalloc

Le jeudi 04 novembre 2010 à 20:08 -0700, Joe Perches a écrit :
> Signed-off-by: Joe Perches <[email protected]>
> ---
> net/netfilter/x_tables.c | 5 ++---
> 1 files changed, 2 insertions(+), 3 deletions(-)

So many 'vzalloc' patches for net tree...

I had _one_ patch, waiting that David actually had vzalloc() in its tree
before sending it.

Given Jesper Juhl was doing this work, could you please take another
one, please ?

For example, explaining him how to use other tools than "bash+egrep
+manual inspection" as he mentioned in a previous mail.

Really Joe, your behavior should be smarter than that.

Thanks

2010-11-05 06:55:50

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 46/49] net/netfilter: Use vzalloc

On Fri, 2010-11-05 at 07:30 +0100, Eric Dumazet wrote:
> I had _one_ patch, waiting that David actually had vzalloc() in its tree
> before sending it.

Fine by me, use yours.

> Given Jesper Juhl was doing this work, could you please take another
> one, please ?
> For example, explaining him how to use other tools than "bash+egrep
> +manual inspection" as he mentioned in a previous mail.

Jesper Juhl was both pointed at the cocci docs and
given a cocci script. He said he'd investigate it
when he could. I trust he will get to it.

I think that for this sort of patchset, grep and
manual inspection works just as well as spatch
and likely better because a simple cocci script
doesn't transform code like:

if (size > PAGE_SIZE)
ptr = vmalloc(size);
else
ptr = kmalloc(size, GFP);
if (ptr)
memset(ptr, 0, size);

I did say in the 00 cover that this was broken up
just to cc the maintainers of each block.

I also think a single rolled-up single patch is good.

I believe Jiri Kosina can easily apply all these
individual patches as a single patch if he chooses.

2010-11-05 07:16:20

by Eric Dumazet

[permalink] [raw]
Subject: Re: [PATCH 46/49] net/netfilter: Use vzalloc

Le jeudi 04 novembre 2010 à 23:55 -0700, Joe Perches a écrit :
> On Fri, 2010-11-05 at 07:30 +0100, Eric Dumazet wrote:
> > I had _one_ patch, waiting that David actually had vzalloc() in its tree
> > before sending it.
>
> Fine by me, use yours.

I dont care at all, only to say that David tree was not ready yet.


>
> > Given Jesper Juhl was doing this work, could you please take another
> > one, please ?
> > For example, explaining him how to use other tools than "bash+egrep
> > +manual inspection" as he mentioned in a previous mail.
>
> Jesper Juhl was both pointed at the cocci docs and
> given a cocci script. He said he'd investigate it
> when he could. I trust he will get to it.
>

Yes, yet you posted patches, knowing he was working on the _same_
subject.

I remember other occurrences of such behavior.

I find this behavior very unfriendly, time consuming, and not useful.

We try to work together, to increase our common knowledge, not to throw
a bunch of patches "just because I know better than you"


2010-11-05 09:11:21

by Jan Kara

[permalink] [raw]
Subject: Re: [PATCH 40/49] fs/udf: Use vzalloc

On Thu 04-11-10 20:08:04, Joe Perches wrote:
> Signed-off-by: Joe Perches <[email protected]>
> ---
> fs/udf/super.c | 5 ++---
> 1 files changed, 2 insertions(+), 3 deletions(-)
I've merged the patch into my tree.

Honza

>
> diff --git a/fs/udf/super.c b/fs/udf/super.c
> index 4a5c7c6..6e07d99 100644
> --- a/fs/udf/super.c
> +++ b/fs/udf/super.c
> @@ -959,9 +959,9 @@ static struct udf_bitmap *udf_sb_alloc_bitmap(struct super_block *sb, u32 index)
> (sizeof(struct buffer_head *) * nr_groups);
>
> if (size <= PAGE_SIZE)
> - bitmap = kmalloc(size, GFP_KERNEL);
> + bitmap = kzalloc(size, GFP_KERNEL);
> else
> - bitmap = vmalloc(size); /* TODO: get rid of vmalloc */
> + bitmap = vzalloc(size); /* TODO: get rid of vmalloc */
>
> if (bitmap == NULL) {
> udf_error(sb, __func__,
> @@ -970,7 +970,6 @@ static struct udf_bitmap *udf_sb_alloc_bitmap(struct super_block *sb, u32 index)
> return NULL;
> }
>
> - memset(bitmap, 0x00, size);
> bitmap->s_block_bitmap = (struct buffer_head **)(bitmap + 1);
> bitmap->s_nr_groups = nr_groups;
> return bitmap;
> --
> 1.7.3.1.g432b3.dirty
>
--
Jan Kara <[email protected]>
SUSE Labs, CR

2010-11-05 09:15:20

by Peter Bortas

[permalink] [raw]
Subject: Re: [PATCH 40/49] fs/udf: Use vzalloc

Hi,

On Fri, Nov 5, 2010 at 10:11 AM, Jan Kara <[email protected]> wrote:
> On Thu 04-11-10 20:08:04, Joe Perches wrote:
>> Signed-off-by: Joe Perches <[email protected]>
>> ---
>> ?fs/udf/super.c | ? ?5 ++---
>> ?1 files changed, 2 insertions(+), 3 deletions(-)
> ?I've merged the patch into my tree.
>
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Honza
>
>>
>> diff --git a/fs/udf/super.c b/fs/udf/super.c
>> index 4a5c7c6..6e07d99 100644
>> --- a/fs/udf/super.c
>> +++ b/fs/udf/super.c
>> @@ -959,9 +959,9 @@ static struct udf_bitmap *udf_sb_alloc_bitmap(struct super_block *sb, u32 index)
>> ? ? ? ? ? ? ? (sizeof(struct buffer_head *) * nr_groups);
>>
>> ? ? ? if (size <= PAGE_SIZE)
>> - ? ? ? ? ? ? bitmap = kmalloc(size, GFP_KERNEL);
>> + ? ? ? ? ? ? bitmap = kzalloc(size, GFP_KERNEL);
>> ? ? ? else
>> - ? ? ? ? ? ? bitmap = vmalloc(size); /* TODO: get rid of vmalloc */
>> + ? ? ? ? ? ? bitmap = vzalloc(size); /* TODO: get rid of vmalloc */

Shouldn't this comment be removed or at least changed to match the new malloc?

>>
>> ? ? ? if (bitmap == NULL) {
>> ? ? ? ? ? ? ? udf_error(sb, __func__,
>> @@ -970,7 +970,6 @@ static struct udf_bitmap *udf_sb_alloc_bitmap(struct super_block *sb, u32 index)
>> ? ? ? ? ? ? ? return NULL;
>> ? ? ? }
>>
>> - ? ? memset(bitmap, 0x00, size);
>> ? ? ? bitmap->s_block_bitmap = (struct buffer_head **)(bitmap + 1);
>> ? ? ? bitmap->s_nr_groups = nr_groups;
>> ? ? ? return bitmap;
>> --
>> 1.7.3.1.g432b3.dirty
>>
> --
> Jan Kara <[email protected]>
> SUSE Labs, CR

--
Peter Bortas

2010-11-05 09:29:47

by Thomas Hellstrom

[permalink] [raw]
Subject: Re: [PATCH 10/49] drivers/gpu: Use vzalloc

On 11/05/2010 04:07 AM, Joe Perches wrote:
> Signed-off-by: Joe Perches<[email protected]>
>
Reviewed-by: Thomas Hellstrom <[email protected]>

> ---
> drivers/gpu/drm/via/via_dmablit.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/via/via_dmablit.c b/drivers/gpu/drm/via/via_dmablit.c
> index 9b5b4d9..3e038a3 100644
> --- a/drivers/gpu/drm/via/via_dmablit.c
> +++ b/drivers/gpu/drm/via/via_dmablit.c
> @@ -235,9 +235,9 @@ via_lock_all_dma_pages(drm_via_sg_info_t *vsg, drm_via_dmablit_t *xfer)
> vsg->num_pages = VIA_PFN(xfer->mem_addr + (xfer->num_lines * xfer->mem_stride - 1)) -
> first_pfn + 1;
>
> - if (NULL == (vsg->pages = vmalloc(sizeof(struct page *) * vsg->num_pages)))
> + vsg->pages = vzalloc(sizeof(struct page *) * vsg->num_pages);
> + if (NULL == vsg->pages)
> return -ENOMEM;
> - memset(vsg->pages, 0, sizeof(struct page *) * vsg->num_pages);
> down_read(&current->mm->mmap_sem);
> ret = get_user_pages(current, current->mm,
> (unsigned long)xfer->mem_addr,
>

2010-11-05 09:31:02

by Jan Kara

[permalink] [raw]
Subject: Re: [PATCH 40/49] fs/udf: Use vzalloc

On Fri 05-11-10 10:15:15, Peter Bortas wrote:
> >> - ? ? ? ? ? ? bitmap = vmalloc(size); /* TODO: get rid of vmalloc */
> >> + ? ? ? ? ? ? bitmap = vzalloc(size); /* TODO: get rid of vmalloc */
>
> Shouldn't this comment be removed or at least changed to match the new malloc?
OK, changed. Thanks for pointing this out.

Honza
--
Jan Kara <[email protected]>
SUSE Labs, CR

2010-11-05 10:53:22

by Ralf Baechle

[permalink] [raw]
Subject: Re: [PATCH 02/49] arch/mips: Use vzalloc

Thanks, queued for 2.6.38.

Ralf

2010-11-05 11:58:51

by Rose, Gregory V

[permalink] [raw]
Subject: RE: [PATCH 23/49] drivers/net/igbvf: Use vzalloc

> -----Original Message-----
> From: Joe Perches [mailto:[email protected]]
> Sent: Thursday, November 04, 2010 8:08 PM
> To: Jiri Kosina
> Cc: Kirsher, Jeffrey T; Brandeburg, Jesse; Allan, Bruce W; Wyborny,
> Carolyn; Skidmore, Donald C; Rose, Gregory V; Waskiewicz Jr, Peter P;
> Duyck, Alexander H; Ronciak, John; [email protected];
> [email protected]; [email protected]
> Subject: [PATCH 23/49] drivers/net/igbvf: Use vzalloc
>
> Signed-off-by: Joe Perches <[email protected]>
> ---
> drivers/net/igbvf/netdev.c | 6 ++----
> 1 files changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/igbvf/netdev.c b/drivers/net/igbvf/netdev.c
> index 28af019..08e7459 100644
> --- a/drivers/net/igbvf/netdev.c
> +++ b/drivers/net/igbvf/netdev.c
> @@ -429,10 +429,9 @@ int igbvf_setup_tx_resources(struct igbvf_adapter
> *adapter,
> int size;
>
> size = sizeof(struct igbvf_buffer) * tx_ring->count;
> - tx_ring->buffer_info = vmalloc(size);
> + tx_ring->buffer_info = vzalloc(size);
> if (!tx_ring->buffer_info)
> goto err;
> - memset(tx_ring->buffer_info, 0, size);
>
> /* round up to nearest 4K */
> tx_ring->size = tx_ring->count * sizeof(union e1000_adv_tx_desc);
> @@ -469,10 +468,9 @@ int igbvf_setup_rx_resources(struct igbvf_adapter
> *adapter,
> int size, desc_len;
>
> size = sizeof(struct igbvf_buffer) * rx_ring->count;
> - rx_ring->buffer_info = vmalloc(size);
> + rx_ring->buffer_info = vzalloc(size);
> if (!rx_ring->buffer_info)
> goto err;
> - memset(rx_ring->buffer_info, 0, size);
>
> desc_len = sizeof(union e1000_adv_rx_desc);
>
> --
> 1.7.3.1.g432b3.dirty

Acked By: Greg Rose <[email protected]>

2010-11-05 11:59:40

by Rose, Gregory V

[permalink] [raw]
Subject: RE: [PATCH 26/49] drivers/net/ixgbevf: Use vzalloc

> -----Original Message-----
> From: Joe Perches [mailto:[email protected]]
> Sent: Thursday, November 04, 2010 8:08 PM
> To: Jiri Kosina
> Cc: Kirsher, Jeffrey T; Brandeburg, Jesse; Allan, Bruce W; Wyborny,
> Carolyn; Skidmore, Donald C; Rose, Gregory V; Waskiewicz Jr, Peter P;
> Duyck, Alexander H; Ronciak, John; [email protected];
> [email protected]; [email protected]
> Subject: [PATCH 26/49] drivers/net/ixgbevf: Use vzalloc
>
> Signed-off-by: Joe Perches <[email protected]>
> ---
> drivers/net/ixgbevf/ixgbevf_main.c | 6 ++----
> 1 files changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ixgbevf/ixgbevf_main.c
> b/drivers/net/ixgbevf/ixgbevf_main.c
> index dc03c96..6aeaf54 100644
> --- a/drivers/net/ixgbevf/ixgbevf_main.c
> +++ b/drivers/net/ixgbevf/ixgbevf_main.c
> @@ -2488,10 +2488,9 @@ int ixgbevf_setup_tx_resources(struct
> ixgbevf_adapter *adapter,
> int size;
>
> size = sizeof(struct ixgbevf_tx_buffer) * tx_ring->count;
> - tx_ring->tx_buffer_info = vmalloc(size);
> + tx_ring->tx_buffer_info = vzalloc(size);
> if (!tx_ring->tx_buffer_info)
> goto err;
> - memset(tx_ring->tx_buffer_info, 0, size);
>
> /* round up to nearest 4K */
> tx_ring->size = tx_ring->count * sizeof(union ixgbe_adv_tx_desc);
> @@ -2555,14 +2554,13 @@ int ixgbevf_setup_rx_resources(struct
> ixgbevf_adapter *adapter,
> int size;
>
> size = sizeof(struct ixgbevf_rx_buffer) * rx_ring->count;
> - rx_ring->rx_buffer_info = vmalloc(size);
> + rx_ring->rx_buffer_info = vzalloc(size);
> if (!rx_ring->rx_buffer_info) {
> hw_dbg(&adapter->hw,
> "Unable to vmalloc buffer memory for "
> "the receive descriptor ring\n");
> goto alloc_failed;
> }
> - memset(rx_ring->rx_buffer_info, 0, size);
>
> /* Round up to nearest 4K */
> rx_ring->size = rx_ring->count * sizeof(union ixgbe_adv_rx_desc);
> --
> 1.7.3.1.g432b3.dirty

Acked By: Greg Rose <[email protected]>

2010-11-05 13:08:58

by Jeremy Kerr

[permalink] [raw]
Subject: Re: [Cbe-oss-dev] [PATCH 03/49] arch/powerpc: Use vzalloc

Hi Joe,

> diff --git a/arch/powerpc/platforms/cell/spufs/lscsa_alloc.c
> b/arch/powerpc/platforms/cell/spufs/lscsa_alloc.c index a101abf..3b894f5
> 100644
> --- a/arch/powerpc/platforms/cell/spufs/lscsa_alloc.c
> +++ b/arch/powerpc/platforms/cell/spufs/lscsa_alloc.c
> @@ -36,10 +36,9 @@ static int spu_alloc_lscsa_std(struct spu_state *csa)
> struct spu_lscsa *lscsa;
> unsigned char *p;
>
> - lscsa = vmalloc(sizeof(struct spu_lscsa));
> + lscsa = vzalloc(sizeof(struct spu_lscsa));
> if (!lscsa)
> return -ENOMEM;
> - memset(lscsa, 0, sizeof(struct spu_lscsa));
> csa->lscsa = lscsa;
>
> /* Set LS pages reserved to allow for user-space mapping. */

For the spufs bit:

Acked-By: Jeremy Kerr <[email protected]>

Cheers,


Jeremy

2010-11-05 15:10:28

by Jiri Kosina

[permalink] [raw]
Subject: Re: [PATCH 46/49] net/netfilter: Use vzalloc

On Thu, 4 Nov 2010, Joe Perches wrote:

> I also think a single rolled-up single patch is good.
>
> I believe Jiri Kosina can easily apply all these individual patches as a
> single patch if he chooses.

I will, after this settles a little bit (the same for the WARN series).
I prefer waiting a bit before applying your patches usually.

First to see what lands in linux-next through maintainer's trees, second
to gather Acks.

--
Jiri Kosina
SUSE Labs, Novell Inc.

2010-11-05 15:25:38

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 46/49] net/netfilter: Use vzalloc

On Fri, 2010-11-05 at 11:10 -0400, Jiri Kosina wrote:
> On Thu, 4 Nov 2010, Joe Perches wrote:
> > I also think a single rolled-up single patch is good.
> > I believe Jiri Kosina can easily apply all these individual patches as a
> > single patch if he chooses.
> I will, after this settles a little bit (the same for the WARN series).
> I prefer waiting a bit before applying your patches usually.
> First to see what lands in linux-next through maintainer's trees, second
> to gather Acks.

I think that's the right way to do these
sorts of trivial changes too.

Individual patches cc'd to maintainers for
feedback, improvement, acks or to be directly
applied to their trees, followed by a longish
delay before any unapplied patches are taken
up as a single patch by your trivial queue.

Thanks for doing that work Jiri.

2010-11-05 17:10:04

by Alex Elder

[permalink] [raw]
Subject: Re: [PATCH 41/49] fs/xfs: Use vzalloc

On Thu, 2010-11-04 at 20:08 -0700, Joe Perches wrote:
> Signed-off-by: Joe Perches <[email protected]>
> ---
> fs/xfs/linux-2.6/kmem.h | 7 +------
> 1 files changed, 1 insertions(+), 6 deletions(-)
>
> diff --git a/fs/xfs/linux-2.6/kmem.h b/fs/xfs/linux-2.6/kmem.h
> index f7c8f7a..292eff1 100644
> --- a/fs/xfs/linux-2.6/kmem.h
> +++ b/fs/xfs/linux-2.6/kmem.h
> @@ -61,12 +61,7 @@ extern void kmem_free(const void *);
>
> static inline void *kmem_zalloc_large(size_t size)
> {
> - void *ptr;
> -
> - ptr = vmalloc(size);
> - if (ptr)
> - memset(ptr, 0, size);
> - return ptr;
> + return vzalloc(size);
> }
> static inline void kmem_free_large(void *ptr)
> {

Looks good to me.

Reviewed-by: Alex Elder <[email protected]>

2010-11-05 17:12:34

by Jesper Juhl

[permalink] [raw]
Subject: Re: [PATCH 46/49] net/netfilter: Use vzalloc

On Fri, 5 Nov 2010, Eric Dumazet wrote:

> Le jeudi 04 novembre 2010 à 23:55 -0700, Joe Perches a écrit :
> > On Fri, 2010-11-05 at 07:30 +0100, Eric Dumazet wrote:
> > > I had _one_ patch, waiting that David actually had vzalloc() in its tree
> > > before sending it.
> >
> > Fine by me, use yours.
>
> I dont care at all, only to say that David tree was not ready yet.
>
>
> >
> > > Given Jesper Juhl was doing this work, could you please take another
> > > one, please ?
> > > For example, explaining him how to use other tools than "bash+egrep
> > > +manual inspection" as he mentioned in a previous mail.
> >
> > Jesper Juhl was both pointed at the cocci docs and
> > given a cocci script. He said he'd investigate it
> > when he could. I trust he will get to it.
> >
>
> Yes, yet you posted patches, knowing he was working on the _same_
> subject.
>
And I will get to look at cocci and spatch, they are definately tools that
I want in my arsenal.

> I remember other occurrences of such behavior.
>
> I find this behavior very unfriendly, time consuming, and not useful.
>
> We try to work together, to increase our common knowledge, not to throw
> a bunch of patches "just because I know better than you"
>

To be completely honest, I did get the feeling that the task I'd set for
myself and was having fun doing in the little spare time I have got
hijacked and I did waste about an hour and a half doing a few more
cleanups before I saw the patchset on lkml.

But on the other hand, the most important thing is that it gets done, not
who ends up doing it - especially since it's such a trivial cleanup, so I
choose to see it as my initial patches just getting the ball rolling.

It would have been nice with at least an email along the lines of "I
know how we can do all those patches in a jiffy, mind if I just go along
and do that?", but I'll live. There's plenty of other stuff to do :-)


--
Jesper Juhl <[email protected]> http://www.chaosbits.net/
Plain text mails only, please http://www.expita.com/nomime.html
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html

2010-11-08 16:45:31

by Konrad Rzeszutek Wilk

[permalink] [raw]
Subject: Re: [PATCH 36/49] drivers/video: Use vzalloc

On Thu, Nov 04, 2010 at 08:08:00PM -0700, Joe Perches wrote:
> Signed-off-by: Joe Perches <[email protected]>

Looks good on xen-fb.


> ---
> drivers/video/arcfb.c | 5 ++---
> drivers/video/broadsheetfb.c | 4 +---
> drivers/video/hecubafb.c | 5 ++---
> drivers/video/metronomefb.c | 4 +---
> drivers/video/xen-fbfront.c | 3 +--
> 5 files changed, 7 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/video/arcfb.c b/drivers/video/arcfb.c
> index 3ec4923..86573e2 100644
> --- a/drivers/video/arcfb.c
> +++ b/drivers/video/arcfb.c
> @@ -515,11 +515,10 @@ static int __devinit arcfb_probe(struct platform_device *dev)
>
> /* We need a flat backing store for the Arc's
> less-flat actual paged framebuffer */
> - if (!(videomemory = vmalloc(videomemorysize)))
> + videomemory = vmalloc(videomemorysize);
> + if (!videomemory)
> return retval;
>
> - memset(videomemory, 0, videomemorysize);
> -
> info = framebuffer_alloc(sizeof(struct arcfb_par), &dev->dev);
> if (!info)
> goto err;
> diff --git a/drivers/video/broadsheetfb.c b/drivers/video/broadsheetfb.c
> index ebda687..377dde3 100644
> --- a/drivers/video/broadsheetfb.c
> +++ b/drivers/video/broadsheetfb.c
> @@ -1101,12 +1101,10 @@ static int __devinit broadsheetfb_probe(struct platform_device *dev)
>
> videomemorysize = roundup((dpyw*dpyh), PAGE_SIZE);
>
> - videomemory = vmalloc(videomemorysize);
> + videomemory = vzalloc(videomemorysize);
> if (!videomemory)
> goto err_fb_rel;
>
> - memset(videomemory, 0, videomemorysize);
> -
> info->screen_base = (char *)videomemory;
> info->fbops = &broadsheetfb_ops;
>
> diff --git a/drivers/video/hecubafb.c b/drivers/video/hecubafb.c
> index c77bcc6..a941e6f 100644
> --- a/drivers/video/hecubafb.c
> +++ b/drivers/video/hecubafb.c
> @@ -231,11 +231,10 @@ static int __devinit hecubafb_probe(struct platform_device *dev)
>
> videomemorysize = (DPY_W*DPY_H)/8;
>
> - if (!(videomemory = vmalloc(videomemorysize)))
> + videomemory = vzalloc(videomemorysize);
> + if (!videomemory)
> return retval;
>
> - memset(videomemory, 0, videomemorysize);
> -
> info = framebuffer_alloc(sizeof(struct hecubafb_par), &dev->dev);
> if (!info)
> goto err_fballoc;
> diff --git a/drivers/video/metronomefb.c b/drivers/video/metronomefb.c
> index 63ed3b7..c0c358c 100644
> --- a/drivers/video/metronomefb.c
> +++ b/drivers/video/metronomefb.c
> @@ -628,12 +628,10 @@ static int __devinit metronomefb_probe(struct platform_device *dev)
> /* we need to add a spare page because our csum caching scheme walks
> * to the end of the page */
> videomemorysize = PAGE_SIZE + (fw * fh);
> - videomemory = vmalloc(videomemorysize);
> + videomemory = vzalloc(videomemorysize);
> if (!videomemory)
> goto err_fb_rel;
>
> - memset(videomemory, 0, videomemorysize);
> -
> info->screen_base = (char __force __iomem *)videomemory;
> info->fbops = &metronomefb_ops;
>
> diff --git a/drivers/video/xen-fbfront.c b/drivers/video/xen-fbfront.c
> index 428d273..81fcaea 100644
> --- a/drivers/video/xen-fbfront.c
> +++ b/drivers/video/xen-fbfront.c
> @@ -395,10 +395,9 @@ static int __devinit xenfb_probe(struct xenbus_device *dev,
> spin_lock_init(&info->dirty_lock);
> spin_lock_init(&info->resize_lock);
>
> - info->fb = vmalloc(fb_size);
> + info->fb = vzalloc(fb_size);
> if (info->fb == NULL)
> goto error_nomem;
> - memset(info->fb, 0, fb_size);
>
> info->nr_pages = (fb_size + PAGE_SIZE - 1) >> PAGE_SHIFT;
>
> --
> 1.7.3.1.g432b3.dirty

2010-11-13 11:19:42

by Artem Bityutskiy

[permalink] [raw]
Subject: Re: [PATCH 16/49] drivers/mtd: Use vzalloc

On Thu, 2010-11-04 at 20:07 -0700, Joe Perches wrote:
> Signed-off-by: Joe Perches <[email protected]>
> ---
> drivers/mtd/nand/nandsim.c | 3 +--
> drivers/mtd/ubi/vtbl.c | 6 ++----
> 2 files changed, 3 insertions(+), 6 deletions(-)

Pushed to l2-mtd-2.6.git, thanks.

--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

2010-11-13 11:19:48

by Artem Bityutskiy

[permalink] [raw]
Subject: Re: [PATCH 38/49] fs/jffs2: Use vzalloc

On Thu, 2010-11-04 at 20:08 -0700, Joe Perches wrote:
> Signed-off-by: Joe Perches <[email protected]>
> ---
> fs/jffs2/build.c | 5 ++---
> 1 files changed, 2 insertions(+), 3 deletions(-)

Pushed to l2-mtd-2.6.git, thanks.

--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

2010-11-22 06:59:59

by Takashi Iwai

[permalink] [raw]
Subject: Re: [PATCH 48/49] sound/oss/dev_table.c: Use vzalloc

At Thu, 4 Nov 2010 20:08:12 -0700,
Joe Perches wrote:
>
> Signed-off-by: Joe Perches <[email protected]>

Thanks, applied.
[Sorry to be late, this has been already applied in my tree but this
reply mail wasn't triggered to be sent out until now...]


Takashi

> ---
> sound/oss/dev_table.c | 6 ++----
> 1 files changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/sound/oss/dev_table.c b/sound/oss/dev_table.c
> index 727bdb9..d8cf3e5 100644
> --- a/sound/oss/dev_table.c
> +++ b/sound/oss/dev_table.c
> @@ -71,7 +71,7 @@ int sound_install_audiodrv(int vers, char *name, struct audio_driver *driver,
> if (sound_nblocks >= MAX_MEM_BLOCKS)
> sound_nblocks = MAX_MEM_BLOCKS - 1;
>
> - op = (struct audio_operations *) (sound_mem_blocks[sound_nblocks] = vmalloc(sizeof(struct audio_operations)));
> + op = (struct audio_operations *) (sound_mem_blocks[sound_nblocks] = vzalloc(sizeof(struct audio_operations)));
> sound_nblocks++;
> if (sound_nblocks >= MAX_MEM_BLOCKS)
> sound_nblocks = MAX_MEM_BLOCKS - 1;
> @@ -81,7 +81,6 @@ int sound_install_audiodrv(int vers, char *name, struct audio_driver *driver,
> sound_unload_audiodev(num);
> return -(ENOMEM);
> }
> - memset((char *) op, 0, sizeof(struct audio_operations));
> init_waitqueue_head(&op->in_sleeper);
> init_waitqueue_head(&op->out_sleeper);
> init_waitqueue_head(&op->poll_sleeper);
> @@ -128,7 +127,7 @@ int sound_install_mixer(int vers, char *name, struct mixer_operations *driver,
> /* FIXME: This leaks a mixer_operations struct every time its called
> until you unload sound! */
>
> - op = (struct mixer_operations *) (sound_mem_blocks[sound_nblocks] = vmalloc(sizeof(struct mixer_operations)));
> + op = (struct mixer_operations *) (sound_mem_blocks[sound_nblocks] = vzalloc(sizeof(struct mixer_operations)));
> sound_nblocks++;
> if (sound_nblocks >= MAX_MEM_BLOCKS)
> sound_nblocks = MAX_MEM_BLOCKS - 1;
> @@ -137,7 +136,6 @@ int sound_install_mixer(int vers, char *name, struct mixer_operations *driver,
> printk(KERN_ERR "Sound: Can't allocate mixer driver for (%s)\n", name);
> return -ENOMEM;
> }
> - memset((char *) op, 0, sizeof(struct mixer_operations));
> memcpy((char *) op, (char *) driver, driver_size);
>
> strlcpy(op->name, name, sizeof(op->name));
> --
> 1.7.3.1.g432b3.dirty
>

2010-11-27 08:32:14

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH 06/49] crypto: Use vzalloc

On Thu, Nov 04, 2010 at 08:07:30PM -0700, Joe Perches wrote:
> Signed-off-by: Joe Perches <[email protected]>

Patch applied. Thanks.
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt