From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.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 3BC2E4D991F for ; Thu, 9 Jul 2026 17:39:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783618780; cv=none; b=I3KSHM83NUwueXQ1YPQnsu1SUFl2JRlvw2QFCqe3I4BMbA01hWT/rnuxSKM6627vXNYFQRl5ZjvlemqgPjfme2P2ge9iDycDlDGmZyq4HzdLrILK9l+PMR0n+kpQ3cT/i03CJROavs8L0QKcUj7/sUkuDQjTzQT9vXIm96Sd2Kc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783618780; c=relaxed/simple; bh=isRrEXvD1833Msa9Uhv6uYDe9oBHnGJ1JdZx+ZAsr54=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BLecQo5eiisIen57X0B0bmMzE5O4u4B5eRLQgETzHE/ZnjYV2BUV06OCuoyMp5+T/m1vFiCPD1vHr+VCzDGPYhCD2WvNzFtMYZYOfvM3YRgFaHGUPyDzRP5JqxwE23FoH6pIc2+ijaJpck0d7FtDbTslDgEDA4oD5pEFdfO1pyU= 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=iQ+NJ5Tm; arc=none smtp.client-ip=209.85.160.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="iQ+NJ5Tm" Received: by mail-qt1-f178.google.com with SMTP id d75a77b69052e-51c1d487f2cso400001cf.1 for ; Thu, 09 Jul 2026 10:39:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg.org; s=google; t=1783618777; x=1784223577; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=u9AnDRBr8KqFPgYAaaOIV/GMT4K0ldCBDDn+vjmduSg=; b=iQ+NJ5TmNtlNNHfgS4MTo7i0I1yhRlY8StFccvaQ/dy3Qj89/xuOR6pd0d9yP58iW3 4yIo4n3NnDxFEnc33moAOGJUwmA9f2jHnAbwjSvNb4PhocyOp5B6lMRWW/vn+iDvdcF2 8r1nw9YnQQnNCNo6sAm1OHEqRMfc6fm4WUjy8LNoPTNAmibw4jBY+IGOwmYcFfguDOHH 6sAtxeN6iNuN8pHZeqBCePQYspzOvrFqC1awBKeD6PWYo3yW+LNpR+DOEnI9+lEjJpAY M7OdJVuZKclPm8pvFblAV+MIpsq3d/SfN6jvN8oPBWuBRYSf7ZIYr/THCmx1f0Oy1Qxl wyMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783618777; x=1784223577; h=in-reply-to:content-disposition:content-type: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 :content-type; bh=u9AnDRBr8KqFPgYAaaOIV/GMT4K0ldCBDDn+vjmduSg=; b=lgraAOnUh+yrZJhRJIbgcwF4zmVHDAVfSqGpg8c9Voz+XO2xfDStRXTpKUgaB8F6Bz ScBIoDYUcMvsI9D1A3GhbpPSafYc7brd0NdpIZWSV6ltTrrjQuuu99Hp07xN8Rk+vikB MLobvAQzkiAjKsfMgBdMJ+96k8JTEfypanqiaU8qIVwqa/P9/oeqS8sjdIfbReHO91/a 9JxFSgUXswe2umrQLQOEWq+UGi9L5zWqGC/dwlwkyJeVpw7qolkT39RyCHlcT5mWhhkx 05fKOEzbapdwWkv6xmHfYgdWDZY4OyizJy9yAYgQB08KYtsxybdiauTLd8HA1cdU82nl KTeQ== X-Forwarded-Encrypted: i=1; AHgh+RoynIB9QJ7OGUkZ6akuB5jOIjsPOHxrFTkl7txSaIL2SIDBmucUni8q/ZIXqAbuiuTdk+bo4Qj0WE3651g=@vger.kernel.org X-Gm-Message-State: AOJu0Ywupzanm2jFB3qqQueHlJiGnXl6YzoIULBfxb2qiACPu4R3f9pg nl1taiu0LK1UCh8A5wS8xaEJL9ibp2JWl7hH9gjR1700GO+ezhbWQpelfySapwbdMdE= X-Gm-Gg: AfdE7cnuUqvg0AnB53R+YBZ+bsW9RUCciw14E/OlRIGkD9ft561CXNkHlDwMVQDcyX9 IasioYTV1s8ogJ3Mt4vIlSmdif2bPo54CvDea7sU0a3RgIBhAi81JUk1goEVUmZ30cKVRJM3v/g XlCmGBNFT7dVN+6HPr4n2eVdCTqzUDWBb/VvUPjkMtrpcExFHL7daBfONejiBjFXzHtmRkCGaYz Pw9ogjSbDZjA+7A2EEB3D8GrSFqu6DY9NBw2hb0aZ6peFfYoK2VKWxUGAWN+W8vQe3ztihhB4t6 m/BP1HGmUSSLGbup+/ASR8ghP6E6yVBG0JLQ/wz/lV1bB4EzM1oowtY3VQVJf3/1SnN7zfM1CXQ GmzwIjZv5Jh+S1BDLzIPpOax/oGmeM63v5dxD9Lr0T946rzhsGLXrh4JiDiYhs555F3brAmAnKS x2AqiGMbsv8jjddX2XMg6VZQ== X-Received: by 2002:ac8:5fcc:0:b0:517:98e3:d939 with SMTP id d75a77b69052e-51c8b48ec53mr93024431cf.49.1783618776845; Thu, 09 Jul 2026 10:39:36 -0700 (PDT) Received: from localhost ([2603:7001:f100:500:365a:60ff:fe62:ff29]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8ffd56bf115sm22855186d6.12.2026.07.09.10.39.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2026 10:39:36 -0700 (PDT) Date: Thu, 9 Jul 2026 13:39:32 -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 2/4] mm: compaction: support non-movable compaction for pageblock requests Message-ID: References: <20260626182215.1107966-1-hannes@cmpxchg.org> <20260626182215.1107966-3-hannes@cmpxchg.org> <61bc1ad0-f9e3-405a-ae32-b89bcdd2e1d1@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: <61bc1ad0-f9e3-405a-ae32-b89bcdd2e1d1@kernel.org> On Thu, Jul 02, 2026 at 11:28:47AM +0200, Vlastimil Babka (SUSE) wrote: > On 7/1/26 23:11, Johannes Weiner wrote: > > On Wed, Jul 01, 2026 at 08:14:05PM +0200, Vlastimil Babka (SUSE) wrote: > >> > >> > This made the migratetype filtering about preventing block > >> > pollution. The patch quotes reduced extfrag numbers. > >> > > >> > So now we have a block pollution guard that we apply only if... the > >> > scanner is latency sensitive? :) Is this actually desired behavior? > >> > >> Yeah indeed I was wondering in this direction. > >> > >> > Another way of looking at it would be this: > >> > > >> > /* > >> > * Allocation fallbacks can spread migratable pages > >> > * into non-movable blocks. > >> > >> But also vice versa, non-movable pages into movable blocks? (without > >> defrag_mode?). > > > > Uhm but those aren't compactable anymore then, right? > > Yeah. > > > There is a flipside, but it isn't quite symmetrical. Movable requests > > are allowed to look for movables in unmovable blocks once they become > > sync (high-effort, low-result). Non-movable requests are finally > > allowed to empty movable blocks once they become sync; they *start* > > with the high-effort, low-result mode to avoid block contamination but > > are allowed to escalate when that doesn't produce results. > > Hm, true! > > I was also thinking, if defrag mode doesn't allow that escalation ever > (IIRC?), should it be reflected here as well even with sync compaction? Ok I made a clarification regarding defrag_mode in the other comment. How about this? diff --git a/mm/compaction.c b/mm/compaction.c index 7df3a85d43af..a12a49eefe85 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1399,13 +1399,24 @@ static bool suitable_migration_source(struct compact_control *cc, if (is_migrate_cma(block_mt) && !(cc->alloc_flags & ALLOC_CMA)) return false; + /* + * Per default, scans are restricted to blocks compatible with + * the request, to prevent cross-contamination. Once + * compaction priority escalates to synchronous scans, though, + * scan all blocks to try to make forward progress. For + * movable request, this likely helps little: there shouldn't + * be many migratable pages inside non-movable blocks besides + * allocator fallbacks. For non-movable requests, this helps a + * lot, as they can finally scan movable blocks. + */ if (cc->mode != MIGRATE_ASYNC) return true; /* * Prevent small unmovable/reclaimable requests from polluting - * movable blocks through fallbacks. Whole-block production is - * exempt as the allocator claims and converts these. + * movable blocks through fallbacks. Whole-block production + * (directly requested, or defrag_mode) is exempt as the + * allocator claims and converts these. */ if (cc->migratetype == MIGRATE_MOVABLE || cc->order >= pageblock_order) return is_migrate_movable(block_mt);