Skip to contentSkip to conversation

tools/testing/nvdimm: use vzalloc() instead of vmalloc()/memset(0)

PATCH In review Wu Bo 2 participants 3 messages May 31, 2021 – Jun 4, 2021 libnvdimm: non-volatile memory device

lore
Share & tools
lore

Wu Bo

author
#0 lore raw

PATCH 1/1 tools/testing/nvdimm: use vzalloc() instead of vmalloc()/memset(0)

Use vzalloc() instead of vmalloc() and memset(0) to simpify the code.

---
 tools/testing/nvdimm/test/nfit.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/testing/nvdimm/test/nfit.c +1 -2
index 54f367cbadae..258bba22780b 100644
@@ -1625,7 +1625,6 @@ static void *__test_alloc(struct nfit_test *t, size_t size, dma_addr_t *dma,
 	if (rc)
 		goto err;
 	INIT_LIST_HEAD(&nfit_res->list);
-	memset(buf, 0, size);
 	nfit_res->dev = dev;
 	nfit_res->buf = buf;
 	nfit_res->res.start = *dma;
@@ -1652,7 +1651,7 @@ static void *test_alloc(struct nfit_test *t, size_t size, dma_addr_t *dma)
 	struct genpool_data_align data = {
 		.align = SZ_128M,
 	};
-	void *buf = vmalloc(size);
+	void *buf = vzalloc(size);
 
 	if (size >= DIMM_SIZE)
 		*dma = gen_pool_alloc_algo(nfit_pool, size,
Signature · 1 line
2.30.0
author
#1 lore raw

Friendly ping ...

Quoted 30 lines · Wu Bo

Use vzalloc() instead of vmalloc() and memset(0) to simpify the code.

---
  tools/testing/nvdimm/test/nfit.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
tools/testing/nvdimm/test/nfit.c +1 -2
index 54f367cbadae..258bba22780b 100644
@@ -1625,7 +1625,6 @@ static void *__test_alloc(struct nfit_test *t, size_t size, dma_addr_t *dma,
  	if (rc)
  		goto err;
  	INIT_LIST_HEAD(&nfit_res->list);
-	memset(buf, 0, size);
  	nfit_res->dev = dev;
  	nfit_res->buf = buf;
  	nfit_res->res.start = *dma;
@@ -1652,7 +1651,7 @@ static void *test_alloc(struct nfit_test *t, size_t size, dma_addr_t *dma)
  	struct genpool_data_align data = {
  		.align = SZ_128M,
  	};
-	void *buf = vmalloc(size);
+	void *buf = vzalloc(size);
 
  	if (size >= DIMM_SIZE)
  		*dma = gen_pool_alloc_algo(nfit_pool, size,
Reviewed-by on v1 1/1
#2 lore raw
In reply to Wu Bo
Quoted 7 lines · Wu Bo

Use vzalloc() instead of vmalloc() and memset(0) to simpify the code.

---
 tools/testing/nvdimm/test/nfit.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

LGTM,

Quoted 24 lines
tools/testing/nvdimm/test/nfit.c +1 -2
index 54f367cbadae..258bba22780b 100644
@@ -1625,7 +1625,6 @@ static void *__test_alloc(struct nfit_test *t, size_t size, dma_addr_t *dma,
 	if (rc)
 		goto err;
 	INIT_LIST_HEAD(&nfit_res->list);
-	memset(buf, 0, size);
 	nfit_res->dev = dev;
 	nfit_res->buf = buf;
 	nfit_res->res.start = *dma;
@@ -1652,7 +1651,7 @@ static void *test_alloc(struct nfit_test *t, size_t size, dma_addr_t *dma)
 	struct genpool_data_align data = {
 		.align = SZ_128M,
 	};
-	void *buf = vmalloc(size);
+	void *buf = vzalloc(size);
 
 	if (size >= DIMM_SIZE)
 		*dma = gen_pool_alloc_algo(nfit_pool, size,
Signature · 1 line
2.30.0