linux-bcache.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Muhammad Usama Anjum <musamaanjum@gmail.com>
To: Coly Li <colyli@suse.de>,
	Zheng Yongjun <zhengyongjun3@huawei.com>,
	Kent Overstreet <kent.overstreet@gmail.com>
Cc: musamaanjum@gmail.com, linux-bcache@vger.kernel.org,
	kernel-janitors@vger.kernel.org, Hulk Robot <hulkci@huawei.com>
Subject: Re: [PATCH -next] bcache: use DEFINE_MUTEX() for mutex lock
Date: Tue, 06 Apr 2021 02:17:25 +0500	[thread overview]
Message-ID: <d7f70ce31f6f61a50c05a5d5ba03582054f144fe.camel@gmail.com> (raw)
In-Reply-To: <42c3e33d-c20e-0fdd-f316-5084e33f9a3b@suse.de>

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).




  reply	other threads:[~2021-04-05 21:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2021-04-28 16:19     ` Muhammad Usama Anjum
2021-04-29  5:56       ` Dan Carpenter
2021-04-29 10:05       ` Coly Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d7f70ce31f6f61a50c05a5d5ba03582054f144fe.camel@gmail.com \
    --to=musamaanjum@gmail.com \
    --cc=colyli@suse.de \
    --cc=hulkci@huawei.com \
    --cc=kent.overstreet@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-bcache@vger.kernel.org \
    --cc=zhengyongjun3@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).