Skip to content

Commit ffedd09

Browse files
Matthew Wilcox (Oracle)tehcaster
authored andcommitted
zsmalloc: Stop using slab fields in struct page
The ->freelist and ->units members of struct page are for the use of slab only. I'm not particularly familiar with zsmalloc, so generate the same code by using page->index to store 'page' (page->index and page->freelist are at the same offset in struct page). This should be cleaned up properly at some point by somebody who is familiar with zsmalloc. Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Signed-off-by: Vlastimil Babka <[email protected]> Acked-by: Minchan Kim <[email protected]> Acked-by: Johannes Weiner <[email protected]> Cc: Nitin Gupta <[email protected]> Cc: Sergey Senozhatsky <[email protected]>
1 parent 9c01e9a commit ffedd09

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

mm/zsmalloc.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
*
1818
* Usage of struct page fields:
1919
* page->private: points to zspage
20-
* page->freelist(index): links together all component pages of a zspage
20+
* page->index: links together all component pages of a zspage
2121
* For the huge page, this is always 0, so we use this field
2222
* to store handle.
23-
* page->units: first object offset in a subpage of zspage
23+
* page->page_type: first object offset in a subpage of zspage
2424
*
2525
* Usage of struct page flags:
2626
* PG_private: identifies the first component page
@@ -489,12 +489,12 @@ static inline struct page *get_first_page(struct zspage *zspage)
489489

490490
static inline int get_first_obj_offset(struct page *page)
491491
{
492-
return page->units;
492+
return page->page_type;
493493
}
494494

495495
static inline void set_first_obj_offset(struct page *page, int offset)
496496
{
497-
page->units = offset;
497+
page->page_type = offset;
498498
}
499499

500500
static inline unsigned int get_freeobj(struct zspage *zspage)
@@ -827,7 +827,7 @@ static struct page *get_next_page(struct page *page)
827827
if (unlikely(PageHugeObject(page)))
828828
return NULL;
829829

830-
return page->freelist;
830+
return (struct page *)page->index;
831831
}
832832

833833
/**
@@ -901,7 +901,7 @@ static void reset_page(struct page *page)
901901
set_page_private(page, 0);
902902
page_mapcount_reset(page);
903903
ClearPageHugeObject(page);
904-
page->freelist = NULL;
904+
page->index = 0;
905905
}
906906

907907
static int trylock_zspage(struct zspage *zspage)
@@ -1027,7 +1027,7 @@ static void create_page_chain(struct size_class *class, struct zspage *zspage,
10271027

10281028
/*
10291029
* Allocate individual pages and link them together as:
1030-
* 1. all pages are linked together using page->freelist
1030+
* 1. all pages are linked together using page->index
10311031
* 2. each sub-page point to zspage using page->private
10321032
*
10331033
* we set PG_private to identify the first page (i.e. no other sub-page
@@ -1036,15 +1036,15 @@ static void create_page_chain(struct size_class *class, struct zspage *zspage,
10361036
for (i = 0; i < nr_pages; i++) {
10371037
page = pages[i];
10381038
set_page_private(page, (unsigned long)zspage);
1039-
page->freelist = NULL;
1039+
page->index = 0;
10401040
if (i == 0) {
10411041
zspage->first_page = page;
10421042
SetPagePrivate(page);
10431043
if (unlikely(class->objs_per_zspage == 1 &&
10441044
class->pages_per_zspage == 1))
10451045
SetPageHugeObject(page);
10461046
} else {
1047-
prev_page->freelist = page;
1047+
prev_page->index = (unsigned long)page;
10481048
}
10491049
prev_page = page;
10501050
}

0 commit comments

Comments
 (0)