* [PATCH 1/3] alloc_tag: use release_pages() in the cleanup path
2025-09-09 23:34 [PATCH 0/3] Minor fixes for memory allocation profiling Suren Baghdasaryan
@ 2025-09-09 23:34 ` Suren Baghdasaryan
2025-09-10 5:31 ` Shakeel Butt
2025-09-10 20:49 ` Usama Arif
2025-09-09 23:34 ` [PATCH 2/3] alloc_tag: prevent enabling memory profiling if it was shut down Suren Baghdasaryan
2025-09-09 23:34 ` [PATCH 3/3] alloc_tag: avoid warnings when freeing non-compound "tail" pages Suren Baghdasaryan
2 siblings, 2 replies; 15+ messages in thread
From: Suren Baghdasaryan @ 2025-09-09 23:34 UTC (permalink / raw)
To: akpm
Cc: kent.overstreet, vbabka, mhocko, jackmanb, hannes, ziy,
usamaarif642, shakeel.butt, 00107082, pasha.tatashin, souravpanda,
surenb, linux-mm, linux-kernel
When bulk-freeing an array of pages use release_pages() instead of freeing
them page-by-page:
Suggested-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
---
lib/alloc_tag.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c
index e9b33848700a..95688c4cba7a 100644
--- a/lib/alloc_tag.c
+++ b/lib/alloc_tag.c
@@ -438,9 +438,10 @@ static int vm_module_tags_populate(void)
if (nr < more_pages ||
vmap_pages_range(phys_end, phys_end + (nr << PAGE_SHIFT), PAGE_KERNEL,
next_page, PAGE_SHIFT) < 0) {
+ release_pages_arg arg = { .pages = next_page };
+
/* Clean up and error out */
- for (int i = 0; i < nr; i++)
- __free_page(next_page[i]);
+ release_pages(arg, nr);
return -ENOMEM;
}
--
2.51.0.384.g4c02a37b29-goog
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 1/3] alloc_tag: use release_pages() in the cleanup path
2025-09-09 23:34 ` [PATCH 1/3] alloc_tag: use release_pages() in the cleanup path Suren Baghdasaryan
@ 2025-09-10 5:31 ` Shakeel Butt
2025-09-10 20:49 ` Usama Arif
1 sibling, 0 replies; 15+ messages in thread
From: Shakeel Butt @ 2025-09-10 5:31 UTC (permalink / raw)
To: Suren Baghdasaryan
Cc: akpm, kent.overstreet, vbabka, mhocko, jackmanb, hannes, ziy,
usamaarif642, 00107082, pasha.tatashin, souravpanda, linux-mm,
linux-kernel
On Tue, Sep 09, 2025 at 04:34:07PM -0700, Suren Baghdasaryan wrote:
> When bulk-freeing an array of pages use release_pages() instead of freeing
> them page-by-page:
>
> Suggested-by: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/3] alloc_tag: use release_pages() in the cleanup path
2025-09-09 23:34 ` [PATCH 1/3] alloc_tag: use release_pages() in the cleanup path Suren Baghdasaryan
2025-09-10 5:31 ` Shakeel Butt
@ 2025-09-10 20:49 ` Usama Arif
2025-09-12 21:05 ` Suren Baghdasaryan
1 sibling, 1 reply; 15+ messages in thread
From: Usama Arif @ 2025-09-10 20:49 UTC (permalink / raw)
To: Suren Baghdasaryan, akpm
Cc: kent.overstreet, vbabka, mhocko, jackmanb, hannes, ziy,
shakeel.butt, 00107082, pasha.tatashin, souravpanda, linux-mm,
linux-kernel
On 10/09/2025 00:34, Suren Baghdasaryan wrote:
> When bulk-freeing an array of pages use release_pages() instead of freeing
> them page-by-page:
>
> Suggested-by: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Suren Baghdasaryan <surenb@google.com>
> ---
> lib/alloc_tag.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
Acked-by: Usama Arif <usamaarif642@gmail.com>
> diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c
> index e9b33848700a..95688c4cba7a 100644
> --- a/lib/alloc_tag.c
> +++ b/lib/alloc_tag.c
> @@ -438,9 +438,10 @@ static int vm_module_tags_populate(void)
> if (nr < more_pages ||
> vmap_pages_range(phys_end, phys_end + (nr << PAGE_SHIFT), PAGE_KERNEL,
> next_page, PAGE_SHIFT) < 0) {
> + release_pages_arg arg = { .pages = next_page };
> +
> /* Clean up and error out */
> - for (int i = 0; i < nr; i++)
> - __free_page(next_page[i]);
> + release_pages(arg, nr);
> return -ENOMEM;
> }
>
Maybe this can be done in free_mod_tags_mem as well?
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH 1/3] alloc_tag: use release_pages() in the cleanup path
2025-09-10 20:49 ` Usama Arif
@ 2025-09-12 21:05 ` Suren Baghdasaryan
0 siblings, 0 replies; 15+ messages in thread
From: Suren Baghdasaryan @ 2025-09-12 21:05 UTC (permalink / raw)
To: Usama Arif
Cc: akpm, kent.overstreet, vbabka, mhocko, jackmanb, hannes, ziy,
shakeel.butt, 00107082, pasha.tatashin, souravpanda, linux-mm,
linux-kernel
On Wed, Sep 10, 2025 at 1:49 PM Usama Arif <usamaarif642@gmail.com> wrote:
>
>
>
> On 10/09/2025 00:34, Suren Baghdasaryan wrote:
> > When bulk-freeing an array of pages use release_pages() instead of freeing
> > them page-by-page:
> >
> > Suggested-by: Andrew Morton <akpm@linux-foundation.org>
> > Signed-off-by: Suren Baghdasaryan <surenb@google.com>
> > ---
> > lib/alloc_tag.c | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> >
>
> Acked-by: Usama Arif <usamaarif642@gmail.com>
>
> > diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c
> > index e9b33848700a..95688c4cba7a 100644
> > --- a/lib/alloc_tag.c
> > +++ b/lib/alloc_tag.c
> > @@ -438,9 +438,10 @@ static int vm_module_tags_populate(void)
> > if (nr < more_pages ||
> > vmap_pages_range(phys_end, phys_end + (nr << PAGE_SHIFT), PAGE_KERNEL,
> > next_page, PAGE_SHIFT) < 0) {
> > + release_pages_arg arg = { .pages = next_page };
> > +
> > /* Clean up and error out */
> > - for (int i = 0; i < nr; i++)
> > - __free_page(next_page[i]);
> > + release_pages(arg, nr);
> > return -ENOMEM;
> > }
> >
>
> Maybe this can be done in free_mod_tags_mem as well?
Good point. I think I will respin this patchset with your suggestions
and will include one more fix for an issue that Shakeel just reported
(see https://lore.kernel.org/all/CAJuCfpGUjaZcs1r9ADKck_Ni7f41kHaiejR01Z0bE8pG0K1uXA@mail.gmail.com/).
Thanks!
Suren.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 2/3] alloc_tag: prevent enabling memory profiling if it was shut down
2025-09-09 23:34 [PATCH 0/3] Minor fixes for memory allocation profiling Suren Baghdasaryan
2025-09-09 23:34 ` [PATCH 1/3] alloc_tag: use release_pages() in the cleanup path Suren Baghdasaryan
@ 2025-09-09 23:34 ` Suren Baghdasaryan
2025-09-10 5:32 ` Shakeel Butt
2025-09-10 20:51 ` Usama Arif
2025-09-09 23:34 ` [PATCH 3/3] alloc_tag: avoid warnings when freeing non-compound "tail" pages Suren Baghdasaryan
2 siblings, 2 replies; 15+ messages in thread
From: Suren Baghdasaryan @ 2025-09-09 23:34 UTC (permalink / raw)
To: akpm
Cc: kent.overstreet, vbabka, mhocko, jackmanb, hannes, ziy,
usamaarif642, shakeel.butt, 00107082, pasha.tatashin, souravpanda,
surenb, linux-mm, linux-kernel
Memory profiling can be shut down due to reasons like a failure during
initialization. When this happens, the user should not be able to
re-enable it. Current sysctrl interface does not handle this properly
and will allow re-enabling memory profiling. Fix this by checking for
this condition during sysctrl write operation.
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
---
lib/alloc_tag.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c
index 95688c4cba7a..79891528e7b6 100644
--- a/lib/alloc_tag.c
+++ b/lib/alloc_tag.c
@@ -767,6 +767,16 @@ struct page_ext_operations page_alloc_tagging_ops = {
EXPORT_SYMBOL(page_alloc_tagging_ops);
#ifdef CONFIG_SYSCTL
+static int proc_mem_profiling_handler(const struct ctl_table *table, int write,
+ void *buffer, size_t *lenp, loff_t *ppos)
+{
+ if (!mem_profiling_support && write)
+ return -EINVAL;
+
+ return proc_do_static_key(table, write, buffer, lenp, ppos);
+}
+
+
static struct ctl_table memory_allocation_profiling_sysctls[] = {
{
.procname = "mem_profiling",
@@ -776,7 +786,7 @@ static struct ctl_table memory_allocation_profiling_sysctls[] = {
#else
.mode = 0644,
#endif
- .proc_handler = proc_do_static_key,
+ .proc_handler = proc_mem_profiling_handler,
},
};
--
2.51.0.384.g4c02a37b29-goog
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 2/3] alloc_tag: prevent enabling memory profiling if it was shut down
2025-09-09 23:34 ` [PATCH 2/3] alloc_tag: prevent enabling memory profiling if it was shut down Suren Baghdasaryan
@ 2025-09-10 5:32 ` Shakeel Butt
2025-09-10 20:51 ` Usama Arif
1 sibling, 0 replies; 15+ messages in thread
From: Shakeel Butt @ 2025-09-10 5:32 UTC (permalink / raw)
To: Suren Baghdasaryan
Cc: akpm, kent.overstreet, vbabka, mhocko, jackmanb, hannes, ziy,
usamaarif642, 00107082, pasha.tatashin, souravpanda, linux-mm,
linux-kernel
On Tue, Sep 09, 2025 at 04:34:08PM -0700, Suren Baghdasaryan wrote:
> Memory profiling can be shut down due to reasons like a failure during
> initialization. When this happens, the user should not be able to
> re-enable it. Current sysctrl interface does not handle this properly
> and will allow re-enabling memory profiling. Fix this by checking for
> this condition during sysctrl write operation.
>
> Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/3] alloc_tag: prevent enabling memory profiling if it was shut down
2025-09-09 23:34 ` [PATCH 2/3] alloc_tag: prevent enabling memory profiling if it was shut down Suren Baghdasaryan
2025-09-10 5:32 ` Shakeel Butt
@ 2025-09-10 20:51 ` Usama Arif
2025-09-11 17:01 ` Suren Baghdasaryan
1 sibling, 1 reply; 15+ messages in thread
From: Usama Arif @ 2025-09-10 20:51 UTC (permalink / raw)
To: Suren Baghdasaryan, akpm
Cc: kent.overstreet, vbabka, mhocko, jackmanb, hannes, ziy,
shakeel.butt, 00107082, pasha.tatashin, souravpanda, linux-mm,
linux-kernel
On 10/09/2025 00:34, Suren Baghdasaryan wrote:
> Memory profiling can be shut down due to reasons like a failure during
> initialization. When this happens, the user should not be able to
> re-enable it. Current sysctrl interface does not handle this properly
> and will allow re-enabling memory profiling. Fix this by checking for
> this condition during sysctrl write operation.
>
> Signed-off-by: Suren Baghdasaryan <surenb@google.com>
> ---
> lib/alloc_tag.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
Acked-by: Usama Arif <usamaarif642@gmail.com>
> diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c
> index 95688c4cba7a..79891528e7b6 100644
> --- a/lib/alloc_tag.c
> +++ b/lib/alloc_tag.c
> @@ -767,6 +767,16 @@ struct page_ext_operations page_alloc_tagging_ops = {
> EXPORT_SYMBOL(page_alloc_tagging_ops);
>
> #ifdef CONFIG_SYSCTL
nit: might be good to add a comment here that we are not using default as we dont want to enable
it back if it fails once. But not worth a respin as someone can always check git log if curious.
> +static int proc_mem_profiling_handler(const struct ctl_table *table, int write,
> + void *buffer, size_t *lenp, loff_t *ppos)
> +{
> + if (!mem_profiling_support && write)
> + return -EINVAL;
> +
> + return proc_do_static_key(table, write, buffer, lenp, ppos);
> +}
> +
> +
> static struct ctl_table memory_allocation_profiling_sysctls[] = {
> {
> .procname = "mem_profiling",
> @@ -776,7 +786,7 @@ static struct ctl_table memory_allocation_profiling_sysctls[] = {
> #else
> .mode = 0644,
> #endif
> - .proc_handler = proc_do_static_key,
> + .proc_handler = proc_mem_profiling_handler,
> },
> };
>
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH 2/3] alloc_tag: prevent enabling memory profiling if it was shut down
2025-09-10 20:51 ` Usama Arif
@ 2025-09-11 17:01 ` Suren Baghdasaryan
0 siblings, 0 replies; 15+ messages in thread
From: Suren Baghdasaryan @ 2025-09-11 17:01 UTC (permalink / raw)
To: Usama Arif
Cc: akpm, kent.overstreet, vbabka, mhocko, jackmanb, hannes, ziy,
shakeel.butt, 00107082, pasha.tatashin, souravpanda, linux-mm,
linux-kernel
On Wed, Sep 10, 2025 at 1:52 PM Usama Arif <usamaarif642@gmail.com> wrote:
>
>
>
> On 10/09/2025 00:34, Suren Baghdasaryan wrote:
> > Memory profiling can be shut down due to reasons like a failure during
> > initialization. When this happens, the user should not be able to
> > re-enable it. Current sysctrl interface does not handle this properly
> > and will allow re-enabling memory profiling. Fix this by checking for
> > this condition during sysctrl write operation.
> >
> > Signed-off-by: Suren Baghdasaryan <surenb@google.com>
> > ---
> > lib/alloc_tag.c | 12 +++++++++++-
> > 1 file changed, 11 insertions(+), 1 deletion(-)
> >
>
> Acked-by: Usama Arif <usamaarif642@gmail.com>
>
>
>
> > diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c
> > index 95688c4cba7a..79891528e7b6 100644
> > --- a/lib/alloc_tag.c
> > +++ b/lib/alloc_tag.c
> > @@ -767,6 +767,16 @@ struct page_ext_operations page_alloc_tagging_ops = {
> > EXPORT_SYMBOL(page_alloc_tagging_ops);
> >
> > #ifdef CONFIG_SYSCTL
>
> nit: might be good to add a comment here that we are not using default as we dont want to enable
> it back if it fails once. But not worth a respin as someone can always check git log if curious.
Ok, if I respin the series will add it. Thanks!
>
> > +static int proc_mem_profiling_handler(const struct ctl_table *table, int write,
> > + void *buffer, size_t *lenp, loff_t *ppos)
> > +{
> > + if (!mem_profiling_support && write)
> > + return -EINVAL;
> > +
> > + return proc_do_static_key(table, write, buffer, lenp, ppos);
> > +}
> > +
> > +
> > static struct ctl_table memory_allocation_profiling_sysctls[] = {
> > {
> > .procname = "mem_profiling",
> > @@ -776,7 +786,7 @@ static struct ctl_table memory_allocation_profiling_sysctls[] = {
> > #else
> > .mode = 0644,
> > #endif
> > - .proc_handler = proc_do_static_key,
> > + .proc_handler = proc_mem_profiling_handler,
> > },
> > };
> >
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 3/3] alloc_tag: avoid warnings when freeing non-compound "tail" pages
2025-09-09 23:34 [PATCH 0/3] Minor fixes for memory allocation profiling Suren Baghdasaryan
2025-09-09 23:34 ` [PATCH 1/3] alloc_tag: use release_pages() in the cleanup path Suren Baghdasaryan
2025-09-09 23:34 ` [PATCH 2/3] alloc_tag: prevent enabling memory profiling if it was shut down Suren Baghdasaryan
@ 2025-09-09 23:34 ` Suren Baghdasaryan
2025-09-11 20:01 ` Shakeel Butt
2025-09-11 22:58 ` Shakeel Butt
2 siblings, 2 replies; 15+ messages in thread
From: Suren Baghdasaryan @ 2025-09-09 23:34 UTC (permalink / raw)
To: akpm
Cc: kent.overstreet, vbabka, mhocko, jackmanb, hannes, ziy,
usamaarif642, shakeel.butt, 00107082, pasha.tatashin, souravpanda,
surenb, linux-mm, linux-kernel
When freeing "tail" pages of a non-compount high-order page, we properly
subtract the allocation tag counters, however later when these pages are
released, alloc_tag_sub() will issue warnings because tags for these pages
are NULL.
This issue was originally anticipated by Vlastimil in his review [1] and
then recently reported by David.
Prevent warnings by marking the tags empty.
[1] https://lore.kernel.org/all/6db0f0c8-81cb-4d04-9560-ba73d63db4b8@suse.cz/
Suggested-by: David Wang <00107082@163.com>
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
---
mm/page_alloc.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 1760346bbd24..d21a411e807e 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5240,9 +5240,16 @@ static void ___free_pages(struct page *page, unsigned int order,
__free_frozen_pages(page, order, fpi_flags);
else if (!head) {
pgalloc_tag_sub_pages(tag, (1 << order) - 1);
- while (order-- > 0)
+ while (order-- > 0) {
+ /*
+ * The "tail" pages of this non-compound high-order
+ * page will have no code tags, so to avoid warnings
+ * mark them as empty.
+ */
+ clear_page_tag_ref(page + (1 << order));
__free_frozen_pages(page + (1 << order), order,
fpi_flags);
+ }
}
}
--
2.51.0.384.g4c02a37b29-goog
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 3/3] alloc_tag: avoid warnings when freeing non-compound "tail" pages
2025-09-09 23:34 ` [PATCH 3/3] alloc_tag: avoid warnings when freeing non-compound "tail" pages Suren Baghdasaryan
@ 2025-09-11 20:01 ` Shakeel Butt
2025-09-11 20:12 ` Suren Baghdasaryan
2025-09-11 22:58 ` Shakeel Butt
1 sibling, 1 reply; 15+ messages in thread
From: Shakeel Butt @ 2025-09-11 20:01 UTC (permalink / raw)
To: Suren Baghdasaryan
Cc: akpm, kent.overstreet, vbabka, mhocko, jackmanb, hannes, ziy,
usamaarif642, 00107082, pasha.tatashin, souravpanda, linux-mm,
linux-kernel
On Tue, Sep 09, 2025 at 04:34:09PM -0700, Suren Baghdasaryan wrote:
> When freeing "tail" pages of a non-compount high-order page, we properly
> subtract the allocation tag counters, however later when these pages are
> released, alloc_tag_sub() will issue warnings because tags for these pages
> are NULL.
> This issue was originally anticipated by Vlastimil in his review [1] and
> then recently reported by David.
> Prevent warnings by marking the tags empty.
>
> [1] https://lore.kernel.org/all/6db0f0c8-81cb-4d04-9560-ba73d63db4b8@suse.cz/
>
> Suggested-by: David Wang <00107082@163.com>
> Signed-off-by: Suren Baghdasaryan <surenb@google.com>
> ---
> mm/page_alloc.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 1760346bbd24..d21a411e807e 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -5240,9 +5240,16 @@ static void ___free_pages(struct page *page, unsigned int order,
> __free_frozen_pages(page, order, fpi_flags);
> else if (!head) {
> pgalloc_tag_sub_pages(tag, (1 << order) - 1);
> - while (order-- > 0)
> + while (order-- > 0) {
> + /*
> + * The "tail" pages of this non-compound high-order
> + * page will have no code tags, so to avoid warnings
> + * mark them as empty.
> + */
> + clear_page_tag_ref(page + (1 << order));
Do we need something similar for the release_pages() code path or is it
happening already?
> __free_frozen_pages(page + (1 << order), order,
> fpi_flags);
> + }
> }
> }
>
> --
> 2.51.0.384.g4c02a37b29-goog
>
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH 3/3] alloc_tag: avoid warnings when freeing non-compound "tail" pages
2025-09-11 20:01 ` Shakeel Butt
@ 2025-09-11 20:12 ` Suren Baghdasaryan
2025-09-11 21:44 ` Shakeel Butt
0 siblings, 1 reply; 15+ messages in thread
From: Suren Baghdasaryan @ 2025-09-11 20:12 UTC (permalink / raw)
To: Shakeel Butt
Cc: akpm, kent.overstreet, vbabka, mhocko, jackmanb, hannes, ziy,
usamaarif642, 00107082, pasha.tatashin, souravpanda, linux-mm,
linux-kernel
On Thu, Sep 11, 2025 at 1:01 PM Shakeel Butt <shakeel.butt@linux.dev> wrote:
>
> On Tue, Sep 09, 2025 at 04:34:09PM -0700, Suren Baghdasaryan wrote:
> > When freeing "tail" pages of a non-compount high-order page, we properly
> > subtract the allocation tag counters, however later when these pages are
> > released, alloc_tag_sub() will issue warnings because tags for these pages
> > are NULL.
> > This issue was originally anticipated by Vlastimil in his review [1] and
> > then recently reported by David.
> > Prevent warnings by marking the tags empty.
> >
> > [1] https://lore.kernel.org/all/6db0f0c8-81cb-4d04-9560-ba73d63db4b8@suse.cz/
> >
> > Suggested-by: David Wang <00107082@163.com>
> > Signed-off-by: Suren Baghdasaryan <surenb@google.com>
> > ---
> > mm/page_alloc.c | 9 ++++++++-
> > 1 file changed, 8 insertions(+), 1 deletion(-)
> >
> > diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> > index 1760346bbd24..d21a411e807e 100644
> > --- a/mm/page_alloc.c
> > +++ b/mm/page_alloc.c
> > @@ -5240,9 +5240,16 @@ static void ___free_pages(struct page *page, unsigned int order,
> > __free_frozen_pages(page, order, fpi_flags);
> > else if (!head) {
> > pgalloc_tag_sub_pages(tag, (1 << order) - 1);
> > - while (order-- > 0)
> > + while (order-- > 0) {
> > + /*
> > + * The "tail" pages of this non-compound high-order
> > + * page will have no code tags, so to avoid warnings
> > + * mark them as empty.
> > + */
> > + clear_page_tag_ref(page + (1 << order));
>
> Do we need something similar for the release_pages() code path or is it
> happening already?
Pages released with release_pages() should have valid tags, so I
expect no warnings.
>
> > __free_frozen_pages(page + (1 << order), order,
> > fpi_flags);
> > + }
> > }
> > }
> >
> > --
> > 2.51.0.384.g4c02a37b29-goog
> >
>
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH 3/3] alloc_tag: avoid warnings when freeing non-compound "tail" pages
2025-09-11 20:12 ` Suren Baghdasaryan
@ 2025-09-11 21:44 ` Shakeel Butt
2025-09-11 21:51 ` Suren Baghdasaryan
0 siblings, 1 reply; 15+ messages in thread
From: Shakeel Butt @ 2025-09-11 21:44 UTC (permalink / raw)
To: Suren Baghdasaryan
Cc: akpm, kent.overstreet, vbabka, mhocko, jackmanb, hannes, ziy,
usamaarif642, 00107082, pasha.tatashin, souravpanda, linux-mm,
linux-kernel
On Thu, Sep 11, 2025 at 01:12:11PM -0700, Suren Baghdasaryan wrote:
> On Thu, Sep 11, 2025 at 1:01 PM Shakeel Butt <shakeel.butt@linux.dev> wrote:
> >
> > On Tue, Sep 09, 2025 at 04:34:09PM -0700, Suren Baghdasaryan wrote:
> > > When freeing "tail" pages of a non-compount high-order page, we properly
> > > subtract the allocation tag counters, however later when these pages are
> > > released, alloc_tag_sub() will issue warnings because tags for these pages
> > > are NULL.
> > > This issue was originally anticipated by Vlastimil in his review [1] and
> > > then recently reported by David.
> > > Prevent warnings by marking the tags empty.
> > >
> > > [1] https://lore.kernel.org/all/6db0f0c8-81cb-4d04-9560-ba73d63db4b8@suse.cz/
> > >
> > > Suggested-by: David Wang <00107082@163.com>
> > > Signed-off-by: Suren Baghdasaryan <surenb@google.com>
> > > ---
> > > mm/page_alloc.c | 9 ++++++++-
> > > 1 file changed, 8 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> > > index 1760346bbd24..d21a411e807e 100644
> > > --- a/mm/page_alloc.c
> > > +++ b/mm/page_alloc.c
> > > @@ -5240,9 +5240,16 @@ static void ___free_pages(struct page *page, unsigned int order,
> > > __free_frozen_pages(page, order, fpi_flags);
> > > else if (!head) {
> > > pgalloc_tag_sub_pages(tag, (1 << order) - 1);
> > > - while (order-- > 0)
> > > + while (order-- > 0) {
> > > + /*
> > > + * The "tail" pages of this non-compound high-order
> > > + * page will have no code tags, so to avoid warnings
> > > + * mark them as empty.
> > > + */
> > > + clear_page_tag_ref(page + (1 << order));
> >
> > Do we need something similar for the release_pages() code path or is it
> > happening already?
>
> Pages released with release_pages() should have valid tags, so I
> expect no warnings.
>
Oh so this is orthogonal to your first patch which is replacing
__free_page with release_pages(). This non-compound high-order page is
not an issue in the codepath vm_module_tags_populate(), correct?
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH 3/3] alloc_tag: avoid warnings when freeing non-compound "tail" pages
2025-09-11 21:44 ` Shakeel Butt
@ 2025-09-11 21:51 ` Suren Baghdasaryan
0 siblings, 0 replies; 15+ messages in thread
From: Suren Baghdasaryan @ 2025-09-11 21:51 UTC (permalink / raw)
To: Shakeel Butt
Cc: akpm, kent.overstreet, vbabka, mhocko, jackmanb, hannes, ziy,
usamaarif642, 00107082, pasha.tatashin, souravpanda, linux-mm,
linux-kernel
On Thu, Sep 11, 2025 at 2:45 PM Shakeel Butt <shakeel.butt@linux.dev> wrote:
>
> On Thu, Sep 11, 2025 at 01:12:11PM -0700, Suren Baghdasaryan wrote:
> > On Thu, Sep 11, 2025 at 1:01 PM Shakeel Butt <shakeel.butt@linux.dev> wrote:
> > >
> > > On Tue, Sep 09, 2025 at 04:34:09PM -0700, Suren Baghdasaryan wrote:
> > > > When freeing "tail" pages of a non-compount high-order page, we properly
> > > > subtract the allocation tag counters, however later when these pages are
> > > > released, alloc_tag_sub() will issue warnings because tags for these pages
> > > > are NULL.
> > > > This issue was originally anticipated by Vlastimil in his review [1] and
> > > > then recently reported by David.
> > > > Prevent warnings by marking the tags empty.
> > > >
> > > > [1] https://lore.kernel.org/all/6db0f0c8-81cb-4d04-9560-ba73d63db4b8@suse.cz/
> > > >
> > > > Suggested-by: David Wang <00107082@163.com>
> > > > Signed-off-by: Suren Baghdasaryan <surenb@google.com>
> > > > ---
> > > > mm/page_alloc.c | 9 ++++++++-
> > > > 1 file changed, 8 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> > > > index 1760346bbd24..d21a411e807e 100644
> > > > --- a/mm/page_alloc.c
> > > > +++ b/mm/page_alloc.c
> > > > @@ -5240,9 +5240,16 @@ static void ___free_pages(struct page *page, unsigned int order,
> > > > __free_frozen_pages(page, order, fpi_flags);
> > > > else if (!head) {
> > > > pgalloc_tag_sub_pages(tag, (1 << order) - 1);
> > > > - while (order-- > 0)
> > > > + while (order-- > 0) {
> > > > + /*
> > > > + * The "tail" pages of this non-compound high-order
> > > > + * page will have no code tags, so to avoid warnings
> > > > + * mark them as empty.
> > > > + */
> > > > + clear_page_tag_ref(page + (1 << order));
> > >
> > > Do we need something similar for the release_pages() code path or is it
> > > happening already?
> >
> > Pages released with release_pages() should have valid tags, so I
> > expect no warnings.
> >
>
> Oh so this is orthogonal to your first patch which is replacing
> __free_page with release_pages(). This non-compound high-order page is
> not an issue in the codepath vm_module_tags_populate(), correct?
Yes, these are independent fixes.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 3/3] alloc_tag: avoid warnings when freeing non-compound "tail" pages
2025-09-09 23:34 ` [PATCH 3/3] alloc_tag: avoid warnings when freeing non-compound "tail" pages Suren Baghdasaryan
2025-09-11 20:01 ` Shakeel Butt
@ 2025-09-11 22:58 ` Shakeel Butt
1 sibling, 0 replies; 15+ messages in thread
From: Shakeel Butt @ 2025-09-11 22:58 UTC (permalink / raw)
To: Suren Baghdasaryan
Cc: akpm, kent.overstreet, vbabka, mhocko, jackmanb, hannes, ziy,
usamaarif642, 00107082, pasha.tatashin, souravpanda, linux-mm,
linux-kernel
On Tue, Sep 09, 2025 at 04:34:09PM -0700, Suren Baghdasaryan wrote:
> When freeing "tail" pages of a non-compount high-order page, we properly
> subtract the allocation tag counters, however later when these pages are
> released, alloc_tag_sub() will issue warnings because tags for these pages
> are NULL.
> This issue was originally anticipated by Vlastimil in his review [1] and
> then recently reported by David.
> Prevent warnings by marking the tags empty.
>
> [1] https://lore.kernel.org/all/6db0f0c8-81cb-4d04-9560-ba73d63db4b8@suse.cz/
>
> Suggested-by: David Wang <00107082@163.com>
> Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
^ permalink raw reply [flat|nested] 15+ messages in thread