Commit 2dafe1c4d69345539735cca64250f2d4657bd057
Committed by
Linus Torvalds
1 parent
ac2a659968
Exists in
master
and in
7 other branches
reduce large do_mount stack usage with noinlines
do_mount() uses a whopping 616 bytes of stack on x86_64 in 2.6.24-mm1, largely thanks to gcc inlining the various helper functions. noinlining these can slim it down a lot; on my box this patch gets it down to 168, which is mostly the struct nameidata nd; left on the stack. These functions are called only as do_mount() helpers; none of them should be in any path that would see a performance benefit from inlining... Signed-off-by: Eric Sandeen <sandeen@redhat.com> Cc: Arjan van de Ven <arjan@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 13 additions and 5 deletions Side-by-side Diff
fs/namespace.c
... | ... | @@ -936,8 +936,9 @@ |
936 | 936 | |
937 | 937 | /* |
938 | 938 | * recursively change the type of the mountpoint. |
939 | + * noinline this do_mount helper to save do_mount stack space. | |
939 | 940 | */ |
940 | -static int do_change_type(struct nameidata *nd, int flag) | |
941 | +static noinline int do_change_type(struct nameidata *nd, int flag) | |
941 | 942 | { |
942 | 943 | struct vfsmount *m, *mnt = nd->mnt; |
943 | 944 | int recurse = flag & MS_REC; |
944 | 945 | |
... | ... | @@ -960,8 +961,10 @@ |
960 | 961 | |
961 | 962 | /* |
962 | 963 | * do loopback mount. |
964 | + * noinline this do_mount helper to save do_mount stack space. | |
963 | 965 | */ |
964 | -static int do_loopback(struct nameidata *nd, char *old_name, int recurse) | |
966 | +static noinline int do_loopback(struct nameidata *nd, char *old_name, | |
967 | + int recurse) | |
965 | 968 | { |
966 | 969 | struct nameidata old_nd; |
967 | 970 | struct vfsmount *mnt = NULL; |
968 | 971 | |
... | ... | @@ -1010,8 +1013,9 @@ |
1010 | 1013 | * change filesystem flags. dir should be a physical root of filesystem. |
1011 | 1014 | * If you've mounted a non-root directory somewhere and want to do remount |
1012 | 1015 | * on it - tough luck. |
1016 | + * noinline this do_mount helper to save do_mount stack space. | |
1013 | 1017 | */ |
1014 | -static int do_remount(struct nameidata *nd, int flags, int mnt_flags, | |
1018 | +static noinline int do_remount(struct nameidata *nd, int flags, int mnt_flags, | |
1015 | 1019 | void *data) |
1016 | 1020 | { |
1017 | 1021 | int err; |
... | ... | @@ -1046,7 +1050,10 @@ |
1046 | 1050 | return 0; |
1047 | 1051 | } |
1048 | 1052 | |
1049 | -static int do_move_mount(struct nameidata *nd, char *old_name) | |
1053 | +/* | |
1054 | + * noinline this do_mount helper to save do_mount stack space. | |
1055 | + */ | |
1056 | +static noinline int do_move_mount(struct nameidata *nd, char *old_name) | |
1050 | 1057 | { |
1051 | 1058 | struct nameidata old_nd, parent_nd; |
1052 | 1059 | struct vfsmount *p; |
1053 | 1060 | |
... | ... | @@ -1121,8 +1128,9 @@ |
1121 | 1128 | /* |
1122 | 1129 | * create a new mount for userspace and request it to be added into the |
1123 | 1130 | * namespace's tree |
1131 | + * noinline this do_mount helper to save do_mount stack space. | |
1124 | 1132 | */ |
1125 | -static int do_new_mount(struct nameidata *nd, char *type, int flags, | |
1133 | +static noinline int do_new_mount(struct nameidata *nd, char *type, int flags, | |
1126 | 1134 | int mnt_flags, char *name, void *data) |
1127 | 1135 | { |
1128 | 1136 | struct vfsmount *mnt; |