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 00510C3601E for ; Thu, 10 Apr 2025 15:19:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BCC8B6B01F7; Thu, 10 Apr 2025 11:19:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B77406B01FA; Thu, 10 Apr 2025 11:19:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A42206B01F9; Thu, 10 Apr 2025 11:19:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 860696B034A for ; Thu, 10 Apr 2025 11:19:14 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id BA8871A0F05 for ; Thu, 10 Apr 2025 15:19:14 +0000 (UTC) X-FDA: 83318492628.07.2F92DA4 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf30.hostedemail.com (Postfix) with ESMTP id 282F78000C for ; Thu, 10 Apr 2025 15:19:11 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=PiV4a3YK; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=rwEhiuOC; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=PiV4a3YK; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=rwEhiuOC; dmarc=none; spf=pass (imf30.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1744298352; 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=qnRe2lXGIvTI/8saZS3JDgYMhiPgHnRNLOQzRSK+CgQ=; b=l+Y3kk4C/PNAbOjTEAOOYs7DBdb10BqbVx/LxjlyJ/uuCC6x27Tik/QB6gbABqBOAxz8VY 4rvdv0jyRy94Wqnhxc7D0iLSaQgZQcRnM/SPNQbcPJhC7dFof/44A2+n2A61SquSZvzei+ 3moJ7dxA111dLCx2EGWy1F43FCnBdmU= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=PiV4a3YK; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=rwEhiuOC; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=PiV4a3YK; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=rwEhiuOC; dmarc=none; spf=pass (imf30.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1744298352; a=rsa-sha256; cv=none; b=BcTV9b5fd8KXkzhLNDHkeHt4NzpOr0NtF+MuB1FzwW3xnZndmxYTZgoVpboURzmBG8p+wF HcW+yOrI1Ht9bvVslwlnTePMq0oGibSQymlP2e61ljZ9o66l8DurWqn6hB1bvcGkTAS89S 9tlL6KJhOd1D6ajYCffoEtOVvDnpAAE= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 694AC1F444; Thu, 10 Apr 2025 15:19:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1744298350; h=from:from:reply-to: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; bh=qnRe2lXGIvTI/8saZS3JDgYMhiPgHnRNLOQzRSK+CgQ=; b=PiV4a3YKSG5ndTPkYH1NFFNKAtTaFkACl9C9hECkCTenFEVEHYUWJ0H3oTiPbw2ryo2EDV Qt70MSX/OyhnlLtTubMtCNqkfHi2J3p9iKqXkvGA7h8taWHKtfYalIC0NS9GnskQ2F8pJQ e9XjfHox1rkr47j3jb+oJbgce6J92go= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1744298350; h=from:from:reply-to: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; bh=qnRe2lXGIvTI/8saZS3JDgYMhiPgHnRNLOQzRSK+CgQ=; b=rwEhiuOCRPlIZc8xBKNKHWvGY9WsyR7GaNVXK6YpOI4dwquFXPqBGpK71n3yE2fSiPutEK LC9CHuxaea/WqHDw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1744298350; h=from:from:reply-to: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; bh=qnRe2lXGIvTI/8saZS3JDgYMhiPgHnRNLOQzRSK+CgQ=; b=PiV4a3YKSG5ndTPkYH1NFFNKAtTaFkACl9C9hECkCTenFEVEHYUWJ0H3oTiPbw2ryo2EDV Qt70MSX/OyhnlLtTubMtCNqkfHi2J3p9iKqXkvGA7h8taWHKtfYalIC0NS9GnskQ2F8pJQ e9XjfHox1rkr47j3jb+oJbgce6J92go= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1744298350; h=from:from:reply-to: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; bh=qnRe2lXGIvTI/8saZS3JDgYMhiPgHnRNLOQzRSK+CgQ=; b=rwEhiuOCRPlIZc8xBKNKHWvGY9WsyR7GaNVXK6YpOI4dwquFXPqBGpK71n3yE2fSiPutEK LC9CHuxaea/WqHDw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 55F1513886; Thu, 10 Apr 2025 15:19:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id u7mkFG7h92d7DAAAD6G6ig (envelope-from ); Thu, 10 Apr 2025 15:19:10 +0000 Message-ID: <2025de6c-a25b-42f2-8ff2-da2bad0e0aa0@suse.cz> Date: Thu, 10 Apr 2025 17:19:06 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/5] mm: compaction: push watermark into compaction_suitable() callers Content-Language: en-US To: Johannes Weiner , Andrew Morton Cc: Mel Gorman , Zi Yan , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20250313210647.1314586-1-hannes@cmpxchg.org> <20250313210647.1314586-2-hannes@cmpxchg.org> From: Vlastimil Babka In-Reply-To: <20250313210647.1314586-2-hannes@cmpxchg.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Action: no action X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 282F78000C X-Stat-Signature: iinipgt7wsp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xvdRrz2JUNi4rs/HV9BHHGIvjK43noZzDowBvhHO787VU9R3k/VX+VZF0pdPhk+QS/cIjyFWSnG2dbpZxC7NBo2ZJJEprkOYS2Js6CTNGkKTRmHGahELXVphxRB7O3tUv57gs5P2q+EmEFPgJIA29H/uNqoH8YBVF0Mr7o6Xv7dagwfEsdJ8pV/9zjUjCNEpgYT8JXpyq4HvbW2S5BrGyaJ9Yf7Pc4U783UgdNhN2EmnPHWFOE0DSdg3jet+UWjDOqpnMqT3415oFBdpVfTcEZrzffQzc6jvg61/QKlePkJJFkC/1bphKtW6PVFW17z+rADYoC13c1wiFZrnIjlLPNbjbBa1hOhFeyDT5vfuPC24Bhuf65sXQvmw= X-Bogosity: Ham, tests=bogofilter, spamicity=0.109491, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 3/13/25 22:05, Johannes Weiner wrote: > compaction_suitable() hardcodes the min watermark, with a boost to the > low watermark for costly orders. However, compaction_ready() requires > order-0 at the high watermark. It currently checks the marks twice. > > Make the watermark a parameter to compaction_suitable() and have the > callers pass in what they require: > > - compaction_zonelist_suitable() is used by the direct reclaim path, > so use the min watermark. > > - compact_suit_allocation_order() has a watermark in context derived > from cc->alloc_flags. > > The only quirk is that kcompactd doesn't initialize cc->alloc_flags > explicitly. There is a direct check in kcompactd_do_work() that > passes ALLOC_WMARK_MIN, but there is another check downstack in > compact_zone() that ends up passing the unset alloc_flags. Since > they default to 0, and that coincides with ALLOC_WMARK_MIN, it is > correct. But it's subtle. Set cc->alloc_flags explicitly. > > - should_continue_reclaim() is direct reclaim, use the min watermark. > > - Finally, consolidate the two checks in compaction_ready() to a > single compaction_suitable() call passing the high watermark. > > There is a tiny change in behavior: before, compaction_suitable() > would check order-0 against min or low, depending on costly > order. Then there'd be another high watermark check. > > Now, the high watermark is passed to compaction_suitable(), and the > costly order-boost (low - min) is added on top. This means > compaction_ready() sets a marginally higher target for free pages. > > In a kernelbuild + THP pressure test, though, this didn't show any > measurable negative effects on memory pressure or reclaim rates. As > the comment above the check says, reclaim is usually stopped short > on should_continue_reclaim(), and this just defines the worst-case > reclaim cutoff in case compaction is not making any headway. > > Signed-off-by: Johannes Weiner > @@ -2513,13 +2516,13 @@ compaction_suit_allocation_order(struct zone *zone, unsigned int order, > */ > if (order > PAGE_ALLOC_COSTLY_ORDER && async && > !(alloc_flags & ALLOC_CMA)) { > - watermark = low_wmark_pages(zone) + compact_gap(order); > - if (!__zone_watermark_ok(zone, 0, watermark, highest_zoneidx, > - 0, zone_page_state(zone, NR_FREE_PAGES))) > + if (!__zone_watermark_ok(zone, 0, watermark + compact_gap(order), > + highest_zoneidx, 0, > + zone_page_state(zone, NR_FREE_PAGES))) > return COMPACT_SKIPPED; The watermark here is no longer recalculated as low_wmark_pages() but the value from above based on alloc_flags is reused. It's probably ok, maybe it's even more correct, just wasn't mentioned in the changelog as another tiny change of behavior so I wanted to point it out.