From nobody Tue Sep 29 06:08:43 2026 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (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 7AEFF3B5E08 for ; Tue, 11 Aug 2026 17:22:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786468938; cv=none; b=tp5MMv1aqbr6Gfr7xIbtSrik3fjzEhsemEOHHdh9fqqCUBX4UomdonSHepRjb9mUCjix3eQnED/uWmIwy7Dkw2QK8cDflc+qeCivgZlByc75dxAUz9yr60ip8Ox+18ZmAlWIDyEIgal5hFtJ2cXAjco0ofWgcqPegB7Saj+L+F8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786468938; c=relaxed/simple; bh=CVAqbrklCwKLjYtyDqWbHvaa/oS2I+vBK0cgWyeihDY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L8tHlDkyBRVKmaTXc2JRPujdbLBXJEnG8uhL0IjomKYXVN2BqB0JO5trKUs809z8+F8lJ1UFRoNuJnWfloxRESkEuZ4rvsmgG9wcbZ/PlrYoEY3e9/M9URHeG2bysmAgyO5OEMGHmZoNsfenzpAQCZQXme4TuADk3Yl/OB7Slts= 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=TVRmqs7y; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=lr81ZlDe; arc=none smtp.client-ip=195.135.223.131 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="TVRmqs7y"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="lr81ZlDe" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104: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-out2.suse.de (Postfix) with ESMTPS id 6F6083E28; Tue, 11 Aug 2026 17:22:10 +0000 (UTC) Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1786468930; 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=SIxFR5T1oCJWCYenB/yqWbkPgsx+4uxFKjjdmptf6BY=; b=TVRmqs7yGQZ7KKUHjCzM1QE9n/S6E4xBaN7F+Hk76LoZ07xt/724Uxc0Xuz2GJBk/NKN54 HFTTHRdEjMEB3DvmJEISOItx2VvJ8y8fCPnYY2xsjyuRi04D9iS9kyOBiqC594KEO58ssi DPVUYtxV/WjkWHnQYUtbeiFntQOhFBI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1786468930; 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=SIxFR5T1oCJWCYenB/yqWbkPgsx+4uxFKjjdmptf6BY=; b=lr81ZlDeeRT19Y9sx8xev7hYNSa3Dnwrrr0HO26qPIa6XpbNtUSnYNmbD6RH0Z3Ff+SM9t 7UeSxtgGv7iLnVDg== 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 73A99779C0; Tue, 11 Aug 2026 17:22:09 +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 AHSqGEFae2r4TAAAD6G6ig (envelope-from ); Tue, 11 Aug 2026 17:22:09 +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 1/2] mm: replace custom bad page map ratelimiting logic Date: Tue, 11 Aug 2026 18:21:55 +0100 Message-ID: <20260811172156.356053-2-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: quoted-printable X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Queue-Id: 6F6083E28 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spam-Flag: NO X-Spam-Score: -4.00 X-Spam-Level: X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action Content-Type: text/plain; charset="utf-8" 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 Acked-by: David Hildenbrand (Arm) Acked-by: Johannes Weiner Acked-by: Mike Rapoport (Microsoft) Acked-by: Vlastimil Babka (SUSE) Acked-by: Zi Yan Reviewed-by: Lorenzo Stoakes (ARM) Reviewed-by: SJ Park --- 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]); } =20 -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 =3D=3D 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 =3D 0; - } - nr_shown =3D 0; - } - if (nr_shown++ =3D=3D 0) - resume =3D 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); =20 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 *v= ma, char entry_str[PTVAL_STR_MAX]; pgoff_t index, anon_index; =20 - if (is_bad_page_map_ratelimited()) + if (!__ratelimit(&bad_page_map_ratelimit)) return; =20 mapping =3D vma->vm_file ? vma->vm_file->f_mapping : NULL; --=20 2.55.0 From nobody Tue Sep 29 06:08:43 2026 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: quoted-printable 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)[] Content-Type: text/plain; charset="utf-8" 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 Acked-by: David Hildenbrand (Arm) Acked-by: Johannes Weiner Acked-by: Mike Rapoport (Microsoft) Acked-by: Vlastimil Babka (SUSE) Acked-by: Zi Yan Reviewed-by: Lorenzo Stoakes (ARM) Reviewed-by: SJ Park --- 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 zo= ne *zone, struct page *page } #endif =20 +/* 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 =3D=3D 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 =3D 0; - } - nr_shown =3D 0; - } - if (nr_shown++ =3D=3D 0) - resume =3D jiffies + 60 * HZ; + if (!__ratelimit(&bad_page_ratelimit)) + goto out; =20 pr_alert("BUG: Bad page state in process %s pfn:%05lx\n", current->comm, page_to_pfn(page)); --=20 2.55.0