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 72F97C48297 for ; Mon, 12 Feb 2024 10:32:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C35B86B0078; Mon, 12 Feb 2024 05:32:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BE66F6B007B; Mon, 12 Feb 2024 05:32:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AAD1D6B007E; Mon, 12 Feb 2024 05:32:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 9B3FC6B0078 for ; Mon, 12 Feb 2024 05:32:37 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0934A809BB for ; Mon, 12 Feb 2024 10:32:37 +0000 (UTC) X-FDA: 81782787954.18.8B05FD0 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf16.hostedemail.com (Postfix) with ESMTP id 6AA3118000A for ; Mon, 12 Feb 2024 10:32:34 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=rvSUIlG3; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=gS0xYZ8n; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=bJ3WSxTo; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=aitiJqMK; dmarc=none; spf=pass (imf16.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 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=1707733955; 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=xEvukcfEXo+TJxamA0z62txjQmubKA5pKuuaq+G1gcE=; b=Gzax7PaKRN+Fba/UJmOq24yUaPlOye8TUUwbrzd7S6h3oq5CMKLjE1ODHjgv7eKG7gk2Bh pSpGdSzMTYug4fYpHAgaKiR5C9XLbApU8+KWxc5PoEPsZmSBC7R39C5fXaPc3Wx56sQgV+ esXwpVe6I/FsyWwlxg0kEzexF9FpCtc= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=rvSUIlG3; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=gS0xYZ8n; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=bJ3WSxTo; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=aitiJqMK; dmarc=none; spf=pass (imf16.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707733955; a=rsa-sha256; cv=none; b=QOtTd7xcACCihNdQL4Dr/hK7b2kTz23FVundCyWFVlH3i0F98+uSVv4ShW5mJIzicpisTI 8xE55YfdzQZPhTf/VsfFea5PIl0cZfTBtdJ9sav09Cxql5und5w0XAv74BMOZz7trljRaH HHuifmAKqhQWi4t+eF6Rc6nhjtdeS6c= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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-out1.suse.de (Postfix) with ESMTPS id 9A3FF21F97; Mon, 12 Feb 2024 10:32:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1707733952; 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=xEvukcfEXo+TJxamA0z62txjQmubKA5pKuuaq+G1gcE=; b=rvSUIlG3wHZ+3COtOGbqO+23go+XO6w3yhMJ+n/zeDPjJ3a8GPQMa9ORv4flGn5Y3443R+ 9E6dQJ5nqR/Tsyg6sKgnyw/WwEAszA/8wwq6eAlxFVSL+UoF/Amp+hHTZh8ahxdSS6NnDN yC6ndCQwTzNvDUuGTFGbs+uhtMMuEoo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1707733952; 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=xEvukcfEXo+TJxamA0z62txjQmubKA5pKuuaq+G1gcE=; b=gS0xYZ8nu4NnxKX23LSMEGS2YDbj9G+uPTKOzFEbShSEG21zAzGvD0mb39uLCxuzTPokZd Ps4VF5HExUHizHBA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1707733950; 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=xEvukcfEXo+TJxamA0z62txjQmubKA5pKuuaq+G1gcE=; b=bJ3WSxTopjt6ssb4s+nb9jduq3Q+G2+W5DsPGN0cJFVf9m05dNVEvpZnZ6Sxjao6OnLf1c prcZzHw63KNYrngSDx7gphq22FDLy+ZqMZY9Rr6zNNurKcwXJV0D8xbwNLxATYOL94pw8R Ei6M/nb54mE6iskJYmy3wY/4/F0g32E= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1707733950; 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=xEvukcfEXo+TJxamA0z62txjQmubKA5pKuuaq+G1gcE=; b=aitiJqMKKUrsvrkiDNzHvKT/QvhYUkSD7pXYx984PPeBi7fwYMS9rOR4o1aw7/V6GiPMy5 U2vPcQ4wTrmfNXBw== 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 8838412FF7; Mon, 12 Feb 2024 10:32:30 +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 EN7vIL7zyWU0FQAAD6G6ig (envelope-from ); Mon, 12 Feb 2024 10:32:30 +0000 Message-ID: <7f34e789-e01f-4929-a618-b73c04ebf4d2@suse.cz> Date: Mon, 12 Feb 2024 11:32:30 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] mm: compaction: update the cc->nr_migratepages when allocating or freeing the freepages Content-Language: en-US To: Baolin Wang , akpm@linux-foundation.org, Zi Yan Cc: mgorman@techsingularity.net, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <0773058df022fa701b78f9a6dfe3c501a1a77351.1705928395.git.baolin.wang@linux.alibaba.com> From: Vlastimil Babka In-Reply-To: <0773058df022fa701b78f9a6dfe3c501a1a77351.1705928395.git.baolin.wang@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 6AA3118000A X-Stat-Signature: c733etgw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Shcf7MdSNwvvQHzORgI81jvJGwJos++OmkLugjEGePGw3pPJT9JuQF6QRatgrZ7JPrIbUc8AMkfQNQ8ykuDRhbXIGIFFpEyI3aZaP8VmXIX5Zv5+ne3iqeJERMzIiESmLn3JnXnVUeafMq110R/1JQsIIKwu+k4R8mRNgkP5yDO9Ov+QcbMp304yzPkmnBvV410Fmhu/o3l7Rg9Ms73vhHhETCqInqtlozkXr87N2nGmR+yZ9+mw0bJsiBhj+VsOPMyTTmaAVS81V52ZoCdk6eM8lXf26rWyJ2RN8XIBrKUrY= 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: On 1/22/24 14:01, Baolin Wang wrote: > Currently we will use 'cc->nr_freepages >= cc->nr_migratepages' comparison > to ensure that enough freepages are isolated in isolate_freepages(), however > it just decreases the cc->nr_freepages without updating cc->nr_migratepages > in compaction_alloc(), which will waste more CPU cycles and cause too many > freepages to be isolated. Hm yeah I guess this can happen with fast_isolate_freepages() if it returns with something but not all the freepages that are expected to be needed, and then we get to isolate_freepages() again. > So we should also update the cc->nr_migratepages when allocating or freeing > the freepages to avoid isolating excess freepages. And I can see fewer free > pages are scanned and isolated when running thpcompact on my Arm64 server: > k6.7 k6.7_patched > Ops Compaction pages isolated 120692036.00 118160797.00 > Ops Compaction migrate scanned 131210329.00 154093268.00 > Ops Compaction free scanned 1090587971.00 1080632536.00 > Ops Compact scan efficiency 12.03 14.26 > > Moreover, I did not see an obvious latency improvements, this is likely because > isolating freepages is not the bottleneck in the thpcompact test case. > k6.7 k6.7_patched > Amean fault-both-1 1089.76 ( 0.00%) 1080.16 * 0.88%* > Amean fault-both-3 1616.48 ( 0.00%) 1636.65 * -1.25%* > Amean fault-both-5 2266.66 ( 0.00%) 2219.20 * 2.09%* > Amean fault-both-7 2909.84 ( 0.00%) 2801.90 * 3.71%* > Amean fault-both-12 4861.26 ( 0.00%) 4733.25 * 2.63%* > Amean fault-both-18 7351.11 ( 0.00%) 6950.51 * 5.45%* > Amean fault-both-24 9059.30 ( 0.00%) 9159.99 * -1.11%* > Amean fault-both-30 10685.68 ( 0.00%) 11399.02 * -6.68%* > > Signed-off-by: Baolin Wang > --- > mm/compaction.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/mm/compaction.c b/mm/compaction.c > index 066b72b3471a..6c84e3a5b32b 100644 > --- a/mm/compaction.c > +++ b/mm/compaction.c > @@ -1779,6 +1779,7 @@ static struct folio *compaction_alloc(struct folio *src, unsigned long data) > dst = list_entry(cc->freepages.next, struct folio, lru); > list_del(&dst->lru); > cc->nr_freepages--; > + cc->nr_migratepages--; This is breaking the tracepoint TRACE_EVENT(mm_compaction_migratepages) which does __entry->nr_failed = cc->nr_migratepages - nr_succeeded; and is called after migrate_pages() finishes, so now this will underflow. Probably need to get a snapshot of cc->nr_migratepages before calling migrate_pages() and then feed that to the tracepoint instead of cc. > > return dst; > } > @@ -1794,6 +1795,7 @@ static void compaction_free(struct folio *dst, unsigned long data) > > list_add(&dst->lru, &cc->freepages); > cc->nr_freepages++; > + cc->nr_migratepages++; > } > > /* possible outcome of isolate_migratepages */