From patchwork Fri Sep 1 15:51:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13372167 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 78A39CA0FE1 for ; Fri, 1 Sep 2023 07:52:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A56438D0021; Fri, 1 Sep 2023 03:52:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A04468D0002; Fri, 1 Sep 2023 03:52:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8F4CF8D0021; Fri, 1 Sep 2023 03:52:17 -0400 (EDT) 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 7EFD18D0002 for ; Fri, 1 Sep 2023 03:52:17 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 4AF981A017B for ; Fri, 1 Sep 2023 07:52:17 +0000 (UTC) X-FDA: 81187260714.22.CFF3347 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by imf30.hostedemail.com (Postfix) with ESMTP id C85B880008 for ; Fri, 1 Sep 2023 07:52:14 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=none; dmarc=none; spf=none (imf30.hostedemail.com: domain of shikemeng@huaweicloud.com has no SPF policy when checking 45.249.212.51) smtp.mailfrom=shikemeng@huaweicloud.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1693554735; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8MqwUjoYRm7M9sHB2ytF/Glosp1TtwwU6438HLLcQ2s=; b=Er3bLqarWJJdGt4u1rsXtxhuMJ5KDggYbmWKCa3qAMiCSgSTTISlfS4sJ0yGxqVGQUzBY+ nxyMw2Kwl5KMpR+PTlp5lPZuQtTJBv0G/eVJIM91iMeKn+WyNjnXim73CjLeOopUSXGE1W Cbw18g3CttN4foOed3X1BJQQUnGayZI= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; dmarc=none; spf=none (imf30.hostedemail.com: domain of shikemeng@huaweicloud.com has no SPF policy when checking 45.249.212.51) smtp.mailfrom=shikemeng@huaweicloud.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1693554735; a=rsa-sha256; cv=none; b=g3ZMhzZLbWJVL37Cak+bHEFmb9bOYrw1D6GY45i59V7aaIUmZfjyl1a+i+BEkloYULukfm fMhX0wSd++UOfyTgb3P7vLScPRxPkU/phqx/zQU1s04WPVTLHU99ss5Oe5PG+DFJqIF4wB RJroxbwbHBh+FcHuYFMQMOXnGOK0RK4= Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4RcVc05X45z4f3kKB for ; Fri, 1 Sep 2023 15:52:00 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP4 (Coremail) with SMTP id gCh0CgDnw6YfmPFk1Z5cCA--.13825S4; Fri, 01 Sep 2023 15:52:01 +0800 (CST) From: Kemeng Shi To: akpm@linux-foundation.org, baolin.wang@linux.alibaba.com, mgorman@techsingularity.net, david@redhat.com, willy@infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/6] mm/compaction: call list_is_{first}/{last} more intuitively in move_freelist_{head}/{tail} Date: Fri, 1 Sep 2023 23:51:37 +0800 Message-Id: <20230901155141.249860-3-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230901155141.249860-1-shikemeng@huaweicloud.com> References: <20230901155141.249860-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: gCh0CgDnw6YfmPFk1Z5cCA--.13825S4 X-Coremail-Antispam: 1UD129KBjvJXoW7ZFyfKF47KryDWF13ZF4fXwb_yoW8Ar1xpa y3ur4rJr4UArWrCFsrXF4q93yrtr43Z3yjkrZ09FyDZFn8J392gFySya1jv3s8XrW5CrWY vrsrKr4rurW7Ar7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUB0b4IE77IF4wAFF20E14v26ryj6rWUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M280x2IEY4vEnII2IxkI6r1a6r45M2 8IrcIa0xkI8VA2jI8067AKxVWUXwA2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK 0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4 x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l 84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I 8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AK xVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64 vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8G jcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2I x0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK 8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I 0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxU3K9-UUUUU X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: C85B880008 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 3mbb6h5kmxbg9new95c54ugtd7o46d1f X-HE-Tag: 1693554734-247651 X-HE-Meta: U2FsdGVkX1/QHXAIe0kgve1i/jfwm81RpDQgOPDm3oavPgZdQy7gw+etF5zJjHAfFm14ZgM4LQQWD6iMFQxqTsl/WNK1F1g4dsjwWjXxDtueFUBuVNtiogwMlfhIZvT2NIGibZgxbtKA2d1D6ry0k2/QdVj7jmgZ7soXwx1UoygFCG23ChjMHGPTpXgg66nrAI8fggjYM1yqNAA9fhUHzQlyogp/IZSus+ffn8DB206tnlI2e54Nii0mLQH0JSBijYi+9qOfiIHCV29pIq+Z+eUl65RCkXbdHz0oCr01lX2pCuvnfRBzK/aNF15mfoSwBdxhBiPwCb445oZMz/iXaya5wvm0TwwD0F2/WyIn70rK2cUbHWi/HDeXCzU5Tt/IZr3i/ORCj3N8ZEatuRAd0rWB0PEsVQIfZSdt3mCL5OpbiymPXZ1r9B8Wrmy6bqcbYZpsYgy+9m9BlWN6CI5JLIcNEaThKcJ1bPDaN9RN71/9AA3X/EmrkETs2vvEE+lXaoIIU9S12BKoZSLEaM7No146mzkdbhiFZ1YacjpsCPq0u+zQHXcBemWw8fPOTloXOIn4RVuwz7nBJLL+SvW5pR9/+v3KEnQLSFZxG7sIC4yj/QTNJ1Jap2fPwrEUsFx6ugruYZEge4c+flopRLrYoWlRHiySYc1HvI3w0G01137tSsv+atyvXplXLKD4Jl4ZasixXSthIRRINB+WDY5ySJ4E2rZgvZgBddGGUhFvS9mgDebZ5pHDVZSIw0qBuL4TsC2rWAR2OIsoPPy6fifqnWSS+ZSFkSg/vQiTP/t4CmNGKWY3BzFFfQo//2bg/flllwYv914c7rtPBN67dJd4CGQ0oV7D3cGsoddMtuaDfGJT7L8FyxpstVM1dqSI/K84H/EcVe5VD5OkJREYH9SQXRxwCucofpYvbMyqucPvbvAQKf7l61kP2lzcRilzFqpIfuRJbs5Q7Q01CUbCNhL vJodLk2l m1sIL0zhOkYpNKKIpvnfxwWw72NUzBvYahQadK6byxmDyKQ4xYWALNoSfz1Lv1IjYHcP2vFTBoYTTuPEJiHoAy81JefnAsw8gksrAfkLAVXxXSAJ85uZGn4NX1QC8wyNn18XqNpLrG7p+70ICr8hsM7dnOzNZCJ0yY3P33CfbHcNXBNs5hWbx85t7GYTXwKlk7fXMjg9CINNDGZ78ju36LF6ugX0Sxqx6W7VoA0f2d0qGzad4plDR2g3Nlzry+s17qimxahdrUXtqeO8wciSf+0WQTh1RKnZFTa8h1I77u6TqPVH0tAHdsN/eIhrbuit3oINH7f8Cov3YLU9wzTQhjHGwaPAF6Y2BmGyS0PwJuzHw0b2JzPpPumK7msobaIS9pIaX5kN90CmOcNw= 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: We use move_freelist_head after list_for_each_entry_reverse to skip recent pages. And there is no need to do actual move if all freepages are searched in list_for_each_entry_reverse, e.g. freepage point to first page in freelist. It's more intuitively to call list_is_first with list entry as the first argument and list head as the second argument to check if list entry is the first list entry instead of call list_is_last with list entry and list head passed in reverse. Similarly, call list_is_last in move_freelist_tail is more intuitively. Signed-off-by: Kemeng Shi Reviewed-by: Baolin Wang Acked-by: Mel Gorman --- mm/compaction.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index e3ee1bc1c0ad..a40550a33aee 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1395,7 +1395,7 @@ move_freelist_head(struct list_head *freelist, struct page *freepage) { LIST_HEAD(sublist); - if (!list_is_last(freelist, &freepage->buddy_list)) { + if (!list_is_first(&freepage->buddy_list, freelist)) { list_cut_before(&sublist, freelist, &freepage->buddy_list); list_splice_tail(&sublist, freelist); } @@ -1412,7 +1412,7 @@ move_freelist_tail(struct list_head *freelist, struct page *freepage) { LIST_HEAD(sublist); - if (!list_is_first(freelist, &freepage->buddy_list)) { + if (!list_is_last(&freepage->buddy_list, freelist)) { list_cut_position(&sublist, freelist, &freepage->buddy_list); list_splice_tail(&sublist, freelist); } From patchwork Fri Sep 1 15:51:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13372170 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 8BE1DCA0FE6 for ; Fri, 1 Sep 2023 07:52:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 720F88D0024; Fri, 1 Sep 2023 03:52:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6D1088D0023; Fri, 1 Sep 2023 03:52:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 571678D0024; Fri, 1 Sep 2023 03:52:19 -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 46AE18D0023 for ; Fri, 1 Sep 2023 03:52:19 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 1003D140177 for ; Fri, 1 Sep 2023 07:52:19 +0000 (UTC) X-FDA: 81187260798.12.4C63073 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by imf12.hostedemail.com (Postfix) with ESMTP id CAACF40009 for ; Fri, 1 Sep 2023 07:52:16 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; dmarc=none; spf=none (imf12.hostedemail.com: domain of shikemeng@huaweicloud.com has no SPF policy when checking 45.249.212.51) smtp.mailfrom=shikemeng@huaweicloud.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1693554737; a=rsa-sha256; cv=none; b=nw9rBo3Uo4KNQXNnYVBmqDQrucg93jCt70V9vRng7YrMNBVvuyQVvcFGHpkj2Ur5G2GLPW HzL8UfHXVzVAepdPbpAkcheAcB7JxonTqxNMzuNeHB9uPX+3pMHjFSPY7GOeNpbiXW8wcC RjU+rsud+1uKFWHMS6Mee1tG9Sp7aUk= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; dmarc=none; spf=none (imf12.hostedemail.com: domain of shikemeng@huaweicloud.com has no SPF policy when checking 45.249.212.51) smtp.mailfrom=shikemeng@huaweicloud.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1693554737; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rR7yXoJyBzsfuZzRhYJlCeGChp8MH3Mlq3MJWURQvYY=; b=Q66yPJR8+C23/nzDdI39D6huA759LX8T8k8KMoDH3+r84pOxhQWPLroxS9ZHlIlUIAY239 5BL7MsAGwK6CdQDVTddvShZ4nG2H+5t/Anf1yNY9hGRl2PhBQa/FdSRkYleEZoSglndGxF IxbmLo6/sC2jibUBx7qGLASegrFMvzA= Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4RcVc13Gnwz4f3kKN for ; Fri, 1 Sep 2023 15:52:01 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP4 (Coremail) with SMTP id gCh0CgDnw6YfmPFk1Z5cCA--.13825S6; Fri, 01 Sep 2023 15:52:01 +0800 (CST) From: Kemeng Shi To: akpm@linux-foundation.org, baolin.wang@linux.alibaba.com, mgorman@techsingularity.net, david@redhat.com, willy@infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 4/6] mm/compaction: remove repeat compact_blockskip_flush check in reset_isolation_suitable Date: Fri, 1 Sep 2023 23:51:39 +0800 Message-Id: <20230901155141.249860-5-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230901155141.249860-1-shikemeng@huaweicloud.com> References: <20230901155141.249860-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: gCh0CgDnw6YfmPFk1Z5cCA--.13825S6 X-Coremail-Antispam: 1UD129KBjvdXoWruFyxur4ruw48JFyxCr15urg_yoWkXwc_Jr 1rtrs0krW5ArykWrZrAFsIvrs8KFWkZF1UWw1Dtan0yasI9an5Ja1DZF17ZF15XFWDur93 u3Z3ZF1YkF1fWjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbS8YFVCjjxCrM7AC8VAFwI0_Wr0E3s1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l87I20VAvwVAaII0Ic2I_JFv_Gryl82 xGYIkIc2x26280x7IE14v26r126s0DM28IrcIa0xkI8VCY1x0267AKxVW5JVCq3wA2ocxC 64kIII0Yj41l84x0c7CEw4AK67xGY2AK021l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM2 8EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4UJVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq 3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8w Aqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE 14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x 0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E 7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcV C0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF 04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7 CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07jstxDUUUUU= X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: CAACF40009 X-Stat-Signature: edmzz6ezbd315x1ngeabwxnyinkjya1c X-Rspam-User: X-HE-Tag: 1693554736-940087 X-HE-Meta: U2FsdGVkX1/zhlnLpsW1foqBAB3Pi3tiQu7hsknItQ5Plxd/kjGrJg6xHrzJ0ogYem5JuXlfCNqnyPo6TAyzlaVjX5ihYRE10ACTDm3zuQDpMW/QZzqF85nKZwLEoFEbGazRfUc8SRlhcg5n8VCz3ph/Hryef3xmd36NIort2BFF1YbdTpmd/zCJUID7sRwKXsAy5HM4KagIuvT0yhGc66W/A1YG8C/Cv4iSagGbwty03mNov2RRjWhO1ofy1P38i0aEiq1uCCF8F7IJdG/ywA/FyGk2OYve53LLGyFrK0Nlpi1iKKpH74UUBVe/VuzW7vzHrY14UD6iAC077+vJpb4dJeje5rPXgDLDtdsg9sl5WVuXfHCREtb1vBdba2KWKuefErLTOitsAvCrWhKpvz00e7EEvEtnr5U4cO2MVG3ej4j17BquJoFiThPctWYx2FE45yX0v5aNoEic424bGqWenLAW98cUmke0Jd9ZaZWXEB/3ukjWBzVoPlJSOj5tUBA4aDfhl1FxjnduwEeIiLtSEUF6XzFhgFeqhjFm27nPSa52xUO4yQOsJgDTfmOOxHqPFj2lZIGCR6ap4pJzv5EOIn2ZwrIV7XAexH7NTZicts1TkVmnO30w7rfVYLaYsxX864KR8xEHuyX9Hq4ekgkef7j0tG4K7SapIi0NNhJkWyjXS+q7ljuSXALI796TKVSpLOczsnYkMdeindXO0wSTyc7WX6gpkfvjXCzgN/Msiy6z1fcsDqPLSHxRWsqNmk5QkGqHiccnakBHi+owHpptBtXsjdANAUyAdmOthh8x9W8s71goTuB36qgM3+yzKrrDdTlP47P7Nb+ZKYMjbe/awVjoBuSUVBMADyG3IQX8yc7ZjVmeNiNgldSWvx7MQndLdwFmSs8vq6N+jW6NBbVuAica4AvAAj28x4xMjmOrh5iItJPQ+4150VxVnoNv1Cokkdp3M7GLcx36vfi bZXLF+f7 RsBZLybipt6orJrNyHUb8SmkIjlxY55sE5umCV5xSHDYYZz+WPJ7spPnOM0ufv8VdjBgYudoq/mzaVAL80XD841XR8DZyB5OVWa+SIb1le9uvi0L2cnV1t9+aQ3sZlNJyYGXh/wylC3Uv90rYcuMvoZEURJdJ1Eh6/sIv8hqPImKIBgdafkMEFNljPL9bXGVNgUrY+JDzPCdhnG277q1+kpGGlxd1sPHF3KkgfMGyhRpZVjHjXdEIHId9rDN2GmqE/bPHPK/CMuwm2ZJtNi+tpk0Qf2H5rU1Ey6Cn+hYuLXeaDd2puut+EfvnwuMXpBQcC3cpVcV9DOfdpZ7Unf1GYN2NXg/jhVoXUMuGO1V2kw7BITDHtbIEJEK5xWBVqMEfLY4fMXQXcxAVq/E= 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: We have compact_blockskip_flush check in __reset_isolation_suitable, just remove repeat check before __reset_isolation_suitable in compact_blockskip_flush. Signed-off-by: Kemeng Shi Reviewed-by: Baolin Wang Acked-by: Mel Gorman --- mm/compaction.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index 9ecbfbc695e5..c377d78e0f15 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -382,6 +382,7 @@ static void __reset_isolation_suitable(struct zone *zone) bool source_set = false; bool free_set = false; + /* Only flush if a full compaction finished recently */ if (!zone->compact_blockskip_flush) return; @@ -434,9 +435,7 @@ void reset_isolation_suitable(pg_data_t *pgdat) if (!populated_zone(zone)) continue; - /* Only flush if a full compaction finished recently */ - if (zone->compact_blockskip_flush) - __reset_isolation_suitable(zone); + __reset_isolation_suitable(zone); } } From patchwork Fri Sep 1 15:51:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13372168 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 902CBCA0FE9 for ; Fri, 1 Sep 2023 07:52:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 12E118D0022; Fri, 1 Sep 2023 03:52:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0DDC38D0002; Fri, 1 Sep 2023 03:52:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EBF8B8D0022; Fri, 1 Sep 2023 03:52:17 -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 DE0E48D0002 for ; Fri, 1 Sep 2023 03:52:17 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B2424120170 for ; Fri, 1 Sep 2023 07:52:17 +0000 (UTC) X-FDA: 81187260714.18.9FB9D82 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by imf06.hostedemail.com (Postfix) with ESMTP id 40CF4180018 for ; Fri, 1 Sep 2023 07:52:14 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; dmarc=none; spf=none (imf06.hostedemail.com: domain of shikemeng@huaweicloud.com has no SPF policy when checking 45.249.212.51) smtp.mailfrom=shikemeng@huaweicloud.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1693554736; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mN73l8G61ghV59udGjlIFAJtpqlW1LFDFmlIeaJRrjo=; b=yvKXfpuZytvz4V2I8VgPB+x9JQ8jV6sI1Cbpt1W79WLgVWLqEzPHZteloRyUVPf4Ja2f30 J9Uaq/LKkmBXF7Sd6EpfmwYPNLX1/zt/zvhHRs3uQ3FUN0vlGzOg2x+E4RRuGmUl/lLbkI cqLi1TPY6yTKthHle4kROTSyAiIvHL8= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; dmarc=none; spf=none (imf06.hostedemail.com: domain of shikemeng@huaweicloud.com has no SPF policy when checking 45.249.212.51) smtp.mailfrom=shikemeng@huaweicloud.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1693554736; a=rsa-sha256; cv=none; b=CwmNV+C53QGx3KVVSs7By69ghLtM3UH61l4g97sGKv4JpSjzIEGWdnlkzXlschAEsq8lQB Bw5BcQd5+DkzmxL7KTt9y2GOl0Orj5XLdybNpwm7M/T3o1a9RRlzeStrNv0vK2YE4BxX99 tiedCyIFnPEbsFU7WcPf6GchXKnhS00= Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4RcVc123jZz4f3m7b for ; Fri, 1 Sep 2023 15:52:01 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP4 (Coremail) with SMTP id gCh0CgDnw6YfmPFk1Z5cCA--.13825S8; Fri, 01 Sep 2023 15:52:02 +0800 (CST) From: Kemeng Shi To: akpm@linux-foundation.org, baolin.wang@linux.alibaba.com, mgorman@techsingularity.net, david@redhat.com, willy@infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 6/6] mm/compaction: factor out code to test if we should run compaction for target order Date: Fri, 1 Sep 2023 23:51:41 +0800 Message-Id: <20230901155141.249860-7-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230901155141.249860-1-shikemeng@huaweicloud.com> References: <20230901155141.249860-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: gCh0CgDnw6YfmPFk1Z5cCA--.13825S8 X-Coremail-Antispam: 1UD129KBjvJXoWxGr1xGry3Jr4xKF17ZrW5Wrg_yoWrAryUpF y8Wry3t395XF17GFWxtF48XF15Xw4xJF1UtwsFq3s7Aw1aya1vv3Wkta4UZFWUX343JF4j qF4FgF1DKanrAaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUB2b4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M280x2IEY4vEnII2IxkI6r1a6r45M2 8IrcIa0xkI8VA2jI8067AKxVWUAVCq3wA2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAv FVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3w A2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE 3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr2 1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv 67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2 Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s02 6x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0x vE2Ix0cI8IcVAFwI0_JFI_Gr1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE 42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6x kF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxUIL05UUUUU X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 40CF4180018 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: doxtosxfacb16czwt1gthbrk4yt6j1s3 X-HE-Tag: 1693554734-824723 X-HE-Meta: U2FsdGVkX1+rK5t/WS1yPRGhNlyJNpSSa4iRdY1GBSDok52dSxP+MTXHAhYqf9Cv3q3GWRjBU6GiH04R+9W1hkwSo+TqfwlG+mz4LNuk7OKcjazz3yRm96CadSfhFR8rjzkbkePkRxQpsNA2PjYV2WDBEgrWrTHYIBkrs+/d7oKl2RUy6egJmcIxekoL3BrzTCVfsmq6lbwJSHeKeCi+M876U7EuYa71wJb+zPJybHaa43UqI4f2jlYsteORGMbga12W5FSrNlieUoWn7dkL7VKqdOKMfbLjSqI35pWMu4sgQdlfXp88C6Hr1/For0nSg48LgQnTxDMNeR6XAFlno+0XRrkvWHwGemhaBbo7kp3C29LPlhqT6BQWKxulRLnbC98dhq5KVWVGox9c+O85IVhyAO9CxHW0OXdU6JxCYXD4QaFqTUOkh0okUxcQ7ZjtacVd2JCe5kW6e6CgWqoxsPAVmnN01XSqUg8X/x+qI4E9rDtMNL+t0+sPI8keYjI3dUrQvyQFbl1GfWxCxUNi9g0mDV/CxpR7WnZ3sq+9kaXm55pfr84zoAg3MXHlQtV273ATp95kAdtF8Dn2R5cMyxVZbjQh9a3oYiWyweP+iGx8m/HBI0rubCxQmrsbcpUnSMe4fhaE7pRChGKi0fB4yF2pAQ5i8g6e92byjpZ9cgRbkfsa/44rudowpF5VsYcuqMy2KxNtFidE4t79sR9nLWUvfI2NV+mlFsxXsdI3D2jQDNYPgRWWZEjLAxUYapRVij/y9t8p7rJLJm73lNrpT2jfGu6C5T6DzY+qgSc0Gox8i5LqTj21In/HtO2NFnf4A5gHHZyZRmWvU4FFfQ4BS0st+gatnloeXJsAGR34jELaXlhdxj6NC168Qh55ZRAsSHQ/cU9Q+k3LqSQIvL54KhkV1wSHkfmG5qfNc/CQ4b89QHARuvuPKMilacuMJ9ZOHx7zN4ovfZzgYJ4jXIi U8RzSa9M WIEL0gVAMHVhN0F8o1SZR88YOrLUOBdt3jL1PxhceKKMtXdSuO7W2yxIdO4zcKbZHgPsl2QPwYieOuFZViJjDvf642TV2X5jbUum+hJaE7pN0OAHghki0khszETtaTV1EVmgyG6cd5xNREYiFaRmIe/8/NvEZsFifzJcUxY8jPv+j+BpUkivjzkdhesQxoW+pvet/ncbOiPXJfjYG7DkeOBLExzT7CT0VdhY0Eqwbfio4NhcZ9IKs0K6FDC0A+1XPuI6qGnA1eJjhO9v5jwJBcAOnrsdYRYkdrLYgZm/vmn6l7MB3hkpxR7QlxAFNFJoR8w99lREqTardSRCkHb6gtOdGTxPvA2aH9gZiUN6ecQMXShI= 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: We always do zone_watermark_ok check and compaction_suitable check together to test if compaction for target order should be ran. Factor these code out to remove repeat code. Signed-off-by: Kemeng Shi Reviewed-by: Baolin Wang --- mm/compaction.c | 66 +++++++++++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 27 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index ff3426a0d9c5..1940e8693638 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -2378,6 +2378,30 @@ bool compaction_zonelist_suitable(struct alloc_context *ac, int order, return false; } +/* + * Should we do compaction for target allocation order. + * Return COMPACT_SUCCESS if allocation for target order can be already + * satisfied + * Return COMPACT_SKIPPED if compaction for target order is likely to fail + * Return COMPACT_CONTINUE if compaction for target order should be ran + */ +static enum compact_result +compaction_suit_allocation_order(struct zone *zone, unsigned int order, + int highest_zoneidx, unsigned int alloc_flags) +{ + unsigned long watermark; + + watermark = wmark_pages(zone, alloc_flags & ALLOC_WMARK_MASK); + if (zone_watermark_ok(zone, order, watermark, highest_zoneidx, + alloc_flags)) + return COMPACT_SUCCESS; + + if (!compaction_suitable(zone, order, highest_zoneidx)) + return COMPACT_SKIPPED; + + return COMPACT_CONTINUE; +} + static enum compact_result compact_zone(struct compact_control *cc, struct capture_control *capc) { @@ -2403,19 +2427,11 @@ compact_zone(struct compact_control *cc, struct capture_control *capc) cc->migratetype = gfp_migratetype(cc->gfp_mask); if (!is_via_compact_memory(cc->order)) { - unsigned long watermark; - - /* Allocation can already succeed, nothing to do */ - watermark = wmark_pages(cc->zone, - cc->alloc_flags & ALLOC_WMARK_MASK); - if (zone_watermark_ok(cc->zone, cc->order, watermark, - cc->highest_zoneidx, cc->alloc_flags)) - return COMPACT_SUCCESS; - - /* Compaction is likely to fail */ - if (!compaction_suitable(cc->zone, cc->order, - cc->highest_zoneidx)) - return COMPACT_SKIPPED; + ret = compaction_suit_allocation_order(cc->zone, cc->order, + cc->highest_zoneidx, + cc->alloc_flags); + if (ret != COMPACT_CONTINUE) + return ret; } /* @@ -2914,6 +2930,7 @@ static bool kcompactd_node_suitable(pg_data_t *pgdat) int zoneid; struct zone *zone; enum zone_type highest_zoneidx = pgdat->kcompactd_highest_zoneidx; + enum compact_result ret; for (zoneid = 0; zoneid <= highest_zoneidx; zoneid++) { zone = &pgdat->node_zones[zoneid]; @@ -2921,14 +2938,10 @@ static bool kcompactd_node_suitable(pg_data_t *pgdat) if (!populated_zone(zone)) continue; - /* Allocation can already succeed, check other zones */ - if (zone_watermark_ok(zone, pgdat->kcompactd_max_order, - min_wmark_pages(zone), - highest_zoneidx, 0)) - continue; - - if (compaction_suitable(zone, pgdat->kcompactd_max_order, - highest_zoneidx)) + ret = compaction_suit_allocation_order(zone, + pgdat->kcompactd_max_order, + highest_zoneidx, ALLOC_WMARK_MIN); + if (ret == COMPACT_CONTINUE) return true; } @@ -2951,6 +2964,8 @@ static void kcompactd_do_work(pg_data_t *pgdat) .ignore_skip_hint = false, .gfp_mask = GFP_KERNEL, }; + enum compact_result ret; + trace_mm_compaction_kcompactd_wake(pgdat->node_id, cc.order, cc.highest_zoneidx); count_compact_event(KCOMPACTD_WAKE); @@ -2965,12 +2980,9 @@ static void kcompactd_do_work(pg_data_t *pgdat) if (compaction_deferred(zone, cc.order)) continue; - /* Allocation can already succeed, nothing to do */ - if (zone_watermark_ok(zone, cc.order, - min_wmark_pages(zone), zoneid, 0)) - continue; - - if (!compaction_suitable(zone, cc.order, zoneid)) + ret = compaction_suit_allocation_order(zone, + cc.order, zoneid, ALLOC_WMARK_MIN); + if (ret != COMPACT_CONTINUE) continue; if (kthread_should_stop())