From mboxrd@z Thu Jan 1 00:00:00 1970 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: 8bit 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 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 --- 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