public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Manfred Spraul <manfred@colorfullife.com>,
	WangYuli <wangyuli@uniontech.com>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Christian Brauner <brauner@kernel.org>,
	1vier1@web.de
Subject: Re: [RESEND PATCH] fs/pipe: Introduce a check to skip sleeping processes during pipe read/write
Date: Thu, 2 Jan 2025 14:57:50 +0100	[thread overview]
Message-ID: <20250102135750.GA30778@redhat.com> (raw)
In-Reply-To: <CAHk-=wiCRwRFi0kGwd_Uv+Xv4HOB-ivHyUp9it6CNSmrKT4gOA@mail.gmail.com>

On 12/31, Linus Torvalds wrote:
>
> On Tue, 31 Dec 2024 at 12:25, Oleg Nesterov <oleg@redhat.com> wrote:
> >
> > But let me ask another question right now. what do you think about another
> > minor change below?
>
> Probably ok. Although I'm not convinced it makes things any more readable.

OK, lets forget it for now.

> > Again, mostly to make this logic more understandable. Although I am not
> > sure I really understand it...
>
> So see commit fe67f4dd8daa ("pipe: do FASYNC notifications for every
> pipe IO, not just state changes") on why that crazy poll_usage thing
> exists.

Ah. Yes, yes, thanks, I have already read this commit/changelog, because
I was confused by the unconditional kill_fasync()'s in pipe_read/write.
So I guess I mostly understand the "edge-triggered" issues.

As for epoll, I even wrote the stupid test-case:

	int main(void)
	{
		int pfd[2], efd;
		struct epoll_event evt = { .events = EPOLLIN | EPOLLET };

		pipe(pfd);
		efd = epoll_create1(0);
		epoll_ctl(efd, EPOLL_CTL_ADD, pfd[0], &evt);

		for (int i = 0; i < 2; ++i) {
			write(pfd[1], "", 1);
			assert(epoll_wait(efd, &evt, 1, 0) == 1);
		}

		return 0;
	}

without the pipe->poll_usage check in pipe_write() assert() fails on the
2nd iteration. BTW, I think pipe_write() needs READ_ONCE(pipe->poll_usage),
KCSAN can complain.

> The
>
>   #ifdef CONFIG_EPOLL
>
> addition is straightforward enough and matches the existing comment.
>
> But you adding the FMODE_READ test should probably get a new comment
> about how we only do this for epoll readability, not for writability..

Agreed. perhaps I'll try to make V2 later...

The unconditional WRITE_ONCE(pipe->poll_usage) in pipe_poll() may hide
some subtle race between pipe_write() and the "normal" select/poll, that
is why I'd like to make ->poll_usage depend on filp->f_ep != NULL.

Thanks!

Oleg.


  reply	other threads:[~2025-01-02 13:58 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-25  9:42 [RESEND PATCH] fs/pipe: Introduce a check to skip sleeping processes during pipe read/write WangYuli
2024-12-25 13:30 ` Andy Shevchenko
2024-12-25 13:53   ` Kent Overstreet
2024-12-25 16:04     ` Mateusz Guzik
2024-12-25 16:32       ` Kent Overstreet
2024-12-25 17:22         ` Mateusz Guzik
2024-12-25 17:41           ` Kent Overstreet
2024-12-25 15:42   ` WangYuli
2024-12-25 16:00     ` Willy Tarreau
2024-12-25 16:32       ` WangYuli
2024-12-25 16:56         ` Willy Tarreau
2024-12-26 16:00 ` Oleg Nesterov
2024-12-26 19:02 ` Linus Torvalds
2024-12-26 20:11   ` Oleg Nesterov
2024-12-26 20:29     ` Linus Torvalds
2024-12-26 20:57       ` Oleg Nesterov
2024-12-27 15:54         ` Oleg Nesterov
2024-12-27 16:43           ` Oleg Nesterov
2024-12-27 18:39     ` Manfred Spraul
2024-12-28 14:32       ` Oleg Nesterov
2024-12-28 15:22         ` Oleg Nesterov
2024-12-28 16:32           ` Oleg Nesterov
2024-12-28 18:53             ` Manfred Spraul
2024-12-29 11:54               ` Oleg Nesterov
2024-12-28 16:45           ` Manfred Spraul
2024-12-29 11:57             ` Oleg Nesterov
2024-12-29 12:41               ` Manfred Spraul
2024-12-29 13:05                 ` Oleg Nesterov
2024-12-29 13:13                   ` Oleg Nesterov
2024-12-29 19:54                     ` Manfred Spraul
2024-12-30 15:38                       ` Oleg Nesterov
2024-12-31 11:14                         ` Manfred Spraul
2024-12-31 19:38                           ` Linus Torvalds
2024-12-31 20:24                             ` Oleg Nesterov
2024-12-31 22:31                               ` Linus Torvalds
2025-01-02 13:57                                 ` Oleg Nesterov [this message]
2025-01-04 21:15                         ` RFC: Checkpatch: Introduce list of functions that need memory barriers Manfred Spraul

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=20250102135750.GA30778@redhat.com \
    --to=oleg@redhat.com \
    --cc=1vier1@web.de \
    --cc=brauner@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manfred@colorfullife.com \
    --cc=torvalds@linux-foundation.org \
    --cc=wangyuli@uniontech.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