From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) (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 24DE54195AA for ; Thu, 9 Jul 2026 17:42:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783618952; cv=none; b=pUvR3FnHLkWr62rgoL1OBqFm0ohnDwDAmLN4Q7eFhWy/v+n3qh2cTpLOpdlFFohQP+GMx+RyC3yWTRDGZWPHn7J6meLZBcD3cw34vd8t28QVkfy1+andW1Q56fo9nna5F+2H0UU94ipFQTpKcmNG7qm7gBCy3FkY9fVrQkUXSNQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783618952; c=relaxed/simple; bh=XyL2e6eM/dq03mG/TgBbcDUYd85X1jB7warfBT5oipg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=VnopFl7G6bVjBs9HPpqY+c0x88SZcn1pfw6Ycnrpg/FUZk7Z6pDTq2u5bNGJ+XSiOtivVMzIosn1Ey4rlx52eui1wqpQh1KbB2ML6h2/i6xF6B7+mCp0NE4bMZ7xaBM5mdycfDaNjGZB2c3ld22Fknsm5q9A2cg7YL+tABMQCgc= 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=ADdC6GiK; arc=none smtp.client-ip=209.85.222.182 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="ADdC6GiK" Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-92e51d3d83cso2398085a.2 for ; Thu, 09 Jul 2026 10:42:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg.org; s=google; t=1783618950; x=1784223750; 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=ZCmYJfmZUrFzu6y7sef3nXo3D+tzzPc1JVMO9nTza9k=; b=ADdC6GiKXzDdg935IXfW5EHmxnza+nXBYCjCDMfgTRImm9htrw3UqBw9wBQRAYENkf 5nRsj4CRO6tET2nJLw1Tm9voo6qOET2XfsKZ2oP2zR3fMdMAzjlqTNw4zcGn2EpZo9IB divw37Yzn47xvp61eIyT/97rDhS2I4ugruyqUKsTtgEyX1KQ3MgNli4mpa3oO/LSsiGi fhtSpEVyMpVJGiX1AfubBMeDxQmXA59K9VIqLTNCZ+V8fCw5Mx98Mzr64Hz6Im/uov4B /tlmdit8pwqSV07uuRVKmH9y256Nz22LnMo676RP8xF2j5/jVOrqkbGc0JGmW9IotjHB IzcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783618950; x=1784223750; 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=ZCmYJfmZUrFzu6y7sef3nXo3D+tzzPc1JVMO9nTza9k=; b=O5UmOZU6LAvUCFfNgLJYW43Nu+U2URztXHUgUvepga/cCkVomCD4Aq0iUlxBBt5Kwt 6tzLDxmsLBy7xS2I/C4lWYkBBbNCJID/ULG4zrJebx2XIrKVp5AjEdnNm6patj/mL6dn PuJHC+Blrgzne1uDG2ozlSz8Mje0UzMM0FIQu+GnwbTHMzbseYkpxsQvuA1qHozYoFsF gT1krzGt77eSR4E0hcP8ZD4P5i8lCL3gU3UZicvhXxtPNL+5ZYN7riqtki1faP9/U1IL y6G7s6vfIOf8FiA0GrNObmE1aoNDk3vvLP3huXV2p0OepmScxwXEuMSq824ZfiG/aZB0 h4MQ== X-Forwarded-Encrypted: i=1; AHgh+Rrkc5dQeSIImzunD4CF3n3AGMkwLoDZAMeZCXyjJo/EtSlyMzfhXpJ2uUf8MENzfGLJ4LQmcnDu6GaecPs=@vger.kernel.org X-Gm-Message-State: AOJu0YzsXuo+TwkGma3vaRlo3OCa2ch8FrW8h4TnIdw0TU8wWRwVjpsZ x9zi387n+i4wniXsAUygz3A0I7liKz4FYwy425khGDXewLhwdDAoUnTUiSAwX1nvi4E= X-Gm-Gg: AfdE7cnyY/Ku7xPD1yNQ5DGxQ4u9LsfVBAJGQ2Tt7SzHlQ7nat62hEXRErArwLaL4Pi eoulxaBJ4s5Gqnng4KKv1bwGPEGqRzWIM7lRN+hex+QdlrlIM9ovWt3c64jhmLosdNfrU7ZM17W JVkV4PquduK+/55v6oqounG1A+0vcFOMSudWPBVosaBJRJLij+tZDSbfrlIAgMLZzyRt36kkxCI i+0CRye3lT8WshglOeHXqn0qngdHRvQHuULAadrfXf516hhBlnf/HXojmPvqpi3LWo/QUV7thmh hXBWWoM/NIHls8mx9OFBW5S2iYR/m9qMfoe5I4x6kkXUr7vSpTUBmuzaP9cb9ihH1Z1lsVqVVZ5 6s95tn3GtTg21oH3MNjkNyfeAqBMwysSL3YhKp3+C7x9KQavdcUklI/2AvkVFg+vPnrdtCx5pWm AegvNQ0isVJhk= X-Received: by 2002:a05:620a:a51b:b0:92e:d953:8283 with SMTP id af79cd13be357-92ed9538814mr421842585a.44.1783618949159; Thu, 09 Jul 2026 10:42:29 -0700 (PDT) Received: from localhost ([2603:7001:f100:500:365a:60ff:fe62:ff29]) by smtp.gmail.com with ESMTPSA id af79cd13be357-92e90ca004fsm1721530585a.28.2026.07.09.10.42.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2026 10:42:28 -0700 (PDT) Date: Thu, 9 Jul 2026 13:42:27 -0400 From: Johannes Weiner To: Zi Yan Cc: Andrew Morton , Vlastimil Babka , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , 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> 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: On Wed, Jul 01, 2026 at 09:47:21PM -0400, Zi Yan wrote: > On Fri Jun 26, 2026 at 2:21 PM EDT, Johannes Weiner wrote: > > While trying to fix a reclaim storm in defrag_mode, I noticed that > > non-movable direct compaction is extremely inefficient. > > > > When searching for space to evacuate, compaction only allows blocks of > > the same type as the incoming request. This is to prevent migratetype > > pollution, where a small non-movable request frees space in a movable > > block and provokes the allocator to fall back and pollute it. > > > > This protection is reasonable on one hand, but the downside is that it > > makes non-movable direct compaction nearly useless: if we get the type > > annotations right, by definition there aren't any movable pages inside > > the non-movable blocks it is allowed to scan. > > > > With defrag_mode, the goal is the production of whole blocks, which > > are essentially type neutral: __rmqueue_claim() will convert them > > wholesale on alloc. This makes type mixing and pollution a non-issue. > > > > Fix the pollution gates to take the requested order into account, and > > allow whole-block requests to scan blocks of other types. > > > > The only exception is CMA blocks. That type is sticky and these blocks > > cannot be claimed to other types. Continue to be strict with them, and > > allow only explicit ALLOC_CMA requests and kcompactd to evacuate them. > > > > Signed-off-by: Johannes Weiner > > --- > > mm/compaction.c | 35 ++++++++++++++++++++++++++++------- > > 1 file changed, 28 insertions(+), 7 deletions(-) > > > > > > > + > > + /* > > + * Prevent small unmovable/reclaimable requests from polluting > > "small" here means smaller than pageblock_order requests? If yes, it is > better to spell it out to prevent confusion. Ah, I thought the order < pageblock_order in the code would make it clear. But I don't mind spelling it out. I will change this to " > > + * movable blocks through fallbacks. Whole-block production is > > + * exempt as the allocator claims and converts these. > > + */ > > + if (cc->migratetype == MIGRATE_MOVABLE || cc->order >= pageblock_order) > > return is_migrate_movable(block_mt); > > else > > return block_mt == cc->migratetype; > > @@ -1974,12 +1995,12 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc) > > return pfn; > > > > /* > > - * Only allow kcompactd and direct requests for movable pages to > > - * quickly clear out a MOVABLE pageblock for allocation. This > > - * reduces the risk that a large movable pageblock is freed for > > - * an unmovable/reclaimable small allocation. > > + * Prevent small unmovable/reclaimable requests from polluting > > This "small" as well. Yep, will keep these in sync.