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); }