Skip to contentSkip to conversation

treewide: Convert vmalloc/memset to vzalloc

PATCH Applied Joe Perches 12 participants 35 messages May 28, 2011 – Jun 3, 2011 2 messages not in the archive

Subsystems (27)
lore
Share & tools
lore
#0 lore raw

cover treewide: Convert vmalloc/memset to vzalloc

Resubmittal of patches from November 2010 and a few new ones.

Joe Perches (15):
s390: Convert vmalloc/memset to vzalloc
x86: Convert vmalloc/memset to vzalloc
atm: Convert vmalloc/memset to vzalloc
drbd: Convert vmalloc/memset to vzalloc
char: Convert vmalloc/memset to vzalloc
isdn: Convert vmalloc/memset to vzalloc
md: Convert vmalloc/memset to vzalloc
media: Convert vmalloc/memset to vzalloc
mtd: Convert vmalloc/memset to vzalloc
scsi: Convert vmalloc/memset to vzalloc
staging: Convert vmalloc/memset to vzalloc
video: Convert vmalloc/memset to vzalloc
fs: Convert vmalloc/memset to vzalloc
mm: Convert vmalloc/memset to vzalloc
net: Convert vmalloc/memset to vzalloc

 arch/s390/hypfs/hypfs_diag.c           |    3 +--
 arch/x86/mm/pageattr-test.c            |    3 +--
 drivers/atm/idt77252.c                 |   11 ++++++-----
 drivers/atm/lanai.c                    |    3 +--
 drivers/block/drbd/drbd_bitmap.c       |    5 ++---
 drivers/char/agp/backend.c             |    3 +--
 drivers/char/raw.c                     |    3 +--
 drivers/isdn/i4l/isdn_common.c         |    4 ++--
 drivers/isdn/mISDN/dsp_core.c          |    3 +--
 drivers/isdn/mISDN/l1oip_codec.c       |    6 ++----
 drivers/md/dm-log.c                    |    3 +--
 drivers/md/dm-snap-persistent.c        |    3 +--
 drivers/md/dm-table.c                  |    4 +---
 drivers/media/video/videobuf2-dma-sg.c |    8 ++------
 drivers/mtd/mtdswap.c                  |    3 +--
 drivers/s390/cio/blacklist.c           |    3 +--
 drivers/scsi/bfa/bfad.c                |    3 +--
 drivers/scsi/bfa/bfad_debugfs.c        |    8 ++------
 drivers/scsi/cxgbi/libcxgbi.h          |    6 ++----
 drivers/scsi/qla2xxx/qla_attr.c        |    6 ++----
 drivers/scsi/qla2xxx/qla_bsg.c         |    3 +--
 drivers/scsi/scsi_debug.c              |    7 ++-----
 drivers/staging/rts_pstor/ms.c         |    3 +--
 drivers/staging/rts_pstor/rtsx_chip.c  |    6 ++----
 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 +--
 fs/coda/coda_linux.h                   |    5 ++---
 fs/reiserfs/journal.c                  |    9 +++------
 fs/reiserfs/resize.c                   |    4 +---
 fs/xfs/linux-2.6/kmem.h                |    7 +------
 mm/page_cgroup.c                       |    3 +--
 net/netfilter/x_tables.c               |    5 ++---
 net/rds/ib_cm.c                        |    6 ++----
 36 files changed, 57 insertions(+), 113 deletions(-)
Signature · 8 lines
1.7.5.rc3.dirty

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#1 lore raw

PATCH 1/15 s390: Convert vmalloc/memset to vzalloc

---
 arch/s390/hypfs/hypfs_diag.c |    3 +--
 drivers/s390/cio/blacklist.c |    3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
arch/s390/hypfs/hypfs_diag.c +1 -2
index 6023c6d..74c8f5e 100644
@@ -562,10 +562,9 @@ static int dbfs_d204_create(void **data, void **data_free_ptr, size_t *size)
 	void *base;
 
 	buf_size = PAGE_SIZE * (diag204_buf_pages + 1) + sizeof(d204->hdr);
-	base = vmalloc(buf_size);
+	base = vzalloc(buf_size);
 	if (!base)
 		return -ENOMEM;
-	memset(base, 0, buf_size);
 	d204 = page_align_ptr(base + sizeof(d204->hdr)) - sizeof(d204->hdr);
 	rc = diag204_do_store(d204->buf, diag204_buf_pages);
 	if (rc) {
drivers/s390/cio/blacklist.c +1 -2
index 76058a5..08c6603 100644
@@ -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;
Signature · 1 line
1.7.5.rc3.dirty
#2 lore raw

PATCH 2/15 x86: Convert vmalloc/memset to vzalloc

In reply to Joe Perches
---
 arch/x86/mm/pageattr-test.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
arch/x86/mm/pageattr-test.c +1 -2
index e1d1069..b008656 100644
@@ -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);
Signature · 1 line
1.7.5.rc3.dirty
#3 lore raw

[tip:x86/cleanups] x86: Convert vmalloc()+memset() to vzalloc()

Commit-ID:  c4d017f21328c269deba3c7acde873204fe595b5
Gitweb:     http://git.kernel.org/tip/c4d017f21328c269deba3c7acde873204fe595b5
Author:     Joe Perches <[email protected]>
AuthorDate: Sat, 28 May 2011 10:36:22 -0700
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 28 May 2011 19:53:57 +0200

x86: Convert vmalloc()+memset() to vzalloc()

---
 arch/x86/mm/pageattr-test.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
arch/x86/mm/pageattr-test.c +1 -2
index e1d1069..b008656 100644
@@ -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);
#4 lore raw

PATCH 3/15 atm: Convert vmalloc/memset to vzalloc

In reply to Joe Perches
---
 drivers/atm/idt77252.c |   11 ++++++-----
 drivers/atm/lanai.c    |    3 +--
 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/atm/idt77252.c +6 -5
index 1f8d724..8d7b663 100644
@@ -3415,27 +3415,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;
drivers/atm/lanai.c +1 -2
index 4e8ba56..be57a14 100644
@@ -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
 }
Signature · 1 line
1.7.5.rc3.dirty
#5 lore raw

PATCH 4/15 drbd: Convert vmalloc/memset to vzalloc

In reply to Joe Perches
---
 drivers/block/drbd/drbd_bitmap.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
drivers/block/drbd/drbd_bitmap.c +2 -3
index f440a02..9dd03b0 100644
@@ -381,15 +381,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];
Signature · 1 line
1.7.5.rc3.dirty
#6 lore raw

PATCH 5/15 char: Convert vmalloc/memset to vzalloc

In reply to Joe Perches
---
 drivers/char/agp/backend.c |    3 +--
 drivers/char/raw.c         |    3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/char/agp/backend.c +1 -2
index f27d0d0..4b71647 100644
@@ -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");
drivers/char/raw.c +1 -2
index b33e8ea..b6de2c0 100644
@@ -324,13 +324,12 @@ static int __init raw_init(void)
 		max_raw_minors = MAX_RAW_MINORS;
 	}
 
-	raw_devices = vmalloc(sizeof(struct raw_device_data) * max_raw_minors);
+	raw_devices = vzalloc(sizeof(struct raw_device_data) * max_raw_minors);
 	if (!raw_devices) {
 		printk(KERN_ERR "Not enough memory for raw device structures\n");
 		ret = -ENOMEM;
 		goto error;
 	}
-	memset(raw_devices, 0, sizeof(struct raw_device_data) * max_raw_minors);
 
 	ret = register_chrdev_region(dev, max_raw_minors, "raw");
 	if (ret)
Signature · 1 line
1.7.5.rc3.dirty
#7 lore raw

PATCH 6/15 isdn: Convert vmalloc/memset to vzalloc

In reply to Joe Perches
---
 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(-)
drivers/isdn/i4l/isdn_common.c +2 -2
index 6ed82ad..6ddb795e 100644
@@ -2308,11 +2308,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);
drivers/isdn/mISDN/dsp_core.c +1 -2
index 2877291..0c41553 100644
@@ -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__);
 
drivers/isdn/mISDN/l1oip_codec.c +2 -4
index bbfd1b8..5a89972 100644
@@ -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) {
Signature · 1 line
1.7.5.rc3.dirty

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw

PATCH 14/15 mm: Convert vmalloc/memset to vzalloc

---
 mm/page_cgroup.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
mm/page_cgroup.c +1 -2
index 74ccff6..dbb28fd 100644
@@ -478,11 +478,10 @@ int swap_cgroup_swapon(int type, unsigned long max_pages)
 	length = DIV_ROUND_UP(max_pages, SC_PER_PAGE);
 	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;
Signature · 1 line
1.7.5.rc3.dirty
#10 lore raw

PATCH 7/15 md: Convert vmalloc/memset to vzalloc

In reply to Joe Perches
---
 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(-)
drivers/md/dm-log.c +1 -2
index a1f3218..b6c2b71 100644
@@ -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;
 
drivers/md/dm-snap-persistent.c +1 -2
index 95891df..be100d4 100644
@@ -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)
drivers/md/dm-table.c +1 -3
index cb8380c..5850497 100644
@@ -154,9 +154,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;
 }
Signature · 1 line
1.7.5.rc3.dirty
#11 lore raw

PATCH 8/15 media: Convert vmalloc/memset to vzalloc

In reply to Joe Perches
---
 drivers/media/video/videobuf2-dma-sg.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)
drivers/media/video/videobuf2-dma-sg.c +2 -6
index b2d9485..15d79a8 100644
@@ -48,12 +48,10 @@ static void *vb2_dma_sg_alloc(void *alloc_ctx, unsigned long size)
 	buf->sg_desc.size = size;
 	buf->sg_desc.num_pages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
 
-	buf->sg_desc.sglist = vmalloc(buf->sg_desc.num_pages *
+	buf->sg_desc.sglist = vzalloc(buf->sg_desc.num_pages *
 				      sizeof(*buf->sg_desc.sglist));
 	if (!buf->sg_desc.sglist)
 		goto fail_sglist_alloc;
-	memset(buf->sg_desc.sglist, 0, buf->sg_desc.num_pages *
-	       sizeof(*buf->sg_desc.sglist));
 	sg_init_table(buf->sg_desc.sglist, buf->sg_desc.num_pages);
 
 	buf->pages = kzalloc(buf->sg_desc.num_pages * sizeof(struct page *),
@@ -136,13 +134,11 @@ static void *vb2_dma_sg_get_userptr(void *alloc_ctx, unsigned long vaddr,
 	last  = ((vaddr + size - 1) & PAGE_MASK) >> PAGE_SHIFT;
 	buf->sg_desc.num_pages = last - first + 1;
 
-	buf->sg_desc.sglist = vmalloc(
+	buf->sg_desc.sglist = vzalloc(
 		buf->sg_desc.num_pages * sizeof(*buf->sg_desc.sglist));
 	if (!buf->sg_desc.sglist)
 		goto userptr_fail_sglist_alloc;
 
-	memset(buf->sg_desc.sglist, 0,
-		buf->sg_desc.num_pages * sizeof(*buf->sg_desc.sglist));
 	sg_init_table(buf->sg_desc.sglist, buf->sg_desc.num_pages);
 
 	buf->pages = kzalloc(buf->sg_desc.num_pages * sizeof(struct page *),
Signature · 1 line
1.7.5.rc3.dirty
#12 lore raw

PATCH 9/15 mtd: Convert vmalloc/memset to vzalloc

In reply to Joe Perches
---
 drivers/mtd/mtdswap.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/mtd/mtdswap.c +1 -2
index fd78853..5e5423b 100644
@@ -1374,11 +1374,10 @@ static int mtdswap_init(struct mtdswap_dev *d, unsigned int eblocks,
 		goto revmap_fail;
 
 	eblk_bytes = sizeof(struct swap_eb)*d->eblks;
-	d->eb_data = vmalloc(eblk_bytes);
+	d->eb_data = vzalloc(eblk_bytes);
 	if (!d->eb_data)
 		goto eb_data_fail;
 
-	memset(d->eb_data, 0, eblk_bytes);
 	for (i = 0; i < pages; i++)
 		d->page_data[i] = BLOCK_UNDEF;
 
Signature · 1 line
1.7.5.rc3.dirty
#13 lore raw

Re: [TRIVIAL PATCH next 09/15] mtd: Convert vmalloc/memset to vzalloc

Quoted 4 lines · Joe Perches
---
 drivers/mtd/mtdswap.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

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

Signature · 2 lines
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
#14 lore raw

PATCH 10/15 scsi: Convert vmalloc/memset to vzalloc

In reply to Joe Perches
---
 drivers/scsi/bfa/bfad.c         |    3 +--
 drivers/scsi/bfa/bfad_debugfs.c |    8 ++------
 drivers/scsi/cxgbi/libcxgbi.h   |    6 ++----
 drivers/scsi/qla2xxx/qla_attr.c |    6 ++----
 drivers/scsi/qla2xxx/qla_bsg.c  |    3 +--
 drivers/scsi/scsi_debug.c       |    7 ++-----
 6 files changed, 10 insertions(+), 23 deletions(-)
drivers/scsi/bfa/bfad.c +1 -2
index 59b5e9b..fc6bb02 100644
@@ -612,13 +612,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:
drivers/scsi/bfa/bfad_debugfs.c +2 -6
index 48be0c5..469b0fc 100644
@@ -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_ioc_debug_fwtrc(&bfad->bfa.ioc,
 			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_ioc_debug_fwsave(&bfad->bfa.ioc,
 			fw_debug->debug_buffer,
drivers/scsi/cxgbi/libcxgbi.h +2 -4
index 9267844..e4c3d63 100644
@@ -658,11 +658,9 @@ static inline u32 cxgbi_tag_nonrsvd_bits(struct cxgbi_tag_format *tformat,
 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;
 }
 
drivers/scsi/qla2xxx/qla_attr.c +2 -4
index 532313e..31634dc 100644
@@ -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;
@@ -338,7 +337,7 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,
 		    ha->optrom_size - start : size;
 
 		ha->optrom_state = QLA_SWRITING;
-		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 update "
@@ -352,7 +351,6 @@ qla2x00_sysfs_write_optrom_ctl(struct file *filp, struct kobject *kobj,
 		    "Staging flash region write -- 0x%x/0x%x.\n",
 		    ha->optrom_region_start, ha->optrom_region_size));
 
-		memset(ha->optrom_buffer, 0, ha->optrom_region_size);
 		break;
 	case 3:
 		if (ha->optrom_state != QLA_SWRITING)
drivers/scsi/qla2xxx/qla_bsg.c +1 -2
index 8c10e2c..5f4e574 100644
@@ -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;
 }
 
drivers/scsi/scsi_debug.c +2 -5
index 6888b2c..185d465 100644
@@ -3334,12 +3334,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);
 
@@ -3384,7 +3383,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);
@@ -3395,8 +3394,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);
Signature · 1 line
1.7.5.rc3.dirty
#15 lore raw

PATCH 11/15 staging: Convert vmalloc/memset to vzalloc

In reply to Joe Perches
---
 drivers/staging/rts_pstor/ms.c        |    3 +--
 drivers/staging/rts_pstor/rtsx_chip.c |    6 ++----
 2 files changed, 3 insertions(+), 6 deletions(-)
drivers/staging/rts_pstor/ms.c +1 -2
index 2e82587..66341df 100644
@@ -2064,11 +2064,10 @@ static int ms_init_l2p_tbl(struct rtsx_chip *chip)
 	RTSX_DEBUGP("ms_card->segment_cnt = %d\n", ms_card->segment_cnt);
 
 	size = ms_card->segment_cnt * sizeof(struct zone_entry);
-	ms_card->segment = (struct zone_entry *)vmalloc(size);
+	ms_card->segment = vzalloc(size);
 	if (ms_card->segment == NULL) {
 		TRACE_RET(chip, STATUS_FAIL);
 	}
-	memset(ms_card->segment, 0, size);
 
 	retval = ms_read_page(chip, ms_card->boot_block, 1);
 	if (retval != STATUS_SUCCESS) {
drivers/staging/rts_pstor/rtsx_chip.c +2 -4
index 4e60780..5452069 100644
@@ -1596,18 +1596,16 @@ int rtsx_write_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf, int l
 	}
 	RTSX_DEBUGP("dw_len = %d\n", dw_len);
 
-	data = (u32 *)vmalloc(dw_len * 4);
+	data = vzalloc(dw_len * 4);
 	if (!data) {
 		TRACE_RET(chip, STATUS_NOMEM);
 	}
-	memset(data, 0, dw_len * 4);
 
-	mask = (u32 *)vmalloc(dw_len * 4);
+	mask = vzalloc(dw_len * 4);
 	if (!mask) {
 		vfree(data);
 		TRACE_RET(chip, STATUS_NOMEM);
 	}
-	memset(mask, 0, dw_len * 4);
 
 	j = 0;
 	for (i = 0; i < len; i++) {
Signature · 1 line
1.7.5.rc3.dirty
#16 lore raw

PATCH 12/15 video: Convert vmalloc/memset to vzalloc

In reply to Joe Perches
---
 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(-)
drivers/video/arcfb.c +2 -3
index 3ec4923..86573e2 100644
@@ -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;
drivers/video/broadsheetfb.c +1 -3
index ebda687..377dde3 100644
@@ -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;
 
drivers/video/hecubafb.c +2 -3
index 1b94643..fbef15f 100644
@@ -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;
drivers/video/metronomefb.c +1 -3
index ed64edf..97d45e5 100644
@@ -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;
 
drivers/video/xen-fbfront.c +1 -2
index a20218c..beac52f 100644
@@ -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;
 
Signature · 1 line
1.7.5.rc3.dirty
#17 lore raw

Re: [TRIVIAL PATCH next 12/15] video: Convert vmalloc/memset to vzalloc

Am Samstag 28 Mai 2011, 19:36:32 schrieb Joe Perches:

drivers/video/arcfb.c static int __devinit arcfb_probe(struct · line 521

Quoted 13 lines
drivers/video/arcfb.c +2 -1
index 3ec4923..86573e2 100644
@@ -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;

shouldn't this be vzalloc too?

drivers/video/arcfb.c static int __devinit arcfb_probe(struct platform_device *dev) · line 524

Quoted 5 lines
drivers/video/arcfb.c +0 -2
-	memset(videomemory, 0, videomemorysize);
-
 	info = framebuffer_alloc(sizeof(struct arcfb_par), &dev->dev);
 	if (!info)
 		goto err;

Heiko

#18 lore raw

PATCH v2 12/15 video: Convert vmalloc/memset to vzalloc

---
Heiko Stübner <[email protected]> pointed out I can't type... s/vmalloc/vmalloc/ doesn't do much.

 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(-)
drivers/video/arcfb.c +2 -3
index 3ec4923..86573e2 100644
@@ -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;
drivers/video/broadsheetfb.c +1 -3
index ebda687..377dde3 100644
@@ -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;
 
drivers/video/hecubafb.c +2 -3
index 1b94643..fbef15f 100644
@@ -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;
drivers/video/metronomefb.c +1 -3
index ed64edf..97d45e5 100644
@@ -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;
 
drivers/video/xen-fbfront.c +1 -2
index a20218c..beac52f 100644
@@ -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;
 
Acked-by on v2 12/15
#19 lore raw

Re: [TRIVIAL PATCH V2 next 12/15] video: Convert vmalloc/memset to vzalloc

Quoted 1 line · Joe Perches
Quoted 15 lines
drivers/video/xen-fbfront.c +1 -2
index a20218c..beac52f 100644
@@ -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;
#20 lore raw

Re: [TRIVIAL PATCH V2 next 12/15] video: Convert vmalloc/memset to vzalloc

In reply to Joe Perches
Quoted 5 lines · Joe Perches

---
Heiko St??bner <[email protected]> pointed out I can't type... s/vmalloc/vmalloc/ doesn't do much.

Quoted 7 lines
 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(-)

v2 applied.

#21 lore raw

Re: [TRIVIAL PATCH V2 next 12/15] video: Convert vmalloc/memset to vzalloc

In reply to Joe Perches
Quoted 5 lines · Joe Perches

---
Heiko St??bner <[email protected]> pointed out I can't type... s/vmalloc/vmalloc/ doesn't do much.

Quoted 7 lines
 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(-)

v2 applied.

#22 lore raw

PATCH v2 12/15 video: Convert vmalloc/memset to vzalloc

In reply to Heiko Stübner

---
Heiko Stübner <[email protected]> pointed out I can't type... s/vmalloc/vmalloc/ doesn't do much.

 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(-)
drivers/video/arcfb.c +2 -3
index 3ec4923..86573e2 100644
@@ -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;
drivers/video/broadsheetfb.c +1 -3
index ebda687..377dde3 100644
@@ -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;
 
drivers/video/hecubafb.c +2 -3
index 1b94643..fbef15f 100644
@@ -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;
drivers/video/metronomefb.c +1 -3
index ed64edf..97d45e5 100644
@@ -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;
 
drivers/video/xen-fbfront.c +1 -2
index a20218c..beac52f 100644
@@ -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;
 
Signature · 4 lines
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/virtualization
#23 lore raw

Re: [TRIVIAL PATCH next 12/15] video: Convert vmalloc/memset to vzalloc

In reply to Joe Perches

Am Samstag 28 Mai 2011, 19:36:32 schrieb Joe Perches:

drivers/video/arcfb.c static int __devinit arcfb_probe(struct · line 521

Quoted 13 lines
drivers/video/arcfb.c +2 -1
index 3ec4923..86573e2 100644
@@ -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;

shouldn't this be vzalloc too?

drivers/video/arcfb.c static int __devinit arcfb_probe(struct platform_device *dev) · line 524

Quoted 5 lines
drivers/video/arcfb.c +0 -2
-	memset(videomemory, 0, videomemorysize);
-
 	info = framebuffer_alloc(sizeof(struct arcfb_par), &dev->dev);
 	if (!info)
 		goto err;

Heiko

#24 lore raw

Re: [TRIVIAL PATCH next 12/15] video: Convert vmalloc/memset to vzalloc

In reply to Joe Perches
Quoted 17 lines · Joe Perches
---
 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(-)
drivers/video/arcfb.c +0 -0
index 3ec4923..86573e2 100644
@@ -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 */

drivers/video/arcfb.c static int __devinit arcfb_probe(struct platform_device *dev) · line 524

Quoted 10 lines
drivers/video/arcfb.c +2 -3
-	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;

This is the first commit I saw and stopped reading at this point because this hunk is not using vzalloc. I imagine grep for ^+ and vmalloc throughout the series would be helpful?

Signature · 2 lines
Mel Gorman
SUSE Labs
#25 lore raw

Re: [TRIVIAL PATCH next 12/15] video: Convert vmalloc/memset to vzalloc

In reply to Joe Perches
Quoted 17 lines · Joe Perches
---
 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(-)
drivers/video/arcfb.c +0 -0
index 3ec4923..86573e2 100644
@@ -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 */

drivers/video/arcfb.c static int __devinit arcfb_probe(struct platform_device *dev) · line 524

Quoted 10 lines
drivers/video/arcfb.c +2 -3
-	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;

This is the first commit I saw and stopped reading at this point because this hunk is not using vzalloc. I imagine grep for ^+ and vmalloc throughout the series would be helpful?

Signature · 2 lines
Mel Gorman
SUSE Labs
#26 lore raw

PATCH 13/15 fs: Convert vmalloc/memset to vzalloc

In reply to Joe Perches
---
 fs/coda/coda_linux.h    |    5 ++---
 fs/reiserfs/journal.c   |    9 +++------
 fs/reiserfs/resize.c    |    4 +---
 fs/xfs/linux-2.6/kmem.h |    7 +------
 4 files changed, 7 insertions(+), 18 deletions(-)
fs/coda/coda_linux.h +2 -3
index 9b0c532..7807025 100644
@@ -59,12 +59,11 @@ void coda_sysctl_clean(void);
 
 #define CODA_ALLOC(ptr, cast, size) do { \
     if (size < PAGE_SIZE) \
-        ptr = kmalloc((unsigned long) size, GFP_KERNEL); \
+        ptr = kzalloc((unsigned long) size, GFP_KERNEL); \
     else \
-        ptr = (cast)vmalloc((unsigned long) size); \
+        ptr = (cast)vzalloc((unsigned long) size); \
     if (!ptr) \
         printk("kernel malloc returns 0 at %s:%d\n", __FILE__, __LINE__); \
-    else memset( ptr, 0, size ); \
 } while (0)
 
 
fs/reiserfs/journal.c +3 -6
index c5e82ec..40d8b0a 100644
@@ -291,14 +291,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);
@@ -353,11 +352,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++) {
@@ -2695,14 +2693,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);
fs/reiserfs/resize.c +1 -3
index b3a94d2..cfb5196 100644
@@ -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];
 
fs/xfs/linux-2.6/kmem.h +1 -6
index f7c8f7a..292eff1 100644
@@ -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)
 {
Signature · 1 line
1.7.5.rc3.dirty
Acked-by on v1 13/15
#27 lore raw

Re: [TRIVIAL PATCH next 13/15] fs: Convert vmalloc/memset to vzalloc

Quoted 8 lines · Joe Perches
---
 fs/coda/coda_linux.h    |    5 ++---
 fs/reiserfs/journal.c   |    9 +++------
 fs/reiserfs/resize.c    |    4 +---
 fs/xfs/linux-2.6/kmem.h |    7 +------
 4 files changed, 7 insertions(+), 18 deletions(-)

. . .

Quoted 8 lines
fs/xfs/linux-2.6/kmem.h +0 -0
index f7c8f7a..292eff1 100644
@@ -61,12 +61,7 @@ extern void  kmem_free(const void *);
 
 static inline void *kmem_zalloc_large(size_t size)
 {

fs/xfs/linux-2.6/kmem.h extern void kmem_free(const void *); · line 67

Quoted 10 lines
fs/xfs/linux-2.6/kmem.h +1 -6
-	void *ptr;
-
-	ptr = vmalloc(size);
-	if (ptr)
-		memset(ptr, 0, size);
-	return ptr;
+	return vzalloc(size);
 }
 static inline void kmem_free_large(void *ptr)
 {

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#28 lore raw

PATCH 14/15 mm: Convert vmalloc/memset to vzalloc

In reply to Joe Perches
---
 mm/page_cgroup.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
mm/page_cgroup.c +1 -2
index 74ccff6..dbb28fd 100644
@@ -478,11 +478,10 @@ int swap_cgroup_swapon(int type, unsigned long max_pages)
 	length = DIV_ROUND_UP(max_pages, SC_PER_PAGE);
 	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;
Signature · 8 lines
1.7.5.rc3.dirty

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

A message that is not in the archive (sent off-list or not yet received): f3d616b526e00bd8f01a250b7ce8c5a6e2412768.1306603968.git.joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org

Acked-by
#30 lore raw

Re: [TRIVIAL PATCH next 14/15] mm: Convert vmalloc/memset to vzalloc

Quoted 1 line · Joe Perches
Quoted 25 lines

---
 mm/page_cgroup.c |    3 +--

 1 files changed, 1 insertions(+), 2 deletions(-)
mm/page_cgroup.c +1 -3
index 74ccff6..dbb28fd 100644
@@ -478,11 +478,10 @@ int swap_cgroup_swapon(int type, unsigned long max_pages)
        length = DIV_ROUND_UP(max_pages, SC_PER_PAGE);
        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;
--

1.7.5.rc3.dirty

Acked-by on v1 14/15
#31 lore raw

Re: [TRIVIAL PATCH next 14/15] mm: Convert vmalloc/memset to vzalloc

In reply to Joe Perches
Quoted 1 line · Joe Perches
Quoted 22 lines

---
 mm/page_cgroup.c |    3 +--

 1 files changed, 1 insertions(+), 2 deletions(-)
mm/page_cgroup.c +1 -3
index 74ccff6..dbb28fd 100644
@@ -478,11 +478,10 @@ int swap_cgroup_swapon(int type, unsigned long max_pages)
        length = DIV_ROUND_UP(max_pages, SC_PER_PAGE);
        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;
--
Quoted 3 lines

1.7.5.rc3.dirty

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#32 lore raw

PATCH 15/15 net: Convert vmalloc/memset to vzalloc

In reply to Joe Perches
---
 net/netfilter/x_tables.c |    5 ++---
 net/rds/ib_cm.c          |    6 ++----
 2 files changed, 4 insertions(+), 7 deletions(-)
net/netfilter/x_tables.c +2 -3
index b0869fe..71441b9 100644
@@ -776,12 +776,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;
net/rds/ib_cm.c +2 -4
index fd453dd..6ecaf78 100644
@@ -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);
 
Signature · 1 line
1.7.5.rc3.dirty
#33 lore raw

Re: [TRIVIAL PATCH next 15/15] net: Convert vmalloc/memset to vzalloc

David,

Are you going to take this patch? it includes one chunck which is out of netfilter scope.

Thanks.

Quoted 55 lines · Joe Perches
---
 net/netfilter/x_tables.c |    5 ++---
 net/rds/ib_cm.c          |    6 ++----
 2 files changed, 4 insertions(+), 7 deletions(-)
net/netfilter/x_tables.c +2 -3
index b0869fe..71441b9 100644
@@ -776,12 +776,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;
net/rds/ib_cm.c +2 -4
index fd453dd..6ecaf78 100644
@@ -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);
 
maintainer Acked-by
#34 lore raw

Re: [TRIVIAL PATCH next 15/15] net: Convert vmalloc/memset to vzalloc

From: Pablo Neira Ayuso <[email protected]>
Date: Thu, 02 Jun 2011 16:49:53 +0200

Quoted 2 lines

Are you going to take this patch? it includes one chunck which is out of netfilter scope.

I think the trivial folks submit these things via their own tree and are only looking for ACKs from us.

#35 lore raw

Re: [TRIVIAL PATCH next 15/15] net: Convert vmalloc/memset to vzalloc

Quoted 7 lines · David Miller

From: Pablo Neira Ayuso <[email protected]>
Date: Thu, 02 Jun 2011 16:49:53 +0200

Quoted 2 lines

Are you going to take this patch? it includes one chunk which is out of netfilter scope.

I think the trivial folks submit these things via their own tree and are only looking for ACKs from us.

Getting trivial patches applied between the various maintainers and the trivial tree is most often a bit uncoordinated and haphazard.

Doing micropatches for each subsystem maintainer does sometimes appear to be detrimental to getting any treewide modification applied.

I've experimented with both micropatches and treewide patches to gauge what happens. I'm not sure either approach is better or worse.

In any case, it commonly takes several submittals for these sort of trivial patches to get applied either by the subtree maintainer or by Jiri.

Jiri often waits a few weeks for patches to get picked up by any subtree maintainer before looking at his trivial emails. Sometimes he acks what's left, sometimes what's left just disappears into the ethervoid waiting for the submitter to try again.

No worries, that's just the way it is.

maintainer Acked-by
#36 lore raw

Re: [TRIVIAL PATCH next 15/15] net: Convert vmalloc/memset to vzalloc

In reply to David Miller
Quoted 10 lines · David Miller

From: Pablo Neira Ayuso <[email protected]>
Date: Thu, 02 Jun 2011 16:49:53 +0200

Quoted 2 lines

Are you going to take this patch? it includes one chunck which is out of netfilter scope.

I think the trivial folks submit these things via their own tree and are only looking for ACKs from us.