summaryrefslogtreecommitdiff
path: root/mm
diff options
context:
space:
mode:
authorSuren Baghdasaryan <surenb@google.com>2024-08-13 08:07:56 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-08-29 17:35:41 +0200
commit71f44df3ec6b44a9df0d5fbf7274861a65f6c806 (patch)
treece95ec69ef39c8886e771528d2a346463d9e45aa /mm
parent411afd86946278b9f5e5e8fa2eb6ede46f3a5415 (diff)
downloadlinux-71f44df3ec6b44a9df0d5fbf7274861a65f6c806.tar.gz
linux-71f44df3ec6b44a9df0d5fbf7274861a65f6c806.tar.bz2
linux-71f44df3ec6b44a9df0d5fbf7274861a65f6c806.zip
alloc_tag: introduce clear_page_tag_ref() helper function
commit a8fc28dad6d574582cdf2f7e78c73c59c623df30 upstream. In several cases we are freeing pages which were not allocated using common page allocators. For such cases, in order to keep allocation accounting correct, we should clear the page tag to indicate that the page being freed is expected to not have a valid allocation tag. Introduce clear_page_tag_ref() helper function to be used for this. Link: https://lkml.kernel.org/r/20240813150758.855881-1-surenb@google.com Fixes: d224eb0287fb ("codetag: debug: mark codetags for reserved pages as empty") Signed-off-by: Suren Baghdasaryan <surenb@google.com> Suggested-by: David Hildenbrand <david@redhat.com> Acked-by: David Hildenbrand <david@redhat.com> Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com> Cc: Kees Cook <keescook@chromium.org> Cc: Kent Overstreet <kent.overstreet@linux.dev> Cc: Sourav Panda <souravpanda@google.com> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: <stable@vger.kernel.org> [6.10] Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/mm_init.c10
-rw-r--r--mm/page_alloc.c9
2 files changed, 2 insertions, 17 deletions
diff --git a/mm/mm_init.c b/mm/mm_init.c
index 13eb7cd58d9e..2addc701790a 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -2507,15 +2507,7 @@ void __init memblock_free_pages(struct page *page, unsigned long pfn,
}
/* pages were reserved and not allocated */
- if (mem_alloc_profiling_enabled()) {
- union codetag_ref *ref = get_page_tag_ref(page);
-
- if (ref) {
- set_codetag_empty(ref);
- put_page_tag_ref(ref);
- }
- }
-
+ clear_page_tag_ref(page);
__free_pages_core(page, order);
}
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index decbed9eb472..b50060405d94 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5806,14 +5806,7 @@ unsigned long free_reserved_area(void *start, void *end, int poison, const char
void free_reserved_page(struct page *page)
{
- if (mem_alloc_profiling_enabled()) {
- union codetag_ref *ref = get_page_tag_ref(page);
-
- if (ref) {
- set_codetag_empty(ref);
- put_page_tag_ref(ref);
- }
- }
+ clear_page_tag_ref(page);
ClearPageReserved(page);
init_page_count(page);
__free_page(page);