mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-22 06:32:08 +00:00
mm: move buddy list manipulations into helpers
In preparation for runtime randomization of the zone lists, take all (well, most of) the list_*() functions in the buddy allocator and put them in helper functions. Provide a common control point for injecting additional behavior when freeing pages. [dan.j.williams@intel.com: fix buddy list helpers] Link: http://lkml.kernel.org/r/155033679702.1773410.13041474192173212653.stgit@dwillia2-desk3.amr.corp.intel.com [vbabka@suse.cz: remove del_page_from_free_area() migratetype parameter] Link: http://lkml.kernel.org/r/4672701b-6775-6efd-0797-b6242591419e@suse.cz Link: http://lkml.kernel.org/r/154899812264.3165233.5219320056406926223.stgit@dwillia2-desk3.amr.corp.intel.com Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Vlastimil Babka <vbabka@suse.cz> Tested-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> Acked-by: Michal Hocko <mhocko@suse.com> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Kees Cook <keescook@chromium.org> Cc: Keith Busch <keith.busch@intel.com> Cc: Robert Elliott <elliott@hpe.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
e900a918b0
commit
b03641af68
5 changed files with 73 additions and 48 deletions
|
@ -18,6 +18,8 @@
|
|||
#include <linux/pageblock-flags.h>
|
||||
#include <linux/page-flags-layout.h>
|
||||
#include <linux/atomic.h>
|
||||
#include <linux/mm_types.h>
|
||||
#include <linux/page-flags.h>
|
||||
#include <asm/page.h>
|
||||
|
||||
/* Free memory management - zoned buddy allocator. */
|
||||
|
@ -98,6 +100,50 @@ struct free_area {
|
|||
unsigned long nr_free;
|
||||
};
|
||||
|
||||
/* Used for pages not on another list */
|
||||
static inline void add_to_free_area(struct page *page, struct free_area *area,
|
||||
int migratetype)
|
||||
{
|
||||
list_add(&page->lru, &area->free_list[migratetype]);
|
||||
area->nr_free++;
|
||||
}
|
||||
|
||||
/* Used for pages not on another list */
|
||||
static inline void add_to_free_area_tail(struct page *page, struct free_area *area,
|
||||
int migratetype)
|
||||
{
|
||||
list_add_tail(&page->lru, &area->free_list[migratetype]);
|
||||
area->nr_free++;
|
||||
}
|
||||
|
||||
/* Used for pages which are on another list */
|
||||
static inline void move_to_free_area(struct page *page, struct free_area *area,
|
||||
int migratetype)
|
||||
{
|
||||
list_move(&page->lru, &area->free_list[migratetype]);
|
||||
}
|
||||
|
||||
static inline struct page *get_page_from_free_area(struct free_area *area,
|
||||
int migratetype)
|
||||
{
|
||||
return list_first_entry_or_null(&area->free_list[migratetype],
|
||||
struct page, lru);
|
||||
}
|
||||
|
||||
static inline void del_page_from_free_area(struct page *page,
|
||||
struct free_area *area)
|
||||
{
|
||||
list_del(&page->lru);
|
||||
__ClearPageBuddy(page);
|
||||
set_page_private(page, 0);
|
||||
area->nr_free--;
|
||||
}
|
||||
|
||||
static inline bool free_area_empty(struct free_area *area, int migratetype)
|
||||
{
|
||||
return list_empty(&area->free_list[migratetype]);
|
||||
}
|
||||
|
||||
struct pglist_data;
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue