From patchwork Tue Sep 12 16:28:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zi Yan X-Patchwork-Id: 13381935 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 18D98CA0EF1 for ; Tue, 12 Sep 2023 16:28:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A53F76B012F; Tue, 12 Sep 2023 12:28:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A044D6B0130; Tue, 12 Sep 2023 12:28:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 87ECA6B0131; Tue, 12 Sep 2023 12:28:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 77EC46B012F for ; Tue, 12 Sep 2023 12:28:39 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 475A2B3EED for ; Tue, 12 Sep 2023 16:28:39 +0000 (UTC) X-FDA: 81228478758.27.47E683D Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by imf26.hostedemail.com (Postfix) with ESMTP id 1FB6614001C for ; Tue, 12 Sep 2023 16:28:36 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=u5uNvQki; dkim=pass header.d=messagingengine.com header.s=fm1 header.b="VvFvl65/"; spf=pass (imf26.hostedemail.com: domain of zi.yan@sent.com designates 66.111.4.26 as permitted sender) smtp.mailfrom=zi.yan@sent.com; dmarc=pass (policy=none) header.from=sent.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694536117; h=from:from:sender:reply-to: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:dkim-signature; bh=TwEWLaTSuiPfXSyZQQREOyn/d6B8hR8gYLYTWMqOU5E=; b=IS5ZOcY8R3N31u7uWjw6sgKYRpvyT8vfzECQ4I15TUL3hNUA7552iSvO5IMSxsU7QcgP7F eer24JBJXS1I+cNKd/FwZ5QthwxDqkQwYt7EcfKemgj+ZwkmE5tbUpUMujXWAiEIe25I6F 7CRMnQ67Rv/1meQblC1ebc39IGw4YLA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694536117; a=rsa-sha256; cv=none; b=36PYi2lm9iJY/WEOk9xJlNetU4nzKer8mv06UR5cN3XeqEk//fi36t2FhQ90Jig2mgOXLj QBYzJe5LuQAnh7q+0tO4QpqAkmleMdiAMGVjEX/dl+ECc3YBZgtoaVeJIooS3nzmpL5vot bJBOttPgcF3AFqRErFbzpkSJ+rxp8kQ= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=sent.com header.s=fm1 header.b=u5uNvQki; dkim=pass header.d=messagingengine.com header.s=fm1 header.b="VvFvl65/"; spf=pass (imf26.hostedemail.com: domain of zi.yan@sent.com designates 66.111.4.26 as permitted sender) smtp.mailfrom=zi.yan@sent.com; dmarc=pass (policy=none) header.from=sent.com Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 5FFBE5C0209; Tue, 12 Sep 2023 12:28:36 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Tue, 12 Sep 2023 12:28:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sent.com; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:sender:subject:subject:to:to; s=fm1; t= 1694536116; x=1694622516; bh=TwEWLaTSuiPfXSyZQQREOyn/d6B8hR8gYLY TWMqOU5E=; b=u5uNvQki5IChwpw7dqOdoH2RgOW6FYZOpuvWCwUsE8BibTdAFyC L8upBPyueKVuNqlWXYbuyapJfDQO20M5AqGh1+0aVvuzhlNl1Krtf7epALgCiqVT LtrFxAwSrToe6Er0K0x1TQOGJUoauWNEH1H9r5iPq0AQSuELfsQjRG9AbfXrPLfz M6xMX2l1mAwZ9/iAbsgg/soIaEIHaX3K9ZC3DzbgNUM+4GsJ94yzCA90KcELtR75 KHS06immhfhB8LT+Ir2TYfZg1Ha9S0LWb4+HYB3Mv0LDhdbH1t91QBfV+b73TkEX H47LcrEu6//1SXi+ITP1Xw21mEu44uXADXg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1694536116; x=1694622516; bh=TwEWLaTSuiPfXSyZQQREOyn/d6B8hR8gYLY TWMqOU5E=; b=VvFvl65/6cb6f0859IZG6gNDxwnMA826lLsINlmO37UMNzdvAeV KvEUnoG/gbp7oYZQ73UiJJiXyyO3TpEqnLU+6Cj6YZlgDhnG825QlYnTlw4bLhp8 JVzF3PzjA0HovacaUJerZ9qdg24e6KF4dV/PPPOGyaRmAekJv4SkXA1xOQtOe6Hu 2PxnMutqZ0KnjG0/dlscS3wTI67voGp/+tzIf453kIeWIUhQ+Z7OdrY75DMFLz9A zKTXBtzoxlfLqjVkSgz+FubWk32IaGcd5KJfDorOCzW3CrckRl9J49UllAbMkild lq6+F8xObqmsMXpZTojwhRCOit/zuGfhW+g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudeiiedguddtudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfrhgggfestdhqredtredttdenucfhrhhomhepkghi ucgjrghnuceoiihirdihrghnsehsvghnthdrtghomheqnecuggftrfgrthhtvghrnhepge eghedugfduuddvleehheetgeeltdetieevuefhffevkefhveeufeeiieejgedvnecuvehl uhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepiihirdihrghnse hsvghnthdrtghomh X-ME-Proxy: Feedback-ID: iccd040f4:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 12 Sep 2023 12:28:35 -0400 (EDT) From: Zi Yan To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Zi Yan , Ryan Roberts , Andrew Morton , "Matthew Wilcox (Oracle)" , David Hildenbrand , "Yin, Fengwei" , Yu Zhao , Vlastimil Babka , Johannes Weiner , Baolin Wang , Kemeng Shi , Mel Gorman , Rohan Puri , Mcgrof Chamberlain , Adam Manzanares , John Hubbard Subject: [RFC PATCH 4/4] mm/compaction: enable compacting >0 order folios. Date: Tue, 12 Sep 2023 12:28:15 -0400 Message-Id: <20230912162815.440749-5-zi.yan@sent.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230912162815.440749-1-zi.yan@sent.com> References: <20230912162815.440749-1-zi.yan@sent.com> Reply-To: Zi Yan MIME-Version: 1.0 X-Rspamd-Queue-Id: 1FB6614001C X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: tbiiq1b1mxkxr4b3iasojbxmnmcaqibp X-HE-Tag: 1694536116-897181 X-HE-Meta: U2FsdGVkX1+yRoe36Gqp1x2O2Bn9un0baSwAfz0cPNwE1gDvfVvRcdM1/Ft/XQFVjJuEgAf3QyQG9N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o3AZh2rLDNjOEeyRN3HWY0p75RcmnAN5XioQKURtj+tolAovZ/7p27p1D/ZszNXs/sQi7LK2l9yhVkGoX+eaWJ7ftcKOed0cFjh19yJH3ImrMsSuXnkUgkg5VCD5VQcnaLjPpNozS31oQV42dC6bhPXwetGpgeR9+Y34Z0NBnDodXsuUoT+zAsXMbxHfIcebMyFGoTAstgvUzy4QzPQp0TwAKMMSxn+JaWMOU3CgwyEQSXofAl20a3c3SAZrbST0LG9GWiSbmrmXN04H0qYKLhKYXPF4TDPEEmukAhGWZlID0CQ== 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: From: Zi Yan Since compaction code can compact >0 order folios, enable it during the process. Signed-off-by: Zi Yan --- mm/compaction.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index 4300d877b824..f72af74094de 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1087,11 +1087,17 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, if (PageCompound(page) && !cc->alloc_contig) { const unsigned int order = compound_order(page); - if (likely(order <= MAX_ORDER)) { - low_pfn += (1UL << order) - 1; - nr_scanned += (1UL << order) - 1; + /* + * Compacting > pageblock_order pages does not improve + * memory fragmentation. Also skip hugetlbfs pages. + */ + if (likely(order >= pageblock_order) || PageHuge(page)) { + if (order <= MAX_ORDER) { + low_pfn += (1UL << order) - 1; + nr_scanned += (1UL << order) - 1; + } + goto isolate_fail; } - goto isolate_fail; } /* @@ -1214,17 +1220,6 @@ isolate_migratepages_block(struct compact_control *cc, unsigned long low_pfn, goto isolate_abort; } } - - /* - * folio become large since the non-locked check, - * and it's on LRU. - */ - if (unlikely(folio_test_large(folio) && !cc->alloc_contig)) { - low_pfn += folio_nr_pages(folio) - 1; - nr_scanned += folio_nr_pages(folio) - 1; - folio_set_lru(folio); - goto isolate_fail_put; - } } /* The folio is taken off the LRU */