* [PATCH] drivers/scsi/fnic/fnic_trace.c: Use vzalloc
@ 2018-11-13 15:08 Sabyasachi Gupta
2018-11-13 15:44 ` John Garry
0 siblings, 1 reply; 10+ messages in thread
From: Sabyasachi Gupta @ 2018-11-13 15:08 UTC (permalink / raw)
To: satishkh, sebaddel, kartilak, jejb, martin.petersen
Cc: jrdr.linux, linux-scsi, linux-kernel, brajeswar.linux
Replaced vmalloc + memset with vzalloc
Signed-off-by: Sabyasachi Gupta <sabyasachi.linux@gmail.com>
---
drivers/scsi/fnic/fnic_trace.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/fnic/fnic_trace.c b/drivers/scsi/fnic/fnic_trace.c
index 8271785..129ab27 100644
--- a/drivers/scsi/fnic/fnic_trace.c
+++ b/drivers/scsi/fnic/fnic_trace.c
@@ -468,14 +468,14 @@ int fnic_trace_buf_init(void)
fnic_max_trace_entries = (trace_max_pages * PAGE_SIZE)/
FNIC_ENTRY_SIZE_BYTES;
- fnic_trace_buf_p = (unsigned long)vmalloc((trace_max_pages * PAGE_SIZE));
+ fnic_trace_buf_p = (unsigned long)vzalloc((trace_max_pages *
+ PAGE_SIZE));
if (!fnic_trace_buf_p) {
printk(KERN_ERR PFX "Failed to allocate memory "
"for fnic_trace_buf_p\n");
err = -ENOMEM;
goto err_fnic_trace_buf_init;
}
- memset((void *)fnic_trace_buf_p, 0, (trace_max_pages * PAGE_SIZE));
fnic_trace_entries.page_offset =
vmalloc(array_size(fnic_max_trace_entries,
--
2.7.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] drivers/scsi/fnic/fnic_trace.c: Use vzalloc
2018-11-13 15:08 [PATCH] drivers/scsi/fnic/fnic_trace.c: Use vzalloc Sabyasachi Gupta
@ 2018-11-13 15:44 ` John Garry
0 siblings, 0 replies; 10+ messages in thread
From: John Garry @ 2018-11-13 15:44 UTC (permalink / raw)
To: Sabyasachi Gupta, satishkh, sebaddel, kartilak, jejb, martin.petersen
Cc: jrdr.linux, linux-scsi, linux-kernel, brajeswar.linux
On 13/11/2018 15:08, Sabyasachi Gupta wrote:
> Replaced vmalloc + memset with vzalloc
>
> Signed-off-by: Sabyasachi Gupta <sabyasachi.linux@gmail.com>
> ---
> drivers/scsi/fnic/fnic_trace.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/fnic/fnic_trace.c b/drivers/scsi/fnic/fnic_trace.c
> index 8271785..129ab27 100644
> --- a/drivers/scsi/fnic/fnic_trace.c
> +++ b/drivers/scsi/fnic/fnic_trace.c
> @@ -468,14 +468,14 @@ int fnic_trace_buf_init(void)
> fnic_max_trace_entries = (trace_max_pages * PAGE_SIZE)/
> FNIC_ENTRY_SIZE_BYTES;
>
> - fnic_trace_buf_p = (unsigned long)vmalloc((trace_max_pages * PAGE_SIZE));
> + fnic_trace_buf_p = (unsigned long)vzalloc((trace_max_pages *
> + PAGE_SIZE));
If you remove the extra brackets in vzalloc() argument then you may not
spill onto the next line.
> if (!fnic_trace_buf_p) {
> printk(KERN_ERR PFX "Failed to allocate memory "
> "for fnic_trace_buf_p\n");
> err = -ENOMEM;
> goto err_fnic_trace_buf_init;
> }
> - memset((void *)fnic_trace_buf_p, 0, (trace_max_pages * PAGE_SIZE));
>
> fnic_trace_entries.page_offset =
> vmalloc(array_size(fnic_max_trace_entries,
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] drivers/scsi/fnic/fnic_trace.c: Use vzalloc
@ 2018-11-13 15:44 ` John Garry
0 siblings, 0 replies; 10+ messages in thread
From: John Garry @ 2018-11-13 15:44 UTC (permalink / raw)
To: Sabyasachi Gupta, satishkh, sebaddel, kartilak, jejb, martin.petersen
Cc: jrdr.linux, linux-scsi, linux-kernel, brajeswar.linux
On 13/11/2018 15:08, Sabyasachi Gupta wrote:
> Replaced vmalloc + memset with vzalloc
>
> Signed-off-by: Sabyasachi Gupta <sabyasachi.linux@gmail.com>
> ---
> drivers/scsi/fnic/fnic_trace.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/fnic/fnic_trace.c b/drivers/scsi/fnic/fnic_trace.c
> index 8271785..129ab27 100644
> --- a/drivers/scsi/fnic/fnic_trace.c
> +++ b/drivers/scsi/fnic/fnic_trace.c
> @@ -468,14 +468,14 @@ int fnic_trace_buf_init(void)
> fnic_max_trace_entries = (trace_max_pages * PAGE_SIZE)/
> FNIC_ENTRY_SIZE_BYTES;
>
> - fnic_trace_buf_p = (unsigned long)vmalloc((trace_max_pages * PAGE_SIZE));
> + fnic_trace_buf_p = (unsigned long)vzalloc((trace_max_pages *
> + PAGE_SIZE));
If you remove the extra brackets in vzalloc() argument then you may not
spill onto the next line.
> if (!fnic_trace_buf_p) {
> printk(KERN_ERR PFX "Failed to allocate memory "
> "for fnic_trace_buf_p\n");
> err = -ENOMEM;
> goto err_fnic_trace_buf_init;
> }
> - memset((void *)fnic_trace_buf_p, 0, (trace_max_pages * PAGE_SIZE));
>
> fnic_trace_entries.page_offset =
> vmalloc(array_size(fnic_max_trace_entries,
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] drivers/scsi/fnic/fnic_trace.c: Use vzalloc
2018-11-13 15:44 ` John Garry
(?)
@ 2018-11-13 15:53 ` Johannes Thumshirn
2018-11-13 16:04 ` Sabyasachi Gupta
2018-11-13 16:11 ` James Bottomley
-1 siblings, 2 replies; 10+ messages in thread
From: Johannes Thumshirn @ 2018-11-13 15:53 UTC (permalink / raw)
To: John Garry, Sabyasachi Gupta, satishkh, sebaddel, kartilak, jejb,
martin.petersen
Cc: jrdr.linux, linux-scsi, linux-kernel, brajeswar.linux
On 13/11/2018 16:44, John Garry wrote:
> On 13/11/2018 15:08, Sabyasachi Gupta wrote:
>> Replaced vmalloc + memset with vzalloc
>>
>> Signed-off-by: Sabyasachi Gupta <sabyasachi.linux@gmail.com>
>> ---
>> drivers/scsi/fnic/fnic_trace.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/scsi/fnic/fnic_trace.c
>> b/drivers/scsi/fnic/fnic_trace.c
>> index 8271785..129ab27 100644
>> --- a/drivers/scsi/fnic/fnic_trace.c
>> +++ b/drivers/scsi/fnic/fnic_trace.c
>> @@ -468,14 +468,14 @@ int fnic_trace_buf_init(void)
>> fnic_max_trace_entries = (trace_max_pages * PAGE_SIZE)/
>> FNIC_ENTRY_SIZE_BYTES;
>>
>> - fnic_trace_buf_p = (unsigned long)vmalloc((trace_max_pages *
>> PAGE_SIZE));
>> + fnic_trace_buf_p = (unsigned long)vzalloc((trace_max_pages *
>> + PAGE_SIZE));
>
> If you remove the extra brackets in vzalloc() argument then you may not
> spill onto the next line.
And remove the unnecessary cast. vzalloc() (just like vmalloc()) returns
a void*, so no reason to cast it.
--
Johannes Thumshirn SUSE Labs
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] drivers/scsi/fnic/fnic_trace.c: Use vzalloc
2018-11-13 15:53 ` Johannes Thumshirn
@ 2018-11-13 16:04 ` Sabyasachi Gupta
2018-11-13 16:11 ` James Bottomley
1 sibling, 0 replies; 10+ messages in thread
From: Sabyasachi Gupta @ 2018-11-13 16:04 UTC (permalink / raw)
To: jthumshirn
Cc: john.garry, satishkh, sebaddel, kartilak, jejb, martin.petersen,
Souptick Joarder, linux-scsi, linux-kernel, Brajeswar Ghosh
On Tue, Nov 13, 2018 at 9:23 PM Johannes Thumshirn <jthumshirn@suse.de> wrote:
>
> On 13/11/2018 16:44, John Garry wrote:
> > On 13/11/2018 15:08, Sabyasachi Gupta wrote:
> >> Replaced vmalloc + memset with vzalloc
> >>
> >> Signed-off-by: Sabyasachi Gupta <sabyasachi.linux@gmail.com>
> >> ---
> >> drivers/scsi/fnic/fnic_trace.c | 4 ++--
> >> 1 file changed, 2 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/scsi/fnic/fnic_trace.c
> >> b/drivers/scsi/fnic/fnic_trace.c
> >> index 8271785..129ab27 100644
> >> --- a/drivers/scsi/fnic/fnic_trace.c
> >> +++ b/drivers/scsi/fnic/fnic_trace.c
> >> @@ -468,14 +468,14 @@ int fnic_trace_buf_init(void)
> >> fnic_max_trace_entries = (trace_max_pages * PAGE_SIZE)/
> >> FNIC_ENTRY_SIZE_BYTES;
> >>
> >> - fnic_trace_buf_p = (unsigned long)vmalloc((trace_max_pages *
> >> PAGE_SIZE));
> >> + fnic_trace_buf_p = (unsigned long)vzalloc((trace_max_pages *
> >> + PAGE_SIZE));
> >
> > If you remove the extra brackets in vzalloc() argument then you may not
> > spill onto the next line.
>
> And remove the unnecessary cast. vzalloc() (just like vmalloc()) returns
> a void*, so no reason to cast it.
>
> --
> Johannes Thumshirn SUSE Labs
> jthumshirn@suse.de +49 911 74053 689
> SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
> GF: Felix Imendörffer, Jane Smithard, Graham Norton
> HRB 21284 (AG Nürnberg)
> Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
I will remove it and send v2
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] drivers/scsi/fnic/fnic_trace.c: Use vzalloc
2018-11-13 15:53 ` Johannes Thumshirn
2018-11-13 16:04 ` Sabyasachi Gupta
@ 2018-11-13 16:11 ` James Bottomley
2018-11-13 16:16 ` Johannes Thumshirn
2018-11-14 10:44 ` David Laight
1 sibling, 2 replies; 10+ messages in thread
From: James Bottomley @ 2018-11-13 16:11 UTC (permalink / raw)
To: Johannes Thumshirn, John Garry, Sabyasachi Gupta, satishkh,
sebaddel, kartilak, martin.petersen
Cc: jrdr.linux, linux-scsi, linux-kernel, brajeswar.linux
On Tue, 2018-11-13 at 16:53 +0100, Johannes Thumshirn wrote:
> On 13/11/2018 16:44, John Garry wrote:
> > On 13/11/2018 15:08, Sabyasachi Gupta wrote:
[...]
> > > - fnic_trace_buf_p = (unsigned long)vmalloc((trace_max_pages *
> > > PAGE_SIZE));
> > > + fnic_trace_buf_p = (unsigned long)vzalloc((trace_max_pages *
> > > + PAGE_SIZE));
> >
> > If you remove the extra brackets in vzalloc() argument then you may
> > not spill onto the next line.
>
> And remove the unnecessary cast. vzalloc() (just like vmalloc())
> returns a void*, so no reason to cast it.
This is incorrect advice: there's no need to cast it to other *pointer*
types, but if you cast it to a non-pointer type (which this is doing)
the compiler will complain if there is no explicit cast.
James
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] drivers/scsi/fnic/fnic_trace.c: Use vzalloc
2018-11-13 16:11 ` James Bottomley
@ 2018-11-13 16:16 ` Johannes Thumshirn
2018-11-13 16:22 ` Sabyasachi Gupta
2018-11-14 10:44 ` David Laight
1 sibling, 1 reply; 10+ messages in thread
From: Johannes Thumshirn @ 2018-11-13 16:16 UTC (permalink / raw)
To: James Bottomley, John Garry, Sabyasachi Gupta, satishkh,
sebaddel, kartilak, martin.petersen
Cc: jrdr.linux, linux-scsi, linux-kernel, brajeswar.linux
On 13/11/2018 17:11, James Bottomley wrote:
> This is incorrect advice: there's no need to cast it to other *pointer*
> types, but if you cast it to a non-pointer type (which this is doing)
> the compiler will complain if there is no explicit cast.
Right, sorry for that and thanks for spotting it James.
Byte,
Johannes
--
Johannes Thumshirn SUSE Labs
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] drivers/scsi/fnic/fnic_trace.c: Use vzalloc
2018-11-13 16:16 ` Johannes Thumshirn
@ 2018-11-13 16:22 ` Sabyasachi Gupta
2018-11-13 16:25 ` Johannes Thumshirn
0 siblings, 1 reply; 10+ messages in thread
From: Sabyasachi Gupta @ 2018-11-13 16:22 UTC (permalink / raw)
To: jthumshirn
Cc: jejb, john.garry, satishkh, sebaddel, kartilak, martin.petersen,
Souptick Joarder, linux-scsi, linux-kernel, Brajeswar Ghosh
On Tue, Nov 13, 2018 at 9:46 PM Johannes Thumshirn <jthumshirn@suse.de> wrote:
>
> On 13/11/2018 17:11, James Bottomley wrote:
> > This is incorrect advice: there's no need to cast it to other *pointer*
> > types, but if you cast it to a non-pointer type (which this is doing)
> > the compiler will complain if there is no explicit cast.
shall I leave the typecast as it is?
> Right, sorry for that and thanks for spotting it James.
>
> Byte,
> Johannes
> --
> Johannes Thumshirn SUSE Labs
> jthumshirn@suse.de +49 911 74053 689
> SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
> GF: Felix Imendörffer, Jane Smithard, Graham Norton
> HRB 21284 (AG Nürnberg)
> Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] drivers/scsi/fnic/fnic_trace.c: Use vzalloc
2018-11-13 16:22 ` Sabyasachi Gupta
@ 2018-11-13 16:25 ` Johannes Thumshirn
0 siblings, 0 replies; 10+ messages in thread
From: Johannes Thumshirn @ 2018-11-13 16:25 UTC (permalink / raw)
To: Sabyasachi Gupta
Cc: jejb, john.garry, satishkh, sebaddel, kartilak, martin.petersen,
Souptick Joarder, linux-scsi, linux-kernel, Brajeswar Ghosh
On 13/11/2018 17:22, Sabyasachi Gupta wrote:
> On Tue, Nov 13, 2018 at 9:46 PM Johannes Thumshirn <jthumshirn@suse.de> wrote:
>>
>> On 13/11/2018 17:11, James Bottomley wrote:
>>> This is incorrect advice: there's no need to cast it to other *pointer*
>>> types, but if you cast it to a non-pointer type (which this is doing)
>>> the compiler will complain if there is no explicit cast.
> shall I leave the typecast as it is?
Yes, sorry for not looking at it deeply enough.
--
Johannes Thumshirn SUSE Labs
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH] drivers/scsi/fnic/fnic_trace.c: Use vzalloc
2018-11-13 16:11 ` James Bottomley
2018-11-13 16:16 ` Johannes Thumshirn
@ 2018-11-14 10:44 ` David Laight
1 sibling, 0 replies; 10+ messages in thread
From: David Laight @ 2018-11-14 10:44 UTC (permalink / raw)
To: 'James Bottomley',
Johannes Thumshirn, John Garry, Sabyasachi Gupta, satishkh,
sebaddel, kartilak, martin.petersen
Cc: jrdr.linux, linux-scsi, linux-kernel, brajeswar.linux
From: James Bottomley
> Sent: 13 November 2018 16:11
>
> On Tue, 2018-11-13 at 16:53 +0100, Johannes Thumshirn wrote:
> > On 13/11/2018 16:44, John Garry wrote:
> > > On 13/11/2018 15:08, Sabyasachi Gupta wrote:
> [...]
> > > > - fnic_trace_buf_p = (unsigned long)vmalloc((trace_max_pages *
> > > > PAGE_SIZE));
> > > > + fnic_trace_buf_p = (unsigned long)vzalloc((trace_max_pages *
> > > > + PAGE_SIZE));
> > >
> > > If you remove the extra brackets in vzalloc() argument then you may
> > > not spill onto the next line.
> >
> > And remove the unnecessary cast. vzalloc() (just like vmalloc())
> > returns a void*, so no reason to cast it.
>
> This is incorrect advice: there's no need to cast it to other *pointer*
> types, but if you cast it to a non-pointer type (which this is doing)
> the compiler will complain if there is no explicit cast.
The real question is why is this code using 'unsigned long'
to hold pointers?
Never mind why it is allocating a large memory block then setting
up another array with pointers to every 64 bytes down it.
Also why default to 16 * PAGE_SIZE - that is silly if pages are big.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2018-11-14 10:44 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-13 15:08 [PATCH] drivers/scsi/fnic/fnic_trace.c: Use vzalloc Sabyasachi Gupta
2018-11-13 15:44 ` John Garry
2018-11-13 15:44 ` John Garry
2018-11-13 15:53 ` Johannes Thumshirn
2018-11-13 16:04 ` Sabyasachi Gupta
2018-11-13 16:11 ` James Bottomley
2018-11-13 16:16 ` Johannes Thumshirn
2018-11-13 16:22 ` Sabyasachi Gupta
2018-11-13 16:25 ` Johannes Thumshirn
2018-11-14 10:44 ` David Laight
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.