From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp153-163.sina.com.cn (smtp153-163.sina.com.cn [61.135.153.163]) (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 9334F24A078 for ; Wed, 24 Jun 2026 01:23:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=61.135.153.163 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782264197; cv=none; b=eaxmrcMdRhqivN5pk80Cv5jv4jSIlHLFKXtDkNPNSYLJrkyXGcxbzP7pPcbWwP6I6CkH45qv45Td9bfCEc4xlCWgi6i1jq54ruP2Ek6X2Jgw/t9YfqCZW/V5oHFSFpAxmYbTsVABj82dO4n6u5pqFVWRFuwV+dEcKgrLU7iMBpc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782264197; c=relaxed/simple; bh=iWDWWC36UEP/Qz+vobLUJth8tBR/qW8n7RuC1NCJD4c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kzhCvba/biO9fVomufW7ezEhsto9/pUUf4Xct59CPrEsZhZGvnxnk/HbG1Q+UD8n57xsIkIimGTYoTMs0KZnyQNsT/2q2guNGoDAfaI/0nt0yVPLO+rBjUN9fut3Nq1+GoQ2kmNjGfbadrsySITn1Lnj1HivEzxF3H6ZZHLxQIs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sina.com; spf=pass smtp.mailfrom=sina.com; dkim=pass (1024-bit key) header.d=sina.com header.i=@sina.com header.b=UHVL/bzf; arc=none smtp.client-ip=61.135.153.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=sina.com header.i=@sina.com header.b="UHVL/bzf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sina.com; s=201208; t=1782264190; bh=ZwPjOiQhIsO80JzngIza/FZ2n0oxv+sciICtuqSosXk=; h=From:Subject:Date:Message-ID; b=UHVL/bzfNiF6LyN4COJzbKKpqcS4tR+0Mkute4CrqSkI/QWDhgYQaw3756RJvFzwC dFgESvV4/RcR8EtYJfLcRM9/2ZXGclnvz5bpLvFBqis4GOFSfcd13E+L91wyp6TcPI jW5cV4mI44UJdVaIjoMEbB52IiGFHKZLO5uCDNHU= X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([114.249.62.144]) by sina.com (10.54.253.32) with ESMTP id 6A3B30E200006131; Wed, 24 Jun 2026 09:20:36 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=hdanton@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=hdanton@sina.com X-SMAIL-MID: 222894457036 X-SMAIL-UIID: D00542BA1DE445BF9B70230553DD5312-20260624-092036-1 From: Hillf Danton To: Dave Chinner Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Matthew Brost , David Hildenbrand , Vlastimil Babka , Michal Hocko , Johannes Weiner Subject: Re: [PATCH v6 1/2] mm: Introduce opportunistic_compaction concept to vmscan and shrinkers Date: Wed, 24 Jun 2026 09:20:25 +0800 Message-ID: <20260624012027.194-1-hdanton@sina.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Tue, 23 Jun 2026 09:10:43 +1000 Dave Chinner wrote: > On Tue, Jun 16, 2026 at 08:22:17PM -0700, Matthew Brost wrote: > > High-order allocations using __GFP_NORETRY or __GFP_RETRY_MAYFAIL > > are often opportunistic attempts to satisfy fragmentation-sensitive > > allocations rather than indications of severe memory pressure. In these > > cases, reclaim may invoke shrinkers that aggressively destroy working > > sets even though reclaim is unlikely to materially improve the > > allocation outcome. > > > > Some shrinkers manage expensive backing or migration operations where > > reclaim can result in substantial working set disruption despite the > > system having sufficient free memory overall. This is particularly > > visible in fragmentation-heavy workloads where reclaim repeatedly tears > > down active state while kswapd attempts to satisfy higher-order > > allocations. > > > > Introduce an opportunistic_compaction hint in shrink_control that allows > > kswapd to communicate when reclaim originates from a high-order > > allocation context that may be fragmentation driven rather than true > > memory pressure. Shrinkers may use this hint to avoid destructive > > working set reclaim while still participating normally during order-0 > > or stronger reclaim conditions. > > To be honest, this seems like another "push a hint through to the XE > shrinker" mechanism under a different name. You seem so focused on > fixing the XE reproducer that the -systemic problem- that -any- > high-order folio demand causes is not being acknowleged. > > e.g. we use high-order folios extensively in the page cache these > days, and there are -many- cases where memory compaction driven by > high-order demand cause significant performance regressions for page > cache performance. To date, every single person who has wanted to > fix the problem they are seeing has effectively attempted to -turn > off compaction- via GFP flags. > > I've even done that myself inside XFS to work around kvmalloc() > issues with a lack of GFP_NOFAIL support and doing costly high order > allocations that fail and trigger compaction before falling back to > vmalloc(). However, these issues have since been fixed in the > kvmalloc() code, such that it now does the right thing for most > calling contexts (i.e. tries high-order kmalloc() without triggering > compaction, then fall back to GFP_NOFAIL vmalloc()). This has made > kvmalloc() more performant and better behaved for -all users-, not > just XFS. > > This is not sustainable - we need compaction to be robust and > performant in the face of high-order folio demands, regardless of > what subsystem is generating the demand. > Because a) compaction works only when there are enough free regular pages available, with nothing to do with shrinker directly, b) both order and gfp are checked in in_reclaim_compaction() in addition to checking __GFP_NORETRY and costly_order in __alloc_pages_slowpath(), I think individual shrinker can have more option by repeating similar check.