All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 5/5] fanotify: add inline modifier
@ 2022-06-28  8:17 Guowei Du
  2022-06-28  9:13 ` Amir Goldstein
  2022-06-28  9:14 ` Jan Kara
  0 siblings, 2 replies; 3+ messages in thread
From: Guowei Du @ 2022-06-28  8:17 UTC (permalink / raw)
  To: jack, amir73il, repnop; +Cc: linux-fsdevel, linux-kernel, duguowei

From: duguowei <duguowei@xiaomi.com>

No functional change.
This patch only makes a little change for compiling.

Signed-off-by: duguowei <duguowei@xiaomi.com>
---
 fs/notify/fanotify/fanotify.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
index 4f897e109547..a32752350e0e 100644
--- a/fs/notify/fanotify/fanotify.c
+++ b/fs/notify/fanotify/fanotify.c
@@ -18,12 +18,12 @@
 
 #include "fanotify.h"
 
-static bool fanotify_path_equal(struct path *p1, struct path *p2)
+static inline bool fanotify_path_equal(struct path *p1, struct path *p2)
 {
 	return p1->mnt == p2->mnt && p1->dentry == p2->dentry;
 }
 
-static unsigned int fanotify_hash_path(const struct path *path)
+static inline unsigned int fanotify_hash_path(const struct path *path)
 {
 	return hash_ptr(path->dentry, FANOTIFY_EVENT_HASH_BITS) ^
 		hash_ptr(path->mnt, FANOTIFY_EVENT_HASH_BITS);
@@ -35,20 +35,18 @@ static inline bool fanotify_fsid_equal(__kernel_fsid_t *fsid1,
 	return fsid1->val[0] == fsid2->val[0] && fsid1->val[1] == fsid2->val[1];
 }
 
-static unsigned int fanotify_hash_fsid(__kernel_fsid_t *fsid)
+static inline unsigned int fanotify_hash_fsid(__kernel_fsid_t *fsid)
 {
 	return hash_32(fsid->val[0], FANOTIFY_EVENT_HASH_BITS) ^
 		hash_32(fsid->val[1], FANOTIFY_EVENT_HASH_BITS);
 }
 
-static bool fanotify_fh_equal(struct fanotify_fh *fh1,
+static inline bool fanotify_fh_equal(struct fanotify_fh *fh1,
 			      struct fanotify_fh *fh2)
 {
-	if (fh1->type != fh2->type || fh1->len != fh2->len)
-		return false;
-
-	return !fh1->len ||
-		!memcmp(fanotify_fh_buf(fh1), fanotify_fh_buf(fh2), fh1->len);
+	return fh1->type == fh2->type && fh1->len == fh2->len &&
+		(!fh1->len ||
+		 !memcmp(fanotify_fh_buf(fh1), fanotify_fh_buf(fh2), fh1->len));
 }
 
 static unsigned int fanotify_hash_fh(struct fanotify_fh *fh)
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 5/5] fanotify: add inline modifier
  2022-06-28  8:17 [PATCH 5/5] fanotify: add inline modifier Guowei Du
@ 2022-06-28  9:13 ` Amir Goldstein
  2022-06-28  9:14 ` Jan Kara
  1 sibling, 0 replies; 3+ messages in thread
From: Amir Goldstein @ 2022-06-28  9:13 UTC (permalink / raw)
  To: Guowei Du
  Cc: Jan Kara, Matthew Bobrowski, linux-fsdevel, linux-kernel, duguowei

On Tue, Jun 28, 2022 at 11:17 AM Guowei Du <duguoweisz@gmail.com> wrote:
>
> From: duguowei <duguowei@xiaomi.com>
>
> No functional change.
> This patch only makes a little change for compiling.

There is no reason to do that.
The compiler does that based on the user's optimization preference.

Thanks,
Amir.

>
> Signed-off-by: duguowei <duguowei@xiaomi.com>
> ---
>  fs/notify/fanotify/fanotify.c | 16 +++++++---------
>  1 file changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
> index 4f897e109547..a32752350e0e 100644
> --- a/fs/notify/fanotify/fanotify.c
> +++ b/fs/notify/fanotify/fanotify.c
> @@ -18,12 +18,12 @@
>
>  #include "fanotify.h"
>
> -static bool fanotify_path_equal(struct path *p1, struct path *p2)
> +static inline bool fanotify_path_equal(struct path *p1, struct path *p2)
>  {
>         return p1->mnt == p2->mnt && p1->dentry == p2->dentry;
>  }
>
> -static unsigned int fanotify_hash_path(const struct path *path)
> +static inline unsigned int fanotify_hash_path(const struct path *path)
>  {
>         return hash_ptr(path->dentry, FANOTIFY_EVENT_HASH_BITS) ^
>                 hash_ptr(path->mnt, FANOTIFY_EVENT_HASH_BITS);
> @@ -35,20 +35,18 @@ static inline bool fanotify_fsid_equal(__kernel_fsid_t *fsid1,
>         return fsid1->val[0] == fsid2->val[0] && fsid1->val[1] == fsid2->val[1];
>  }
>
> -static unsigned int fanotify_hash_fsid(__kernel_fsid_t *fsid)
> +static inline unsigned int fanotify_hash_fsid(__kernel_fsid_t *fsid)
>  {
>         return hash_32(fsid->val[0], FANOTIFY_EVENT_HASH_BITS) ^
>                 hash_32(fsid->val[1], FANOTIFY_EVENT_HASH_BITS);
>  }
>
> -static bool fanotify_fh_equal(struct fanotify_fh *fh1,
> +static inline bool fanotify_fh_equal(struct fanotify_fh *fh1,
>                               struct fanotify_fh *fh2)
>  {
> -       if (fh1->type != fh2->type || fh1->len != fh2->len)
> -               return false;
> -
> -       return !fh1->len ||
> -               !memcmp(fanotify_fh_buf(fh1), fanotify_fh_buf(fh2), fh1->len);
> +       return fh1->type == fh2->type && fh1->len == fh2->len &&
> +               (!fh1->len ||
> +                !memcmp(fanotify_fh_buf(fh1), fanotify_fh_buf(fh2), fh1->len));
>  }
>
>  static unsigned int fanotify_hash_fh(struct fanotify_fh *fh)
> --
> 2.36.1
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 5/5] fanotify: add inline modifier
  2022-06-28  8:17 [PATCH 5/5] fanotify: add inline modifier Guowei Du
  2022-06-28  9:13 ` Amir Goldstein
@ 2022-06-28  9:14 ` Jan Kara
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Kara @ 2022-06-28  9:14 UTC (permalink / raw)
  To: Guowei Du; +Cc: jack, amir73il, repnop, linux-fsdevel, linux-kernel, duguowei

On Tue 28-06-22 16:17:31, Guowei Du wrote:
> From: duguowei <duguowei@xiaomi.com>
> 
> No functional change.
> This patch only makes a little change for compiling.
> 
> Signed-off-by: duguowei <duguowei@xiaomi.com>

Thanks for the patch but I'm sorry I don't see a benefit of these changes.
For static functions 'inline' is not really useful because the compiler
decides about inlining of static functions on its own.

Also the change to fanotify_fh_equal() makes the code less readable, not
more...

								Honza

> ---
>  fs/notify/fanotify/fanotify.c | 16 +++++++---------
>  1 file changed, 7 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
> index 4f897e109547..a32752350e0e 100644
> --- a/fs/notify/fanotify/fanotify.c
> +++ b/fs/notify/fanotify/fanotify.c
> @@ -18,12 +18,12 @@
>  
>  #include "fanotify.h"
>  
> -static bool fanotify_path_equal(struct path *p1, struct path *p2)
> +static inline bool fanotify_path_equal(struct path *p1, struct path *p2)
>  {
>  	return p1->mnt == p2->mnt && p1->dentry == p2->dentry;
>  }
>  
> -static unsigned int fanotify_hash_path(const struct path *path)
> +static inline unsigned int fanotify_hash_path(const struct path *path)
>  {
>  	return hash_ptr(path->dentry, FANOTIFY_EVENT_HASH_BITS) ^
>  		hash_ptr(path->mnt, FANOTIFY_EVENT_HASH_BITS);
> @@ -35,20 +35,18 @@ static inline bool fanotify_fsid_equal(__kernel_fsid_t *fsid1,
>  	return fsid1->val[0] == fsid2->val[0] && fsid1->val[1] == fsid2->val[1];
>  }
>  
> -static unsigned int fanotify_hash_fsid(__kernel_fsid_t *fsid)
> +static inline unsigned int fanotify_hash_fsid(__kernel_fsid_t *fsid)
>  {
>  	return hash_32(fsid->val[0], FANOTIFY_EVENT_HASH_BITS) ^
>  		hash_32(fsid->val[1], FANOTIFY_EVENT_HASH_BITS);
>  }
>  
> -static bool fanotify_fh_equal(struct fanotify_fh *fh1,
> +static inline bool fanotify_fh_equal(struct fanotify_fh *fh1,
>  			      struct fanotify_fh *fh2)
>  {
> -	if (fh1->type != fh2->type || fh1->len != fh2->len)
> -		return false;
> -
> -	return !fh1->len ||
> -		!memcmp(fanotify_fh_buf(fh1), fanotify_fh_buf(fh2), fh1->len);
> +	return fh1->type == fh2->type && fh1->len == fh2->len &&
> +		(!fh1->len ||
> +		 !memcmp(fanotify_fh_buf(fh1), fanotify_fh_buf(fh2), fh1->len));
>  }
>  
>  static unsigned int fanotify_hash_fh(struct fanotify_fh *fh)
> -- 
> 2.36.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-06-28  9:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-28  8:17 [PATCH 5/5] fanotify: add inline modifier Guowei Du
2022-06-28  9:13 ` Amir Goldstein
2022-06-28  9:14 ` Jan Kara

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.