From: Christian Brauner <brauner@kernel.org>
To: Mateusz Guzik <mjguzik@gmail.com>,
Oleg Nesterov <oleg@redhat.com>,
Linus Torvalds <torvalds@linux-foundation.org>
Cc: David Howells <dhowells@redhat.com>,
"Gautham R. Shenoy" <gautham.shenoy@amd.com>,
K Prateek Nayak <kprateek.nayak@amd.com>,
Neeraj Upadhyay <Neeraj.Upadhyay@amd.com>,
Oliver Sang <oliver.sang@intel.com>,
Swapnil Sapkal <swapnil.sapkal@amd.com>,
WangYuli <wangyuli@uniontech.com>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] pipe: don't update {a,c,m}time for anonymous pipes
Date: Tue, 4 Feb 2025 17:34:48 +0100 [thread overview]
Message-ID: <20250204-autohandel-gebastelt-0ca4424b697b@brauner> (raw)
In-Reply-To: <CAGudoHGptAB1C+vKpfoYo+S9tU2Ow2LWbQeyHKwBpzy9Xh_b=w@mail.gmail.com>
On Tue, Feb 04, 2025 at 03:21:18PM +0100, Mateusz Guzik wrote:
> On Tue, Feb 4, 2025 at 2:22 PM Oleg Nesterov <oleg@redhat.com> wrote:
> > These numbers are visible in fstat() but hopefully nobody uses this
> > information and file_accessed/file_update_time are not that cheap.
>
> I'll note majority of the problem most likely stems from
> mnt_get_write_access rolling with:
So anonymous pipes are based on pipefs which isn't exposed to userspace
at all. Neither the superblock nor an individual mount can go read-only
or change mount properties. The superblock cannot be frozen etc.
So really that mnt_get_write_access() should be pointless for
anonymous pipes. In other words, couldn't this also just be:
diff --git a/fs/pipe.c b/fs/pipe.c
index 8df42e1ab3a3..e9989621362c 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -604,12 +604,25 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
if (wake_next_writer)
wake_up_interruptible_sync_poll(&pipe->wr_wait, EPOLLOUT | EPOLLWRNORM);
- if (ret > 0 && sb_start_write_trylock(file_inode(filp)->i_sb)) {
- int err = file_update_time(filp);
- if (err)
- ret = err;
- sb_end_write(file_inode(filp)->i_sb);
+ if (ret > 0) {
+ int err;
+
+ if (!is_anon_pipe(file)) {
+ if (sb_start_write_trylock(file_inode(filp)->i_sb)) {
+ err = file_update_time(filp);
+ if (err)
+ ret = err;
+
+ sb_end_write(file_inode(filp)->i_sb);
+ }
+ } else {
+ // Anonymous pipes don't need all the mount + sb bruah.
+ err = inode_needs_update_time(inode);
+ if (err > 0)
+ ret = inode_update_time(file_inode(filp), err);
+ }
}
+
return ret;
}
and then have zero regression risk?
next prev parent reply other threads:[~2025-02-04 16:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-04 13:21 Oleg Nesterov
2025-02-04 14:21 ` Mateusz Guzik
2025-02-04 14:39 ` Oleg Nesterov
2025-02-04 16:34 ` Christian Brauner [this message]
2025-02-04 16:49 ` Linus Torvalds
2025-02-04 14:48 ` Jeff Layton
2025-02-04 14:53 ` Jeff Layton
2025-02-04 15:28 ` Linus Torvalds
2025-02-04 15:55 ` 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=20250204-autohandel-gebastelt-0ca4424b697b@brauner \
--to=brauner@kernel.org \
--cc=Neeraj.Upadhyay@amd.com \
--cc=dhowells@redhat.com \
--cc=gautham.shenoy@amd.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mjguzik@gmail.com \
--cc=oleg@redhat.com \
--cc=oliver.sang@intel.com \
--cc=swapnil.sapkal@amd.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
all inboxes | Powered by JetHome®