From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 6CFB837CD2E for ; Mon, 30 Mar 2026 03:17:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774840655; cv=none; b=q8Rts+OSoFuPktYWX71irIMfy1SEUitvFfgG1r6Pk0/AvDbrSggYfviRQdtziI25Hrw7LetwuX/E9k+JLLVaRjrGq51hvIPyOudKrA80dI20HmzCV79AZtsul2UGsv+nMwW7MIMqmP/6ih0oO3Vlx3zcl8zWWX4uLO6b6rxgqtU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774840655; c=relaxed/simple; bh=leCGs2E2/RYWvyxtjIdMHYtCcR5huYLaLndiJf5ULzs=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=ssoX2riEUFHxpHVGRqzOfHJVTJ5DImeU0zZPE58B62OhhCMbLJ10iqj1bHbtEf/wo5JaIUQqASNovFj5QwtQ3Y4MJhy8kEL0bK3mUJUcKcoQOwhug8/U8JrIsRdBD4/HlGroBFQW2qr/1q6SpqftGLmmxvOnQ5q2ZJ6AAxFxGhc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=1bk7XnxG; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="1bk7XnxG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2EADFC116C6; Mon, 30 Mar 2026 03:17:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1774840654; bh=leCGs2E2/RYWvyxtjIdMHYtCcR5huYLaLndiJf5ULzs=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=1bk7XnxGiZBM4qXQX8H4y4Uggw4oKnzOUa5CWw4GSnkRwZrp/KsrsbRJiyv1bNvOF VRlvL10CW/oVS9fJU7CWkJqdrBZFk1q+ws1HooWh+Ppuj+JP8jJN5y8QujkesbFQiU aGbjpVbhyxr1w5OhDzpa8mPSU1XLe9T/6FYvQUNA= Date: Sun, 29 Mar 2026 20:17:33 -0700 From: Andrew Morton To: David Rientjes Cc: Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan , Petr Mladek , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [patch] mm, page_alloc: reintroduce page allocation stall warning Message-Id: <20260329201733.6a4647ade4751e761034b9b9@linux-foundation.org> In-Reply-To: <231154f8-a3c3-229a-31a7-f91ab8ec1773@google.com> References: <30945cc3-9c4d-94bb-e7e7-dde71483800c@google.com> <231154f8-a3c3-229a-31a7-f91ab8ec1773@google.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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-Transfer-Encoding: 7bit On Sun, 29 Mar 2026 18:08:52 -0700 (PDT) David Rientjes wrote: > 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 will only be emitted when a page > allocation takes longer than 10 seconds. 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 once for the system every 10 seconds. Otherwise, many concurrent > reclaimers could spam the kernel log unnecessarily. Stalls are only > reported when calling into direct reclaim. > > ... > > +static void check_alloc_stall_warn(gfp_t gfp_mask, nodemask_t *nodemask, > + unsigned int order, unsigned long alloc_start_time) > +{ > + static DEFINE_SPINLOCK(alloc_stall_lock); > + unsigned long stall_msecs = jiffies_to_msecs(jiffies - alloc_start_time); > + > + if (likely(stall_msecs < ALLOC_STALL_WARN_MSECS)) > + return; > + if (time_before(jiffies, READ_ONCE(alloc_stall_warn_jiffies))) > + return; > + if (gfp_mask & __GFP_NOWARN) > + return; > + > + if (!spin_trylock(&alloc_stall_lock)) > + return; > + > + if (time_after_eq(jiffies, alloc_stall_warn_jiffies)) { > + WRITE_ONCE(alloc_stall_warn_jiffies, > + jiffies + msecs_to_jiffies(ALLOC_STALL_WARN_MSECS)); > + spin_unlock(&alloc_stall_lock); > + > + pr_warn("%s: page allocation stall for %lu secs: order:%d, mode:%#x(%pGg) nodemask=%*pbl", > + current->comm, stall_msecs / MSEC_PER_SEC, order, gfp_mask, &gfp_mask, > + nodemask_pr_args(nodemask)); Snould we use dump_page() in here? It prints more info, does the snapshotting thing. > + cpuset_print_current_mems_allowed(); > + pr_cont("\n"); > + dump_stack(); > + warn_alloc_show_mem(gfp_mask, nodemask); > + return; > + } > + > + spin_unlock(&alloc_stall_lock); > +} > +