From: Alexander Monakov <amonakov@ispras.ru>
To: musl@lists.openwall.com
Cc: Dominic Chen <d.c.ddcc@gmail.com>
Subject: Re: [musl] Issue with fread() and unaligned readv()
Date: Tue, 16 Mar 2021 01:42:48 +0300 (MSK) [thread overview]
Message-ID: <alpine.LNX.2.20.13.2103160137290.17743@monopod.intra.ispras.ru> (raw)
In-Reply-To: <20210315222916.GG32655@brightrain.aerifal.cx>
On Mon, 15 Mar 2021, Rich Felker wrote:
> > If musl always does such off-by-one, it is an efficiency issue (forces
> > a copy with mismatching source/dest alignment).
>
> It's necessary to work around a kernel bug, whereby the kernel fails
> to honor the requirement that a readv of total length n behave
> identically, except for where the data is stored, as a single read of
> length n. For vfs backends that don't implement a proper readv
> operation, the kernel executes readv as a sequence of reads. When this
> happens, if the amount of data to read is exactly the length of the
> first iov (the length requested by the application), continuing to the
> second iov with no more data available will cause the operation to
> block indefinitely until more data is available. By reducing the
> length of the first iov (the caller's buffer) by 1, we ensure that at
> least 1 byte of the second iov (the FILE's buffer) is actually needed
> to satisfy the caller, and thus that the call will return without
> blocking as soon as everything the caller requested is available.
Thanks. Can musl reduce the first iov tuple by, say, 8 bytes rather than
1 byte, to avoid forcing the kernel to perform a misaligned copy?
Alexander
next prev parent reply other threads:[~2021-03-15 22:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-15 21:39 Dominic Chen
2021-03-15 21:51 ` Rich Felker
2021-03-15 22:09 ` Alexander Monakov
2021-03-15 22:29 ` Rich Felker
2021-03-15 22:42 ` Alexander Monakov [this message]
2021-03-16 2:13 ` Rich Felker
2021-03-16 9:30 ` Alexander Monakov
2021-03-16 23:54 ` Rich Felker
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=alpine.LNX.2.20.13.2103160137290.17743@monopod.intra.ispras.ru \
--to=amonakov@ispras.ru \
--cc=d.c.ddcc@gmail.com \
--cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).