diff mbox series

[v3,2/2] alloc_tag: mark pages reserved during CMA activation as not tagged

Message ID 20240813150758.855881-2-surenb@google.com (mailing list archive)
State New
Headers show
Series [v3,1/2] alloc_tag: introduce clear_page_tag_ref() helper function | expand

Commit Message

Suren Baghdasaryan Aug. 13, 2024, 3:07 p.m. UTC
During CMA activation, pages in CMA area are prepared and then freed
without being allocated. This triggers warnings when memory allocation
debug config (CONFIG_MEM_ALLOC_PROFILING_DEBUG) is enabled. Fix this
by marking these pages not tagged before freeing them.

Fixes: d224eb0287fb ("codetag: debug: mark codetags for reserved pages as empty")
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Cc: stable@vger.kernel.org # v6.10
---
Changes since v2 [1]:
- Add and use clear_page_tag_ref helper, per David Hildenbrand

https://lore.kernel.org/all/20240812192428.151825-1-surenb@google.com/

 mm/mm_init.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

David Hildenbrand Aug. 13, 2024, 3:09 p.m. UTC | #1
On 13.08.24 17:07, Suren Baghdasaryan wrote:
> During CMA activation, pages in CMA area are prepared and then freed
> without being allocated. This triggers warnings when memory allocation
> debug config (CONFIG_MEM_ALLOC_PROFILING_DEBUG) is enabled. Fix this
> by marking these pages not tagged before freeing them.
> 
> Fixes: d224eb0287fb ("codetag: debug: mark codetags for reserved pages as empty")
> Signed-off-by: Suren Baghdasaryan <surenb@google.com>
> Cc: stable@vger.kernel.org # v6.10
> ---
> Changes since v2 [1]:
> - Add and use clear_page_tag_ref helper, per David Hildenbrand
> 
> https://lore.kernel.org/all/20240812192428.151825-1-surenb@google.com/
> 
>   mm/mm_init.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/mm/mm_init.c b/mm/mm_init.c
> index 907c46b0773f..13c4060bb01a 100644
> --- a/mm/mm_init.c
> +++ b/mm/mm_init.c
> @@ -2245,6 +2245,8 @@ void __init init_cma_reserved_pageblock(struct page *page)
>   
>   	set_pageblock_migratetype(page, MIGRATE_CMA);
>   	set_page_refcounted(page);
> +	/* pages were reserved and not allocated */
> +	clear_page_tag_ref(page);
>   	__free_pages(page, pageblock_order);
>   
>   	adjust_managed_page_count(page, pageblock_nr_pages);

Acked-by: David Hildenbrand <david@redhat.com>
Suren Baghdasaryan Aug. 13, 2024, 4:06 p.m. UTC | #2
On Tue, Aug 13, 2024 at 8:09 AM David Hildenbrand <david@redhat.com> wrote:
>
> On 13.08.24 17:07, Suren Baghdasaryan wrote:
> > During CMA activation, pages in CMA area are prepared and then freed
> > without being allocated. This triggers warnings when memory allocation
> > debug config (CONFIG_MEM_ALLOC_PROFILING_DEBUG) is enabled. Fix this
> > by marking these pages not tagged before freeing them.
> >
> > Fixes: d224eb0287fb ("codetag: debug: mark codetags for reserved pages as empty")
> > Signed-off-by: Suren Baghdasaryan <surenb@google.com>
> > Cc: stable@vger.kernel.org # v6.10
> > ---
> > Changes since v2 [1]:
> > - Add and use clear_page_tag_ref helper, per David Hildenbrand
> >
> > https://lore.kernel.org/all/20240812192428.151825-1-surenb@google.com/
> >
> >   mm/mm_init.c | 2 ++
> >   1 file changed, 2 insertions(+)
> >
> > diff --git a/mm/mm_init.c b/mm/mm_init.c
> > index 907c46b0773f..13c4060bb01a 100644
> > --- a/mm/mm_init.c
> > +++ b/mm/mm_init.c
> > @@ -2245,6 +2245,8 @@ void __init init_cma_reserved_pageblock(struct page *page)
> >
> >       set_pageblock_migratetype(page, MIGRATE_CMA);
> >       set_page_refcounted(page);
> > +     /* pages were reserved and not allocated */
> > +     clear_page_tag_ref(page);
> >       __free_pages(page, pageblock_order);
> >
> >       adjust_managed_page_count(page, pageblock_nr_pages);
>
> Acked-by: David Hildenbrand <david@redhat.com>

Thanks!

>
> --
> Cheers,
>
> David / dhildenb
>
Andrew Morton Aug. 13, 2024, 6:40 p.m. UTC | #3
On Tue, 13 Aug 2024 08:07:57 -0700 Suren Baghdasaryan <surenb@google.com> wrote:

> Fixes: d224eb0287fb ("codetag: debug: mark codetags for reserved pages as empty")

I copied this into [1/2] so everything lands nicely.
Suren Baghdasaryan Aug. 13, 2024, 7:37 p.m. UTC | #4
On Tue, Aug 13, 2024 at 11:40 AM Andrew Morton
<akpm@linux-foundation.org> wrote:
>
> On Tue, 13 Aug 2024 08:07:57 -0700 Suren Baghdasaryan <surenb@google.com> wrote:
>
> > Fixes: d224eb0287fb ("codetag: debug: mark codetags for reserved pages as empty")
>
> I copied this into [1/2] so everything lands nicely.

Yeah, technically this does not "fix" that patch but since it's needed
for the next patch I think that's fine.
diff mbox series

Patch

diff --git a/mm/mm_init.c b/mm/mm_init.c
index 907c46b0773f..13c4060bb01a 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -2245,6 +2245,8 @@  void __init init_cma_reserved_pageblock(struct page *page)
 
 	set_pageblock_migratetype(page, MIGRATE_CMA);
 	set_page_refcounted(page);
+	/* pages were reserved and not allocated */
+	clear_page_tag_ref(page);
 	__free_pages(page, pageblock_order);
 
 	adjust_managed_page_count(page, pageblock_nr_pages);