[02/20] mm: zswap: inline and remove zswap_entry_find_get()

Message ID 20240130014208.565554-3-hannes@cmpxchg.org
State New
Headers
Series mm: zswap: cleanups |

Commit Message

Johannes Weiner Jan. 30, 2024, 1:36 a.m. UTC
  There is only one caller and the function is trivial. Inline it.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
---
 mm/zswap.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)
  

Comments

Chengming Zhou Jan. 30, 2024, 3:37 a.m. UTC | #1
On 2024/1/30 09:36, Johannes Weiner wrote:
> There is only one caller and the function is trivial. Inline it.
> 
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>

Reviewed-by: Chengming Zhou <zhouchengming@bytedance.com>

> ---
>  mm/zswap.c | 17 ++---------------
>  1 file changed, 2 insertions(+), 15 deletions(-)
> 
> diff --git a/mm/zswap.c b/mm/zswap.c
> index 173f2e6657de..cf864aaa214d 100644
> --- a/mm/zswap.c
> +++ b/mm/zswap.c
> @@ -559,19 +559,6 @@ static void zswap_entry_put(struct zswap_entry *entry)
>  	}
>  }
>  
> -/* caller must hold the tree lock */
> -static struct zswap_entry *zswap_entry_find_get(struct rb_root *root,
> -				pgoff_t offset)
> -{
> -	struct zswap_entry *entry;
> -
> -	entry = zswap_rb_search(root, offset);
> -	if (entry)
> -		zswap_entry_get(entry);
> -
> -	return entry;
> -}
> -
>  /*********************************
>  * shrinker functions
>  **********************************/
> @@ -1708,13 +1695,13 @@ bool zswap_load(struct folio *folio)
>  
>  	VM_WARN_ON_ONCE(!folio_test_locked(folio));
>  
> -	/* find */
>  	spin_lock(&tree->lock);
> -	entry = zswap_entry_find_get(&tree->rbroot, offset);
> +	entry = zswap_rb_search(&tree->rbroot, offset);
>  	if (!entry) {
>  		spin_unlock(&tree->lock);
>  		return false;
>  	}
> +	zswap_entry_get(entry);
>  	spin_unlock(&tree->lock);
>  
>  	if (entry->length)
  
Yosry Ahmed Jan. 30, 2024, 8:09 a.m. UTC | #2
On Mon, Jan 29, 2024 at 08:36:38PM -0500, Johannes Weiner wrote:
> There is only one caller and the function is trivial. Inline it.
> 
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>

Acked-by: Yosry Ahmed <yosryahmed@google.com>
  
Nhat Pham Jan. 30, 2024, 4:24 p.m. UTC | #3
On Mon, Jan 29, 2024 at 5:42 PM Johannes Weiner <hannes@cmpxchg.org> wrote:
>
> There is only one caller and the function is trivial. Inline it.
>
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
> ---
>  mm/zswap.c | 17 ++---------------
>  1 file changed, 2 insertions(+), 15 deletions(-)
>
> diff --git a/mm/zswap.c b/mm/zswap.c
> index 173f2e6657de..cf864aaa214d 100644
> --- a/mm/zswap.c
> +++ b/mm/zswap.c
> @@ -559,19 +559,6 @@ static void zswap_entry_put(struct zswap_entry *entry)
>         }
>  }
>
> -/* caller must hold the tree lock */
> -static struct zswap_entry *zswap_entry_find_get(struct rb_root *root,
> -                               pgoff_t offset)
> -{
> -       struct zswap_entry *entry;
> -
> -       entry = zswap_rb_search(root, offset);
> -       if (entry)
> -               zswap_entry_get(entry);
> -
> -       return entry;
> -}
> -
>  /*********************************
>  * shrinker functions
>  **********************************/
> @@ -1708,13 +1695,13 @@ bool zswap_load(struct folio *folio)
>
>         VM_WARN_ON_ONCE(!folio_test_locked(folio));
>
> -       /* find */
>         spin_lock(&tree->lock);
> -       entry = zswap_entry_find_get(&tree->rbroot, offset);
> +       entry = zswap_rb_search(&tree->rbroot, offset);
>         if (!entry) {
>                 spin_unlock(&tree->lock);
>                 return false;
>         }
> +       zswap_entry_get(entry);

Neat.
Reviewed-by: Nhat Pham <nphamcs@gmail.com>

>         spin_unlock(&tree->lock);
>
>         if (entry->length)
> --
> 2.43.0
>
  

Patch

diff --git a/mm/zswap.c b/mm/zswap.c
index 173f2e6657de..cf864aaa214d 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -559,19 +559,6 @@  static void zswap_entry_put(struct zswap_entry *entry)
 	}
 }
 
-/* caller must hold the tree lock */
-static struct zswap_entry *zswap_entry_find_get(struct rb_root *root,
-				pgoff_t offset)
-{
-	struct zswap_entry *entry;
-
-	entry = zswap_rb_search(root, offset);
-	if (entry)
-		zswap_entry_get(entry);
-
-	return entry;
-}
-
 /*********************************
 * shrinker functions
 **********************************/
@@ -1708,13 +1695,13 @@  bool zswap_load(struct folio *folio)
 
 	VM_WARN_ON_ONCE(!folio_test_locked(folio));
 
-	/* find */
 	spin_lock(&tree->lock);
-	entry = zswap_entry_find_get(&tree->rbroot, offset);
+	entry = zswap_rb_search(&tree->rbroot, offset);
 	if (!entry) {
 		spin_unlock(&tree->lock);
 		return false;
 	}
+	zswap_entry_get(entry);
 	spin_unlock(&tree->lock);
 
 	if (entry->length)