From: "Alex Xu (Hello71)" <alex_y_xu@yahoo.ca>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: christian@brauner.io, dhowells@redhat.com,
linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.or, linux@rasmusvillemoes.dk,
nicolas.dichtel@6wind.com, peterz@infradead.org,
raven@themaw.net, torvalds@linux-foundation.org
Subject: Re: [PATCH] pipe: increase minimum default pipe size to 2 pages
Date: Thu, 05 Aug 2021 10:18:22 -0400 [thread overview]
Message-ID: <1628172774.4en5vcorw2.none@localhost> (raw)
In-Reply-To: <YQuixFfztw0RaDFi@kroah.com>
Excerpts from Greg KH's message of August 5, 2021 4:35 am:
> On Wed, Aug 04, 2021 at 08:04:35PM -0400, Alex Xu (Hello71) wrote:
>> Before this patch, the following program prints 4096 and hangs.
>> Afterwards, it prints 8192 and exits successfully. Note that you may
>> need to increase your RLIMIT_NOFILE before running the program.
>>
>> int main() {
>> int pipefd[2];
>> for (int i = 0; i < 1025; i++)
>> if (pipe(pipefd) == -1)
>> return 1;
>> size_t bufsz = fcntl(pipefd[1], F_GETPIPE_SZ);
>> printf("%zd\n", bufsz);
>> char *buf = calloc(bufsz, 1);
>> write(pipefd[1], buf, bufsz);
>> read(pipefd[0], buf, bufsz-1);
>> write(pipefd[1], buf, 1);
>> }
>>
>> Signed-off-by: Alex Xu (Hello71) <alex_y_xu@yahoo.ca>
>> ---
>
> Is this due to the changes that happened in 5.5? If so, a cc: stable
> and a fixes tag would be nice to have :)
>
>> See discussion at https://lore.kernel.org/lkml/1628086770.5rn8p04n6j.none@localhost/.
>
> This can go up in the changelog text too.
>
> thanks,
>
> greg k-h
>
I tested 5.4 and it exhibits the same problem as master using this
non-racy program. I think the problem goes back to v4.5, the first
release with 759c01142a ("pipe: limit the per-user amount of pages
allocated in pipes"). The issue likely become more apparent with the
improvement in pipe performance from v5.5, whereas before that, pipes
were too slow for the issue to manifest in racy environments.
I'll send a new patch with #include lines and a Fixes: 759c01142a. I'm
not 100% sure that it actually goes back that far, but the worst thing
that can plausibly happen is that applications opening very large
numbers of pipes suddenly use slightly more memory. I certainly hope
nobody is relying on pipes randomly blocking roughly 1/4096 of the
time.
Regards,
Alex.
next prev parent reply other threads:[~2021-08-05 14:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20210805000435.10833-1-alex_y_xu.ref@yahoo.ca>
2021-08-05 0:04 ` [PATCH] pipe: increase minimum default pipe size to 2 pages Alex Xu (Hello71)
2021-08-05 8:35 ` Greg KH
2021-08-05 14:18 ` Alex Xu (Hello71) [this message]
2021-08-05 17:41 ` Linus Torvalds
[not found] <20210805144047.13518-1-alex_y_xu.ref@yahoo.ca>
2021-08-05 14:40 ` Alex Xu (Hello71)
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=1628172774.4en5vcorw2.none@localhost \
--to=alex_y_xu@yahoo.ca \
--cc=christian@brauner.io \
--cc=dhowells@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.or \
--cc=linux@rasmusvillemoes.dk \
--cc=nicolas.dichtel@6wind.com \
--cc=peterz@infradead.org \
--cc=raven@themaw.net \
--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).