summaryrefslogtreecommitdiffstats
path: root/include/linux/mount.h
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@redhat.com>2023-10-25 16:02:00 +0200
committerChristian Brauner <brauner@kernel.org>2023-11-18 14:56:16 +0100
commit2eea9ce4310d8c0f8ef1dbe7b0e7d9219ff02b97 (patch)
tree6e1759ae01554e15a6d7b92d4a243f469deaa5b2 /include/linux/mount.h
parent98d2b43081972abeb5bb5a087bc3e3197531c46e (diff)
downloadlinux-2eea9ce4310d8c0f8ef1dbe7b0e7d9219ff02b97.tar.gz
linux-2eea9ce4310d8c0f8ef1dbe7b0e7d9219ff02b97.tar.bz2
linux-2eea9ce4310d8c0f8ef1dbe7b0e7d9219ff02b97.zip
mounts: keep list of mounts in an rbtree
When adding a mount to a namespace insert it into an rbtree rooted in the mnt_namespace instead of a linear list. The mnt.mnt_list is still used to set up the mount tree and for propagation, but not after the mount has been added to a namespace. Hence mnt_list can live in union with rb_node. Use MNT_ONRB mount flag to validate that the mount is on the correct list. This allows removing the cursor used for reading /proc/$PID/mountinfo. The mnt_id_unique of the next mount can be used as an index into the seq file. Tested by inserting 100k bind mounts, unsharing the mount namespace, and unmounting. No performance regressions have been observed. For the last mount in the 100k list the statmount() call was more than 100x faster due to the mount ID lookup not having to do a linear search. This patch makes the overhead of mount ID lookup non-observable in this range. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> Link: https://lore.kernel.org/r/20231025140205.3586473-3-mszeredi@redhat.com Reviewed-by: Ian Kent <raven@themaw.net> Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'include/linux/mount.h')
-rw-r--r--include/linux/mount.h5
1 files changed, 2 insertions, 3 deletions
diff --git a/include/linux/mount.h b/include/linux/mount.h
index ac3dd2876197..c34c18b4e8f3 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -50,8 +50,7 @@ struct path;
#define MNT_ATIME_MASK (MNT_NOATIME | MNT_NODIRATIME | MNT_RELATIME )
#define MNT_INTERNAL_FLAGS (MNT_SHARED | MNT_WRITE_HOLD | MNT_INTERNAL | \
- MNT_DOOMED | MNT_SYNC_UMOUNT | MNT_MARKED | \
- MNT_CURSOR)
+ MNT_DOOMED | MNT_SYNC_UMOUNT | MNT_MARKED | MNT_ONRB)
#define MNT_INTERNAL 0x4000
@@ -65,7 +64,7 @@ struct path;
#define MNT_SYNC_UMOUNT 0x2000000
#define MNT_MARKED 0x4000000
#define MNT_UMOUNT 0x8000000
-#define MNT_CURSOR 0x10000000
+#define MNT_ONRB 0x10000000
struct vfsmount {
struct dentry *mnt_root; /* root of the mounted tree */