diff mbox series

vfs: inline getname()

Message ID 20250206000105.432528-1-mjguzik@gmail.com (mailing list archive)
State New
Headers show
Series vfs: inline getname() | expand

Commit Message

Mateusz Guzik Feb. 6, 2025, 12:01 a.m. UTC
It is merely a trivial wrapper around getname_flags which adds a zeroed
argument, no point paying for an extra call.

Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>
---
 fs/namei.c         | 5 -----
 include/linux/fs.h | 5 ++++-
 2 files changed, 4 insertions(+), 6 deletions(-)

Comments

Jan Kara Feb. 6, 2025, 9:02 a.m. UTC | #1
On Thu 06-02-25 01:01:05, Mateusz Guzik wrote:
> It is merely a trivial wrapper around getname_flags which adds a zeroed
> argument, no point paying for an extra call.
> 
> Signed-off-by: Mateusz Guzik <mjguzik@gmail.com>

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:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/namei.c         | 5 -----
>  include/linux/fs.h | 5 ++++-
>  2 files changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/namei.c b/fs/namei.c
> index 3ab9440c5b93..3a4039acdb3f 100644
> --- a/fs/namei.c
> +++ b/fs/namei.c
> @@ -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;
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index e73d9b998780..85d88dd5ab6c 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -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)
> -- 
> 2.43.0
>
Christian Brauner Feb. 6, 2025, 9:22 a.m. UTC | #2
On Thu, 06 Feb 2025 01:01:05 +0100, Mateusz Guzik wrote:
> It is merely a trivial wrapper around getname_flags which 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
diff mbox series

Patch

diff --git a/fs/namei.c b/fs/namei.c
index 3ab9440c5b93..3a4039acdb3f 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -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;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index e73d9b998780..85d88dd5ab6c 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -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)