2021-04-28 17:41:10

by Muhammad Usama Anjum

[permalink] [raw]
Subject: Re: [PATCH -next] bcache: use DEFINE_MUTEX() for mutex lock

On Tue, 2021-04-06 at 02:17 +0500, Muhammad Usama Anjum wrote:
> On Mon, 2021-04-05 at 22:02 +0800, Coly Li wrote:
> > On 4/5/21 6:14 PM, Zheng Yongjun wrote:
> > > mutex lock can be initialized automatically with DEFINE_MUTEX()
> > > rather than explicitly calling mutex_init().
> > >
> > > Reported-by: Hulk Robot <[email protected]>
> > > Signed-off-by: Zheng Yongjun <[email protected]>
> >
> > NACK. This is not the first time people try to "fix" this location...
> >
> > Using DEFINE_MUTEX() does not gain anything for us, it will generate
> > unnecessary extra size for the bcache.ko.
> > ines.
>
> How can the final binary have larger size by just static declaration?
> By using DEFINE_MUTEX, the mutex is initialized at compile time. It'll
> save initialization at run time and one line of code will be less also
> from text section.
>
> #### with no change (dynamic initialization)
> size drivers/md/bcache/bcache.ko
> text data bss dec hex filename
> 187792 25310 152 213254 34106 drivers/md/bcache/bcache.ko
>
> #### with patch applied (static initialization)
> text data bss dec hex filename
> 187751 25342 120 213213 340dd drivers/md/bcache/bcache.ko
>
> Module's binary size has decreased by 41 bytes with the path applied
> (x86_64 arch).
>
Anybody has any thoughts on it?



2021-04-29 05:58:57

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH -next] bcache: use DEFINE_MUTEX() for mutex lock

On Wed, Apr 28, 2021 at 09:19:26PM +0500, Muhammad Usama Anjum wrote:
> On Tue, 2021-04-06 at 02:17 +0500, Muhammad Usama Anjum wrote:
> > On Mon, 2021-04-05 at 22:02 +0800, Coly Li wrote:
> > > On 4/5/21 6:14 PM, Zheng Yongjun wrote:
> > > > mutex lock can be initialized automatically with DEFINE_MUTEX()
> > > > rather than explicitly calling mutex_init().
> > > >
> > > > Reported-by: Hulk Robot <[email protected]>
> > > > Signed-off-by: Zheng Yongjun <[email protected]>
> > >
> > > NACK. This is not the first time people try to "fix" this location...
> > >
> > > Using DEFINE_MUTEX() does not gain anything for us, it will generate
> > > unnecessary extra size for the bcache.ko.
> > > ines.
> >
> > How can the final binary have larger size by just static declaration?
> > By using DEFINE_MUTEX, the mutex is initialized at compile time. It'll
> > save initialization at run time and one line of code will be less also
> > from text section.
> >
> > #### with no change (dynamic initialization)
> > size drivers/md/bcache/bcache.ko
> > text data bss dec hex filename
> > 187792 25310 152 213254 34106 drivers/md/bcache/bcache.ko
> >
> > #### with patch applied (static initialization)
> > text data bss dec hex filename
> > 187751 25342 120 213213 340dd drivers/md/bcache/bcache.ko
> >
> > Module's binary size has decreased by 41 bytes with the path applied
> > (x86_64 arch).
> >
> Anybody has any thoughts on it?
>

I think you're right and the response is puzzling. But who cares? It's
a small thing. Leave it and move on.

regards,
dan carpenter

2021-04-29 10:08:48

by Coly Li

[permalink] [raw]
Subject: Re: [PATCH -next] bcache: use DEFINE_MUTEX() for mutex lock

On 4/29/21 12:19 AM, Muhammad Usama Anjum wrote:
> On Tue, 2021-04-06 at 02:17 +0500, Muhammad Usama Anjum wrote:
>> On Mon, 2021-04-05 at 22:02 +0800, Coly Li wrote:
>>> On 4/5/21 6:14 PM, Zheng Yongjun wrote:
>>>> mutex lock can be initialized automatically with DEFINE_MUTEX()
>>>> rather than explicitly calling mutex_init().
>>>>
>>>> Reported-by: Hulk Robot <[email protected]>
>>>> Signed-off-by: Zheng Yongjun <[email protected]>
>>>
>>> NACK. This is not the first time people try to "fix" this location...
>>>
>>> Using DEFINE_MUTEX() does not gain anything for us, it will generate
>>> unnecessary extra size for the bcache.ko.
>>> ines.
>>
>> How can the final binary have larger size by just static declaration?
>> By using DEFINE_MUTEX, the mutex is initialized at compile time. It'll
>> save initialization at run time and one line of code will be less also
>> from text section.
>>
>> #### with no change (dynamic initialization)
>> size drivers/md/bcache/bcache.ko
>> text data bss dec hex filename
>> 187792 25310 152 213254 34106 drivers/md/bcache/bcache.ko
>>
>> #### with patch applied (static initialization)
>> text data bss dec hex filename
>> 187751 25342 120 213213 340dd drivers/md/bcache/bcache.ko
>>
>> Module's binary size has decreased by 41 bytes with the path applied
>> (x86_64 arch).
>>
> Anybody has any thoughts on it?
>
>


I am waiting for Yongjun's v4 patch to update the commit log, which was
suggested by Pavel Goran.

Coly Li