diff mbox series

[16/20] mm: zswap: function ordering: move entry section out of tree section

Message ID 20240130014208.565554-17-hannes@cmpxchg.org (mailing list archive)
State New
Headers show
Series mm: zswap: cleanups | expand

Commit Message

Johannes Weiner Jan. 30, 2024, 1:36 a.m. UTC
The higher-level entry operations modify the tree, so move the entry
API after the tree section.

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

Comments

Nhat Pham Jan. 31, 2024, 11:24 p.m. UTC | #1
On Mon, Jan 29, 2024 at 5:42 PM Johannes Weiner <hannes@cmpxchg.org> wrote:
>
> The higher-level entry operations modify the tree, so move the entry
> API after the tree section.
>
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>

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

> ---
>  mm/zswap.c | 42 +++++++++++++++++++++---------------------
>  1 file changed, 21 insertions(+), 21 deletions(-)
>
> diff --git a/mm/zswap.c b/mm/zswap.c
> index 756d4d575efe..80adc2f7d1a2 100644
> --- a/mm/zswap.c
> +++ b/mm/zswap.c
> @@ -848,27 +848,6 @@ void zswap_memcg_offline_cleanup(struct mem_cgroup *memcg)
>         spin_unlock(&zswap_pools_lock);
>  }
>
> -/*********************************
> -* zswap entry functions
> -**********************************/
> -static struct kmem_cache *zswap_entry_cache;
> -
> -static struct zswap_entry *zswap_entry_cache_alloc(gfp_t gfp, int nid)
> -{
> -       struct zswap_entry *entry;
> -       entry = kmem_cache_alloc_node(zswap_entry_cache, gfp, nid);
> -       if (!entry)
> -               return NULL;
> -       entry->refcount = 1;
> -       RB_CLEAR_NODE(&entry->rbnode);
> -       return entry;
> -}
> -
> -static void zswap_entry_cache_free(struct zswap_entry *entry)
> -{
> -       kmem_cache_free(zswap_entry_cache, entry);
> -}
> -
>  /*********************************
>  * rbtree functions
>  **********************************/
> @@ -930,6 +909,27 @@ static bool zswap_rb_erase(struct rb_root *root, struct zswap_entry *entry)
>         return false;
>  }
>
> +/*********************************
> +* zswap entry functions
> +**********************************/
> +static struct kmem_cache *zswap_entry_cache;
> +
> +static struct zswap_entry *zswap_entry_cache_alloc(gfp_t gfp, int nid)
> +{
> +       struct zswap_entry *entry;
> +       entry = kmem_cache_alloc_node(zswap_entry_cache, gfp, nid);
> +       if (!entry)
> +               return NULL;
> +       entry->refcount = 1;
> +       RB_CLEAR_NODE(&entry->rbnode);
> +       return entry;
> +}
> +
> +static void zswap_entry_cache_free(struct zswap_entry *entry)
> +{
> +       kmem_cache_free(zswap_entry_cache, entry);
> +}
> +
>  static struct zpool *zswap_find_zpool(struct zswap_entry *entry)
>  {
>         int i = 0;
> --
> 2.43.0
>
diff mbox series

Patch

diff --git a/mm/zswap.c b/mm/zswap.c
index 756d4d575efe..80adc2f7d1a2 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -848,27 +848,6 @@  void zswap_memcg_offline_cleanup(struct mem_cgroup *memcg)
 	spin_unlock(&zswap_pools_lock);
 }
 
-/*********************************
-* zswap entry functions
-**********************************/
-static struct kmem_cache *zswap_entry_cache;
-
-static struct zswap_entry *zswap_entry_cache_alloc(gfp_t gfp, int nid)
-{
-	struct zswap_entry *entry;
-	entry = kmem_cache_alloc_node(zswap_entry_cache, gfp, nid);
-	if (!entry)
-		return NULL;
-	entry->refcount = 1;
-	RB_CLEAR_NODE(&entry->rbnode);
-	return entry;
-}
-
-static void zswap_entry_cache_free(struct zswap_entry *entry)
-{
-	kmem_cache_free(zswap_entry_cache, entry);
-}
-
 /*********************************
 * rbtree functions
 **********************************/
@@ -930,6 +909,27 @@  static bool zswap_rb_erase(struct rb_root *root, struct zswap_entry *entry)
 	return false;
 }
 
+/*********************************
+* zswap entry functions
+**********************************/
+static struct kmem_cache *zswap_entry_cache;
+
+static struct zswap_entry *zswap_entry_cache_alloc(gfp_t gfp, int nid)
+{
+	struct zswap_entry *entry;
+	entry = kmem_cache_alloc_node(zswap_entry_cache, gfp, nid);
+	if (!entry)
+		return NULL;
+	entry->refcount = 1;
+	RB_CLEAR_NODE(&entry->rbnode);
+	return entry;
+}
+
+static void zswap_entry_cache_free(struct zswap_entry *entry)
+{
+	kmem_cache_free(zswap_entry_cache, entry);
+}
+
 static struct zpool *zswap_find_zpool(struct zswap_entry *entry)
 {
 	int i = 0;