From: Al Viro <viro@zeniv.linux.org.uk>
To: David Howells <dhowells@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Dan Williams <dan.j.williams@intel.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
nvdimm@lists.linux.dev
Subject: Re: [RFC][PATCH] fix short copy handling in copy_mc_pipe_to_iter()
Date: Tue, 14 Jun 2022 13:11:51 +0100 [thread overview]
Message-ID: <Yqh7B+tVDutCwuG1@ZenIV> (raw)
In-Reply-To: <1586153.1655188579@warthog.procyon.org.uk>
On Tue, Jun 14, 2022 at 07:36:19AM +0100, David Howells wrote:
> Al Viro <viro@zeniv.linux.org.uk> wrote:
>
> > What's wrong with
> > p_occupancy = pipe_occupancy(head, tail);
> > if (p_occupancy >= pipe->max_usage)
> > return 0;
> > else
> > return pipe->max_usage - p_occupancy;
>
> Because "pipe->max_usage - p_occupancy" can be negative.
Sure can. And in that case you return 0; no problem wiht that.
It's what happens when occupancy is below max_usage that is weird.
> post_one_notification() is limited by pipe->ring_size, not pipe->max_usage.
>
> The idea is to allow some slack in a watch pipe for the watch_queue code to
> use that userspace can't.
Sure. And if this function is supposed to report how many times would
userspace be able to grab a slot, it's returning the wrong value.
Look: 32-slot ring. max_usage is 16. 14 slots are already occupied.
Userland (sure as hell, anything in iov_iter.c) will be able to occupy
two more before it runs into the pipe_full(). And your function returns
min(32 - 14, 16), i.e. 16.
What am I missing here?
next prev parent reply other threads:[~2022-06-14 12:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-13 0:10 [RFC][PATCH] fix short copy handling in copy_mc_pipe_to_iter() Al Viro
2022-06-13 17:54 ` Linus Torvalds
2022-06-13 22:28 ` Al Viro
2022-06-13 23:25 ` Al Viro
2022-06-13 23:34 ` Al Viro
2022-06-14 0:53 ` Al Viro
2022-06-14 17:12 ` Al Viro
2022-06-14 6:36 ` David Howells
2022-06-14 12:11 ` Al Viro [this message]
2022-06-16 21:22 ` Dan Williams
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=Yqh7B+tVDutCwuG1@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=dan.j.williams@intel.com \
--cc=dhowells@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nvdimm@lists.linux.dev \
--cc=torvalds@linux-foundation.org \
/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;
as well as URLs for NNTP newsgroup(s).