From: Oleg Nesterov <oleg@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: WangYuli <wangyuli@uniontech.com>,
viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
yushengjin@uniontech.com, zhangdandan@uniontech.com,
guanwentao@uniontech.com, zhanjun@uniontech.com,
oliver.sang@intel.com, ebiederm@xmission.com,
colin.king@canonical.com, josh@joshtriplett.org,
penberg@cs.helsinki.fi, manfred@colorfullife.com, mingo@elte.hu,
jes@sgi.com, hch@lst.de, aia21@cantab.net, arjan@infradead.org,
jgarzik@pobox.com, neukum@fachschaft.cup.uni-muenchen.de,
oliver@neukum.name, dada1@cosmosbay.com, axboe@kernel.dk,
axboe@suse.de, nickpiggin@yahoo.com.au, dhowells@redhat.com,
nathans@sgi.com, rolandd@cisco.com, tytso@mit.edu,
bunk@stusta.de, pbadari@us.ibm.com, ak@linux.intel.com,
ak@suse.de, davem@davemloft.net, jsipek@cs.sunysb.edu,
jens.axboe@oracle.com, ramsdell@mitre.org, hch@infradead.org,
akpm@linux-foundation.org, randy.dunlap@oracle.com,
efault@gmx.de, rdunlap@infradead.org, haveblue@us.ibm.com,
drepper@redhat.com, dm.n9107@gmail.com, jblunck@suse.de,
davidel@xmailserver.org, mtk.manpages@googlemail.com,
linux-arch@vger.kernel.org, vda.linux@googlemail.com,
jmorris@namei.org, serue@us.ibm.com, hca@linux.ibm.com,
rth@twiddle.net, lethal@linux-sh.org, tony.luck@intel.com,
heiko.carstens@de.ibm.com, andi@firstfloor.org, corbet@lwn.net,
crquan@gmail.com, mszeredi@suse.cz, miklos@szeredi.hu,
peterz@infradead.org, a.p.zijlstra@chello.nl,
earl_chew@agilent.com, npiggin@gmail.com, npiggin@suse.de,
julia@diku.dk, jaxboe@fusionio.com, nikai@nikai.net,
dchinner@redhat.com, davej@redhat.com, npiggin@kernel.dk,
eric.dumazet@gmail.com, tim.c.chen@linux.intel.com,
xemul@parallels.com, tj@kernel.org, serge.hallyn@canonical.com,
gorcunov@openvz.org, levinsasha928@gmail.com, penberg@kernel.org,
amwang@redhat.com, bcrl@kvack.org, muthu.lkml@gmail.com,
muthur@gmail.com, mjt@tls.msk.ru, alan@lxorguk.ukuu.org.uk,
raven@themaw.net, thomas@m3y3r.de, will.deacon@arm.com,
will@kernel.org, josef@redhat.com, anatol.pomozov@gmail.com,
koverstreet@google.com, zab@redhat.com, balbi@ti.com,
gregkh@linuxfoundation.org, mfasheh@suse.com, jlbec@evilplan.org,
rusty@rustcorp.com.au, asamymuthupa@micron.com, smani@micron.com,
sbradshaw@micron.com, jmoyer@redhat.com, sim@hostway.ca,
ia@cloudflare.com, dmonakhov@openvz.org, ebiggers3@gmail.com,
socketpair@gmail.com, penguin-kernel@i-love.sakura.ne.jp,
w@1wt.eu, kirill.shutemov@linux.intel.com, mhocko@suse.com,
vdavydov.dev@gmail.com, vdavydov@virtuozzo.com,
hannes@cmpxchg.org, mhocko@kernel.org, minchan@kernel.org,
deepa.kernel@gmail.com, arnd@arndb.de, balbi@kernel.org,
swhiteho@redhat.com, konishi.ryusuke@lab.ntt.co.jp,
dsterba@suse.com, vegard.nossum@oracle.com, axboe@fb.com,
pombredanne@nexb.com, tglx@linutronix.de,
joe.lawrence@redhat.com, mpatocka@redhat.com, mcgrof@kernel.org,
keescook@chromium.org, linux@dominikbrodowski.net,
jannh@google.com, shakeelb@google.com, guro@fb.com,
willy@infradead.org, khlebnikov@yandex-team.ru, kirr@nexedi.com,
stern@rowland.harvard.edu, elver@google.com,
parri.andrea@gmail.com, paulmck@kernel.org, rasibley@redhat.com,
jstancek@redhat.com, avagin@gmail.com, cai@redhat.com,
josef@toxicpanda.com, hare@suse.de, colyli@suse.de,
johannes@sipsolutions.net, sspatil@android.com,
alex_y_xu@yahoo.ca, mgorman@techsingularity.net,
gor@linux.ibm.com, jhubbard@nvidia.com,
andriy.shevchenko@linux.intel.com, crope@iki.fi,
yzaikin@google.com, bfields@fieldses.org, jlayton@kernel.org,
kernel@tuxforce.de, steve@sk2.org, nixiaoming@huawei.com,
0x7f454c46@gmail.com, kuniyu@amazon.co.jp,
alexander.h.duyck@intel.com, kuni1840@gmail.com,
soheil@google.com, sridhar.samudrala@intel.com,
Vincenzo.Frascino@arm.com, chuck.lever@oracle.com,
Kevin.Brodsky@arm.com, Szabolcs.Nagy@arm.com,
David.Laight@aculab.com, Mark.Rutland@arm.com,
linux-morello@op-lists.linaro.org, Luca.Vizzarro@arm.com,
max.kellermann@ionos.com, adobriyan@gmail.com, lukas@schauer.dev,
j.granados@samsung.com, djwong@kernel.org,
kent.overstreet@linux.dev, linux@weissschuh.net,
kstewart@efficios.com
Subject: Re: [RESEND PATCH] fs/pipe: Introduce a check to skip sleeping processes during pipe read/write
Date: Thu, 26 Dec 2024 21:11:58 +0100 [thread overview]
Message-ID: <20241226201158.GB11118@redhat.com> (raw)
In-Reply-To: <CAHk-=wj5A-fO+GnfwqGpXhFbfpS4+_8xU+dnXkSx+0AfwBYrxA@mail.gmail.com>
I mostly agree, see my reply to this patch, but...
On 12/26, Linus Torvalds wrote:
>
> If the optimization is correct, there is no point to having a config option.
>
> If the optimization is incorrect, there is no point to having the code.
>
> Either way, there's no way we'd ever have a config option for this.
Agreed,
> > + if (was_full && pipe_check_wq_has_sleeper(&pipe->wr_wait))
> > wake_up_interruptible_sync_poll(&pipe->wr_wait, EPOLLOUT | EPOLLWRNORM);
>
> End result: you need to explain why the race cannot exist.
Agreed,
> And I think your patch is simply buggy
Agreed again, but probably my reasoning was wrong,
> But now waiters use "wait_event_interruptible_exclusive()" explicitly
> outside the pipe mutex, so the waiters and wakers aren't actually
> serialized.
This is what I don't understand... Could you spell ?
I _think_ that
wait_event_whatever(WQ, CONDITION);
vs
CONDITION = 1;
if (wq_has_sleeper(WQ))
wake_up_xxx(WQ, ...);
is fine.
Both wq_has_sleeper() and wait_event_whatever()->prepare_to_wait_event()
have the necessary barriers to serialize the waiters and wakers.
Damn I am sure I missed something ;)
> And no, you are unlikely to see the races in practice (particularly
> the memory ordering ones). So you have to *think* about them, not test
> them.
Yes! agreed again.
Oleg.
next prev parent reply other threads:[~2024-12-26 20:13 UTC|newest]
Thread overview: 10+ 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 15:42 ` WangYuli
2024-12-26 16:00 ` Oleg Nesterov
2024-12-26 19:02 ` Linus Torvalds
2024-12-26 20:11 ` Oleg Nesterov [this message]
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
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=20241226201158.GB11118@redhat.com \
--to=oleg@redhat.com \
--cc=0x7f454c46@gmail.com \
--cc=David.Laight@aculab.com \
--cc=Kevin.Brodsky@arm.com \
--cc=Luca.Vizzarro@arm.com \
--cc=Mark.Rutland@arm.com \
--cc=Szabolcs.Nagy@arm.com \
--cc=Vincenzo.Frascino@arm.com \
--cc=a.p.zijlstra@chello.nl \
--cc=adobriyan@gmail.com \
--cc=aia21@cantab.net \
--cc=ak@linux.intel.com \
--cc=ak@suse.de \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=alex_y_xu@yahoo.ca \
--cc=alexander.h.duyck@intel.com \
--cc=amwang@redhat.com \
--cc=anatol.pomozov@gmail.com \
--cc=andi@firstfloor.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=arjan@infradead.org \
--cc=arnd@arndb.de \
--cc=asamymuthupa@micron.com \
--cc=avagin@gmail.com \
--cc=axboe@fb.com \
--cc=axboe@kernel.dk \
--cc=axboe@suse.de \
--cc=balbi@kernel.org \
--cc=balbi@ti.com \
--cc=bcrl@kvack.org \
--cc=bfields@fieldses.org \
--cc=brauner@kernel.org \
--cc=bunk@stusta.de \
--cc=cai@redhat.com \
--cc=chuck.lever@oracle.com \
--cc=colin.king@canonical.com \
--cc=colyli@suse.de \
--cc=corbet@lwn.net \
--cc=crope@iki.fi \
--cc=crquan@gmail.com \
--cc=dada1@cosmosbay.com \
--cc=davej@redhat.com \
--cc=davem@davemloft.net \
--cc=davidel@xmailserver.org \
--cc=dchinner@redhat.com \
--cc=deepa.kernel@gmail.com \
--cc=dhowells@redhat.com \
--cc=djwong@kernel.org \
--cc=dm.n9107@gmail.com \
--cc=dmonakhov@openvz.org \
--cc=drepper@redhat.com \
--cc=dsterba@suse.com \
--cc=earl_chew@agilent.com \
--cc=ebiederm@xmission.com \
--cc=ebiggers3@gmail.com \
--cc=efault@gmx.de \
--cc=elver@google.com \
--cc=eric.dumazet@gmail.com \
--cc=gor@linux.ibm.com \
--cc=gorcunov@openvz.org \
--cc=gregkh@linuxfoundation.org \
--cc=guanwentao@uniontech.com \
--cc=guro@fb.com \
--cc=hannes@cmpxchg.org \
--cc=hare@suse.de \
--cc=haveblue@us.ibm.com \
--cc=hca@linux.ibm.com \
--cc=hch@infradead.org \
--cc=hch@lst.de \
--cc=heiko.carstens@de.ibm.com \
--cc=ia@cloudflare.com \
--cc=j.granados@samsung.com \
--cc=jack@suse.cz \
--cc=jannh@google.com \
--cc=jaxboe@fusionio.com \
--cc=jblunck@suse.de \
--cc=jens.axboe@oracle.com \
--cc=jes@sgi.com \
--cc=jgarzik@pobox.com \
--cc=jhubbard@nvidia.com \
--cc=jlayton@kernel.org \
--cc=jlbec@evilplan.org \
--cc=jmorris@namei.org \
--cc=jmoyer@redhat.com \
--cc=joe.lawrence@redhat.com \
--cc=johannes@sipsolutions.net \
--cc=josef@redhat.com \
--cc=josef@toxicpanda.com \
--cc=josh@joshtriplett.org \
--cc=jsipek@cs.sunysb.edu \
--cc=jstancek@redhat.com \
--cc=julia@diku.dk \
--cc=keescook@chromium.org \
--cc=kent.overstreet@linux.dev \
--cc=kernel@tuxforce.de \
--cc=khlebnikov@yandex-team.ru \
--cc=kirill.shutemov@linux.intel.com \
--cc=kirr@nexedi.com \
--cc=konishi.ryusuke@lab.ntt.co.jp \
--cc=koverstreet@google.com \
--cc=kstewart@efficios.com \
--cc=kuni1840@gmail.com \
--cc=kuniyu@amazon.co.jp \
--cc=lethal@linux-sh.org \
--cc=levinsasha928@gmail.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-morello@op-lists.linaro.org \
--cc=linux@dominikbrodowski.net \
--cc=linux@weissschuh.net \
--cc=lukas@schauer.dev \
--cc=manfred@colorfullife.com \
--cc=max.kellermann@ionos.com \
--cc=mcgrof@kernel.org \
--cc=mfasheh@suse.com \
--cc=mgorman@techsingularity.net \
--cc=mhocko@kernel.org \
--cc=mhocko@suse.com \
--cc=miklos@szeredi.hu \
--cc=minchan@kernel.org \
--cc=mingo@elte.hu \
--cc=mjt@tls.msk.ru \
--cc=mpatocka@redhat.com \
--cc=mszeredi@suse.cz \
--cc=mtk.manpages@googlemail.com \
--cc=muthu.lkml@gmail.com \
--cc=muthur@gmail.com \
--cc=nathans@sgi.com \
--cc=neukum@fachschaft.cup.uni-muenchen.de \
--cc=nickpiggin@yahoo.com.au \
--cc=nikai@nikai.net \
--cc=nixiaoming@huawei.com \
--cc=npiggin@gmail.com \
--cc=npiggin@kernel.dk \
--cc=npiggin@suse.de \
--cc=oliver.sang@intel.com \
--cc=oliver@neukum.name \
--cc=parri.andrea@gmail.com \
--cc=paulmck@kernel.org \
--cc=pbadari@us.ibm.com \
--cc=penberg@cs.helsinki.fi \
--cc=penberg@kernel.org \
--cc=penguin-kernel@i-love.sakura.ne.jp \
--cc=peterz@infradead.org \
--cc=pombredanne@nexb.com \
--cc=ramsdell@mitre.org \
--cc=randy.dunlap@oracle.com \
--cc=rasibley@redhat.com \
--cc=raven@themaw.net \
--cc=rdunlap@infradead.org \
--cc=rolandd@cisco.com \
--cc=rth@twiddle.net \
--cc=rusty@rustcorp.com.au \
--cc=sbradshaw@micron.com \
--cc=serge.hallyn@canonical.com \
--cc=serue@us.ibm.com \
--cc=shakeelb@google.com \
--cc=sim@hostway.ca \
--cc=smani@micron.com \
--cc=socketpair@gmail.com \
--cc=soheil@google.com \
--cc=sridhar.samudrala@intel.com \
--cc=sspatil@android.com \
--cc=stern@rowland.harvard.edu \
--cc=steve@sk2.org \
--cc=swhiteho@redhat.com \
--cc=tglx@linutronix.de \
--cc=thomas@m3y3r.de \
--cc=tim.c.chen@linux.intel.com \
--cc=tj@kernel.org \
--cc=tony.luck@intel.com \
--cc=torvalds@linux-foundation.org \
--cc=tytso@mit.edu \
--cc=vda.linux@googlemail.com \
--cc=vdavydov.dev@gmail.com \
--cc=vdavydov@virtuozzo.com \
--cc=vegard.nossum@oracle.com \
--cc=viro@zeniv.linux.org.uk \
--cc=w@1wt.eu \
--cc=wangyuli@uniontech.com \
--cc=will.deacon@arm.com \
--cc=will@kernel.org \
--cc=willy@infradead.org \
--cc=xemul@parallels.com \
--cc=yushengjin@uniontech.com \
--cc=yzaikin@google.com \
--cc=zab@redhat.com \
--cc=zhangdandan@uniontech.com \
--cc=zhanjun@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;
as well as URLs for NNTP newsgroup(s).