Re: [PATCH v2 2/5] nbd: replace socks pointer array with xarray
- To: "Yang Erkun" <yangerkun@huawei.com>, <josef@toxicpanda.com>, <axboe@kernel.dk>, <hch@lst.de>, <yukuai@fygo.io>
- Cc: <yi.zhang@huawei.com>, <chengzhihao1@huawei.com>, <echo.chenlin@huawei.com>, <leo.lilong@huaweicloud.com>, <wangkefeng.wang@huawei.com>, <linux-block@vger.kernel.org>, <nbd@other.debian.org>
- Subject: Re: [PATCH v2 2/5] nbd: replace socks pointer array with xarray
- From: "yu kuai" <yukuai@fygo.io>
- Date: Sun, 5 Jul 2026 18:02:16 +0800
- Message-id: <[🔎] 913d11fc-0fb8-4111-b995-7fe7e893025e@fygo.io>
- Reply-to: yukuai@fygo.io
- In-reply-to: <20260625084458.4171890-3-yangerkun@huawei.com>
- References: <20260625084458.4171890-1-yangerkun@huawei.com> <20260625084458.4171890-3-yangerkun@huawei.com>
Hi,
在 2026/6/25 16:44, Yang Erkun 写道:
> Replace the krealloc-based struct nbd_sock **socks array with struct
> xarray socks. Each nbd sock is fully initialized before being stored
> into the xarray via xa_store(), ensuring concurrent readers calling
> xa_load() never observe a partially initialized socket.
>
> Convert all array index accesses to xa_load() and open-coded for-loops
> to xa_for_each().
>
> Signed-off-by: Long Li<leo.lilong@huawei.com>
xarray may not be good idea for IO hot path because of the overhead.
https://lore.kernel.org/all/60f9a88b-b750-3579-bdfd-5421f2040406@huaweicloud.com/
--
Thanks,
Kuai
Reply to: