* [RESEND PATCH] scsi: fnic: Use vzalloc() instead of vmalloc() and memset(0)
@ 2024-10-07 11:58 Thorsten Blum
2024-10-07 12:04 ` Johannes Thumshirn
0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2024-10-07 11:58 UTC (permalink / raw)
To: Satish Kharat, Sesidhar Baddela, Karan Tilak Kumar,
James E.J. Bottomley, Martin K. Petersen
Cc: Thorsten Blum, linux-scsi, linux-kernel
Use vzalloc() instead of vmalloc() followed by memset(0) to simplify the
functions fnic_trace_buf_init() and fnic_fc_trace_init().
Compile-tested only.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
drivers/scsi/fnic/fnic_trace.c | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/drivers/scsi/fnic/fnic_trace.c b/drivers/scsi/fnic/fnic_trace.c
index aaa4ea02fb7c..06fcd4d45415 100644
--- a/drivers/scsi/fnic/fnic_trace.c
+++ b/drivers/scsi/fnic/fnic_trace.c
@@ -485,7 +485,7 @@ int fnic_trace_buf_init(void)
}
fnic_trace_entries.page_offset =
- vmalloc(array_size(fnic_max_trace_entries,
+ vzalloc(array_size(fnic_max_trace_entries,
sizeof(unsigned long)));
if (!fnic_trace_entries.page_offset) {
printk(KERN_ERR PFX "Failed to allocate memory for"
@@ -497,8 +497,6 @@ int fnic_trace_buf_init(void)
err = -ENOMEM;
goto err_fnic_trace_buf_init;
}
- memset((void *)fnic_trace_entries.page_offset, 0,
- (fnic_max_trace_entries * sizeof(unsigned long)));
fnic_trace_entries.wr_idx = fnic_trace_entries.rd_idx = 0;
fnic_buf_head = fnic_trace_buf_p;
@@ -559,7 +557,7 @@ int fnic_fc_trace_init(void)
fc_trace_max_entries = (fnic_fc_trace_max_pages * PAGE_SIZE)/
FC_TRC_SIZE_BYTES;
fnic_fc_ctlr_trace_buf_p =
- (unsigned long)vmalloc(array_size(PAGE_SIZE,
+ (unsigned long)vzalloc(array_size(PAGE_SIZE,
fnic_fc_trace_max_pages));
if (!fnic_fc_ctlr_trace_buf_p) {
pr_err("fnic: Failed to allocate memory for "
@@ -568,12 +566,9 @@ int fnic_fc_trace_init(void)
goto err_fnic_fc_ctlr_trace_buf_init;
}
- memset((void *)fnic_fc_ctlr_trace_buf_p, 0,
- fnic_fc_trace_max_pages * PAGE_SIZE);
-
/* Allocate memory for page offset */
fc_trace_entries.page_offset =
- vmalloc(array_size(fc_trace_max_entries,
+ vzalloc(array_size(fc_trace_max_entries,
sizeof(unsigned long)));
if (!fc_trace_entries.page_offset) {
pr_err("fnic:Failed to allocate memory for page_offset\n");
@@ -585,8 +580,6 @@ int fnic_fc_trace_init(void)
err = -ENOMEM;
goto err_fnic_fc_ctlr_trace_buf_init;
}
- memset((void *)fc_trace_entries.page_offset, 0,
- (fc_trace_max_entries * sizeof(unsigned long)));
fc_trace_entries.rd_idx = fc_trace_entries.wr_idx = 0;
fc_trace_buf_head = fnic_fc_ctlr_trace_buf_p;
--
2.46.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [RESEND PATCH] scsi: fnic: Use vzalloc() instead of vmalloc() and memset(0)
2024-10-07 11:58 [RESEND PATCH] scsi: fnic: Use vzalloc() instead of vmalloc() and memset(0) Thorsten Blum
@ 2024-10-07 12:04 ` Johannes Thumshirn
0 siblings, 0 replies; 2+ messages in thread
From: Johannes Thumshirn @ 2024-10-07 12:04 UTC (permalink / raw)
To: Thorsten Blum, Satish Kharat, Sesidhar Baddela, Karan Tilak Kumar,
James E.J. Bottomley, Martin K. Petersen
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
On 07.10.24 14:02, Thorsten Blum wrote:
> @@ -559,7 +557,7 @@ int fnic_fc_trace_init(void)
> fc_trace_max_entries = (fnic_fc_trace_max_pages * PAGE_SIZE)/
> FC_TRC_SIZE_BYTES;
> fnic_fc_ctlr_trace_buf_p =
> - (unsigned long)vmalloc(array_size(PAGE_SIZE,
> + (unsigned long)vzalloc(array_size(PAGE_SIZE,
> fnic_fc_trace_max_pages));
Casting the vzalloc() shouldn't be needed.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-10-07 12:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-07 11:58 [RESEND PATCH] scsi: fnic: Use vzalloc() instead of vmalloc() and memset(0) Thorsten Blum
2024-10-07 12:04 ` Johannes Thumshirn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox