From: Lucas Karpinski <lkarpins@redhat.com>
To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz
Cc: raven@themaw.net, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org,
Lucas Karpinski <lkarpins@redhat.com>,
Alexander Larsson <alexl@redhat.com>,
Eric Chanudet <echanude@redhat.com>, Ian Kent <ikent@redhat.com>
Subject: [RFC v3 1/1] fs/namespace: remove RCU sync for MNT_DETACH umount
Date: Wed, 26 Jun 2024 16:07:49 -0400 [thread overview]
Message-ID: <20240626201129.272750-3-lkarpins@redhat.com> (raw)
In-Reply-To: <20240626201129.272750-2-lkarpins@redhat.com>
When detaching (MNT_DETACH) a filesystem, it should not be necessary to
wait for the grace period before completing the syscall. The
expectation that the filesystem is shut down by the time the syscall
returns does not apply in this case. The synchronize_expedited() is not
needed in the lazy umount case, so don't use it.
Without patch, on 6.10-rc2-rt kernel:
perf stat -r 10 --null --pre 'mount -t tmpfs tmpfs mnt' -- umount mnt
0.07333 +- 0.00615 seconds time elapsed ( +- 8.38% )
perf stat -r 10 --null --pre 'mount -t tmpfs tmpfs mnt' -- umount -l mnt
0.07229 +- 0.00672 seconds time elapsed ( +- 9.29% )
With patch, on 6.10-rc2-rt kernel:
perf stat -r 10 --null --pre 'mount -t tmpfs tmpfs mnt' -- umount mnt
0.02834 +- 0.00419 seconds time elapsed ( +- 14.78% )
perf stat -r 10 --null --pre 'mount -t tmpfs tmpfs mnt' -- umount -l mnt
0.0029830 +- 0.0000767 seconds time elapsed ( +- 2.57% )
Signed-off-by: Alexander Larsson <alexl@redhat.com>
Signed-off-by: Eric Chanudet <echanude@redhat.com>
Signed-off-by: Lucas Karpinski <lkarpins@redhat.com>
Suggested-by: Ian Kent <ikent@redhat.com>
---
fs/namespace.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/fs/namespace.c b/fs/namespace.c
index 5a51315c6678..5d889e05dd14 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -78,6 +78,7 @@ static struct kmem_cache *mnt_cache __ro_after_init;
static DECLARE_RWSEM(namespace_sem);
static HLIST_HEAD(unmounted); /* protected by namespace_sem */
static LIST_HEAD(ex_mountpoints); /* protected by namespace_sem */
+static bool lazy_unlock = false; /* protected by namespace_sem */
struct mount_kattr {
unsigned int attr_set;
@@ -1555,6 +1556,7 @@ EXPORT_SYMBOL(may_umount);
static void namespace_unlock(void)
{
+ bool lazy;
struct hlist_head head;
struct hlist_node *p;
struct mount *m;
@@ -1563,6 +1565,9 @@ static void namespace_unlock(void)
hlist_move_list(&unmounted, &head);
list_splice_init(&ex_mountpoints, &list);
+ lazy = lazy_unlock;
+ lazy_unlock = false;
+
up_write(&namespace_sem);
shrink_dentry_list(&list);
@@ -1570,7 +1575,8 @@ static void namespace_unlock(void)
if (likely(hlist_empty(&head)))
return;
- synchronize_rcu_expedited();
+ if (!lazy)
+ synchronize_rcu_expedited();
hlist_for_each_entry_safe(m, p, &head, mnt_umount) {
hlist_del(&m->mnt_umount);
@@ -1798,6 +1804,7 @@ static int do_umount(struct mount *mnt, int flags)
}
out:
unlock_mount_hash();
+ lazy_unlock = flags & MNT_DETACH ? true : false;
namespace_unlock();
return retval;
}
--
2.45.2
next prev parent reply other threads:[~2024-06-26 20:16 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-26 20:07 [RFC v3 0/1] fs/namespace: defer RCU sync for MNT_DETACH umount Lucas Karpinski
2024-06-26 20:07 ` Lucas Karpinski [this message]
2024-06-26 20:47 ` [RFC v3 1/1] fs/namespace: remove " Matthew Wilcox
2024-06-27 1:11 ` Ian Kent
2024-06-27 11:54 ` Jan Kara
2024-06-27 15:16 ` Christian Brauner
2024-06-28 3:17 ` Ian Kent
2024-06-28 12:54 ` Christian Brauner
2024-06-28 15:13 ` Alexander Larsson
2024-07-01 0:58 ` Ian Kent
2024-07-01 5:50 ` Christian Brauner
2024-07-01 8:03 ` Ian Kent
2024-07-01 8:41 ` Alexander Larsson
2024-07-01 10:15 ` Jan Kara
2024-07-01 12:13 ` Christian Brauner
2024-07-01 12:10 ` Christian Brauner
2024-07-03 9:22 ` Christian Brauner
2024-07-04 1:23 ` Ian Kent
2024-07-02 1:29 ` Ian Kent
2024-07-02 4:50 ` Christian Brauner
2024-06-28 2:58 ` Ian Kent
2024-06-28 11:13 ` Jan Kara
2024-07-01 1:08 ` Ian Kent
2024-07-02 4:58 ` Christian Brauner
2024-07-02 7:01 ` Ian Kent
2024-07-02 10:01 ` Jan Kara
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=20240626201129.272750-3-lkarpins@redhat.com \
--to=lkarpins@redhat.com \
--cc=alexl@redhat.com \
--cc=brauner@kernel.org \
--cc=echanude@redhat.com \
--cc=ikent@redhat.com \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=raven@themaw.net \
--cc=viro@zeniv.linux.org.uk \
/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).