Commit 17b46e7b authored by Brendan Jackman's avatar Brendan Jackman Committed by Andrew Morton

mm/page_alloc: dedupe some memcg uncharging logic

The duplication makes it seem like some work is required before uncharging
in the !PageHWPoison case.  But it isn't, so we can simplify the code a
little.

Note the PageMemcgKmem check is redundant, but I've left it in as it
avoids an unnecessary function call.

Link: https://lkml.kernel.org/r/20231108164920.3401565-1-jackmanb@google.comSigned-off-by: default avatarBrendan Jackman <jackmanb@google.com>
Reviewed-by: default avatarYosry Ahmed <yosryahmed@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Shakeel Butt <shakeelb@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 2033c98c
...@@ -1086,13 +1086,11 @@ static __always_inline bool free_pages_prepare(struct page *page, ...@@ -1086,13 +1086,11 @@ static __always_inline bool free_pages_prepare(struct page *page,
trace_mm_page_free(page, order); trace_mm_page_free(page, order);
kmsan_free_page(page, order); kmsan_free_page(page, order);
if (memcg_kmem_online() && PageMemcgKmem(page))
__memcg_kmem_uncharge_page(page, order);
if (unlikely(PageHWPoison(page)) && !order) { if (unlikely(PageHWPoison(page)) && !order) {
/* /* Do not let hwpoison pages hit pcplists/buddy */
* Do not let hwpoison pages hit pcplists/buddy
* Untie memcg state and reset page's owner
*/
if (memcg_kmem_online() && PageMemcgKmem(page))
__memcg_kmem_uncharge_page(page, order);
reset_page_owner(page, order); reset_page_owner(page, order);
page_table_check_free(page, order); page_table_check_free(page, order);
return false; return false;
...@@ -1123,8 +1121,6 @@ static __always_inline bool free_pages_prepare(struct page *page, ...@@ -1123,8 +1121,6 @@ static __always_inline bool free_pages_prepare(struct page *page,
} }
if (PageMappingFlags(page)) if (PageMappingFlags(page))
page->mapping = NULL; page->mapping = NULL;
if (memcg_kmem_online() && PageMemcgKmem(page))
__memcg_kmem_uncharge_page(page, order);
if (is_check_pages_enabled()) { if (is_check_pages_enabled()) {
if (free_page_is_bad(page)) if (free_page_is_bad(page))
bad++; bad++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment