From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202602 header.b=kGDbvC/X; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id C964F5A0265 for ; Fri, 03 Apr 2026 14:35:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202602; t=1775219739; bh=+yyjCfLVm3bbCTT0z0zJXpvsVH4ZYF6BENdpi5zQSLg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kGDbvC/XIVPhLg5EjUHIu7eP8CSUziWCfg/4xYIchboMymaf+ESZBXdVKjkK1c9pO qlArQuwT9dFWNxU4dbm25nrhXDLIJlajNdfETueBA1SOdLizCnLRV4VyKVg519k+7s EqBcxX+5o/lw+GkTD7vkR6LxYyKSp06g6c7KQYj5diJ+X8wcdlPmu5VXy3sf4LbrKH 4cGeZqbgP4ZEr+5T+E+VkChFz3dNcf9youmPOKDbV7TJe6BFSlnCGu7ufLKxLxvxWI 5lxQoh17hLMnwTN3M7oa4LziGHRdtXTdIG0Wf5FAB2LBuKAndByw/vM3NbKubX2s37 TRL1faK8xz8AA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4fnJ973NJ1z4w9r; Fri, 03 Apr 2026 23:35:39 +1100 (AEDT) Date: Fri, 3 Apr 2026 23:35:00 +1100 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH 01/10] iov: Introduce iov_memset() Message-ID: References: <20260401191826.1782394-1-lvivier@redhat.com> <20260401191826.1782394-2-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="k+XnJbitAib30YCo" Content-Disposition: inline In-Reply-To: <20260401191826.1782394-2-lvivier@redhat.com> Message-ID-Hash: JSCDQOMM2NEOXR3NPTY4PY5IF2TA3IHT X-Message-ID-Hash: JSCDQOMM2NEOXR3NPTY4PY5IF2TA3IHT X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --k+XnJbitAib30YCo Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Apr 01, 2026 at 09:18:17PM +0200, Laurent Vivier wrote: > Add a helper to set a range of bytes across an IO vector to a given > value, similar to memset() but operating over scatter-gather buffers. > It skips to the given offset and fills across iovec entries up to the > requested length. >=20 > Signed-off-by: Laurent Vivier Reviewed-by: David Gibson > --- > iov.c | 27 +++++++++++++++++++++++++++ > iov.h | 2 ++ > 2 files changed, 29 insertions(+) >=20 > diff --git a/iov.c b/iov.c > index ae0743931d18..0188acdf5eba 100644 > --- a/iov.c > +++ b/iov.c > @@ -170,6 +170,33 @@ size_t iov_truncate(struct iovec *iov, size_t iov_cn= t, size_t size) > return i; > } > =20 > +/** > + * iov_memset() - Set bytes of an IO vector to a given value > + * @iov: IO vector > + * @iov_cnt: Number of elements in @iov > + * @offset: Byte offset in the iovec at which to start > + * @c: Byte value to fill with > + * @length: Number of bytes to set > + * Will write less than @length bytes if it runs out of space in > + * the iov > + */ > +/* cppcheck-suppress unusedFunction */ > +void iov_memset(const struct iovec *iov, size_t iov_cnt, size_t offset, = int c, > + size_t length) > +{ > + size_t i; > + > + i =3D iov_skip_bytes(iov, iov_cnt, offset, &offset); > + > + for ( ; i < iov_cnt && length; i++) { > + size_t n =3D MIN(iov[i].iov_len - offset, length); > + > + memset((char *)iov[i].iov_base + offset, c, n); > + offset =3D 0; > + length -=3D n; > + } > +} > + > /** > * iov_tail_prune() - Remove any unneeded buffers from an IOV tail > * @tail: IO vector tail (modified) > diff --git a/iov.h b/iov.h > index b4e50b0fca5a..d295d05b3bab 100644 > --- a/iov.h > +++ b/iov.h > @@ -30,6 +30,8 @@ size_t iov_to_buf(const struct iovec *iov, size_t iov_c= nt, > size_t offset, void *buf, size_t bytes); > size_t iov_size(const struct iovec *iov, size_t iov_cnt); > size_t iov_truncate(struct iovec *iov, size_t iov_cnt, size_t size); > +void iov_memset(const struct iovec *iov, size_t iov_cnt, size_t offset, = int c, > + size_t length); > =20 > /* > * DOC: Theory of Operation, struct iov_tail > --=20 > 2.53.0 >=20 --=20 David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson --k+XnJbitAib30YCo Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmnPs94ACgkQzQJF27ox 2GdGVQ/8DvQVHCOJsY3hSHqGf50t6YrAF6pCdzhXdvIZ70QeclbEXpjW1ViwJ1OM MBSAQvqZgKcgiTi4AKVMnB/3rliBsd0NthgTKjjzbTiQjqqKG/83E/581qncKMNp oUgGrTamK6betq5vm8wmg+PAU2D5MI+hbE9B+9LM3XTiv4MoYaGl82RcFhgphbh8 zm9/2hpKruXeDOJKi3F/qdc2C4TVuOinhbqXQaL1b5DlYMKpGIO0ctkcFebJ+Eym oUwZTUUnBaFjglvXWYFwy3ODwZEK5gubWNgyA7+ELiSR5R7G24LkBUwnWEL6Gzys 4b2yyizolwar4sQRrH9Ay2vUp9fjm2WeBxqYcHtQwGmvCWcG8lot4bXJeMcdBFT5 6JMgKY92w99moMz6xA+bMl2jkehWPfydfOCOPGUX0UKi/E71aXVLYcHe4aamDet6 jpRhcutWR6NDoZlbdw1S0yDhffU4z+KgYfK867Fx8W8Eh1X0MeV/QLY/C5cDJ0BE P4pnYZxiNpLVQkyvVjW8dLRPJ1u2NQDQCpBl64NPfafSf+5D9/ZkvebLwtSsQRNm nj8N4h17tbk35OwAwZlXkiDBBfX1vmSbFhNPgLwXEpLQPQ5Cv14EIecLHFf3yHd7 x6qZ6/xN5h3m/g1+2MNppzto82EGlBVOAoS1A789Y/L+3m3FPjQ= =f2Ke -----END PGP SIGNATURE----- --k+XnJbitAib30YCo--