Re: [PATCH v4 2/5] mm: memcontrol: directly access page->memcg_data in mm/page_alloc.c

2021-03-18 Thread Shakeel Butt
On Thu, Mar 18, 2021 at 4:08 AM Muchun Song  wrote:
>
> The page_memcg() is not suitable for use by page_expected_state() and
> page_bad_reason(). Because it can BUG_ON() for the slab pages when
> CONFIG_DEBUG_VM is enabled. As neither lru, nor kmem, nor slab page
> should have anything left in there by the time the page is freed, what
> we care about is whether the value of page->memcg_data is 0. So just
> directly access page->memcg_data here.
>
> Signed-off-by: Muchun Song 

Reviewed-by: Shakeel Butt 


Re: [PATCH v4 2/5] mm: memcontrol: directly access page->memcg_data in mm/page_alloc.c

2021-03-18 Thread Johannes Weiner
On Thu, Mar 18, 2021 at 07:06:55PM +0800, Muchun Song wrote:
> The page_memcg() is not suitable for use by page_expected_state() and
> page_bad_reason(). Because it can BUG_ON() for the slab pages when
> CONFIG_DEBUG_VM is enabled. As neither lru, nor kmem, nor slab page
> should have anything left in there by the time the page is freed, what
> we care about is whether the value of page->memcg_data is 0. So just
> directly access page->memcg_data here.
> 
> Signed-off-by: Muchun Song 

Acked-by: Johannes Weiner 


[PATCH v4 2/5] mm: memcontrol: directly access page->memcg_data in mm/page_alloc.c

2021-03-18 Thread Muchun Song
The page_memcg() is not suitable for use by page_expected_state() and
page_bad_reason(). Because it can BUG_ON() for the slab pages when
CONFIG_DEBUG_VM is enabled. As neither lru, nor kmem, nor slab page
should have anything left in there by the time the page is freed, what
we care about is whether the value of page->memcg_data is 0. So just
directly access page->memcg_data here.

Signed-off-by: Muchun Song 
---
 mm/page_alloc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index f10966e3b4a5..e5454b85a106 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1124,7 +1124,7 @@ static inline bool page_expected_state(struct page *page,
if (unlikely((unsigned long)page->mapping |
page_ref_count(page) |
 #ifdef CONFIG_MEMCG
-   (unsigned long)page_memcg(page) |
+   page->memcg_data |
 #endif
(page->flags & check_flags)))
return false;
@@ -1149,7 +1149,7 @@ static const char *page_bad_reason(struct page *page, 
unsigned long flags)
bad_reason = "PAGE_FLAGS_CHECK_AT_FREE flag(s) set";
}
 #ifdef CONFIG_MEMCG
-   if (unlikely(page_memcg(page)))
+   if (unlikely(page->memcg_data))
bad_reason = "page still charged to cgroup";
 #endif
return bad_reason;
-- 
2.11.0