From nobody Sat Apr 4 00:05:54 2026 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 8D456846F for ; Sun, 22 Mar 2026 03:03:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774148600; cv=none; b=Si/cwX+cpNLijNAzr3qp8KgUBdqcnNX8sSwv43J8WHgcQKvYOag9hMlPEve+gQAuT4NN4UDpJf3+8StsLer/VNT25hOQSwliUCPIfGbi3LJpWZptHbJSOoUogxTDJDLDxtowbMexNn3jNypsOj0NWoYLMsqcALpMp13Dwjp3/+E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774148600; c=relaxed/simple; bh=/nxqs+nQO3cGzxs2km3YCisCkRfcRRl/XxK2m+KOwSY=; h=Date:From:To:cc:Subject:Message-ID:MIME-Version:Content-Type; b=NT6slQl9eL4y75Iu1BCuvTBe+i4c6YYxYHNmOWLuAUXm/cSsOKIlD17emrJbmz9/SDpF+NHQYAhzpBWB+j/vILRBV6qvNjZvrkRFfDOsaBiNRLy0XmWflXU1jW1+r5HOleneu0XAON93PLrc0yqclJ0BOGQW79ItUdm0Dg5apUU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=l0WClfTm; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="l0WClfTm" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2b052562254so106365ad.0 for ; Sat, 21 Mar 2026 20:03:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1774148599; x=1774753399; darn=vger.kernel.org; h=mime-version:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to; bh=fVSYBz8Z8p4RnssOWosJ/Ow1yuYWBSen1k8jPwBg8ro=; b=l0WClfTmF7RC4aR/DXqxb2KX8CY6yCjjrR4lv3dpMhANWx1w2r3PP7boeGFo20Wp6j hB3rHja217uOay2CJguuN7eI/on8GNVyUoeiMgBlIjFV/OlXqZ8nOpVMN1mFYRY1cgsT ENs/u1/ACSHNGH1nefyklRJ6B/SRUN3dlOnGg+ouCtvchkusCF+ih9ulEgsv3SMRSNwS Lb1WDpatziZH4x9DD2Dtb+8UaZma65EVgHAFgHmcW4Y1DXT4yP8eKkt9xyH0y5iPYMPM KxgEZTNtePyFmZd8Enpgva84ZHNTZdh7dWiFRXAbAprMjfCad3AVfiQdndhtiHxbwpGW iq+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774148599; x=1774753399; h=mime-version:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fVSYBz8Z8p4RnssOWosJ/Ow1yuYWBSen1k8jPwBg8ro=; b=g4t6jl6mBOKAwtzh6WzVjEijsC1w0F6JpruYc2bJL73Jax+2+I/tWyn0zUBFcn1SDJ S2ESc0VQfFla4t6NxYvxPLPekBGbtNWf8a0UvkW9M3AiLP/4IiV65pUWmVeJK85HRU1p zHvzqiLMSTBKq7b0bNEOA3Ek0D+Z8KWpuBhdhqyj6deAQFCMOOWLikUVKUravBqUG2+c kQQepK1GaSQIYNLUa/ZySBJH1x98e/bkwa/JM58n3oxA5rvUZ2UqXugI9/jYQ0gBHaLf mnMpj2bNsxeoRHnzRj6XYykHGlPkzY4mUXnAt+PhyT+IA5MQ3IRtTpoDVx4Ho4UdcH6O IOYA== X-Forwarded-Encrypted: i=1; AJvYcCUZ7OWn9h7MD5qqG0lZAGtmoO2ELWIEjsamLMhx2EJJMI2VnoNvz6MzHsrc8xk68gBM5f58jjqia1MymEs=@vger.kernel.org X-Gm-Message-State: AOJu0Yx7v+rjNi9MNB4F2RWVZCDvhYQlIaaMarHSmnMN7MBGWNd/YjvP gwnaOppKI8/1CTP0wyq8DV4GkzmhpnXZPEJ8eEMsMhhJZ3WcXKfheeIh0nyid3va/Q== X-Gm-Gg: ATEYQzzCxuCQ/AS73BK8680nxx8p7aKtpLSyRCJTJF1KU8355dO1MUmoggvGMnjdJkZ IaZnXISL7dYVv+ytchmqaoOTCAz22+kZ8GgYUT4CqSegrxT81CE8bCIDYKwotfzhMyt3L+t0U9L lVpcFdc2C5vHL69b7Vus6chXCE1//RrLB/LfAGjqLDFiJx96fzgWkxsOT/cu9f1r7ucyvBxxIaK ZgcgseVyXtJMNqfEn6FgvjVRcTFDt8vUNyKNPv67GwFqrUS2Z+qMpPFpPfggGq1CiDRr0DJtX1H FRlkCd1s+jli6Pzn4k9sGHGH20ZZfuAz7bKqaM1wYWs+melDmGXSE/+Potig6/tm2gX9Py9HJfP xZGH/21JwyHH+UO1wMKQqrTfYknPheZvyutedJUDbk+3lApH6wTEXTFTDWAWUQtAjQh94v/5WP+ xJUnYTGFWmSm0NVFt1GLPnQLPgyHoN7BWUt954K1f+W46WK9SW6WAkv5WGEgDszMWCVp4GtOZGl cwQ6pkIgAsQMKOEMvAtSVBG3v35oR2JQNhYSsHo5WAlEM6waLLOZ2gktcdDNQ== X-Received: by 2002:a17:903:234b:b0:2ae:c566:bd99 with SMTP id d9443c01a7336-2b08b4fd93dmr2418915ad.22.1774148598281; Sat, 21 Mar 2026 20:03:18 -0700 (PDT) Received: from [2a00:79e0:2eb0:8:95a:51de:9167:5c82] ([2a00:79e0:2eb0:8:95a:51de:9167:5c82]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82b03be3396sm6104262b3a.27.2026.03.21.20.03.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Mar 2026 20:03:17 -0700 (PDT) Date: Sat, 21 Mar 2026 20:03:16 -0700 (PDT) From: David Rientjes To: Andrew Morton , Vlastimil Babka cc: Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC] mm, page_alloc: reintroduce page allocation stall warning Message-ID: <30945cc3-9c4d-94bb-e7e7-dde71483800c@google.com> 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 Content-Type: text/plain; charset="utf-8" Previously, we had warnings when a single page allocation took longer than reasonably expected. This was introduced in commit 63f53dea0c98 ("mm: warn about allocations which stall for too long"). The warning was subsequently reverted in commit 400e22499dd9 ("mm: don't warn about allocations which stall for too long") but for reasons unrelated to the warning itself. Page allocation stalls in excess of 10 seconds are always useful to debug because they can result in severe userspace unresponsiveness. Adding this artifact can be used to correlate with userspace going out to lunch and to understand the state of memory at the time. There should be a reasonable expectation that this warning will never trigger given it is very passive, it starts with a 10 second floor to begin with. If it does trigger, this reveals an issue that should be fixed: a single page allocation should never loop for more than 10 seconds without oom killing to make memory available. Unlike the original implementation, this implementation only reports stalls that are at least a second longer than the longest stall reported thus far. Signed-off-by: David Rientjes --- mm/page_alloc.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4706,6 +4706,36 @@ check_retry_cpuset(int cpuset_mems_cookie, struct al= loc_context *ac) return false; } =20 +static unsigned long max_alloc_stall_warn_msecs =3D 10 * 1000L; + +static void check_alloc_stall_warn(gfp_t gfp_mask, nodemask_t *nodemask, + unsigned int order, unsigned long alloc_start_time) +{ + static DEFINE_SPINLOCK(max_alloc_stall_lock); + unsigned long stall_msecs =3D jiffies_to_msecs(jiffies - alloc_start_time= ); + unsigned long flags; + + if (likely(stall_msecs <=3D READ_ONCE(max_alloc_stall_warn_msecs))) + return; + if (gfp_mask & __GFP_NOWARN) + return; + + spin_lock_irqsave(&max_alloc_stall_lock, flags); + if (stall_msecs > max_alloc_stall_warn_msecs) { + pr_warn("%s: page allocation stall for %lu secs: order:%d, mode:%#x(%pGg= ) nodemask=3D%*pbl", + current->comm, stall_msecs / MSEC_PER_SEC, order, gfp_mask, &gfp_mask, + nodemask_pr_args(nodemask)); + cpuset_print_current_mems_allowed(); + pr_cont("\n"); + dump_stack(); + warn_alloc_show_mem(gfp_mask, nodemask); + + /* Only print future stalls that are more than a second longer */ + WRITE_ONCE(max_alloc_stall_warn_msecs, stall_msecs + MSEC_PER_SEC); + } + spin_unlock_irqrestore(&max_alloc_stall_lock, flags); +} + static inline struct page * __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, struct alloc_context *ac) @@ -4726,6 +4756,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int o= rder, int reserve_flags; bool compact_first =3D false; bool can_retry_reserves =3D true; + unsigned long alloc_start_time =3D jiffies; =20 if (unlikely(nofail)) { /* @@ -4990,6 +5021,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int o= rder, warn_alloc(gfp_mask, ac->nodemask, "page allocation failure: order:%u", order); got_pg: + check_alloc_stall_warn(gfp_mask, ac->nodemask, order, alloc_start_time); return page; }