mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 11:41:38 -04:00
memcg: bad page if page_cgroup when free
Replace free_hot_cold_page's VM_BUG_ON(page_get_page_cgroup(page)) by a "Bad page state" and clear: most users don't have CONFIG_DEBUG_VM on, and if it were set here, it'd likely cause corruption when the page is reused. Don't use page_assign_page_cgroup to clear it: that should be private to memcontrol.c, and always called with the lock taken; and memmap_init_zone doesn't need it either - like page->mapping and other pointers throughout the kernel, Linux assumes pointers in zeroed structures are NULL pointers. Instead use page_reset_bad_cgroup, added to memcontrol.h for this only. Signed-off-by: Hugh Dickins <[email protected]> Cc: David Rientjes <[email protected]> Acked-by: Balbir Singh <[email protected]> Acked-by: KAMEZAWA Hiroyuki <[email protected]> Cc: Hirokazu Takahashi <[email protected]> Cc: YAMAMOTO Takashi <[email protected]> Cc: Paul Menage <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
98837c7f82
commit
9442ec9df4
3 changed files with 28 additions and 25 deletions
|
|
@ -140,11 +140,17 @@ struct mem_cgroup {
|
|||
|
||||
/*
|
||||
* We use the lower bit of the page->page_cgroup pointer as a bit spin
|
||||
* lock. We need to ensure that page->page_cgroup is atleast two
|
||||
* byte aligned (based on comments from Nick Piggin)
|
||||
* lock. We need to ensure that page->page_cgroup is at least two
|
||||
* byte aligned (based on comments from Nick Piggin). But since
|
||||
* bit_spin_lock doesn't actually set that lock bit in a non-debug
|
||||
* uniprocessor kernel, we should avoid setting it here too.
|
||||
*/
|
||||
#define PAGE_CGROUP_LOCK_BIT 0x0
|
||||
#define PAGE_CGROUP_LOCK (1 << PAGE_CGROUP_LOCK_BIT)
|
||||
#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
|
||||
#define PAGE_CGROUP_LOCK (1 << PAGE_CGROUP_LOCK_BIT)
|
||||
#else
|
||||
#define PAGE_CGROUP_LOCK 0x0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* A page_cgroup page is associated with every page descriptor. The
|
||||
|
|
@ -271,19 +277,10 @@ static inline int page_cgroup_locked(struct page *page)
|
|||
&page->page_cgroup);
|
||||
}
|
||||
|
||||
void page_assign_page_cgroup(struct page *page, struct page_cgroup *pc)
|
||||
static void page_assign_page_cgroup(struct page *page, struct page_cgroup *pc)
|
||||
{
|
||||
int locked;
|
||||
|
||||
/*
|
||||
* While resetting the page_cgroup we might not hold the
|
||||
* page_cgroup lock. free_hot_cold_page() is an example
|
||||
* of such a scenario
|
||||
*/
|
||||
if (pc)
|
||||
VM_BUG_ON(!page_cgroup_locked(page));
|
||||
locked = (page->page_cgroup & PAGE_CGROUP_LOCK);
|
||||
page->page_cgroup = ((unsigned long)pc | locked);
|
||||
VM_BUG_ON(!page_cgroup_locked(page));
|
||||
page->page_cgroup = ((unsigned long)pc | PAGE_CGROUP_LOCK);
|
||||
}
|
||||
|
||||
struct page_cgroup *page_get_page_cgroup(struct page *page)
|
||||
|
|
|
|||
Loading…
Reference in a new issue