OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: no-reply@sashiko.virtuozzo.com
To: Liu Kui <kui.liu@virtuozzo.com>,
	Konstantin Khorenko <khorenko@virtuozzo.com>
Cc: devel@openvz.org, azaitsev@virtuozzo.com
Subject: Re: [Devel] [PATCH hci-8.1 v2] fs/fuse kio: build the rdma sgl from folios
Date: Wed, 18 Nov 2026 16:16:33 +0000	[thread overview]
Message-ID: <010701a1ef721549-1a0e456c-75f6-4171-aef5-4f6ce75eb5bb-000000@eu-central-1.amazonses.com> (raw)
In-Reply-To: <20261118-b4-vstor-155302-sgl-folio-v2-1-bc5e45a53792@virtuozzo.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] fuse kio: pcs_sgl_buf_init_from_msg() sizes the sgl by the whole
  remaining iterator
--

commit bf611f05472805568665b417b7285a66d56f26a0
Author: Liu Kui <kui.liu@virtuozzo.com>

fs/fuse kio: build the rdma sgl from folios

This commit switches pcs_sgl_buf_init_from_msg() and the related sgl helpers to build the scatterlist from folios. This way a bio_vec segment over a hugepage-backed buffer no longer overruns a scatterlist sized by segment count.

> diff --git a/fs/fuse/kio/pcs/pcs_rdma_rw.c b/fs/fuse/kio/pcs/pcs_rdma_rw.c
> --- a/fs/fuse/kio/pcs/pcs_rdma_rw.c
> +++ b/fs/fuse/kio/pcs/pcs_rdma_rw.c

[ ... ]

> +	/* count the entries, one per segment unless a segment is longer than max_seg */
> +	sbuf->sg_cnt = 0;
> +	msg_offset = offset;
> +	while (msg_offset < end_offset) {
> +		msg->get_iter(msg, msg_offset, &it, dir);
> +
> +		/* a kvec may be over vmalloc memory, leave it to the MR fallback */
> +		if (iov_iter_is_kvec(&it))
> +			return -EINVAL;
> +
> +		len = iov_iter_count(&it);
> +		if (len > end_offset - msg_offset)
> +			len = end_offset - msg_offset;
> +
> +		/* may overcount here, which is rare and harmless */
> +		sbuf->sg_cnt += it.nr_segs;

[Severity: Low]
Is the overcount here really rare? it.nr_segs is the number of segments left in the whole iterator, not the number inside [msg_offset, msg_offset + len). The get_iter() callbacks only truncate the byte count: req_get_iter() builds iov_iter_bvec() over all of r->exec.io.num_bvecs, and cs_get_read_response_iter() then calls iov_iter_truncate(), which leaves nr_segs alone.

So when fuse_io.c splits a request into chunks, each chunk is sized for every bvec left in the request. For a 1MB request with 256 bvecs, a chunk covering a quarter of it gets about 256 sg entries instead of about 64. That is an 8KB GFP_NOIO kzalloc plus memset on the RDMA read path, where the old code sized the list exactly.

It is bounded and transient, with no memory-safety impact, since sg_cnt is trimmed to cnt and the list is closed with sg_mark_end(). But the "rare and harmless" comment is inaccurate for split requests. Could the count be limited to the bvecs that cover len, for example by walking the segments against len?

Carry the trailer below into the next revision and Sashiko will not review this patch again.

Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261118-b4-vstor-155302-sgl-folio-v2-1-bc5e45a53792@virtuozzo.com?part=1

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  parent reply	other threads:[~2026-11-18 16:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 15:57 Liu Kui
2026-11-18 16:12 ` Konstantin Khorenko
2026-11-18 16:41   ` Alexey Kuznetsov
2026-11-18 16:16 ` no-reply [this message]
2026-11-18 19:32 ` Konstantin Khorenko
2026-11-18 19:33 ` Konstantin Khorenko
2026-11-18 19:44   ` Konstantin Khorenko
2026-11-18 19:39 ` Konstantin Khorenko

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=010701a1ef721549-1a0e456c-75f6-4171-aef5-4f6ce75eb5bb-000000@eu-central-1.amazonses.com \
    --to=no-reply@sashiko.virtuozzo.com \
    --cc=azaitsev@virtuozzo.com \
    --cc=devel@openvz.org \
    --cc=khorenko@virtuozzo.com \
    --cc=kui.liu@virtuozzo.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