From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) (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 EDE452C11E4 for ; Wed, 1 Jul 2026 21:02:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782939728; cv=none; b=VDeEOzXPWJkODQxP9rcn/mXIWntW3DG7flKhW6H9hXYQ6/OENVdSnISuqjUkMkSutgQeo65j+10KRF1Q1/CkxQXmBPpSW3dPn3tQ7rZ488xYyNPHcLALywI5DWnUjrNlhhzOuNIzEBXJ8r4iqs50XIdIAnXfGTqpKqFZTS6YfGI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782939728; c=relaxed/simple; bh=vUClexfLfN6ME6y7QwDde5v/jnshDjukfpJTu2NZV34=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=GNiHZZgbmlWXftC8Iypsv2a/tAl+mGBzOiiVDtEXJ6jeK6D0dPQGk+QVzMxV0LZHW8cmPSVH/zlzV2zmecs1D2jz3tk7CBMSCaxCoxcWozZOGTaQTTFiAuxKfwDSGUCOLK63hy44Y2AYke9rLICswK1/KcmoVIvZsHqcN1fZSGs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org; spf=pass smtp.mailfrom=cmpxchg.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b=iayr+BE6; arc=none smtp.client-ip=209.85.160.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b="iayr+BE6" Received: by mail-qt1-f172.google.com with SMTP id d75a77b69052e-51c19f91d7dso7383231cf.1 for ; Wed, 01 Jul 2026 14:02:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg.org; s=google; t=1782939726; x=1783544526; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=CgoJ3yv/kd4nt172CXBYk0k1UCgr2gZrqUzf4dc6O8U=; b=iayr+BE6K4mGjeqSSfy6B3+1wgsXRjVrwUAiq1DyCDCKYK80UVQaySxVWtHGdtjCi2 AhvI4f+xVylKB3ZqHIaO0fbbB5GWURTrwftERK5Rr05UID+gAC0Uae8cMA92WVvILThb Qv+4svnqTYKhgjsfghPLtxhyxA59fPw61F0kSqdfzJFHhFTUY0FbqT4y4TlTVPWbSW90 GD6BXMVIKDFfNAyuf5f6bTp4qHXd16O1NU++6yNQgRMaWzlyT5JD2No+k2+nQ4nY8H7E 59i4iVqLLF8jL8Dzm1xTfecxPLExL6RLY/WiuNaHSzHWLmAS3lG+xBllV4Tewvy+2V+I 0fCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782939726; x=1783544526; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CgoJ3yv/kd4nt172CXBYk0k1UCgr2gZrqUzf4dc6O8U=; b=cAAk7xBsnJ3Ybq1zgUHJ9C/KypZcYYFHi/rtB+Yy/TZskXUyFjN8KlQhHk1RP2lEVO 94DXaDWzg8bUgUcRSf5CnArlt4gw+HN9DcJeDSf2zB5JSwfeV5S+s06E7XWrerAmtS9C noqd0FonSTaagqVyLlsJioBfNjYb1as0uj75+tpybs3qTL++Au/4o0LoMBhmEgHo4x8r Mr951+BVRttDeSicZ6fvE2zdXKlNjVpevYbBZFV6zOEPszclLXOyrm65dzsU6mwzHS8j /t7Oapf3+0Au3n6SgxAtxjcEC9oSk8XqfC2OQdgfUpbtCL74bv+ybqp+jChf5+kkNK6H Gy/w== X-Forwarded-Encrypted: i=1; AFNElJ8ECr/sgwoCBYAQQimB4UjwEOastod/4b0Jc9kMtvTAXxGNccc5ZAsyaAhMkmuCv+ejIyklKtTtbN86vcc=@vger.kernel.org X-Gm-Message-State: AOJu0YzFHN1XvwBMr8N4l1sZwwNkpVYNSMI0hTxXNda13xiAZNy+UV5X 0/92PNYucMmcQr0LzBzJ4j82NMWj1STN5zh5mhSDr2uFxYcXSN0ybLho6DQ4TU5cfQU= X-Gm-Gg: AfdE7cl5hzWTyid4q7v7ATbtGcM/K1igN2g1J5zHmV0LL0t4gJwQR4+9AZfP6ZGmLIZ 2RTJb7v84adoqOfqIhDQt+zJbKojnPFpdQ7AWUh2axO5krjFvU/8pIx13nn7cjIlMlYe0FlnaHo /bJt8H4fVZIdEpNjSF6dzzOm6Wphms3mJtsgYl55TLoWTMLPP3xH2qTJoSBz2LXHYGVW5iNkLkn auJcwNqlWDIPzsYP5Sb9PP6mo3pGWoRMqRqOiPOB89XV+bQCJ0is3KKQHdcZfoH0twKb9rWTrY3 yQr+jT7veznl9qUAHDhIz6OcYU9oEtXp58SDTl3Yf+zSvGh/iaiowcMt74/rxdyUisZg+yKzacy hrT8pvb96+2tsLMlkjtagAc1xIA9J83PzCrgGLg9ldj9y1BRSh7NUXE8eH5Mj5mgO0OD+zkCO1z wdTSq1uKBENiM= X-Received: by 2002:a05:622a:1a84:b0:51c:1f97:e860 with SMTP id d75a77b69052e-51c2ace8f61mr32125791cf.3.1782939725667; Wed, 01 Jul 2026 14:02:05 -0700 (PDT) Received: from localhost ([2603:7001:f100:500:365a:60ff:fe62:ff29]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-51c30c4c3c8sm625881cf.23.2026.07.01.14.02.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2026 14:02:03 -0700 (PDT) Date: Wed, 1 Jul 2026 17:02:02 -0400 From: Johannes Weiner To: "Vlastimil Babka (SUSE)" Cc: Andrew Morton , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Zi Yan , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Mike Rapoport , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/4] mm: page_alloc: fix non-movable reclaim storm in defrag_mode Message-ID: References: <20260626182215.1107966-1-hannes@cmpxchg.org> <20260626182215.1107966-5-hannes@cmpxchg.org> <3f013cf5-008a-4207-85ce-d6f7c0296d99@kernel.org> 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-Disposition: inline In-Reply-To: <3f013cf5-008a-4207-85ce-d6f7c0296d99@kernel.org> On Wed, Jul 01, 2026 at 08:06:03PM +0200, Vlastimil Babka (SUSE) wrote: > On 6/26/26 20:21, Johannes Weiner wrote: > > As we deployed defrag_mode into Meta production, pressure spikes and > > excessive swapping were observed on some workloads. Tracing confirmed > > that this is unmovable/reclaimable requests spinning in the allocator > > and direct reclaim, causing excessive amounts of swap. > > > > The initial plan for defrag_mode was to rely on kswapd/kcompactd to > > produce blocks, and if those are overwhelmed under high pressure, let > > the allocator fall back (__rmqueue_steal()) after its retry loops. > > However, that retrying results in more reclaim on some of these > > workloads than we'd hoped, sometimes excessively so, spurred on by the > > !costly order conditions in should_reclaim_retry(). > > > > The storms are dependent on the request type. Reclaim will inevitably > > make room in existing movable blocks, since that's where the LRU pages > > live. So if movable requests retry on reclaim, they make progress. > > > > When non-movable requests spin in reclaim that isn't productive. They > > cannot use the individually freed pages, and the process is unlikely > > to accidentally free whole blocks to meet the ALLOC_NOFRAGMENT bar. > > They spin and overreclaim excessively, which tanks performance and > > triggers userspace guards like swap exhaustion or pressure based OOM. > > > > To fix this, send non-movable requests, regardless of order, into > > pageblock reclaim/compaction. This way, they help move things along to > > meet the ALLOC_NOFRAGMENT bar. After this patch, the reclaim storms > > and excess OOM rates are no longer observed in production. > > > > The longer-term plan is still to have all requests, including the > > movable ones, help make blocks to spread the cost of defragmenting > > more evenly and fairly; combined with proper watermarking to reduce > > allocation latencies in the common case. However, doing this naively > > unearths scaling and concurrency limitations in compaction that need > > to be addressed first. Promoting just non-movables for now is the > > minimally viable bug fix for the above issue. > > > > Fixes: f38356df6474 ("mm: page_alloc: introduce defrag_mode") > > That's from 6.15. Do you intend any stable backporting, or we just mark it > as a heads up for anyone who tracks fixes and might consider it. Good point, let's Cc: stable. I doubt there are many defrag_mode users at this point, but this is quite the handgrenade that went off in production once already and was a pain to debug.