mm/page_ext: support extra space allocation by page_ext user
Subsystems (3)
[email protected]
maintainerPATCH 33/127 mm/page_ext: support extra space allocation by page_ext user
From: Joonsoo Kim <[email protected]>
Subject: mm/page_ext: support extra space allocation by page_ext user
Until now, if some page_ext users want to use it's own field on page_ext, it should be defined in struct page_ext by hard-coding. It has a problem that wastes memory in following situation.
struct page_ext {
#ifdef CONFIG_A int a; #endif #ifdef CONFIG_B int b;
#endif
};
Assume that kernel is built with both CONFIG_A and CONFIG_B. Even if we enable feature A and doesn't enable feature B at runtime, each entry of struct page_ext takes two int rather than one int. It's undesirable result so this patch tries to fix it.
To solve above problem, this patch implements to support extra space allocation at runtime. When need() callback returns true, it's extra memory requirement is summed to entry size of page_ext. Also, offset for each user's extra memory space is returned. With this offset, user can use this extra space and there is no need to define needed field on page_ext by hard-coding.
This patch only implements an infrastructure. Following patch will use it for page_owner which is only user having it's own fields on page_ext.
---
include/linux/page_ext.h | 2 + mm/page_alloc.c | 2 - mm/page_ext.c | 41 +++++++++++++++++++++++++++---------- 3 files changed, 34 insertions(+), 11 deletions(-)
include/linux/page_ext.h renamed from include/linux/page_ext.h~mm-page_ext-support-extra-space-allocation-by-page_ext-user +2 -0
@@ -7,6 +7,8 @@struct pglist_data ;struct page_ext_operations { +size_t offset; +size_t size;bool (*need)(void );void (*init)(void ); };
mm/page_alloc.c renamed from mm/page_alloc.c~mm-page_ext-support-extra-space-allocation-by-page_ext-user +1 -1
@@ -687,7 +687,7 @@ static inline void clear_page_guard(stru__mod_zone_freepage_state (zone, (1 << order), migratetype); }#else -struct page_ext_operations debug_guardpage_ops = {NULL , }; +struct page_ext_operations debug_guardpage_ops;static inline bool set_page_guard (struct zone *zone,struct page *page,unsigned int order,int migratetype) {return false; } static inline void clear_page_guard(struct zone *zone, struct page *page,
mm/page_ext.c renamed from mm/page_ext.c~mm-page_ext-support-extra-space-allocation-by-page_ext-user +31 -10
110 lines not on this page · raw message
_