diff mbox series

[RFC,v3,03/21] mm/zsmalloc: replace first_page to first_zsdesc in struct zspage

Message ID 20231130101242.2590384-4-42.hyeyoo@gmail.com (mailing list archive)
State New
Headers show
Series mm/zsmalloc: Split zsdesc from struct page | expand

Commit Message

Hyeonggon Yoo Nov. 30, 2023, 10:12 a.m. UTC
Replace first_page to first_zsdesc in struct zspage for further
conversion.

Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
---
 mm/zsmalloc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Minchan Kim Dec. 1, 2023, 7:23 p.m. UTC | #1
On Thu, Nov 30, 2023 at 07:12:24PM +0900, Hyeonggon Yoo wrote:
> Replace first_page to first_zsdesc in struct zspage for further
> conversion.
> 
> Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
> ---
>  mm/zsmalloc.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> index 47df9103787e..4c9f9a2cb681 100644
> --- a/mm/zsmalloc.c
> +++ b/mm/zsmalloc.c
> @@ -317,7 +317,7 @@ struct zspage {
>  	};
>  	unsigned int inuse;
>  	unsigned int freeobj;
> -	struct page *first_page;
> +	struct zsdesc *first_zsdesc;
>  	struct list_head list; /* fullness list */
>  	struct zs_pool *pool;
>  	rwlock_t lock;
> @@ -516,7 +516,7 @@ static inline void mod_zspage_inuse(struct zspage *zspage, int val)
>  
>  static inline struct page *get_first_page(struct zspage *zspage)
>  {
> -	struct page *first_page = zspage->first_page;
> +	struct page *first_page = zsdesc_page(zspage->first_zsdesc);
>  
>  	VM_BUG_ON_PAGE(!is_first_page(first_page), first_page);
>  	return first_page;
> @@ -1028,7 +1028,7 @@ static void create_page_chain(struct size_class *class, struct zspage *zspage,
>  		set_page_private(page, (unsigned long)zspage);
>  		page->index = 0;
>  		if (i == 0) {
> -			zspage->first_page = page;
> +			zspage->first_zsdesc = page_zsdesc(page);
>  			SetPagePrivate(page);
>  			if (unlikely(class->objs_per_zspage == 1 &&
>  					class->pages_per_zspage == 1))
> @@ -1402,7 +1402,7 @@ static unsigned long obj_malloc(struct zs_pool *pool,
>  		link->handle = handle;
>  	else
>  		/* record handle to page->index */
           
Can you update the comment, too?

> -		zspage->first_page->index = handle;
> +		zspage->first_zsdesc->handle = handle;
>  
>  	kunmap_atomic(vaddr);
>  	mod_zspage_inuse(zspage, 1);
> -- 
> 2.39.3
>
Hyeonggon Yoo Dec. 3, 2023, 5:22 a.m. UTC | #2
On Sat, Dec 2, 2023 at 4:23 AM Minchan Kim <minchan@kernel.org> wrote:
>
> On Thu, Nov 30, 2023 at 07:12:24PM +0900, Hyeonggon Yoo wrote:
> > Replace first_page to first_zsdesc in struct zspage for further
> > conversion.
> >
> > Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
> > ---
> >  mm/zsmalloc.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
> > index 47df9103787e..4c9f9a2cb681 100644
> > --- a/mm/zsmalloc.c
> > +++ b/mm/zsmalloc.c
> > @@ -317,7 +317,7 @@ struct zspage {
> >       };
> >       unsigned int inuse;
> >       unsigned int freeobj;
> > -     struct page *first_page;
> > +     struct zsdesc *first_zsdesc;
> >       struct list_head list; /* fullness list */
> >       struct zs_pool *pool;
> >       rwlock_t lock;
> > @@ -516,7 +516,7 @@ static inline void mod_zspage_inuse(struct zspage *zspage, int val)
> >
> >  static inline struct page *get_first_page(struct zspage *zspage)
> >  {
> > -     struct page *first_page = zspage->first_page;
> > +     struct page *first_page = zsdesc_page(zspage->first_zsdesc);
> >
> >       VM_BUG_ON_PAGE(!is_first_page(first_page), first_page);
> >       return first_page;
> > @@ -1028,7 +1028,7 @@ static void create_page_chain(struct size_class *class, struct zspage *zspage,
> >               set_page_private(page, (unsigned long)zspage);
> >               page->index = 0;
> >               if (i == 0) {
> > -                     zspage->first_page = page;
> > +                     zspage->first_zsdesc = page_zsdesc(page);
> >                       SetPagePrivate(page);
> >                       if (unlikely(class->objs_per_zspage == 1 &&
> >                                       class->pages_per_zspage == 1))
> > @@ -1402,7 +1402,7 @@ static unsigned long obj_malloc(struct zs_pool *pool,
> >               link->handle = handle;
> >       else
> >               /* record handle to page->index */
>
> Can you update the comment, too?

Will do in the next revision, thanks!

> > -             zspage->first_page->index = handle;
> > +             zspage->first_zsdesc->handle = handle;
> >
> >       kunmap_atomic(vaddr);
> >       mod_zspage_inuse(zspage, 1);
> > --
> > 2.39.3
> >
diff mbox series

Patch

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 47df9103787e..4c9f9a2cb681 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -317,7 +317,7 @@  struct zspage {
 	};
 	unsigned int inuse;
 	unsigned int freeobj;
-	struct page *first_page;
+	struct zsdesc *first_zsdesc;
 	struct list_head list; /* fullness list */
 	struct zs_pool *pool;
 	rwlock_t lock;
@@ -516,7 +516,7 @@  static inline void mod_zspage_inuse(struct zspage *zspage, int val)
 
 static inline struct page *get_first_page(struct zspage *zspage)
 {
-	struct page *first_page = zspage->first_page;
+	struct page *first_page = zsdesc_page(zspage->first_zsdesc);
 
 	VM_BUG_ON_PAGE(!is_first_page(first_page), first_page);
 	return first_page;
@@ -1028,7 +1028,7 @@  static void create_page_chain(struct size_class *class, struct zspage *zspage,
 		set_page_private(page, (unsigned long)zspage);
 		page->index = 0;
 		if (i == 0) {
-			zspage->first_page = page;
+			zspage->first_zsdesc = page_zsdesc(page);
 			SetPagePrivate(page);
 			if (unlikely(class->objs_per_zspage == 1 &&
 					class->pages_per_zspage == 1))
@@ -1402,7 +1402,7 @@  static unsigned long obj_malloc(struct zs_pool *pool,
 		link->handle = handle;
 	else
 		/* record handle to page->index */
-		zspage->first_page->index = handle;
+		zspage->first_zsdesc->handle = handle;
 
 	kunmap_atomic(vaddr);
 	mod_zspage_inuse(zspage, 1);