mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Leonardo Bras <leonardo@linux.ibm.com>, linux-kernel@vger.kernel.org
Cc: Dennis Zhou <dennis@kernel.org>, Hannes Reinecke <hare@suse.com>,
	Damien Le Moal <damien.lemoal@wdc.com>, Tejun Heo <tj@kernel.org>,
	"Dennis Zhou (Facebook)" <dennisszhou@gmail.com>,
	Johannes Thumshirn <jthumshirn@suse.de>,
	Sagi Grimberg <sagi@grimberg.me>
Subject: Re: [PATCH 1/1] block: Use bits.h macros to improve readability
Date: Fri, 2 Aug 2019 21:18:10 -0700	[thread overview]
Message-ID: <a41b5530-f2e1-0932-1f39-0ce66ce902ae@kernel.dk> (raw)
In-Reply-To: <20190802000041.24513-1-leonardo@linux.ibm.com>

On 8/1/19 6:00 PM, Leonardo Bras wrote:
> Applies some bits.h macros in order to improve readability of
> linux/blk_types.h.
> 
> Signed-off-by: Leonardo Bras <leonardo@linux.ibm.com>
> ---
>   include/linux/blk_types.h | 55 ++++++++++++++++++++-------------------
>   1 file changed, 28 insertions(+), 27 deletions(-)
> 
> diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
> index 95202f80676c..31c8c6d274f6 100644
> --- a/include/linux/blk_types.h
> +++ b/include/linux/blk_types.h
> @@ -9,6 +9,7 @@
>   #include <linux/types.h>
>   #include <linux/bvec.h>
>   #include <linux/ktime.h>
> +#include <linux/bits.h>
>   
>   struct bio_set;
>   struct bio;
> @@ -101,13 +102,13 @@ static inline bool blk_path_error(blk_status_t error)
>   #define BIO_ISSUE_SIZE_BITS     12
>   #define BIO_ISSUE_RES_SHIFT     (64 - BIO_ISSUE_RES_BITS)
>   #define BIO_ISSUE_SIZE_SHIFT    (BIO_ISSUE_RES_SHIFT - BIO_ISSUE_SIZE_BITS)
> -#define BIO_ISSUE_TIME_MASK     ((1ULL << BIO_ISSUE_SIZE_SHIFT) - 1)
> +#define BIO_ISSUE_TIME_MASK     GENMASK_ULL(BIO_ISSUE_SIZE_SHIFT - 1, 0)

Not sure why we even have these helpers, I'd argue that patches like
this HURT readability, not improve it. When I see

((1ULL << SOME_SHIFT) - 1)

I know precisely what that does, whereas I have to think about the other
one, maybe even look it up to be sure. For instance, without looking
now, I have no idea what the second argument is. Looking at the git log,
I see numerous instances of:

"xxx: Fix misuses of GENMASK macro

 Arguments are supposed to be ordered high then low."

Hence it seems GENMASK_ULL is easy to misuse or get wrong, the very
opposite of what you'd want in a helper. How is it helping readability
if the helper is easy to misuse?

Ditto with

(1ULL << SOME_SHIFT)

vs BIT_ULL. But at least that one doesn't have a mysterious 2nd
argument.

Hence I'm not inclined to apply this patch.

-- 
Jens Axboe


  reply	other threads:[~2019-08-03  4:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-02  0:00 Leonardo Bras
2019-08-03  4:18 ` Jens Axboe [this message]
2019-08-04 20:17   ` Joe Perches
2019-08-04 21:10     ` Jens Axboe
2019-08-08 18:35   ` Leonardo Bras

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=a41b5530-f2e1-0932-1f39-0ce66ce902ae@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=damien.lemoal@wdc.com \
    --cc=dennis@kernel.org \
    --cc=dennisszhou@gmail.com \
    --cc=hare@suse.com \
    --cc=jthumshirn@suse.de \
    --cc=leonardo@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sagi@grimberg.me \
    --cc=tj@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

all inboxes | Powered by JetHome®