* [PATCH -next] bcache: use DEFINE_MUTEX() for mutex lock
@ 2021-04-05 10:14 Zheng Yongjun
2021-04-05 14:02 ` Coly Li
0 siblings, 1 reply; 6+ messages in thread
From: Zheng Yongjun @ 2021-04-05 10:14 UTC (permalink / raw)
To: zhengyongjun3, Coly Li, Kent Overstreet
Cc: linux-bcache, kernel-janitors, Hulk Robot
mutex lock can be initialized automatically with DEFINE_MUTEX()
rather than explicitly calling mutex_init().
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
---
drivers/md/bcache/super.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 78c08a8aece8..c124da6e646d 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -41,7 +41,7 @@ static const char invalid_uuid[] = {
};
static struct kobject *bcache_kobj;
-struct mutex bch_register_lock;
+DEFINE_MUTEX(bch_register_lock);
bool bcache_is_reboot;
LIST_HEAD(bch_cache_sets);
static LIST_HEAD(uncached_devices);
@@ -2870,7 +2870,6 @@ static int __init bcache_init(void)
check_module_parameters();
- mutex_init(&bch_register_lock);
init_waitqueue_head(&unregister_wait);
register_reboot_notifier(&reboot);
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH -next] bcache: use DEFINE_MUTEX() for mutex lock
2021-04-05 10:14 [PATCH -next] bcache: use DEFINE_MUTEX() for mutex lock Zheng Yongjun
@ 2021-04-05 14:02 ` Coly Li
2021-04-05 21:17 ` Muhammad Usama Anjum
0 siblings, 1 reply; 6+ messages in thread
From: Coly Li @ 2021-04-05 14:02 UTC (permalink / raw)
To: Zheng Yongjun, Kent Overstreet; +Cc: linux-bcache, kernel-janitors, Hulk Robot
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 <hulkci@huawei.com>
> Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
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.
> ---
> drivers/md/bcache/super.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
> index 78c08a8aece8..c124da6e646d 100644
> --- a/drivers/md/bcache/super.c
> +++ b/drivers/md/bcache/super.c
> @@ -41,7 +41,7 @@ static const char invalid_uuid[] = {
> };
>
> static struct kobject *bcache_kobj;
> -struct mutex bch_register_lock;
Hmm, maybe if you compose a patch to add comments for bch_register_lock,
for something like: Don't initialize global variable here. It might be
helpful for noticing people not to fixing this in future.
Thanks.
Coly Li
> +DEFINE_MUTEX(bch_register_lock);
> bool bcache_is_reboot;
> LIST_HEAD(bch_cache_sets);
> static LIST_HEAD(uncached_devices);
> @@ -2870,7 +2870,6 @@ static int __init bcache_init(void)
>
> check_module_parameters();
>
> - mutex_init(&bch_register_lock);
> init_waitqueue_head(&unregister_wait);
> register_reboot_notifier(&reboot);
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH -next] bcache: use DEFINE_MUTEX() for mutex lock
2021-04-05 14:02 ` Coly Li
@ 2021-04-05 21:17 ` Muhammad Usama Anjum
2021-04-28 16:19 ` Muhammad Usama Anjum
0 siblings, 1 reply; 6+ messages in thread
From: Muhammad Usama Anjum @ 2021-04-05 21:17 UTC (permalink / raw)
To: Coly Li, Zheng Yongjun, Kent Overstreet
Cc: musamaanjum, linux-bcache, kernel-janitors, Hulk Robot
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 <hulkci@huawei.com>
> > Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
>
> 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).
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH -next] bcache: use DEFINE_MUTEX() for mutex lock
2021-04-05 21:17 ` Muhammad Usama Anjum
@ 2021-04-28 16:19 ` Muhammad Usama Anjum
2021-04-29 5:56 ` Dan Carpenter
2021-04-29 10:05 ` Coly Li
0 siblings, 2 replies; 6+ messages in thread
From: Muhammad Usama Anjum @ 2021-04-28 16:19 UTC (permalink / raw)
To: Coly Li, Zheng Yongjun, Kent Overstreet, Dan Carpenter
Cc: musamaanjum, linux-bcache, kernel-janitors, Hulk Robot, linux-kernel
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 <hulkci@huawei.com>
> > > Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
> >
> > 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?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH -next] bcache: use DEFINE_MUTEX() for mutex lock
2021-04-28 16:19 ` Muhammad Usama Anjum
@ 2021-04-29 5:56 ` Dan Carpenter
2021-04-29 10:05 ` Coly Li
1 sibling, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2021-04-29 5:56 UTC (permalink / raw)
To: Muhammad Usama Anjum
Cc: Coly Li, Zheng Yongjun, Kent Overstreet, linux-bcache,
kernel-janitors, Hulk Robot, linux-kernel
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 <hulkci@huawei.com>
> > > > Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
> > >
> > > 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH -next] bcache: use DEFINE_MUTEX() for mutex lock
2021-04-28 16:19 ` Muhammad Usama Anjum
2021-04-29 5:56 ` Dan Carpenter
@ 2021-04-29 10:05 ` Coly Li
1 sibling, 0 replies; 6+ messages in thread
From: Coly Li @ 2021-04-29 10:05 UTC (permalink / raw)
To: Muhammad Usama Anjum, Zheng Yongjun, Kent Overstreet, Dan Carpenter
Cc: linux-bcache, kernel-janitors, Hulk Robot, linux-kernel
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 <hulkci@huawei.com>
>>>> Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
>>>
>>> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-04-29 10:06 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-05 10:14 [PATCH -next] bcache: use DEFINE_MUTEX() for mutex lock Zheng Yongjun
2021-04-05 14:02 ` Coly Li
2021-04-05 21:17 ` Muhammad Usama Anjum
2021-04-28 16:19 ` Muhammad Usama Anjum
2021-04-29 5:56 ` Dan Carpenter
2021-04-29 10:05 ` Coly Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).