vfs: inline getname()
PATCH 1/1 vfs: inline getname()
It is merely a trivial wrapper around getname_flags which adds a zeroed argument, no point paying for an extra call.
--- fs/namei.c | 5 ----- include/linux/fs.h | 5 ++++- 2 files changed, 4 insertions(+), 6 deletions(-)
fs/namei.c +0 -5
@@ -218,11 +218,6 @@ struct filename *getname_uflags(const char __user *filename, int uflags)return getname_flags (filename, flags); } -struct filename *getname (const char __user * filename) -{ -return getname_flags (filename,0 ); -} -struct filename *__getname_maybe_null (const char __user *pathname) {struct filename *name;
include/linux/fs.h +4 -1
@@ -2840,7 +2840,10 @@ extern int filp_close(struct file *, fl_owner_t id);extern struct filename *getname_flags (const char __user *,int );extern struct filename *getname_uflags (const char __user *,int ); -extern struct filename *getname (const char __user *); +static inline struct filename *getname (const char __user *name) +{ +return getname_flags (name,0 ); +}extern struct filename *getname_kernel (const char *);extern struct filename *__getname_maybe_null (const char __user *);static inline struct filename *getname_maybe_null (const char __user *name,int flags)
Signature · 1 line
2.43.0
Quoted 4 lines · Mateusz Guzik
It is merely a trivial wrapper around
getname_flagswhich adds a zeroed argument, no point paying for an extra call.Signed-off-by Mateusz Guzik <[email protected]>
Well, the "extra call" in your changelog is a bit overrated. Such wrappers get compiled into a constant jump anyway - e.g. in my kernel:
Dump of assembler code for function getname:
0xffffffff815edb80 <+0>: endbr64
0xffffffff815edb84 <+4>: call 0xffffffff8131cad0 <__fentry__>
0xffffffff815edb89 <+9>: xor %esi,%esi
0xffffffff815edb8b <+11>: jmp 0xffffffff815ed750 <getname_flags>
And the jmp to constant is practically free on current CPUs.
Overall inline function for this is I guess a more common way how we do things like this so feel free to add:
Honza
Quoted 40 lines
--- fs/namei.c | 5 ----- include/linux/fs.h | 5 ++++- 2 files changed, 4 insertions(+), 6 deletions(-)fs/namei.c +0
-5@@ -218,11 +218,6 @@ struct filename *getname_uflags(const char __user *filename, int uflags)return getname_flags (filename, flags); } -struct filename *getname (const char __user * filename) -{ -return getname_flags (filename,0 ); -} -struct filename *__getname_maybe_null (const char __user *pathname) {struct filename *name;include/linux/fs.h +4
-1@@ -2840,7 +2840,10 @@ extern int filp_close(struct file *, fl_owner_t id);extern struct filename *getname_flags (const char __user *,int );extern struct filename *getname_uflags (const char __user *,int ); -extern struct filename *getname (const char __user *); +static inline struct filename *getname (const char __user *name) +{ +return getname_flags (name,0 ); +}extern struct filename *getname_kernel (const char *);extern struct filename *__getname_maybe_null (const char __user *);static inline struct filename *getname_maybe_null (const char __user *name,int flags)Signature · 1 line
2.43.0
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 4 lines · Mateusz Guzik
It is merely a trivial wrapper around
getname_flagswhich adds a zeroed argument, no point paying for an extra call.
Applied to the vfs-6.15.misc branch of the vfs/vfs.git tree. Patches in the vfs-6.15.misc branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs-6.15.misc
[1/1] vfs: inline getname()
https://git.kernel.org/vfs/vfs/c/521fbc6e8653