From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF6D4481236 for ; Thu, 13 Aug 2026 14:01:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786629695; cv=none; b=MKoEVyOUFKXniFv4RrWwK2YKcWZsoQ7z+gVpilD+iHZXxJ9Zo0wyyE4blctS70+qT2HwVIImy6NP0aE7QkG5ijGk4MNwM7JXO9I6m2GsCprmfBDklTDSRgKW0xv+3xdbPUy39i49/8YFxAVJzg63o2dyPmaN6NZ4zLovbgx8UyA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786629695; c=relaxed/simple; bh=booYxczfvW5RU3EwLrw6NAfIn4pzdLxS6yWfqTeJcs8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=q3SqHOSZk4x9XfkENjhBlvbrKwPEoWlm9b8RHFRs1fXtmSFytLHrr8NUcLdf1I2mBoJvylqZZJNeQ4rN+gNd/dHfJNkKpUeG3S64NrUV7OJ4hi0+fnsJWky9H8TL1rJXNfT6VeskPnm1gZOOYxXOC+vox6r6vMI7hgrnLR5ER7Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=b5pyqJYf; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="b5pyqJYf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0AC41F00A3A; Thu, 13 Aug 2026 14:01:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1786629693; bh=QkIqkMTKmkFkOVJjNZ4y+l5KuM1u+wDEcZU7VVL0jWk=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=b5pyqJYfyrjA8JeWy0+LAbakSmadU1JZ6YkaMIVF9pvzBsCU50kUUiGHT+MMTJL2X CR6JVa8MmXk0Ts8uITDGupmcikB0MwBvhyU1PzKcJYuyFKXEdQF4HTRl3nfwiLBQu8 hP/HVoKeoj2WL9KNqEdc/GqgvS19ni7gqqCaSRHOwJkORnVrSjTKNssOPPMCzJ0N4d fcw/pyvVFPh5AUddcwuooDnnTRHFYLnKqdguwlWXC2R/nAY1v/mZ5OWrzRC1omVnOo PXCrVjUk6KWO3gN+wtlhL1vEXh2fCc8i0v2JbZNRONlWJLmAEEBDYoGWdM4R6iIEXe KmGdQpO+YrsFw== Date: Thu, 13 Aug 2026 15:01:14 +0100 From: "Lorenzo Stoakes (ARM)" 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@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] mm/page_alloc: replace custom bad page ratelimiting logic Message-ID: References: <20260811172156.356053-1-pfalcato@suse.de> <20260811172156.356053-3-pfalcato@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 LGTM so: Reviewed-by: Lorenzo Stoakes (ARM) > --- > 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