From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8EAD3C02187 for ; Wed, 15 Jan 2025 09:18:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EE88C6B0082; Wed, 15 Jan 2025 04:18:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E98F46B0085; Wed, 15 Jan 2025 04:18:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D6080280001; Wed, 15 Jan 2025 04:18:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id BBC956B0082 for ; Wed, 15 Jan 2025 04:18:04 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 39DBFA1148 for ; Wed, 15 Jan 2025 09:18:04 +0000 (UTC) X-FDA: 83009134488.29.34661BA Received: from m16.mail.126.com (m16.mail.126.com [220.197.31.7]) by imf16.hostedemail.com (Postfix) with ESMTP id ED60E180007 for ; Wed, 15 Jan 2025 09:18:00 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=126.com header.s=s110527 header.b=QE3iCI5C; spf=pass (imf16.hostedemail.com: domain of yangge1116@126.com designates 220.197.31.7 as permitted sender) smtp.mailfrom=yangge1116@126.com; dmarc=pass (policy=none) header.from=126.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736932682; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=pq/5bG1rfrNfQiX1eubItDMA9TfIiO6JY4M8DEI/q1k=; b=rjtULH0p14mM6oMChN04+XHKGfls8tnK80zuoxwst1k/Nw7GAwGC9oBmTtZJCQyBjGj/Tf 74/rMlJN/AcIIZ1ZquRr52MA/i4/uDkv9SPIeoDtSUiLvyiFm/us4tX9zA/mU9FHRevWNr ZSCNNjaEeZdE70LRcVxIU+ZoAkec/0U= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736932682; a=rsa-sha256; cv=none; b=6E33qcbeJ9qEEUtZtldsbFRfm3/hvjw36hjAEXdADQA8jUZMipLC0ikhSqdDzHTZYViV0H YIcXU7+FvxQnz9lI8XzJnQLSh0vr4xeHPuX/9WOrbM7+8o2XNfGp5rLQ2JtSVmaYMH59VN p50rhcKB1f5VRQflKnvDZWhfe9P810I= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=126.com header.s=s110527 header.b=QE3iCI5C; spf=pass (imf16.hostedemail.com: domain of yangge1116@126.com designates 220.197.31.7 as permitted sender) smtp.mailfrom=yangge1116@126.com; dmarc=pass (policy=none) header.from=126.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=Message-ID:Date:MIME-Version:Subject:From: Content-Type; bh=pq/5bG1rfrNfQiX1eubItDMA9TfIiO6JY4M8DEI/q1k=; b=QE3iCI5CmzBJr3NdCVHi1sWYmQGC5eZjXkSNV7kS1Qe3GIytdgt/KIG8GxoM67 ThF8SSJTsSLYU0S0C4Rn2+1o9EWcCy6XL+UNRIiJGrzQiHotBMeHHA8fxNDa6B6j EeKnUUrizp6yPN3yxcdRZg3BtUpwXUDnnRmIFuSuRRJlo= Received: from [172.19.20.199] (unknown []) by gzga-smtp-mtada-g0-0 (Coremail) with SMTP id _____wB31P0+fYdn0+MaBA--.26710S2; Wed, 15 Jan 2025 17:17:50 +0800 (CST) Message-ID: <0347ff02-eac4-4fa5-88c3-6d12988438d1@126.com> Date: Wed, 15 Jan 2025 17:17:50 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH V3] mm: compaction: skip memory compaction when there are not enough migratable pages To: Vlastimil Babka , akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, 21cnbao@gmail.com, david@redhat.com, baolin.wang@linux.alibaba.com, hannes@cmpxchg.org, liuzixing@hygon.cn References: <1736335854-548-1-git-send-email-yangge1116@126.com> <39709cd7-0de6-4247-a70a-9f81fccbce6a@suse.cz> <1ada3f6d-72bb-46a4-9fef-0bf6a7b32e62@suse.cz> From: Ge Yang In-Reply-To: <1ada3f6d-72bb-46a4-9fef-0bf6a7b32e62@suse.cz> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID:_____wB31P0+fYdn0+MaBA--.26710S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxCrW3AF1kCr4DJrWUKF4xCrg_yoW5GF4Dpa yUWFsF9FZ5XF43Aw1vyw4vgF1Ykw4xGryUJrnaqryDuwsI9FyI9FWIyFWUCayUXr4ftFWj vFW0gFy7AFsIva7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jbPEfUUUUU= X-Originating-IP: [112.64.138.194] X-CM-SenderInfo: 51dqwwjhrrila6rslhhfrp/1tbifgvVG2eHcDbhdAAAsI X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: ED60E180007 X-Stat-Signature: uaensx3ek1c5hpzusggu5nphmbh8jfun X-Rspam-User: X-HE-Tag: 1736932680-434713 X-HE-Meta: U2FsdGVkX19cVY5DMelEGV8wzmL4U11Cwe/H80UanGGuv3qeizsQnZxVRpfw5AolZcU0oDgWVSy3EJGjj5XnkuJJ6zZZUSkl5Zf/Wfy5gJCr6hP2BAAopm28t3LwrRjUGG4m24FeDcP50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kMaUGM7v68X3IfuNhBfy1JRlOONyAqu5qsrwLkNP4d6V2RNQjUN1ARjp7W+2iT2Ed5UC4bRebYrvKstpGyUcgE0amKkhd12m0ZDAv5ertD+RBfB2C/r6CELwUZwqq0Y3gnWjmvmOoJ5E1HMcMbYUk0VA7uorLcbspjN3dijJ3wXJLO+EyA/nhZh X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 在 2025/1/14 20:51, Vlastimil Babka 写道: > On 1/14/25 13:24, Ge Yang wrote: >>> Hopefully also when done from the pin_user_pages_remote(..., FOLL_LONGTERM, >>> ...) context the allocation gfp_mask correctly lacks __GFP_MOVABLE? >> yes. >> I guess >>> it has to, otherwise it would allocate from the CMA pageblocks. >>> >>> Then I wonder if we could use the real allocation context to determine >>> watermarks, as __compaction_suitable() is passing ALLOC_CMA instead because >>> it's checking only for migration targets, which have to be CMA compatible by >>> definition. But we could use the real unmovable allocation context to have >>> __zone_watermark_unusable_free() subtract CMA pages, and thus we won't pass >>> the order-0 check anymore once the non-CMA part is exhausted. >>> >>> There's some risk that in some different scenario the compaction could in >>> fact migrate pages from the exhausted non-CMA part of the zone to the CMA >>> part and succeed, and we'll skip it instead. But that should be rare? >>> >> Below is the previous discussion: >> https://lore.kernel.org/lkml/1734436004-1212-1-git-send-email-yangge1116@126.com/ > > Right so Johannes had the same concern. > >>> Anyway given that concern I'm not sure about changing >>> __compaction_suitable() for every caller like this. We could (at least >>> initially) target this heuristic only for COMPACT_PRIO_ASYNC which is being >>> used for this THP opportunistic attempt. >>> >>> So for example: >>> - add a new bool flag to compact_control that is true for COMPACT_PRIO_ASYNC >>> - pass cc pointer to compaction_suit_allocation_order() >>> - in that function, add another check if the the new cc flag is true, >>> between the current zone_watermark_ok() and compaction_suitable() checks, >>> which works like __compaction_suitable() but uses alloc_flags (which should >>> not be ALLOC_CMA in our pinned allocation case) instead of ALLOC_CMA, return >>> COMPACT_SKIPPED if it fails. >>> >> I will send a new version of the patch based on the suggestions here. >> Thank you. > > Yeah that way should hopefully limit the concern sufficiently. Maybe we > could also add costly_order condition in addition to COMPACT_PRIO_ASYNC > condition to set the new compact_control flag. But only __GFP_NORETRY > allocations should be affected in the immediate "goto nopage" when > compaction is skipped, others will attempt with DEF_COMPACT_PRIORITY anyway > and won't fail without trying to compact-migrate the non-CMA pageblocks into > CMA pageblocks first, so it should be fine. Ok, thanks.