linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Damien Le Moal <Damien.LeMoal@wdc.com>
To: Bart Van Assche <bvanassche@acm.org>, Jens Axboe <axboe@kernel.dk>
Cc: "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
	Christoph Hellwig <hch@lst.de>, Ming Lei <ming.lei@redhat.com>,
	Chaitanya Kulkarni <Chaitanya.Kulkarni@wdc.com>,
	Alexander Potapenko <glider@google.com>
Subject: Re: [PATCH 5/5] null_blk: Zero-initialize read buffers in non-memory-backed mode
Date: Mon, 18 May 2020 01:12:48 +0000	[thread overview]
Message-ID: <BY5PR04MB69008A16B82CD028FC01D0A6E7B80@BY5PR04MB6900.namprd04.prod.outlook.com> (raw)
In-Reply-To: 20200516001914.17138-6-bvanassche@acm.org

On 2020/05/16 9:19, 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>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/block/null_blk_main.c | 30 ++++++++++++++++++++++++++++++
>  1 file changed, 30 insertions(+)
> 
> diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c
> index 06f5761fccb6..df1e144eeaa4 100644
> --- a/drivers/block/null_blk_main.c
> +++ b/drivers/block/null_blk_main.c
> @@ -1250,8 +1250,38 @@ static inline blk_status_t null_handle_memory_backed(struct nullb_cmd *cmd,
>  	return errno_to_blk_status(err);
>  }
>  
> +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);
> +}
> +
> +static void nullb_zero_read_cmd_buffer(struct nullb_cmd *cmd)
> +{
> +	struct nullb_device *dev = cmd->nq->dev;
> +
> +	if (dev->queue_mode == NULL_Q_BIO && bio_op(cmd->bio) == REQ_OP_READ)
> +		zero_fill_bio(cmd->bio);
> +	else if (req_op(cmd->rq) == REQ_OP_READ)
> +		nullb_zero_rq_data_buffer(cmd->rq);
> +}

Shouldn't the definition of these two functions be under a "#ifdef CONFIG_KMSAN" ?

> +
> +/* Complete a request. Only called if dev->memory_backed == 0. */
>  static inline void nullb_complete_cmd(struct nullb_cmd *cmd)
>  {
> +	/*
> +	 * Since root privileges are required to configure the null_blk
> +	 * driver, it is fine that this driver does not initialize the
> +	 * data buffers of read commands. Zero-initialize these buffers
> +	 * anyway if KMSAN is enabled to prevent that KMSAN complains
> +	 * about null_blk not initializing read data buffers.
> +	 */
> +	if (IS_ENABLED(CONFIG_KMSAN))
> +		nullb_zero_read_cmd_buffer(cmd);
> +
>  	/* Complete IO by inline, softirq or timer */
>  	switch (cmd->nq->dev->irqmode) {
>  	case NULL_IRQ_SOFTIRQ:
> 


-- 
Damien Le Moal
Western Digital Research

  parent reply	other threads:[~2020-05-18  1:12 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-16  0:19 [PATCH 0/5] Block layer patches for kernel v5.8 Bart Van Assche
2020-05-16  0:19 ` [PATCH 1/5] block: Fix type of first compat_put_{,u}long() argument Bart Van Assche
2020-05-16  7:40   ` Arnd Bergmann
2020-05-16 12:41   ` Christoph Hellwig
2020-05-16  0:19 ` [PATCH 2/5] bio.h: Declare the arguments of bio iteration functions const Bart Van Assche
2020-05-16  8:55   ` Alexander Potapenko
2020-05-16 17:10     ` Bart Van Assche
2020-05-16 12:42   ` Christoph Hellwig
2020-05-17 22:46   ` Chaitanya Kulkarni
2020-05-16  0:19 ` [PATCH 3/5] block: Document the bio_vec properties Bart Van Assche
2020-05-16 12:43   ` Christoph Hellwig
2020-05-16  0:19 ` [PATCH 4/5] block: Fix zero_fill_bio() Bart Van Assche
2020-05-16  5:50   ` Ming Lei
2020-05-16  0:19 ` [PATCH 5/5] null_blk: Zero-initialize read buffers in non-memory-backed mode Bart Van Assche
2020-05-16  9:40   ` Alexander Potapenko
2020-05-18  1:12   ` Damien Le Moal [this message]
2020-05-18  1:32     ` Bart Van Assche
2020-05-18  2:10       ` Damien Le Moal
2020-05-18  2:56         ` Bart Van Assche
2020-05-18  3:12           ` Damien Le Moal
2020-05-18 14:31             ` Bart Van Assche
2020-05-19  3:03               ` Damien Le Moal
2020-05-19  4:10                 ` Bart Van Assche

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=BY5PR04MB69008A16B82CD028FC01D0A6E7B80@BY5PR04MB6900.namprd04.prod.outlook.com \
    --to=damien.lemoal@wdc.com \
    --cc=Chaitanya.Kulkarni@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=glider@google.com \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=ming.lei@redhat.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).