All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: Pedro Falcato <pfalcato@suse.de>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	 David Hildenbrand <david@kernel.org>,
	"Liam R. Howlett" <liam@infradead.org>,
	 Vlastimil Babka <vbabka@kernel.org>,
	Mike Rapoport <rppt@kernel.org>,
	 Suren Baghdasaryan <surenb@google.com>,
	Michal Hocko <mhocko@suse.com>,
	 Brendan Jackman <brendan.jackman@linux.dev>,
	Johannes Weiner <hannes@cmpxchg.org>, Zi Yan <ziy@nvidia.com>,
	 linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] mm/page_alloc: replace custom bad page ratelimiting logic
Date: Thu, 13 Aug 2026 15:01:14 +0100	[thread overview]
Message-ID: <an3OI_aflDc0ZxO7@lucifer> (raw)
In-Reply-To: <20260811172156.356053-3-pfalcato@suse.de>

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


  parent reply	other threads:[~2026-08-13 14:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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) [this message]
2026-08-12 13:26 ` [PATCH 0/2] mm: replace custom " Mike Rapoport

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=an3OI_aflDc0ZxO7@lucifer \
    --to=ljs@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=brendan.jackman@linux.dev \
    --cc=david@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=pfalcato@suse.de \
    --cc=rppt@kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.