Linux block layer
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Nilay Vaish <nilayvaish@google.com>
Cc: Jens Axboe <axboe@kernel.dk>,
	Christoph Hellwig <hch@infradead.org>,
	Bart Van Assche <bvanassche@acm.org>,
	linux-block@vger.kernel.org
Subject: Re: [PATCH v2 1/2] null_blk: convert the page stores to XArray
Date: Mon, 30 Nov 2026 00:01:20 -0800	[thread overview]
Message-ID: <aw0tUGiutMed9kZC@infradead.org> (raw)
In-Reply-To: <20261126212341.916839-2-nilayvaish@google.com>

On Thu, Nov 26, 2026 at 01:23:40PM -0800, Nilay Vaish wrote:
> A store that runs out of memory partway can leave empty nodes in the
> array until the retry completes, or for good if the retry cannot
> allocate either. So check that the cache holds no page after a flush
> with xa_find() instead of xa_empty(), and call xa_destroy() when the
> storage is freed.

What is this supposed to tell?

> +	/* A failed insert can leave empty nodes behind. */
> +	xa_destroy(xa);

Same here.  xa_destroy is always required, why do we need a comment?

>  	__acquires(&nullb->lock)
>  {
> -	u64 idx;
> -	struct nullb_page *t_page;
> +	struct xarray *xa = ignore_cache ? &nullb->dev->data : &nullb->dev->cache;

Overly long line.

But this whole concept of picking a struct xarray based on a boolean flag
is a bit iffy.  It looks to me like we should have a xarray mark for
'stable data' set on a cache flush, and then pass the named marked around
instead of this bool magic.  Maybe as a follow on..

> +	/*
> +	 * The store has to happen under nullb->lock, where it cannot sleep.
> +	 * If it runs out of memory, drop the lock, let xas_nomem() allocate
> +	 * and try again.
> +	 */
> +	do {
> +		spin_lock_irq(&nullb->lock);
> +		xas_lock(&xas);
> +		cur = xas_load(&xas);
> +		if (!cur)
> +			xas_store(&xas, t_page);
> +		xas_unlock(&xas);
> +		if (!xas_error(&xas))
> +			break;
> +		spin_unlock_irq(&nullb->lock);
> +	} while (xas_nomem(&xas, GFP_NOIO));

Just use xa_reserve()? And in the long run we could look into phasing
out nullb->lock in favor of just using the lock in the xarray.

> +	xa_for_each_start(&nullb->dev->cache, idx, c_page,
> +			  nullb->cache_flush_pos) {
> +		c_pages[nr_pages++] = c_page;
> +		if (nr_pages == FREE_BATCH)
> +			break;
> +	}

This should be using the xas_for_each family of helpers to avoid
restarting the lookup every time.

> +	/*
> +	 * No page may be left. Do not use xa_empty(): an insert that ran out
> +	 * of memory can leave empty nodes in the array.
> +	 */

I'm really not getting what this is trying to say, but it feels like
something is really off here.


  reply	other threads:[~2026-11-30  8:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 21:23 [PATCH v2 0/2] null_blk: stop using page->private Nilay Vaish
2026-11-26 21:23 ` [PATCH v2 1/2] null_blk: convert the page stores to XArray Nilay Vaish
2026-11-30  8:01   ` Christoph Hellwig [this message]
2026-11-26 21:23 ` [PATCH v2 2/2] null_blk: stop storing the page index in page->private Nilay Vaish
2026-11-30  8:03   ` Christoph Hellwig

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=aw0tUGiutMed9kZC@infradead.org \
    --to=hch@infradead.org \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=linux-block@vger.kernel.org \
    --cc=nilayvaish@google.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