linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Bart Van Assche <bvanassche@acm.org>
Cc: Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
	Alexander Potapenko <glider@google.com>,
	Damien Le Moal <damien.lemoal@wdc.com>,
	Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Subject: Re: [PATCH v2 4/4] null_blk: Zero-initialize read buffers in non-memory-backed mode
Date: Mon, 18 May 2020 11:07:05 +0800	[thread overview]
Message-ID: <20200518030705.GB20647@T590> (raw)
In-Reply-To: <20200518014807.7749-5-bvanassche@acm.org>

On Sun, May 17, 2020 at 06:48:07PM -0700, Bart Van Assche wrote:
> This patch suppresses an uninteresting KMSAN complaint without affecting
> performance of the null_blk driver if CONFIG_KMSAN is disabled.
> 
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Ming Lei <ming.lei@redhat.com>
> Cc: Damien Le Moal <damien.lemoal@wdc.com>
> Cc: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
> Cc: Alexander Potapenko <glider@google.com>
> Reported-by: Alexander Potapenko <glider@google.com>
> Tested-by: Alexander Potapenko <glider@google.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/block/null_blk_main.c | 50 +++++++++++++++++++++++++++++++++++
>  1 file changed, 50 insertions(+)
> 
> diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c
> index 06f5761fccb6..0c1df6ecb30b 100644
> --- a/drivers/block/null_blk_main.c
> +++ b/drivers/block/null_blk_main.c
> @@ -1250,8 +1250,58 @@ static inline blk_status_t null_handle_memory_backed(struct nullb_cmd *cmd,
>  	return errno_to_blk_status(err);
>  }
>  
> +static void zero_fill_bvec(const struct bio_vec *bvec)
> +{
> +	struct page *page = bvec->bv_page;
> +	u32 offset = bvec->bv_offset;
> +	u32 left = bvec->bv_len;
> +
> +	while (left) {
> +		u32 len = min_t(u32, left, PAGE_SIZE - offset);
> +		void *kaddr;
> +
> +		kaddr = kmap_atomic(page);
> +		memset(kaddr + offset, 0, len);
> +		flush_dcache_page(page);
> +		kunmap_atomic(kaddr);
> +		page++;
> +		left -= len;
> +		offset = 0;
> +	}
> +}
> +
> +static void nullb_zero_rq_data_buffer(const struct request *rq)
> +{
> +	struct req_iterator iter;
> +	struct bio_vec bvec;
> +
> +	rq_for_each_bvec(bvec, rq, iter)
> +		zero_fill_bvec(&bvec);
> +}

Not necessary to add zero_fill_bvec(), and it can be done in the
following two line code:

	__rq_for_each_bio(bio, rq)
		zero_fill_bio(bio);


Thanks,
Ming


      reply	other threads:[~2020-05-18  3:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-18  1:48 [PATCH v2 0/4] Block layer patches for kernel v5.8 Bart Van Assche
2020-05-18  1:48 ` [PATCH v2 1/4] block: Fix type of first compat_put_{,u}long() argument Bart Van Assche
2020-05-18  1:48 ` [PATCH v2 2/4] bio.h: Declare the arguments of the bio iteration functions const Bart Van Assche
2020-05-18  1:48 ` [PATCH v2 3/4] block: Document the bio_vec properties Bart Van Assche
2020-05-18  5:23   ` Christoph Hellwig
2020-05-18  1:48 ` [PATCH v2 4/4] null_blk: Zero-initialize read buffers in non-memory-backed mode Bart Van Assche
2020-05-18  3:07   ` Ming Lei [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=20200518030705.GB20647@T590 \
    --to=ming.lei@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=chaitanya.kulkarni@wdc.com \
    --cc=damien.lemoal@wdc.com \
    --cc=glider@google.com \
    --cc=hch@lst.de \
    --cc=linux-block@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 NNTP newsgroup(s).