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: 138515 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp779007vqx; Tue, 12 Sep 2023 18:04:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH0FlHfrZ57S9RhgUB/P/REuRwe9cZcyb7BkdEYMzu+6MMax2JUqSDZ5eOtAy+SqrqerZbz X-Received: by 2002:a05:6e02:1ba1:b0:34c:cbd4:114b with SMTP id n1-20020a056e021ba100b0034ccbd4114bmr1362034ili.7.1694567098285; Tue, 12 Sep 2023 18:04:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694567098; cv=none; d=google.com; s=arc-20160816; b=Ha9c2D1H7f2aT/XiQ1VVL+HsRIfGzOepC7VuQ6FZQXbzRDO6QMa8w1Xl5vrZ6SJqko yvrRdaqR1quojE03+DstskaSLOpggW1NKtOL8JgEx4sOgNZV4JQocAgtOn8IAVZUu99s DYeW6+TiDCjILMSuZvo1FxLRKC5cFDeHiiCakHyE+wmLPYR8pNddr7KzutdYaG+qp0dy JThLY0PjiCwsHKhoVi3y02lkzVI1KwKmco6wNgsoJ1YkvBOqNxi2w+Ow96vFhHpKgFy5 7U9zOVYvTsnFQ6gyQZ45LKImQSeAYA1Zp1z/mAgZiEN/TlMZzh2kAdkFz3cNXV4sn2bq tn5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version:reply-to :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=TwEWLaTSuiPfXSyZQQREOyn/d6B8hR8gYLYTWMqOU5E=; fh=bUDnJOBC0/apF/24NaPi+H6rvMB40CebS5Pe6QbQjAo=; b=YWfiXjtzWaZsrcK0ELerPLipAN/XBYycS/ai+En/tLTuTToSMISJmJHUSBS7yLCnTD LY9F3p1KZ3x3TCKIR+CyNF4VdCrjjEZcFA6BPstIMh6umDiFiPnF1CiOGoxwKgiLUbVQ 0BlWpgTthwr1m2JNcaMvTpDKyOFrW8H3djkFqBjDSd1d5aMM9cZ/Z+sz3eBtymGxIEHT aSpYk4s+T1sNnJXFEV7ex+qCZaY68quyC3rVoEbpS1xP+BdnYnifhHRDxLpe4YvpEtiO IpiDp/RLxlY1eboKGDNVlj/PjiM2J+EghFfT+MQFt1ajSNeRa3k1L9XKgruKl7zN1mmJ F9IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sent.com header.s=fm1 header.b=u5uNvQki; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b="VvFvl65/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sent.com Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id v71-20020a63894a000000b0057754fff97fsi6074351pgd.492.2023.09.12.18.04.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 18:04:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@sent.com header.s=fm1 header.b=u5uNvQki; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b="VvFvl65/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sent.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 3503E85C4D47; Tue, 12 Sep 2023 09:28:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236847AbjILQ2v (ORCPT + 37 others); Tue, 12 Sep 2023 12:28:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233213AbjILQ2k (ORCPT ); Tue, 12 Sep 2023 12:28:40 -0400 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0165910F2 for ; Tue, 12 Sep 2023 09:28:37 -0700 (PDT) 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 12 Sep 2023 09:28:56 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776882389724026298 X-GMAIL-MSGID: 1776882389724026298 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 */