From patchwork Mon May 15 11:33:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mel Gorman X-Patchwork-Id: 13241281 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 21BB5C77B7D for ; Mon, 15 May 2023 11:34:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9B1FE900005; Mon, 15 May 2023 07:34:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 961BC900002; Mon, 15 May 2023 07:34:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 829D1900005; Mon, 15 May 2023 07:34:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 73575900002 for ; Mon, 15 May 2023 07:34:11 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 09A8E161428 for ; Mon, 15 May 2023 11:34:11 +0000 (UTC) X-FDA: 80792280702.25.D79269E Received: from outbound-smtp36.blacknight.com (outbound-smtp36.blacknight.com [46.22.139.219]) by imf03.hostedemail.com (Postfix) with ESMTP id 2BEB320011 for ; Mon, 15 May 2023 11:34:08 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; spf=pass (imf03.hostedemail.com: domain of mgorman@techsingularity.net designates 46.22.139.219 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684150449; a=rsa-sha256; cv=none; b=GhVMJMCfCcoDPlQrF6iM6PiPqZQwofFbJcTSclrHVzRqXVrFlWsB2UzXuO6PpDT8wcGF2p l1CYK6P72k/sTu5i8mjCi6J82mPoNyo8wJPIlcD87k7+/vaC7NJwoEKNno8xoWmF9T3pxv ZOuAoluBJHBrGpg/3kqe1l0a/yzsYb8= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; spf=pass (imf03.hostedemail.com: domain of mgorman@techsingularity.net designates 46.22.139.219 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684150449; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y1cOqJXY7aZ9Lb2ZYK9B8/0b1tBjH9Wwuq/UJgsC/Lo=; b=5H3zUqPHDBnTQ4dxZXlkjLcVPbXDySbJqXD39TQAAn97T4yXnyO08vEtO0c4RX4X2SiLvL LsegMAKn5YgPA6WcRNW/kBefbZtHww7XdXG4zpEd51wFiKshbHdR4n62bAsw3mLDBmuZw6 unoPtD2O9cjyJUuOd8l/BUiafqhilc0= Received: from mail.blacknight.com (pemlinmail04.blacknight.ie [81.17.254.17]) by outbound-smtp36.blacknight.com (Postfix) with ESMTPS id 3A417230D for ; Mon, 15 May 2023 12:34:07 +0100 (IST) Received: (qmail 25659 invoked from network); 15 May 2023 11:34:07 -0000 Received: from unknown (HELO localhost.localdomain) (mgorman@techsingularity.net@[193.118.249.27]) by 81.17.254.9 with ESMTPA; 15 May 2023 11:34:06 -0000 From: Mel Gorman To: Vlastimil Babka Cc: Andrew Morton , Jiri Slaby , Maxim Levitsky , Michal Hocko , Pedro Falcato , Paolo Bonzini , Chuyi Zhou , Linux-MM , LKML , Mel Gorman Subject: [PATCH 1/4] mm: compaction: Ensure rescanning only happens on partially scanned pageblocks Date: Mon, 15 May 2023 12:33:41 +0100 Message-Id: <20230515113344.6869-2-mgorman@techsingularity.net> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230515113344.6869-1-mgorman@techsingularity.net> References: <20230515113344.6869-1-mgorman@techsingularity.net> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: qgpo9aimapjxg683jwcqth3dsmsft6yc X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 2BEB320011 X-HE-Tag: 1684150448-108526 X-HE-Meta: U2FsdGVkX19ZNXaeFILcePQWPYoGRXqkH5x+4OHWWnjjx/aEeqVX5yDsQvIICzpXOIBr6qcLfoyh6mBzZ/etVz7tqzoZsMKVaA5MCsbCIz0MyeOT6D5zHEKB7OenogMnzl16EvbnqrGZDz3QwcFz8tLXsVcjHLhrN92yHbCwj+WQICpNcGyg9QlRV2g2kAVRYrke5OxC0m3X+3AcKu3uYvfuXnNjzEMjFQuXMtUG4nSdFZOjtOgO/Pk5vLBulwFCU0MSOUwJThMWPw8c1TK8ArM3xTstwuM+Fdngjo673U3OgZMuutC1js7RvRCO2x1SCu+u22LC8e9IDan4fkZVAdvBnm+M3Vv+QskFPPBBEJIczoxeA3//ItwyIa6ErfYJUSRxAmf+5mg6cnXufzQ58bF5u6uSRsLFndod4m3Kjyxw2RLt8vfVuNVL9L3yTP+0IM+tx3iuJcM0DPIJ1SEXEEvqdnWLYuyYzq7Z4hygY3fS3aGm8SlXcH+M1nnrkNoBfQN4+jHJYbo8t8VPkcxHd1qWk/9aQ+qUiXWcUaAi178vrgfO7ounRKuF5UBoU0KDPD2RnoyaCGxRHHhmZ8pi1+OYFlgm35tlfzlgvhcqTXP8Em3MdIDpXhqUVzOKYZN1aPdtS9QTTeX3vUyfmXqXiEdHfHlOwTJ4C+znsblVWwqUHiDdKxbhKv8uUPQRkhRAOjuR40b6r+mLQyJrGxQr/tN8KN6BErH4nktiguyveIWuLBGhUZhlGI9u6Ex+yGfkg85Fhu9IHch8URS6kRvrV2HDVhUvglDp0SkWBg8gOoAkVXHTJiwolvPQ0wBZchFJXdz3ABtPpShFgrW2IkP7osnCpDl3AFI/+fieSA2UUoYsKUIyQp1I7nmm9NJXyspVQ0uHk0oRamYzNxD6i0nZ28aefM++UMoSe/SwylEfAEHPvQFlJTTsadLtMXm+nBVUgUVaaHwnI3VBXn3hKmr 4aR4wmBl KrPHM/kIAKZZd67UVT1HkZ2UTKZ5v1wAXV+xcXhunHcET7GIzjCtFQG8XURMDF6M23J4r1TaSarRvR1GYpuf9zCAgtYUejmITjMbhCYpzQj0T8WP4HNioQ3OlAKlzWRO/CX5gCoA3ovXeASQLIs2iKeZA+F5/t4+hGY42kJkZhr31yJdpCkyx5csqcGWrYpYs+n4ATq9RGe2mYNXDZUy9PVg0AmTpUX4RarfT7f+xocE+RnET+bd5lPXbeLkTCdgZWWjAQ5GZ5+RnZvlAiXa9HCkcvy004Nk5IsZY 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: compact_zone() intends to rescan pageblocks if there is a failure to migrate "within the current order-aligned block". However, the pageblock scan may already be complete and moved to the next block causing the next pageblock to be "rescanned". Ensure only the most recent pageblock is rescanned. Reported-by: Vlastimil Babka Signed-off-by: Mel Gorman Acked-by: Vlastimil Babka --- mm/compaction.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index c8bcdea15f5f..81791c124bb8 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -2464,8 +2464,9 @@ compact_zone(struct compact_control *cc, struct capture_control *capc) * fast_find_migrateblock revisiting blocks that were * recently partially scanned. */ - if (cc->direct_compaction && !cc->finish_pageblock && - (cc->mode < MIGRATE_SYNC)) { + if (!pageblock_aligned(cc->migrate_pfn) && + cc->direct_compaction && !cc->finish_pageblock && + (cc->mode < MIGRATE_SYNC)) { cc->finish_pageblock = true; /* From patchwork Mon May 15 11:33:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mel Gorman X-Patchwork-Id: 13241282 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 D621FC77B75 for ; Mon, 15 May 2023 11:34:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F23D900006; Mon, 15 May 2023 07:34:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A26C900002; Mon, 15 May 2023 07:34:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 59182900006; Mon, 15 May 2023 07:34:21 -0400 (EDT) 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 4A9B7900002 for ; Mon, 15 May 2023 07:34:21 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 2CEA81C8C96 for ; Mon, 15 May 2023 11:34:21 +0000 (UTC) X-FDA: 80792281122.27.AFBD194 Received: from outbound-smtp17.blacknight.com (outbound-smtp17.blacknight.com [46.22.139.234]) by imf02.hostedemail.com (Postfix) with ESMTP id 404FE8000E for ; Mon, 15 May 2023 11:34:19 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf02.hostedemail.com: domain of mgorman@techsingularity.net designates 46.22.139.234 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684150459; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pi112mLeRM+erqz/KNGo0TvI7Z4NtOUOSuT9Dm0OpxM=; b=40sNeyZYihckq912vdYXP23q6RCM4R6ccy8UwWNWla2SlITfsget1Jg9MU4V7v00V3SPqG SOcmJfOFkzx6DzCsWWhcxqQ1BUR75a+zFXQBZykHhQmOsJvu/Lg9HdCErGwaSlfppTizDy HoMmvIMb4BQcImtR315qkDgXazS2tFc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684150459; a=rsa-sha256; cv=none; b=k3VK1cmza4gsXrWe1bfBbaGoxZiddKUUqNmdwcY1a64yfaZQ9OrMXBpUSkHro+GPblyfyW 9VO1POrnDKMEEqOazAtm8Na0k1586k9ky7CkUP/7OZ1ypR6rOUajjbgosbqVxCQoKbHJ/G kxIKg8TVBK4PbwZzmmxWZLlkS7HWmAs= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf02.hostedemail.com: domain of mgorman@techsingularity.net designates 46.22.139.234 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net Received: from mail.blacknight.com (pemlinmail04.blacknight.ie [81.17.254.17]) by outbound-smtp17.blacknight.com (Postfix) with ESMTPS id DA4F81C451F for ; Mon, 15 May 2023 12:34:17 +0100 (IST) Received: (qmail 26294 invoked from network); 15 May 2023 11:34:17 -0000 Received: from unknown (HELO localhost.localdomain) (mgorman@techsingularity.net@[193.118.249.27]) by 81.17.254.9 with ESMTPA; 15 May 2023 11:34:17 -0000 From: Mel Gorman To: Vlastimil Babka Cc: Andrew Morton , Jiri Slaby , Maxim Levitsky , Michal Hocko , Pedro Falcato , Paolo Bonzini , Chuyi Zhou , Linux-MM , LKML , Mel Gorman Subject: [PATCH 2/4] mm: compaction: Only force pageblock scan completion when skip hints are obeyed Date: Mon, 15 May 2023 12:33:42 +0100 Message-Id: <20230515113344.6869-3-mgorman@techsingularity.net> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230515113344.6869-1-mgorman@techsingularity.net> References: <20230515113344.6869-1-mgorman@techsingularity.net> MIME-Version: 1.0 X-Stat-Signature: zpyutr4g4pi8ztj8sxmqu7riwsaecxno X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 404FE8000E X-Rspam-User: X-HE-Tag: 1684150458-575097 X-HE-Meta: U2FsdGVkX1+i8z4pbFqvlxmkq5ThwucxDCEnw/AlX+4lrfH9ZLTgv6LagOU9/pVpg6vS6u4qi/ocDO585luBgaYhJJS/6z0DMQMIeWIqYtm6p2ZE1QYawDAMvluaPzS7668mDMigxjcabN17R04NDhRzffSi0WKY1u6mdsFB97zX/4ZVCeAgUuvI5NNxTcd4oEl/2yzYvDftI9M47YluNQ3PNIIGkcuIKVnbRHrZSsvHxadWS/wPNXKZz5j+Dydso+1yjUvaZKdaO2quGb887EpiteFpcCe6ekQHUmDhnY3PVQ9Vu80ecZuqiKDdkcUAskaveByat4eyXh5mYngtJQXFTUMUN1Uf26pjL/tHVbpFIznYmMMu79pBKZvN7T7RPy5vFQh/ga/3OdHu68nfRO8ERmzYHhQ5ZKsbGlEqHhmMq5PsXHZqiwd/r7hDecIh+sLi6TmNxTK62hMKxz50m/ZR1S2kvTgUooikPvOVXN+q/IeNSQ1j0w2CQu5iqupTMsB09pS4pQHR0Z4ortVwlR0Qly1fSjmAzTyU1H8hkfUJDsc1t0tIIZcLOvPgzmZZcBYoQhGqgp07853z5vOk+kdAZiMpXJnSjh6Or8N/rNdbz/zV52bponmbS1uGmhu3c0n1itO8wYsavmxyhATzeY8iqU6/HW1OGl2/A/38dnVLGNuwvHYLusy02KxhvcMS5F/e9q/c6ImFaOgp3yIzkj/vVEveZZttDKZYvjLfhTw3z1cAkPkRyMwDX3RAnt2t0pBGv1xRcdQ/ZMFi5OPMKccx7dMpuJ7sGTvjSuWeo8bS34fke5GSRfZeyFCRnCSrO1mTqErOvGRorhXliRYUeuQY4/FffswSlPRx017EkY1mh/6ql4T7qDsATCPVuRJ9Cd8LmfS6WmeNAxA/qv6WBtVumd3r1YnwmSkgNzRA68U1QFLAS4/mqrk9NGMiNu2YdPkIVGeQr1ymG4wP9UO 9zsO4ief LAVYR+IBrh7sXO0PxcxtYejFWnc/N4KMEqDPsfC1+dWWbLCbOVbQKI3mS+/erqmbneyg7leYCsXgCyWQTQhRjmq2prd0agNcTXcJBdUlIqTpmdYpPsjbgZc5vUU4XJmfCFuqHk335mk67Vi1kHZXtEb9Nz/5yeftpSVmXqA7tmfjdG5FaPRxzvDZqSe9s2VEAUbKda38oHC14TTYyaJ8FP+Y/y+hLJi2TR5unckpDa5uVe0vUyXcJWSFioMD71NS9E/PGpiUbyRwFHn5FLZAIVLFiIVZN7mscWKkj 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: fast_find_migrateblock relies on skip hints to avoid rescanning a recently selected pageblock but compact_zone() only forces the pageblock scan completion to set the skip hint if in direct compaction. While this prevents direct compaction repeatedly scanning a subset of blocks due to fast_find_migrateblock(), it does not prevent proactive compaction, node compaction and kcompactd encountering the same problem described in commit cfccd2e63e7e ("mm, compaction: finish pageblocks on complete migration failure"). Force the scan completion of a pageblock to set the skip hint if skip hints are obeyed to prevent fast_find_migrateblock() repeatedly selecting a subset of pageblocks. Suggested-by: Vlastimil Babka Signed-off-by: Mel Gorman Acked-by: Vlastimil Babka --- mm/compaction.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index 81791c124bb8..accc6568091a 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -2456,7 +2456,8 @@ compact_zone(struct compact_control *cc, struct capture_control *capc) } /* * If an ASYNC or SYNC_LIGHT fails to migrate a page - * within the current order-aligned block, scan the + * within the current order-aligned block and + * fast_find_migrateblock may be used then scan the * remainder of the pageblock. This will mark the * pageblock "skip" to avoid rescanning in the near * future. This will isolate more pages than necessary @@ -2465,7 +2466,7 @@ compact_zone(struct compact_control *cc, struct capture_control *capc) * recently partially scanned. */ if (!pageblock_aligned(cc->migrate_pfn) && - cc->direct_compaction && !cc->finish_pageblock && + !cc->ignore_skip_hint && !cc->finish_pageblock && (cc->mode < MIGRATE_SYNC)) { cc->finish_pageblock = true; From patchwork Mon May 15 11:33:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mel Gorman X-Patchwork-Id: 13241286 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 96CD2C77B7D for ; Mon, 15 May 2023 11:34:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D430900007; Mon, 15 May 2023 07:34:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 283F4900002; Mon, 15 May 2023 07:34:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 19A07900007; Mon, 15 May 2023 07:34:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 0AA58900002 for ; Mon, 15 May 2023 07:34:32 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id CFBE8141405 for ; Mon, 15 May 2023 11:34:31 +0000 (UTC) X-FDA: 80792281542.07.BC25FFB Received: from outbound-smtp04.blacknight.com (outbound-smtp04.blacknight.com [81.17.249.35]) by imf08.hostedemail.com (Postfix) with ESMTP id ED9DC160017 for ; Mon, 15 May 2023 11:34:29 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of mgorman@techsingularity.net designates 81.17.249.35 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684150470; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Jz8SIeZM33TCY29BiJtLYJYjb71lbG7QpgZzYM5PrZA=; b=KF3vx0LsXHp0/I5tYycdPYi5B3VmLmQLoGQouf0n8wo+F38nvf5L+mGNxqoSlHm1DL+YHb 0MRY2r6IFVMzNydRu53U6Rseh9717zuiSJzWDqvDZdV9Mk6LhQjyGEyedUAMQPvgiEMjPP xPv52mA8x0pHtR+NwpKme0xFCKjAYzc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684150470; a=rsa-sha256; cv=none; b=Z8yVwYFbWdra+zygCeXQYo98JB9gIJ0C/84WoGmykaOd8z1fdnbT6TTB/lKTHol5PgzQjS VDI2I93Fs4PanjVOdfWCU1lSkVJNdnrdvlfWbjkwmRJzallHj5k/Irv9nrOusqYtLyhEuQ aiTXoijdbAEdPLe/bwNdvEVuFzpl8JU= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of mgorman@techsingularity.net designates 81.17.249.35 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net; dmarc=none Received: from mail.blacknight.com (pemlinmail04.blacknight.ie [81.17.254.17]) by outbound-smtp04.blacknight.com (Postfix) with ESMTPS id 8D063BEE71 for ; Mon, 15 May 2023 12:34:28 +0100 (IST) Received: (qmail 27031 invoked from network); 15 May 2023 11:34:28 -0000 Received: from unknown (HELO localhost.localdomain) (mgorman@techsingularity.net@[193.118.249.27]) by 81.17.254.9 with ESMTPA; 15 May 2023 11:34:28 -0000 From: Mel Gorman To: Vlastimil Babka Cc: Andrew Morton , Jiri Slaby , Maxim Levitsky , Michal Hocko , Pedro Falcato , Paolo Bonzini , Chuyi Zhou , Linux-MM , LKML , Mel Gorman Subject: [PATCH 3/4] mm: compaction: Update pageblock skip when first migration candidate is not at the start Date: Mon, 15 May 2023 12:33:43 +0100 Message-Id: <20230515113344.6869-4-mgorman@techsingularity.net> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230515113344.6869-1-mgorman@techsingularity.net> References: <20230515113344.6869-1-mgorman@techsingularity.net> MIME-Version: 1.0 X-Rspamd-Queue-Id: ED9DC160017 X-Rspam-User: X-Rspamd-Server: rspam06 X-Stat-Signature: zemrrrc7fzusjd935pdxzcy6zhhe65in X-HE-Tag: 1684150469-927299 X-HE-Meta: U2FsdGVkX19If7R4JO55heFX7RsBWGyr5ADVXroZ5Bm7NDfCTKGxlCmRMPpDEmP0GhnmqyUEKXUTqIrrJxPOLiQtnN56zm31VLj2zUk+8IMwmF7Aqr2jTz3n3H+MZx1herGRkecfCKzrhgsFnX974vozXKnRX6I3CE+CHVCep9ve04CsAun1M22BK+YtB5fbMSt/QgX5+967Xaoq54+2ebygmow8tJ8AsHD0JjRXhiyHYS/PmTIIkn+pPmCIP4G+PgyO+mb8onYRjws7NOlXqalI2taWkVXQ55YiXe4tqnMtOPAueFO2yxocATPY4lgVxXj2N8ZWnyzdltdfrmQPUwgPHOINPrplfT9FmiHYFTiF1evZe1EU6GC3Jv8WQriRy7rvrrIUB9KIZ3K6bqw4FpGa88mcodMB144tFPuXy8tWrQnA2FU1Jjx0xCkuc06/NnBNM+NuuVKVMfwmEzO3dpywnGTYMG9nQjlstOTTohyB9zm5mcXPldgVfgLQ1gdChSLvi8lNBLCb2SO9ExskF4pdmpcGSaJfkoodS51Qoriij43+lpbOx3IACKlqvyiA79Xe2H3i7W36eEfSaejscfcfs+yDevelVg4sJLKqtKsIhaMK9kZB4xIvgCq/HCG3jVNgyKW9hMonJKfchP94CNTT6WD4NFZYf8APd0uZiExdPf6cpYvzTdpRtuO5MuuERvWo4D8mstcYdPuPQSrko3bsTwHSV5OlVSHnjnaXbQtD9enO28xzH7z/POGcPJkMErEUTY1wS556AHqCBQ9/9AAye97xVIUWh4OteW7ZatAZSfDw3d84X/pU0EEl3ogSFwqzA4KLaJmCNwr5Td3MciGjOKXLzHRawiY/xrr5ae9MDDHCE++6kAS7JKhdBStM1I4OjV+Dl+LngcXvK66wm7JGcfkj4D3329KaBIjuVzYH9u/dSB16//DirMtcM2mYqLEAJlqH+AVKcYhgv0s uYF2lHm+ hpeg/k9ACX/TMX4NSBSMxuqMngrufdrYxE3ul1lb1BrorCObg4pKh2aKhk2fD1rd601NvGaJXOQf7RHruKZG2lPGHVZbdZ/R4HPfTT0l4pAB7KodEtXcN4H7wYxt42FhEj2HunPGOBE78Ijfgeu7ykew7Epk9C50ILxhJth5xqfTtHklNllN2BFLIKDT6p0FJii8ItD7ixFx4zUW5eklauP84MbrhJvTlxQ3hjYoEqmAVNx7MUJcRXZiHCtv2pZLffKMm/qmlVvIjx5dKikR3jaGUrfxjH38sMEtw 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: isolate_migratepages_block should mark a pageblock as skip if scanning started on an aligned pageblock boundary but it only updates the skip flag if the first migration candidate is also aligned. Tracing during a compaction stress load (mmtests: workload-usemem-stress-numa-compact) that many pageblocks are not marked skip causing excessive scanning of blocks that had been recently checked. Update pageblock skip based on "valid_page" which is set if scanning started on a pageblock boundary. Signed-off-by: Mel Gorman --- mm/compaction.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index accc6568091a..d7be990b1d60 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -392,18 +392,14 @@ void reset_isolation_suitable(pg_data_t *pgdat) * Sets the pageblock skip bit if it was clear. Note that this is a hint as * locks are not required for read/writers. Returns true if it was already set. */ -static bool test_and_set_skip(struct compact_control *cc, struct page *page, - unsigned long pfn) +static bool test_and_set_skip(struct compact_control *cc, struct page *page) { bool skip; - /* Do no update if skip hint is being ignored */ + /* Do not update if skip hint is being ignored */ if (cc->ignore_skip_hint) return false; - if (!pageblock_aligned(pfn)) - return false; - skip = get_pageblock_skip(page); if (!skip && !cc->no_set_skip_hint) set_pageblock_skip(page); @@ -470,8 +466,7 @@ static void update_cached_migrate(struct compact_control *cc, unsigned long pfn) { } -static bool test_and_set_skip(struct compact_control *cc, struct page *page, - unsigned long pfn) +static bool test_and_set_skip(struct compact_control *cc, struct page *page) { return false; } @@ -1075,9 +1070,9 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, lruvec_memcg_debug(lruvec, page_folio(page)); /* Try get exclusive access under lock */ - if (!skip_updated) { + if (!skip_updated && valid_page) { skip_updated = true; - if (test_and_set_skip(cc, page, low_pfn)) + if (test_and_set_skip(cc, valid_page)) goto isolate_abort; } From patchwork Mon May 15 11:33:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mel Gorman X-Patchwork-Id: 13241287 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 6627AC77B75 for ; Mon, 15 May 2023 11:34:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 03CE5900008; Mon, 15 May 2023 07:34:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F2DFF900002; Mon, 15 May 2023 07:34:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E1D13900008; Mon, 15 May 2023 07:34:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id D43B2900002 for ; Mon, 15 May 2023 07:34:42 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 9C1BF41490 for ; Mon, 15 May 2023 11:34:42 +0000 (UTC) X-FDA: 80792282004.16.C36C655 Received: from outbound-smtp42.blacknight.com (outbound-smtp42.blacknight.com [46.22.139.226]) by imf15.hostedemail.com (Postfix) with ESMTP id A1B61A0007 for ; Mon, 15 May 2023 11:34:40 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of mgorman@techsingularity.net designates 46.22.139.226 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684150480; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4egGt2Hlv8ZiZOcQjixQGa0JaEL2H2KNf/q3/YHYMsA=; b=IftRqqGPoMrkQgGdh5yCRkRXblUabC5NE3iFLzLrauL4uVV613RL0CZ6HV3y/uBMM+gtHK muYuDIEbJqb9fQkLNKtwdXv3d7hydv/7SAUzLAYsSz45ymevWkbUn9Rjso5x/VHEORq13Z bj4U3dIMrLYFpygjs7IhE8qv/sONhl4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684150480; a=rsa-sha256; cv=none; b=3OLMBKUcz6DTprM1U4D/XbSYMNdyucceCyKhkyaBzayxAUV8rJdny/Itsml9C9z/vxGAvR 7HKX7H3tV4+6uDkkdcT8B/KJNB1R5jX6xCVEbDHXKaFpVi4IfOxkoc5KKrlHQ8vEfw0K2C 0PqysogqOoXPPw68nib8nznaTRpzR1g= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; spf=pass (imf15.hostedemail.com: domain of mgorman@techsingularity.net designates 46.22.139.226 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net; dmarc=none Received: from mail.blacknight.com (pemlinmail04.blacknight.ie [81.17.254.17]) by outbound-smtp42.blacknight.com (Postfix) with ESMTPS id 48F9D230D for ; Mon, 15 May 2023 12:34:39 +0100 (IST) Received: (qmail 27631 invoked from network); 15 May 2023 11:34:39 -0000 Received: from unknown (HELO localhost.localdomain) (mgorman@techsingularity.net@[193.118.249.27]) by 81.17.254.9 with ESMTPA; 15 May 2023 11:34:38 -0000 From: Mel Gorman To: Vlastimil Babka Cc: Andrew Morton , Jiri Slaby , Maxim Levitsky , Michal Hocko , Pedro Falcato , Paolo Bonzini , Chuyi Zhou , Linux-MM , LKML , Mel Gorman Subject: [PATCH 4/4] Revert "Revert "mm/compaction: fix set skip in fast_find_migrateblock"" Date: Mon, 15 May 2023 12:33:44 +0100 Message-Id: <20230515113344.6869-5-mgorman@techsingularity.net> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230515113344.6869-1-mgorman@techsingularity.net> References: <20230515113344.6869-1-mgorman@techsingularity.net> MIME-Version: 1.0 X-Rspamd-Queue-Id: A1B61A0007 X-Rspam-User: X-Rspamd-Server: rspam06 X-Stat-Signature: 5xf5pjzkixe4dn3attt9a8iepdiu3gzz X-HE-Tag: 1684150480-742089 X-HE-Meta: U2FsdGVkX19vwErwcsoI0KsvGIW3KuTQeZ+Eg7hxxg/tL35LXnAuYk1BaOomIdFzRqkSJHIpQLZUToPdi8vfyuWT34UaWgmpHMZIKr3OtpSvvulP7GwV3gPuTM3NoJN5EQPvQJYDquACk/gxa/Ax7AI2TYmvO7JZ9CB8CggJ3EU6uCuWaBsD0Bb167/nUDqwazZ4sPGQGX/j1eM1dEPbrAMdpsK6ReK8jJG2aEnTl6NPhr2Qy6zp4S4IKwKDr93pcuclBflERa1LCA8USB9ABKyMC8JPqopfhNyrcf/q/U2SAvv45+Ov4/1rDMBeHceRorIdv+6u1ytmxa5OZA7S5kHQdLYtpiNqNKyb/anZOHnvb8yROmIgd0M1HctzvKt/vGezLIcPoraWxxdU2DCKud2xSfEEDUCeBXc22sl5zkCbvPDEhQL0oX4+6IQhDcZHAvhuqnEBc8+yOpvxsXFHrleRn9ezZZs4/Ty3HTEr+NiwZpqlP9z6Fo98gkYcxem2OI3UWbadcLK3VtYSmJwVZkM/LfZKdxtQ/UBhHSSYAPWn+cwqBmreGrABL1qTAfqPBTkrvK6lZbc01L4w78dWRuJlxuGw0y+yfcI6yYTXU11a3GXA0p1XziUEim0EijwASnMvAOo2c0mhH/n29qdMJFkKJh+TvsQMfjH78chiVbxKoHSqb8OVkoVN5LOf5DfhtrF/O2Z2WAMO8GkL9w4yYimxEOKehwletWZxnPtfFljSMM/2/9USElXk+fcdwpEY1tAWI6gp6HfVSpHZnkrw5JMEYtHAR6Fo4hKjY3bzB4drMffaAs848EuJt2m/EVnpJyFUJESZUa7wSTWbl0dtsPH1Bp0tAV3HLj4lZzvIsklbQcWULgvbjJfQimkgOxJkVNds0cRx/Q7WAvlieLvgIbSHkT/eE99pQ50e8PZO/9hOkiLt0SdRfx6RLDSaagSL7Rijtp0FVYdCTeV42Yk 7x+o04Sd DC+nfVOZ0UZihwaS6xOr9m5K2sbSSu2yrj11AcUVW7/bLUuBJS5V9/Jbj77ahSOKcl5mccGVhPLkLtkgT+i3t9hs8n6yppgakth1dh+R5lCVOVBD/Ar30RE2kGzSwjHEMq4ZHx8+3HV6UCuBRWJtMa9Qcer/jkkC4sKLe5waynjXzDomiauKwJjYLTb9jKfHQlYBvkZGsaqY6/3lYSefuIy90dsU9jLoCwsPDVvE7pYRlbgPiKEJoajBbI/2vXtxnVc9Gby5+SokkNrhYXBlSAZLAebdCenjCoNF2+EEchbOMwQVNqweF0Si64GFbMfxaT4gj3VwuEw5KHGs1YHOaC126H6Vyzj09nXphQMRTTBUCkUAS8aRD6faDVOyoTBfLesK8nviMHmtFkHY= 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: This reverts commit 95e7a450b819 ("Revert "mm/compaction: fix set skip in fast_find_migrateblock""). Commit 7efc3b726103 ("mm/compaction: fix set skip in fast_find_migrateblock") was reverted due to bug reports about khugepaged consuming large amounts of CPU without making progress. The underlying bug was partially fixed by commit cfccd2e63e7e ("mm, compaction: finish pageblocks on complete migration failure") but it only mitigated the problem and Vlastimil Babka pointing out the same issue could theoretically happen to kcompactd. As pageblocks containing pages that fail to migrate should now be forcibly rescanned to set the skip hint if skip hints are used, fast_find_migrateblock() should no longer loop on a small subset of pageblocks for prolonged periods of time. Revert the revert so fast_find_migrateblock() is effective again. Using the mmtests config workload-usemem-stress-numa-compact, the number of unique ranges scanned was analysed for both kcompactd and !kcompactd activity. 6.4.0-rc1-vanilla kcompactd 7 range=(0x10d600~0x10d800) 7 range=(0x110c00~0x110e00) 7 range=(0x110e00~0x111000) 7 range=(0x111800~0x111a00) 7 range=(0x111a00~0x111c00) !kcompactd 1 range=(0x113e00~0x114000) 1 range=(0x114000~0x114020) 1 range=(0x114400~0x114489) 1 range=(0x114489~0x1144aa) 1 range=(0x1144aa~0x114600) 6.4.0-rc1-mm-revertfastmigrate kcompactd 17 range=(0x104200~0x104400) 17 range=(0x104400~0x104600) 17 range=(0x104600~0x104800) 17 range=(0x104800~0x104a00) 17 range=(0x104a00~0x104c00) !kcompactd 1793 range=(0x15c200~0x15c400) 5436 range=(0x105800~0x105a00) 19826 range=(0x150a00~0x150c00) 19833 range=(0x150800~0x150a00) 19834 range=(0x11ce00~0x11d000) 6.4.0-rc1-mm-follupfastfind kcompactd 22 range=(0x107200~0x107400) 23 range=(0x107400~0x107600) 23 range=(0x107600~0x107800) 23 range=(0x107c00~0x107e00) 23 range=(0x107e00~0x108000) !kcompactd 3 range=(0x890240~0x890400) 5 range=(0x886e00~0x887000) 5 range=(0x88a400~0x88a600) 6 range=(0x88f800~0x88fa00) 9 range=(0x88a400~0x88a420) Note that the vanilla kernel and the full series had some duplication of ranges scanned but it was not severe and would be in line with compaction resets when the skip hints are cleared. Just a revert of commit 7efc3b726103 ("mm/compaction: fix set skip in fast_find_migrateblock") showed excessive rescans of the same ranges so the series should not reintroduce bug 1206848. Link: https://bugzilla.suse.com/show_bug.cgi?id=1206848 Signed-off-by: Mel Gorman Acked-by: Vlastimil Babka --- mm/compaction.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mm/compaction.c b/mm/compaction.c index d7be990b1d60..91af6a8b7a98 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1859,7 +1859,6 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc) pfn = cc->zone->zone_start_pfn; cc->fast_search_fail = 0; found_block = true; - set_pageblock_skip(freepage); break; } }