* [PATCH 0/2] mm: replace custom ratelimiting logic
@ 2026-08-11 17:21 Pedro Falcato
2026-08-11 17:21 ` [PATCH 1/2] mm: replace custom bad page map " Pedro Falcato
` (2 more replies)
0 siblings, 3 replies; 14+ messages in thread
From: Pedro Falcato @ 2026-08-11 17:21 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand
Cc: Pedro Falcato, Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka,
Mike Rapoport, Suren Baghdasaryan, Michal Hocko, Brendan Jackman,
Johannes Weiner, Zi Yan, linux-mm, linux-kernel
The kernel has a perfectly cromulent and mostly-equivalent variant in
lib/ratelimit.c that can be used.
To: Andrew Morton <akpm@linux-foundation.org>
To: David Hildenbrand <david@kernel.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: "Liam R. Howlett" <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Brendan Jackman <brendan.jackman@linux.dev>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Zi Yan <ziy@nvidia.com>
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
Pedro Falcato (2):
mm: replace custom bad page map ratelimiting logic
mm/page_alloc: replace custom bad page ratelimiting logic
mm/memory.c | 30 +++---------------------------
mm/page_alloc.c | 28 +++++-----------------------
2 files changed, 8 insertions(+), 50 deletions(-)
--
2.55.0
^ permalink raw reply [flat|nested] 14+ messages in thread* [PATCH 1/2] mm: replace custom bad page map ratelimiting logic 2026-08-11 17:21 [PATCH 0/2] mm: replace custom ratelimiting logic Pedro Falcato @ 2026-08-11 17:21 ` Pedro Falcato 2026-08-11 19:13 ` Johannes Weiner ` (4 more replies) 2026-08-11 17:21 ` [PATCH 2/2] mm/page_alloc: replace custom bad page " Pedro Falcato 2026-08-12 13:26 ` [PATCH 0/2] mm: replace custom " Mike Rapoport 2 siblings, 5 replies; 14+ messages in thread From: Pedro Falcato @ 2026-08-11 17:21 UTC (permalink / raw) To: Andrew Morton, David Hildenbrand Cc: Pedro Falcato, Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko, Brendan Jackman, Johannes Weiner, Zi Yan, linux-mm, linux-kernel The current logic (allow up to $BURST prints per minute) can be entirely replaced by the generic version in lib/ratelimit.c, used around the kernel. Do so. The only functional difference should be that the new logs will read something like: KERN_WARNING "print_bad_page_map: %d callbacks suppressed\n", ... But that should be fine enough. Signed-off-by: Pedro Falcato <pfalcato@suse.de> --- mm/memory.c | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 4134ac607ee0..b4be57b590ce 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -492,32 +492,8 @@ static inline void add_mm_rss_vec(struct mm_struct *mm, int *rss) add_mm_counter(mm, i, rss[i]); } -static bool is_bad_page_map_ratelimited(void) -{ - static unsigned long resume; - static unsigned long nr_shown; - static unsigned long nr_unshown; - - /* - * Allow a burst of 60 reports, then keep quiet for that minute; - * or allow a steady drip of one report per second. - */ - if (nr_shown == 60) { - if (time_before(jiffies, resume)) { - nr_unshown++; - return true; - } - if (nr_unshown) { - pr_alert("BUG: Bad page map: %lu messages suppressed\n", - nr_unshown); - nr_unshown = 0; - } - nr_shown = 0; - } - if (nr_shown++ == 0) - resume = jiffies + 60 * HZ; - return false; -} +/* Allow a burst of 60 bad page map reports per minute. */ +static DEFINE_RATELIMIT_STATE(bad_page_map_ratelimit, 60 * HZ, 60); static void ptval_bytes_to_hex_str(char *buf, size_t buf_size, const void *entry, size_t entry_size) { @@ -633,7 +609,7 @@ static void print_bad_page_map(struct vm_area_struct *vma, char entry_str[PTVAL_STR_MAX]; pgoff_t index, anon_index; - if (is_bad_page_map_ratelimited()) + if (!__ratelimit(&bad_page_map_ratelimit)) return; mapping = vma->vm_file ? vma->vm_file->f_mapping : NULL; -- 2.55.0 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 1/2] mm: replace custom bad page map ratelimiting logic 2026-08-11 17:21 ` [PATCH 1/2] mm: replace custom bad page map " Pedro Falcato @ 2026-08-11 19:13 ` Johannes Weiner 2026-08-11 19:37 ` Zi Yan ` (3 subsequent siblings) 4 siblings, 0 replies; 14+ messages in thread From: Johannes Weiner @ 2026-08-11 19:13 UTC (permalink / raw) To: Pedro Falcato Cc: Andrew Morton, David Hildenbrand, Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko, Brendan Jackman, Zi Yan, linux-mm, linux-kernel On Tue, Aug 11, 2026 at 06:21:55PM +0100, Pedro Falcato wrote: > The current logic (allow up to $BURST prints per minute) can be entirely > replaced by the generic version in lib/ratelimit.c, used around the kernel. > > Do so. The only functional difference should be that the new logs will > read something like: > > KERN_WARNING "print_bad_page_map: %d callbacks suppressed\n", ... > > But that should be fine enough. > > Signed-off-by: Pedro Falcato <pfalcato@suse.de> Acked-by: Johannes Weiner <hannes@cmpxchg.org> ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/2] mm: replace custom bad page map ratelimiting logic 2026-08-11 17:21 ` [PATCH 1/2] mm: replace custom bad page map " Pedro Falcato 2026-08-11 19:13 ` Johannes Weiner @ 2026-08-11 19:37 ` Zi Yan 2026-08-12 2:56 ` SJ Park ` (2 subsequent siblings) 4 siblings, 0 replies; 14+ messages in thread From: Zi Yan @ 2026-08-11 19:37 UTC (permalink / raw) To: Pedro Falcato, Andrew Morton, David Hildenbrand Cc: Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko, Brendan Jackman, Johannes Weiner, linux-mm, linux-kernel On Tue Aug 11, 2026 at 1:21 PM EDT, Pedro Falcato wrote: > The current logic (allow up to $BURST prints per minute) can be entirely > replaced by the generic version in lib/ratelimit.c, used around the kernel. > > Do so. The only functional difference should be that the new logs will > read something like: > > KERN_WARNING "print_bad_page_map: %d callbacks suppressed\n", ... > > But that should be fine enough. > > Signed-off-by: Pedro Falcato <pfalcato@suse.de> > --- > mm/memory.c | 30 +++--------------------------- > 1 file changed, 3 insertions(+), 27 deletions(-) > Great! Acked-by: Zi Yan <ziy@nvidia.com> -- Best Regards, Yan, Zi ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/2] mm: replace custom bad page map ratelimiting logic 2026-08-11 17:21 ` [PATCH 1/2] mm: replace custom bad page map " Pedro Falcato 2026-08-11 19:13 ` Johannes Weiner 2026-08-11 19:37 ` Zi Yan @ 2026-08-12 2:56 ` SJ Park 2026-08-12 7:45 ` David Hildenbrand (Arm) 2026-08-13 11:29 ` Lorenzo Stoakes (ARM) 4 siblings, 0 replies; 14+ messages in thread From: SJ Park @ 2026-08-12 2:56 UTC (permalink / raw) To: Pedro Falcato Cc: SJ Park, Andrew Morton, David Hildenbrand, Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko, Brendan Jackman, Johannes Weiner, Zi Yan, linux-mm, linux-kernel On Tue, 11 Aug 2026 18:21:55 +0100 Pedro Falcato <pfalcato@suse.de> wrote: > The current logic (allow up to $BURST prints per minute) can be entirely > replaced by the generic version in lib/ratelimit.c, used around the kernel. > > Do so. The only functional difference should be that the new logs will > read something like: > > KERN_WARNING "print_bad_page_map: %d callbacks suppressed\n", ... > > But that should be fine enough. Nice cleanup, thank you! I also agree the change on the log message should be fine. > > Signed-off-by: Pedro Falcato <pfalcato@suse.de> Reviewed-by: SJ Park <sj@kernel.org> Thanks, SJ [...] ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/2] mm: replace custom bad page map ratelimiting logic 2026-08-11 17:21 ` [PATCH 1/2] mm: replace custom bad page map " Pedro Falcato ` (2 preceding siblings ...) 2026-08-12 2:56 ` SJ Park @ 2026-08-12 7:45 ` David Hildenbrand (Arm) 2026-08-13 11:29 ` Lorenzo Stoakes (ARM) 4 siblings, 0 replies; 14+ messages in thread From: David Hildenbrand (Arm) @ 2026-08-12 7:45 UTC (permalink / raw) To: Pedro Falcato, Andrew Morton Cc: Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko, Brendan Jackman, Johannes Weiner, Zi Yan, linux-mm, linux-kernel On 8/11/26 19:21, Pedro Falcato wrote: > The current logic (allow up to $BURST prints per minute) can be entirely > replaced by the generic version in lib/ratelimit.c, used around the kernel. > > Do so. The only functional difference should be that the new logs will > read something like: > > KERN_WARNING "print_bad_page_map: %d callbacks suppressed\n", ... > > But that should be fine enough. > > Signed-off-by: Pedro Falcato <pfalcato@suse.de> > --- Well that's nice! Acked-by: David Hildenbrand (Arm) <david@kernel.org> -- Cheers, David ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/2] mm: replace custom bad page map ratelimiting logic 2026-08-11 17:21 ` [PATCH 1/2] mm: replace custom bad page map " Pedro Falcato ` (3 preceding siblings ...) 2026-08-12 7:45 ` David Hildenbrand (Arm) @ 2026-08-13 11:29 ` Lorenzo Stoakes (ARM) 4 siblings, 0 replies; 14+ messages in thread From: Lorenzo Stoakes (ARM) @ 2026-08-13 11:29 UTC (permalink / raw) To: Pedro Falcato Cc: Andrew Morton, David Hildenbrand, Liam R. Howlett, Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko, Brendan Jackman, Johannes Weiner, Zi Yan, linux-mm, linux-kernel On Tue, Aug 11, 2026 at 06:21:55PM +0100, Pedro Falcato wrote: > The current logic (allow up to $BURST prints per minute) can be entirely > replaced by the generic version in lib/ratelimit.c, used around the kernel. > > Do so. The only functional difference should be that the new logs will > read something like: > > KERN_WARNING "print_bad_page_map: %d callbacks suppressed\n", ... > > But that should be fine enough. > > Signed-off-by: Pedro Falcato <pfalcato@suse.de> Oh I love this :) seems __ratelimited() uses a try-lock on a spinlock internally but I don't think that's an issue, a spurious not-rate-limted output on any contention isn't really a big problem. So LGTM and: Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org> > --- > mm/memory.c | 30 +++--------------------------- > 1 file changed, 3 insertions(+), 27 deletions(-) > > diff --git a/mm/memory.c b/mm/memory.c > index 4134ac607ee0..b4be57b590ce 100644 > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -492,32 +492,8 @@ static inline void add_mm_rss_vec(struct mm_struct *mm, int *rss) > add_mm_counter(mm, i, rss[i]); > } > > -static bool is_bad_page_map_ratelimited(void) > -{ > - static unsigned long resume; > - static unsigned long nr_shown; > - static unsigned long nr_unshown; > - > - /* > - * Allow a burst of 60 reports, then keep quiet for that minute; > - * or allow a steady drip of one report per second. > - */ > - if (nr_shown == 60) { > - if (time_before(jiffies, resume)) { > - nr_unshown++; > - return true; > - } > - if (nr_unshown) { > - pr_alert("BUG: Bad page map: %lu messages suppressed\n", > - nr_unshown); > - nr_unshown = 0; > - } > - nr_shown = 0; > - } > - if (nr_shown++ == 0) > - resume = jiffies + 60 * HZ; > - return false; > -} > +/* Allow a burst of 60 bad page map reports per minute. */ > +static DEFINE_RATELIMIT_STATE(bad_page_map_ratelimit, 60 * HZ, 60); > > static void ptval_bytes_to_hex_str(char *buf, size_t buf_size, const void *entry, size_t entry_size) > { > @@ -633,7 +609,7 @@ static void print_bad_page_map(struct vm_area_struct *vma, > char entry_str[PTVAL_STR_MAX]; > pgoff_t index, anon_index; > > - if (is_bad_page_map_ratelimited()) > + if (!__ratelimit(&bad_page_map_ratelimit)) > return; > > mapping = vma->vm_file ? vma->vm_file->f_mapping : NULL; > -- > 2.55.0 > -- Cheers, Lorenzo ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 2/2] mm/page_alloc: replace custom bad page ratelimiting logic 2026-08-11 17:21 [PATCH 0/2] mm: replace custom ratelimiting logic Pedro Falcato 2026-08-11 17:21 ` [PATCH 1/2] mm: replace custom bad page map " Pedro Falcato @ 2026-08-11 17:21 ` Pedro Falcato 2026-08-11 19:13 ` Johannes Weiner ` (4 more replies) 2026-08-12 13:26 ` [PATCH 0/2] mm: replace custom " Mike Rapoport 2 siblings, 5 replies; 14+ messages in thread From: Pedro Falcato @ 2026-08-11 17:21 UTC (permalink / raw) To: Andrew Morton, David Hildenbrand Cc: Pedro Falcato, Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko, Brendan Jackman, Johannes Weiner, Zi Yan, linux-mm, linux-kernel The current logic (allow up to $BURST prints per minute) can be entirely replaced by the generic version in lib/ratelimit.c, used around the kernel. Do so. The only functional difference should be that the new logs will read something like: KERN_WARNING "bad_page: %d callbacks suppressed\n", ... But that should be fine enough. Signed-off-by: Pedro Falcato <pfalcato@suse.de> --- mm/page_alloc.c | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 12fac9084c48..9ccfd87bc273 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -613,31 +613,13 @@ static inline bool __maybe_unused bad_range(struct zone *zone, struct page *page } #endif +/* Allow a burst of 60 reports per minute */ +static DEFINE_RATELIMIT_STATE(bad_page_ratelimit, 60 * HZ, 60); + static void bad_page(struct page *page, const char *reason) { - static unsigned long resume; - static unsigned long nr_shown; - static unsigned long nr_unshown; - - /* - * Allow a burst of 60 reports, then keep quiet for that minute; - * or allow a steady drip of one report per second. - */ - if (nr_shown == 60) { - if (time_before(jiffies, resume)) { - nr_unshown++; - goto out; - } - if (nr_unshown) { - pr_alert( - "BUG: Bad page state: %lu messages suppressed\n", - nr_unshown); - nr_unshown = 0; - } - nr_shown = 0; - } - if (nr_shown++ == 0) - resume = jiffies + 60 * HZ; + if (!__ratelimit(&bad_page_ratelimit)) + goto out; pr_alert("BUG: Bad page state in process %s pfn:%05lx\n", current->comm, page_to_pfn(page)); -- 2.55.0 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] mm/page_alloc: replace custom bad page ratelimiting logic 2026-08-11 17:21 ` [PATCH 2/2] mm/page_alloc: replace custom bad page " Pedro Falcato @ 2026-08-11 19:13 ` Johannes Weiner 2026-08-11 19:39 ` Zi Yan ` (3 subsequent siblings) 4 siblings, 0 replies; 14+ messages in thread From: Johannes Weiner @ 2026-08-11 19:13 UTC (permalink / raw) To: Pedro Falcato Cc: Andrew Morton, David Hildenbrand, Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko, Brendan Jackman, Zi Yan, linux-mm, linux-kernel On Tue, Aug 11, 2026 at 06:21:56PM +0100, Pedro Falcato wrote: > The current logic (allow up to $BURST prints per minute) can be entirely > replaced by the generic version in lib/ratelimit.c, used around the kernel. > > Do so. The only functional difference should be that the new logs will > read something like: > > KERN_WARNING "bad_page: %d callbacks suppressed\n", ... > > But that should be fine enough. > > Signed-off-by: Pedro Falcato <pfalcato@suse.de> Acked-by: Johannes Weiner <hannes@cmpxchg.org> ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] mm/page_alloc: replace custom bad page ratelimiting logic 2026-08-11 17:21 ` [PATCH 2/2] mm/page_alloc: replace custom bad page " Pedro Falcato 2026-08-11 19:13 ` Johannes Weiner @ 2026-08-11 19:39 ` Zi Yan 2026-08-12 2:59 ` SJ Park ` (2 subsequent siblings) 4 siblings, 0 replies; 14+ messages in thread From: Zi Yan @ 2026-08-11 19:39 UTC (permalink / raw) To: Pedro Falcato, Andrew Morton, David Hildenbrand Cc: Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko, Brendan Jackman, Johannes Weiner, linux-mm, linux-kernel On Tue Aug 11, 2026 at 1:21 PM EDT, Pedro Falcato wrote: > The current logic (allow up to $BURST prints per minute) can be entirely > replaced by the generic version in lib/ratelimit.c, used around the kernel. > > Do so. The only functional difference should be that the new logs will > read something like: > > KERN_WARNING "bad_page: %d callbacks suppressed\n", ... > > But that should be fine enough. > > Signed-off-by: Pedro Falcato <pfalcato@suse.de> > --- > mm/page_alloc.c | 28 +++++----------------------- > 1 file changed, 5 insertions(+), 23 deletions(-) > LGTM. Acked-by: Zi Yan <ziy@nvidia.com> -- Best Regards, Yan, Zi ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] mm/page_alloc: replace custom bad page ratelimiting logic 2026-08-11 17:21 ` [PATCH 2/2] mm/page_alloc: replace custom bad page " Pedro Falcato 2026-08-11 19:13 ` Johannes Weiner 2026-08-11 19:39 ` Zi Yan @ 2026-08-12 2:59 ` SJ Park 2026-08-12 7:45 ` David Hildenbrand (Arm) 2026-08-13 14:01 ` Lorenzo Stoakes (ARM) 4 siblings, 0 replies; 14+ messages in thread From: SJ Park @ 2026-08-12 2:59 UTC (permalink / raw) To: Pedro Falcato Cc: SJ Park, Andrew Morton, David Hildenbrand, Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko, Brendan Jackman, Johannes Weiner, Zi Yan, linux-mm, linux-kernel On Tue, 11 Aug 2026 18:21:56 +0100 Pedro Falcato <pfalcato@suse.de> wrote: > The current logic (allow up to $BURST prints per minute) can be entirely > replaced by the generic version in lib/ratelimit.c, used around the kernel. > > Do so. The only functional difference should be that the new logs will > read something like: > > KERN_WARNING "bad_page: %d callbacks suppressed\n", ... > > But that should be fine enough. I agree that should be fine. This looks good cleanup to me. > > Signed-off-by: Pedro Falcato <pfalcato@suse.de> Reviewed-by: SJ Park <sj@kernel.org> Thanks, SJ [...] ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] mm/page_alloc: replace custom bad page ratelimiting logic 2026-08-11 17:21 ` [PATCH 2/2] mm/page_alloc: replace custom bad page " Pedro Falcato ` (2 preceding siblings ...) 2026-08-12 2:59 ` SJ Park @ 2026-08-12 7:45 ` David Hildenbrand (Arm) 2026-08-13 14:01 ` Lorenzo Stoakes (ARM) 4 siblings, 0 replies; 14+ messages in thread From: David Hildenbrand (Arm) @ 2026-08-12 7:45 UTC (permalink / raw) To: Pedro Falcato, Andrew Morton Cc: Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko, Brendan Jackman, Johannes Weiner, Zi Yan, linux-mm, linux-kernel On 8/11/26 19:21, Pedro Falcato wrote: > The current logic (allow up to $BURST prints per minute) can be entirely > replaced by the generic version in lib/ratelimit.c, used around the kernel. > > Do so. The only functional difference should be that the new logs will > read something like: > > KERN_WARNING "bad_page: %d callbacks suppressed\n", ... > > But that should be fine enough. > > Signed-off-by: Pedro Falcato <pfalcato@suse.de> > --- Nice :) Acked-by: David Hildenbrand (Arm) <david@kernel.org> -- Cheers, David ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/2] mm/page_alloc: replace custom bad page ratelimiting logic 2026-08-11 17:21 ` [PATCH 2/2] mm/page_alloc: replace custom bad page " Pedro Falcato ` (3 preceding siblings ...) 2026-08-12 7:45 ` David Hildenbrand (Arm) @ 2026-08-13 14:01 ` Lorenzo Stoakes (ARM) 4 siblings, 0 replies; 14+ messages in thread From: Lorenzo Stoakes (ARM) @ 2026-08-13 14:01 UTC (permalink / raw) To: Pedro Falcato Cc: Andrew Morton, David Hildenbrand, Liam R. Howlett, Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko, Brendan Jackman, Johannes Weiner, Zi Yan, linux-mm, linux-kernel On Tue, Aug 11, 2026 at 06:21:56PM +0100, Pedro Falcato wrote: > The current logic (allow up to $BURST prints per minute) can be entirely > replaced by the generic version in lib/ratelimit.c, used around the kernel. > > Do so. The only functional difference should be that the new logs will > read something like: > > KERN_WARNING "bad_page: %d callbacks suppressed\n", ... > > But that should be fine enough. > > Signed-off-by: Pedro Falcato <pfalcato@suse.de> LGTM so: Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org> > --- > mm/page_alloc.c | 28 +++++----------------------- > 1 file changed, 5 insertions(+), 23 deletions(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 12fac9084c48..9ccfd87bc273 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -613,31 +613,13 @@ static inline bool __maybe_unused bad_range(struct zone *zone, struct page *page > } > #endif > > +/* Allow a burst of 60 reports per minute */ > +static DEFINE_RATELIMIT_STATE(bad_page_ratelimit, 60 * HZ, 60); > + > static void bad_page(struct page *page, const char *reason) > { > - static unsigned long resume; > - static unsigned long nr_shown; > - static unsigned long nr_unshown; > - > - /* > - * Allow a burst of 60 reports, then keep quiet for that minute; > - * or allow a steady drip of one report per second. > - */ > - if (nr_shown == 60) { > - if (time_before(jiffies, resume)) { > - nr_unshown++; > - goto out; > - } > - if (nr_unshown) { > - pr_alert( > - "BUG: Bad page state: %lu messages suppressed\n", > - nr_unshown); > - nr_unshown = 0; > - } > - nr_shown = 0; > - } > - if (nr_shown++ == 0) > - resume = jiffies + 60 * HZ; > + if (!__ratelimit(&bad_page_ratelimit)) > + goto out; > > pr_alert("BUG: Bad page state in process %s pfn:%05lx\n", > current->comm, page_to_pfn(page)); > -- > 2.55.0 > -- Cheers, Lorenzo ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 0/2] mm: replace custom ratelimiting logic 2026-08-11 17:21 [PATCH 0/2] mm: replace custom ratelimiting logic Pedro Falcato 2026-08-11 17:21 ` [PATCH 1/2] mm: replace custom bad page map " Pedro Falcato 2026-08-11 17:21 ` [PATCH 2/2] mm/page_alloc: replace custom bad page " Pedro Falcato @ 2026-08-12 13:26 ` Mike Rapoport 2 siblings, 0 replies; 14+ messages in thread From: Mike Rapoport @ 2026-08-12 13:26 UTC (permalink / raw) To: Pedro Falcato Cc: Andrew Morton, David Hildenbrand, Lorenzo Stoakes, Liam R. Howlett, Vlastimil Babka, Suren Baghdasaryan, Michal Hocko, Brendan Jackman, Johannes Weiner, Zi Yan, linux-mm, linux-kernel On Tue, Aug 11, 2026 at 06:21:54PM +0100, Pedro Falcato wrote: > The kernel has a perfectly cromulent and mostly-equivalent variant in > lib/ratelimit.c that can be used. > > To: Andrew Morton <akpm@linux-foundation.org> > To: David Hildenbrand <david@kernel.org> > Cc: Lorenzo Stoakes <ljs@kernel.org> > Cc: "Liam R. Howlett" <liam@infradead.org> > Cc: Vlastimil Babka <vbabka@kernel.org> > Cc: Mike Rapoport <rppt@kernel.org> > Cc: Suren Baghdasaryan <surenb@google.com> > Cc: Michal Hocko <mhocko@suse.com> > Cc: Brendan Jackman <brendan.jackman@linux.dev> > Cc: Johannes Weiner <hannes@cmpxchg.org> > Cc: Zi Yan <ziy@nvidia.com> > Cc: linux-mm@kvack.org > Cc: linux-kernel@vger.kernel.org > > Pedro Falcato (2): > mm: replace custom bad page map ratelimiting logic > mm/page_alloc: replace custom bad page ratelimiting logic For the series: Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org> > mm/memory.c | 30 +++--------------------------- > mm/page_alloc.c | 28 +++++----------------------- > 2 files changed, 8 insertions(+), 50 deletions(-) > > -- > 2.55.0 > -- Sincerely yours, Mike. ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2026-08-13 14:01 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-08-11 17:21 [PATCH 0/2] mm: replace custom ratelimiting logic Pedro Falcato 2026-08-11 17:21 ` [PATCH 1/2] mm: replace custom bad page map " Pedro Falcato 2026-08-11 19:13 ` Johannes Weiner 2026-08-11 19:37 ` Zi Yan 2026-08-12 2:56 ` SJ Park 2026-08-12 7:45 ` David Hildenbrand (Arm) 2026-08-13 11:29 ` Lorenzo Stoakes (ARM) 2026-08-11 17:21 ` [PATCH 2/2] mm/page_alloc: replace custom bad page " Pedro Falcato 2026-08-11 19:13 ` Johannes Weiner 2026-08-11 19:39 ` Zi Yan 2026-08-12 2:59 ` SJ Park 2026-08-12 7:45 ` David Hildenbrand (Arm) 2026-08-13 14:01 ` Lorenzo Stoakes (ARM) 2026-08-12 13:26 ` [PATCH 0/2] mm: replace custom " Mike Rapoport
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.