mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Jianyu Zhan <nasa4836@gmail.com>
Cc: axboe@kernel.dk, hch@lst.de, jack@suse.cz,
	viro@zeniv.linux.org.uk, kmo@daterainc.com,
	namjae.jeon@samsung.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] blkdev: use an efficient way to check merge flags
Date: Wed, 2 Apr 2014 20:13:54 +0200	[thread overview]
Message-ID: <20140402181354.GB13479@quack.suse.cz> (raw)
In-Reply-To: <1396451946-13924-1-git-send-email-nasa4836@gmail.com>

On Wed 02-04-14 23:19:06, Jianyu Zhan wrote:
> A bitwise flag comparison could be done using a more efficient bit-ops way.
  OK, but have you checked the generated code is actually any better? This
is something I'd expect a compiler might be able to optimize anyway. And the
original code looks more readable to me.

								Honza

> Signed-off-by: Jianyu Zhan <nasa4836@gmail.com>
> ---
>  include/linux/blkdev.h | 13 +++----------
>  1 file changed, 3 insertions(+), 10 deletions(-)
> 
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index 1e1fa3f..adfa40a 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -655,16 +655,9 @@ static inline bool rq_mergeable(struct request *rq)
>  static inline bool blk_check_merge_flags(unsigned int flags1,
>  					 unsigned int flags2)
>  {
> -	if ((flags1 & REQ_DISCARD) != (flags2 & REQ_DISCARD))
> -		return false;
> -
> -	if ((flags1 & REQ_SECURE) != (flags2 & REQ_SECURE))
> -		return false;
> -
> -	if ((flags1 & REQ_WRITE_SAME) != (flags2 & REQ_WRITE_SAME))
> -		return false;
> -
> -	return true;
> +	return (flags1 & (REQ_DISCARD | REQ_SECURE | REQ_WRITE_SAME)) ^
> +	       (flags2 & (REQ_DISCARD | REQ_SECURE | REQ_WRITE_SAME))
> +		== 0;
>  }
>  
>  static inline bool blk_write_same_mergeable(struct bio *a, struct bio *b)
> -- 
> 1.9.0.GIT
> 
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

  reply	other threads:[~2014-04-02 18:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-02 15:19 Jianyu Zhan
2014-04-02 18:13 ` Jan Kara [this message]
2014-04-03  8:00   ` Zhan Jianyu
2014-04-03 12:45     ` Jan Kara
2014-04-03 13:37 Jianyu Zhan

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=20140402181354.GB13479@quack.suse.cz \
    --to=jack@suse.cz \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=kmo@daterainc.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namjae.jeon@samsung.com \
    --cc=nasa4836@gmail.com \
    --cc=viro@zeniv.linux.org.uk \
    /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®