From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.137.202.133 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796025688; b=cMBYBjWtZqEwWfvBe54W1gC71EI0AkwVgXuN2ux3l9qztl+mw9R5FRFGLoxMLTNToeni 4N+AZzYqkdbSD8gTur/ujCojZFziN0iub7d4JvKNlVXEguT/E2/xqvwPYuI3Wzyrw32iD 2CTngV1MOubUSZhoX/cyGXcmoYb0S0flHuVwC03kawhhijruU8OD3foDnzq+NzVakY2ua JSXvKJj0lmmnR8WtggV6LjVPRRTOlfFvRIlS3baYyLdtjhcjqbN5tkfZUx8qnyqqwuLkU n9zQFjHOjLSUSdlsf8DD3afw00Ja9TDmRQmauNMhNh7b4fakQXFPWwV612srlstTTVA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796025688; h=DMARC-Filter:DKIM-Signature:Received:Date:From:To:Cc:Subject: Message-ID:References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To:X-SRS-Rewrite; bh=G1YIj6sIEJJ7OMa98ZwRWpWPUWrdvA5KsLCgYd5ZAG8=; b=cIvfhgSDHtGb8fmKHkH7Ci6ND5o7ScXminq3V2VhKXg4g5RTlUXhXZv16gCquo25y2lh rDbmq3enmJnyih0656rPoaV02S2lZWsvf1ChQDZQO4XtZcziOL3ClcU8fs8a5L1/sodWs 9NIOxQwn3pJ6Z1F4x8l+kX2i9EEeFb9n8x38lr7WhTHGWtCMimCSvvvjyLCPOH27Bigzg SZW/RPV+kC0EeBmXTE5tH2MFVjSgaK2ZBRK/T346qylIY4NlctfSGkJKxO7KBWmcug0Pe zLXjwpYp+C1u8ip5tT4GwVwqE5gz6na3XcOC+VC/CWzIgjwP1sSk+SgokzdhhBCuGsA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=infradead.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=urE7h0Ax; arc=none smtp.remote-ip=198.137.202.133 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E35E0606A31C for ; Mon, 30 Nov 2026 08:01:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E35E0606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=urE7h0Ax DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=G1YIj6sIEJJ7OMa98ZwRWpWPUWrdvA5KsLCgYd5ZAG8=; b=urE7h0AxLXLdne2XeS2OvK2S/J lq//gV3dNrJp9hlzamIFuqOBqrIMPNEhgNzGkNi6IrU20suOx1vFAvk0MXlEpMzLgouxEnIcf01z1 V1s/Om4UGMntsVRtQZy2ra/E3NifjdLNFI0VaR6gIOOTFDqiHYg9j6MBlguJ/Sugxzm6cwHL+5duT o1Yqk9vlvbMBgR9+Bt9pPtWNOLOXdN9Sk3T35s8RoKvMYGZThYqcAxkOwT21xtmAb9ZcbjMDZPStB i7yjVAtGZMUV9LexdYAHV44/qofD8Yuz2Eq6EPkxCIGhL97p9ko1VbhLn4f5Qo7KTqeVC9dlOQLLo +3EFIO2A==; Received: from hch by bombadil.infradead.org with local (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXwK8-00000003fxj-3d7d; Mon, 30 Nov 2026 08:01:20 +0000 Date: Mon, 30 Nov 2026 00:01:20 -0800 From: Christoph Hellwig To: Nilay Vaish Cc: Jens Axboe , Christoph Hellwig , Bart Van Assche , linux-block@vger.kernel.org Subject: Re: [PATCH v2 1/2] null_blk: convert the page stores to XArray Message-ID: References: <20261126212341.916839-1-nilayvaish@google.com> <20261126212341.916839-2-nilayvaish@google.com> X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261126212341.916839-2-nilayvaish@google.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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.