Linux-bcache Archive mirror
 help / color / mirror / Atom feed
From: Coly Li <colyli@suse.de>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Kent Overstreet <kent.overstreet@gmail.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-bcache@vger.kernel.org
Subject: Re: [PATCH] bcache: Optimize sysfs_hprint()
Date: Mon, 30 Oct 2023 15:38:08 +0800	[thread overview]
Message-ID: <BF96F92E-B483-4FC7-B4DB-B9D76E44D9A7@suse.de> (raw)
In-Reply-To: <9b82413f1ca0b924cc139d945777e32dd22ffe41.1698575385.git.christophe.jaillet@wanadoo.fr>



> 2023年10月29日 18:30,Christophe JAILLET <christophe.jaillet@wanadoo.fr> 写道:
> 
> The size of what is in 'buf' is already computed by bch_hprint(), so skip
> these bytes when calling strcat().
> 
> This easily saves a few cycles. (should it matter)
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Your change does save several cpu cycles, but hurts the readability. This is not hot code path, just let strcat to do what it was designed for. 

Thanks.

Coly Li

> ---
> drivers/md/bcache/sysfs.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/md/bcache/sysfs.h b/drivers/md/bcache/sysfs.h
> index 65b8bd975ab1..798bcbeab0bb 100644
> --- a/drivers/md/bcache/sysfs.h
> +++ b/drivers/md/bcache/sysfs.h
> @@ -78,7 +78,7 @@ do { \
> do { \
> if (attr == &sysfs_ ## file) { \
> ssize_t ret = bch_hprint(buf, val); \
> - strcat(buf, "\n"); \
> + strcat(buf + ret, "\n"); \
> return ret + 1; \
> } \
> } while (0)
> -- 
> 2.34.1
> 


      reply	other threads:[~2023-10-30  7:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-29 10:30 [PATCH] bcache: Optimize sysfs_hprint() Christophe JAILLET
2023-10-30  7:38 ` Coly Li [this message]

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=BF96F92E-B483-4FC7-B4DB-B9D76E44D9A7@suse.de \
    --to=colyli@suse.de \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=kent.overstreet@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-bcache@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).