From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7794244E676 for ; Tue, 11 Aug 2026 17:22:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786468942; cv=none; b=XW+MYbkk4Sr681EKJSG5K4EYI/WK/34AbT7EtIAbrn11PqUQNgrSV/xMvfqcspB5o9xgnstkiShmFnODUElyi+aBpJP3keVkwTCpcOc+QyYUY+t3mUVSoyl/eVfJnT5ChGuVZ2611ZauaUjveWMbP6CVkc2mxWoZ6gljAJ6KmpA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786468942; c=relaxed/simple; bh=VpHkceAC85L3N0y+qp/Pmw5NqAGsIOGpv78n9k6p9dI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e2KG5ohufeWjev0YsTma2pDUGB8UiG+tiEpn/h6Ua0RnA4lWsv3vK6STlteTKgOFFd1uOn81iOThKWsH3pgQmMe74KkmJqw2WDHjRyrbWua8uVXtT+hBhZan1fy3SbaKK8P2+AZLU7zK1ZIhOnUCf10muG0+GeuqckXSBDRIdvY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=bmkn/KxE; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=o6vE+0Uy; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=kg9th9bj; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=WyX1Rtkz; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="bmkn/KxE"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="o6vE+0Uy"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="kg9th9bj"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="WyX1Rtkz" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 6843881E24; Tue, 11 Aug 2026 17:22:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1786468935; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QVVRJXXPliRw542MzPPo/aSrNZpWcD5mogMspae6XJg=; b=bmkn/KxETuYeMw7x8dcFnw9dIhsrAQCJC5yTHtppE9HguWipXZpNneGBjsH2nVCE5BRfSc qRYCAMZUJgSx+uYsxrAm3j1Y+eSvbonBTjslA3dQmuLIC26rs8EQvW1LpcDP7CGkUdlgMz cScUFBy1a8Uy3gMcYbsRL7yGFv72uew= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1786468935; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QVVRJXXPliRw542MzPPo/aSrNZpWcD5mogMspae6XJg=; b=o6vE+0UyArwueO4JKqOqo64yikHdC0UvQ9cq//mu+V9uHVnJ1P6qeg/IEIkY41KvXTjJLd /tiALZCDWc+M1gDw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1786468931; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QVVRJXXPliRw542MzPPo/aSrNZpWcD5mogMspae6XJg=; b=kg9th9bj0aBc+OEPaRUPY/JpVcY2EBCoCSOLU/h60H2ruut+EXaCqrB1DY1P3eYPUVqQmF Ov9RDagYfXAe0AsgXw3dMqxtfNGaXVVE2jltvBhk+HER+8Q5LbvalcBp6Va3JUk0XT92Nj I/Rnt0EeHOHjp5LR1FQ4A5nscrnJAOY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1786468931; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QVVRJXXPliRw542MzPPo/aSrNZpWcD5mogMspae6XJg=; b=WyX1RtkzCgFCkwYHcdrvhNzeFN32s09tnGRHNebjjL4A0F4TyFBmlS8fF0cV5J+chMbAA4 SROgW/k1rRDDofDw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 7CE5C779C3; Tue, 11 Aug 2026 17:22:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id SMgLG0Jae2r4TAAAD6G6ig (envelope-from ); Tue, 11 Aug 2026 17:22:10 +0000 From: Pedro Falcato 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@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] mm/page_alloc: replace custom bad page ratelimiting logic Date: Tue, 11 Aug 2026 18:21:56 +0100 Message-ID: <20260811172156.356053-3-pfalcato@suse.de> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260811172156.356053-1-pfalcato@suse.de> References: <20260811172156.356053-1-pfalcato@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -6.80 X-Spam-Level: X-Spam-Flag: NO X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.995]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCPT_COUNT_TWELVE(0.00)[14]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:email,suse.de:mid]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_DN_SOME(0.00)[]; RCVD_TLS_ALL(0.00)[] 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 --- 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