From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) (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 660113BB668 for ; Tue, 19 May 2026 20:28:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779222512; cv=none; b=RAiMvou1RFbWpBGRQZmXfn0boxvLQR4HJADtGKQb4zQ98CkW41LirdgV254FvYyKkUb5zGKn2l2aui3T7y6VFTPMowbi+A2XTqZOO0HEeGgu3cxLswqFTSjz/833vE1tRJ/fee1J5P64P0oFLeq70bJ6PuqGknqm3q2SZnv2nB4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779222512; c=relaxed/simple; bh=mtCTOEj4SWlzM10qMVWCS2Sw2Ct+z0wGP1VGBF7Rwv4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JO+7dgTa2MKjp0/KPk57IQJ0VdSOMgW1XYAFIAvFZ2mDutgBFut/fVMFEIQiGiCApHjrx1WhGM9qZjr3Gt0PpStuvd89E/nt/LbkoUqP//JXHKJKDl0CbkUIMxZHgwUbZd1knXEmcB2odBbwGp07lq9BQ4cE1msGLsu09UoXFPE= 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=Eo72hadb; arc=none smtp.client-ip=209.85.222.178 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="Eo72hadb" Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-90fe17c157aso472213785a.0 for ; Tue, 19 May 2026 13:28:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg.org; s=google; t=1779222509; x=1779827309; 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=lSwhsPuJIqUQQohobkJMpwlzAsTqFWfrWTjdV97EMcY=; b=Eo72hadbFF67HY7kX4+njLTqoWU1kvqmgiZ4Gz+BaKCMbjJ5Po80doWGBtlvoPvN3R TAWPyz+lNdN35owPligVTPAB5oc9yUzE4730vDVFDb588aAHJrvDCi1BDTKdRlwbsknD q+j5+bnmUlQUjirdWU04Y0SIk3HJ5gCY6uI9ZGJnxMrSttORFWj9b67SOg5K0YmfY6A/ riXpmtBaVsZZpcaRrcMY5DNMxt6BFN78MN+OK928GRXnfOAaeIG6E5w3QqC7fayGgv4B 7JOAJizGz8JQLvbqWo1YG7DTGJNCxFACfVygpQaKscn4tJ2KOOMrYDn5EBdQHvF5snhb jepA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779222509; x=1779827309; 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=lSwhsPuJIqUQQohobkJMpwlzAsTqFWfrWTjdV97EMcY=; b=Tiq3fyM9q5TdHSm+7eyvOEf0kQbwR5B2P8xQoB/a+Vo1nYm5e255jdzYMP0oReA/N3 phMKW4YrZiaCeQd4o7bP6J7eL9YYU543zKL6uzEhE3VREgSs158R+LadjSujC6q7Zxot p5exQuW/dXXTQYMjSwKqmS3CrAG+W5EC3zUIWwnVrSCdT4dfHDIV+FcDWDYTCmYA9Pa+ sQAc4oF8Ayy6FZmPjYgOY0MIIz1X6upBb0OkFF2NX8Kwv+ScI33UXY10ck+1xtuyCsem u/d7KRiErd2ra7pnODSgqgmZTVSY3jjvjOaeKT3y6ZnaRMdCfElkCymomcSWDel4h04r R5pg== X-Forwarded-Encrypted: i=1; AFNElJ9I8bF5LkfZwAxYaQJRP2SepS0f7oltF24QwcGsmxCzUUyk+6LSidiPtkOg1r3jXgxiuR43pwOQJINHf/c=@vger.kernel.org X-Gm-Message-State: AOJu0YwkUvcOmVGQtOdO3w/g+c3Cbo1uscAc+YJuq2MoGPjzyau1Pjkw w+NSA9Q3288HwAKYtcZqNQZsRj0SdoRryUtnBXNezZzPs4yLnJLoZCjLKcgUx9ov6wk= X-Gm-Gg: Acq92OEYQdylIPerLvXSys+w1DHnTZl5gjZXbSq0FawxLn8e/+3lpOsWt0xk5efj8+A Gafenw/PVrd/qoHTOhXJ8S2DuRZxY3mdaRZb6yNNwCnzwzOzKHQsPjrmvtlkBcza/9phMOZp6v7 ZiJGpR7V0nduIkwUjSFv0RxsLVzPd/GbNyAcv7oOcrxZ9Di4n4JS5/ThbucOY9moWcxSre0jpD0 TYD2gdXj7u+NBY1yYxDt37q2CLtt4Nsz6ZJUtFvpioHjNP64e+6Om7f1g6b4RmivnONfzUty3HB o0wf/3hznctTspOfd5fZY2OzWAo33qowe2pf4tTmQczXugiWJgg6QllOgJFtKhOEuXLWCoIadd1 8AVj/rQVwKSc3EtETqVtiYAsuz6W8WypfL5OCTuNhDaXXZt9eCSLib+JrpgOvkCgRBcrk0sf3az DgfZ1CWBwPfEgSkeoUOSW2ag== X-Received: by 2002:a05:620a:7116:b0:911:6136:281d with SMTP id af79cd13be357-911cda50909mr3238889585a.23.1779222509012; Tue, 19 May 2026 13:28:29 -0700 (PDT) Received: from localhost ([2603:7001:f100:500:365a:60ff:fe62:ff29]) by smtp.gmail.com with ESMTPSA id af79cd13be357-910baf2236fsm1951430885a.20.2026.05.19.13.28.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2026 13:28:28 -0700 (PDT) Date: Tue, 19 May 2026 16:28:20 -0400 From: Johannes Weiner To: "JP Kobryn (Meta)" Cc: akpm@linux-foundation.org, vbabka@kernel.org, surenb@google.com, mhocko@suse.com, jackmanb@google.com, ziy@nvidia.com, linux-mm@kvack.org, usama.arif@linux.dev, kirill@shutemov.name, willy@infradead.org, linux-kernel@vger.kernel.org, kernel-team@meta.com Subject: Re: [PATCH] mm/page_alloc: skip high atomic reservation at or below costly order Message-ID: References: <20260519012532.272770-1-jp.kobryn@linux.dev> 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: <20260519012532.272770-1-jp.kobryn@linux.dev> On Mon, May 18, 2026 at 06:25:32PM -0700, JP Kobryn (Meta) wrote: > We're seeing a pattern in production where 2MB THP order-9 allocations are > failing due to fragmentation and triggering reclaim on systems with plenty > of free memory. Over time, the success rate of these THP allocations do not > increase at all. > > Inspecting zone->vm_stat[NR_FREE_PAGES] via kprobe on compaction_suitable() > indicated the given zone had sufficient free pages for order-9 allocations, > yet they were going unused. Drilling down into the zone and inspecting > /proc/pagetypeinfo revealed why. Order-9 blocks were accumulating in the > zone's HighAtomic bucket (while zero were present in Movable). THP is > unable to draw blocks from HighAtomic since that bucket is not in the > fallback list. > > The heuristic for reserving pageblocks in HighAtomic is that any atomic > allocation greater than order-0 will result in the full pageblock being > captured. This means that an order-1 atomic allocation will over-reserve by > 256x, a full 512 pageblock. > > Gate the reservation on order. Skip for allocations at or below > PAGE_ALLOC_COSTLY_ORDER. This prevents smaller atomic allocations from > reserving entire pageblocks, and significantly helps when THP is in use on > a fragmented but otherwise healthy system. > > Testing was performed using an A/B instagram workload receiving prod > traffic. Each side had ~60 hosts with 64G memory. The patch resulted in > several gains: > > Unpatched > HighAtomic pageblocks per host: 309-312 (1% of zone or 620MB), > ...all order-9 blocks in HighAtomic > THP success rate: 1-6% > Compaction success rate: 0-2% > pgscan_kswapd (total across ~60 hosts, per minute): ~70.2M > Atomic order-4+ allocations: 0 > > Patched > HighAtomic pageblocks per host: 1 > THP success rate: 44-78% > Compaction success rate: 24-47% > pgscan_kswapd (total across ~60 hosts, per minute): ~29.9M > Atomic order-4+ allocations: 0 This is an interesting patch. A couple of thoughts: 1. You disabled the highatomic reserve for this workload and it didn't seem to matter. Presumably