-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mm/page_ext: resurrect struct page extending code for debugging
When we debug something, we'd like to insert some information to every page. For this purpose, we sometimes modify struct page itself. But, this has drawbacks. First, it requires re-compile. This makes us hesitate to use the powerful debug feature so development process is slowed down. And, second, sometimes it is impossible to rebuild the kernel due to third party module dependency. At third, system behaviour would be largely different after re-compile, because it changes size of struct page greatly and this structure is accessed by every part of kernel. Keeping this as it is would be better to reproduce errornous situation. This feature is intended to overcome above mentioned problems. This feature allocates memory for extended data per page in certain place rather than the struct page itself. This memory can be accessed by the accessor functions provided by this code. During the boot process, it checks whether allocation of huge chunk of memory is needed or not. If not, it avoids allocating memory at all. With this advantage, we can include this feature into the kernel in default and can avoid rebuild and solve related problems. Until now, memcg uses this technique. But, now, memcg decides to embed their variable to struct page itself and it's code to extend struct page has been removed. I'd like to use this code to develop debug feature, so this patch resurrect it. To help these things to work well, this patch introduces two callbacks for clients. One is the need callback which is mandatory if user wants to avoid useless memory allocation at boot-time. The other is optional, init callback, which is used to do proper initialization after memory is allocated. Detailed explanation about purpose of these functions is in code comment. Please refer it. Others are completely same with previous extension code in memcg. Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com> Cc: Mel Gorman <mgorman@suse.de> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Minchan Kim <minchan@kernel.org> Cc: Dave Hansen <dave@sr71.net> Cc: Michal Nazarewicz <mina86@mina86.com> Cc: Jungsoo Son <jungsoo.son@lge.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
- Loading branch information
1 parent
2d48366
commit eefa864
Showing
7 changed files
with
485 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#ifndef __LINUX_PAGE_EXT_H | ||
#define __LINUX_PAGE_EXT_H | ||
|
||
struct pglist_data; | ||
struct page_ext_operations { | ||
bool (*need)(void); | ||
void (*init)(void); | ||
}; | ||
|
||
#ifdef CONFIG_PAGE_EXTENSION | ||
|
||
/* | ||
* Page Extension can be considered as an extended mem_map. | ||
* A page_ext page is associated with every page descriptor. The | ||
* page_ext helps us add more information about the page. | ||
* All page_ext are allocated at boot or memory hotplug event, | ||
* then the page_ext for pfn always exists. | ||
*/ | ||
struct page_ext { | ||
unsigned long flags; | ||
}; | ||
|
||
extern void pgdat_page_ext_init(struct pglist_data *pgdat); | ||
|
||
#ifdef CONFIG_SPARSEMEM | ||
static inline void page_ext_init_flatmem(void) | ||
{ | ||
} | ||
extern void page_ext_init(void); | ||
#else | ||
extern void page_ext_init_flatmem(void); | ||
static inline void page_ext_init(void) | ||
{ | ||
} | ||
#endif | ||
|
||
struct page_ext *lookup_page_ext(struct page *page); | ||
|
||
#else /* !CONFIG_PAGE_EXTENSION */ | ||
struct page_ext; | ||
|
||
static inline void pgdat_page_ext_init(struct pglist_data *pgdat) | ||
{ | ||
} | ||
|
||
static inline struct page_ext *lookup_page_ext(struct page *page) | ||
{ | ||
return NULL; | ||
} | ||
|
||
static inline void page_ext_init(void) | ||
{ | ||
} | ||
|
||
static inline void page_ext_init_flatmem(void) | ||
{ | ||
} | ||
#endif /* CONFIG_PAGE_EXTENSION */ | ||
#endif /* __LINUX_PAGE_EXT_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.