From patchwork Sat Aug 26 15:36:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13366512 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 E2BCBC83F01 for ; Sat, 26 Aug 2023 07:36:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0638368001A; Sat, 26 Aug 2023 03:36:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0124368000D; Sat, 26 Aug 2023 03:36:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E42E068001A; Sat, 26 Aug 2023 03:36:38 -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 D916768000D for ; Sat, 26 Aug 2023 03:36:38 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9F31D80135 for ; Sat, 26 Aug 2023 07:36:38 +0000 (UTC) X-FDA: 81165448476.18.C2EDE62 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by imf08.hostedemail.com (Postfix) with ESMTP id 3CD8A16000A for ; Sat, 26 Aug 2023 07:36:35 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=none; spf=none (imf08.hostedemail.com: domain of shikemeng@huaweicloud.com has no SPF policy when checking 45.249.212.56) smtp.mailfrom=shikemeng@huaweicloud.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1693035397; 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=XTgKO6jORutQUkgvvUvyNFTEKm3g5V43Zg7Gzlmrc54=; b=jk1zxTYT+QZF1hSbflzi8Z2wn/A8j7MXg3nTIWN2xGynENhhXvlW5ZX37MlGXIRfmsCFro IRq18sK9QK5KBadLsDckkuu9yc8aG8bOxNCM53K8JIyZMM9fpjSAIilF4JY/0cMt1V1yHV ts7+t+qSu5ArolKAVknMwq/JNUHBFBk= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; dmarc=none; spf=none (imf08.hostedemail.com: domain of shikemeng@huaweicloud.com has no SPF policy when checking 45.249.212.56) smtp.mailfrom=shikemeng@huaweicloud.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1693035397; a=rsa-sha256; cv=none; b=6U+CBa3BTWOovvJgfnEURrb8FNjmxBy53yXJebd1YTJsJzYWm2ynyCXMJKpQJXC9y31jJj vtqiRjizDG61I2o5HkzqYIvTOxcyvunexNEFFMrqT0Y+Qp+Zl68OnQaf5LX+xbBgo27Iuv sQcUmAJuFOfwCQfE1q2U/jxvSlyUCDM= Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4RXpXq0NfVz4f3kj3 for ; Sat, 26 Aug 2023 15:36:27 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP1 (Coremail) with SMTP id cCh0CgDHQi98q+lk6GgZBg--.2153S4; Sat, 26 Aug 2023 15:36:30 +0800 (CST) From: Kemeng Shi To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, baolin.wang@linux.alibaba.com, mgorman@techsingularity.net, david@redhat.com, willy@infradead.org Cc: shikemeng@huaweicloud.com Subject: [PATCH v2 2/7] mm/compaction: call list_is_{first}/{last} more intuitively in move_freelist_{head}/{tail} Date: Sat, 26 Aug 2023 23:36:12 +0800 Message-Id: <20230826153617.4019189-3-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230826153617.4019189-1-shikemeng@huaweicloud.com> References: <20230826153617.4019189-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: cCh0CgDHQi98q+lk6GgZBg--.2153S4 X-Coremail-Antispam: 1UD129KBjvJXoW7ZFyfKF47KryDWF13ZF4fXwb_yoW8WF4Dpa y5ur4rJr4UArWrCFsrXF4q934rtr43Z3yjkrZ09FyDAFn8J392gFySya1jvr98XrWUCrWY vrsrKr4rurW7Ar7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPIb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M280x2IEY4vEnII2IxkI6r1a6r45M2 8IrcIa0xkI8VA2jI8067AKxVWUXwA2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK 0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW8JVW5JwA2z4 x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28E F7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F4 0EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_ Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc 8vx2IErcIFxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02 F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GF ylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7Cj xVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r 1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0piH mhUUUUUU= X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 3CD8A16000A X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: nz3bdg9o8yhe5g9y1a53n3czdndtgrr4 X-HE-Tag: 1693035395-137052 X-HE-Meta: U2FsdGVkX19VbfGay7IiUTdq9C/tBF7YDzyokGS7IHygKz7S+D/CPNi1pbrRxEfYk7b0yXWVA8CaEdH/9tRXrajXgrir9oUENXFBOhhts09A57qkSxk+3fwQ6AU1yz6lGVik7x+GDk+ZOfj4YyW3Gcugr3ZaisE8nImK0bQa7uveLqhHojEU0fVL82yaTdwOi+Y1Hev23iTufD8tLqTGuaFoOVJTyQN2u1ZGCCD5/DXZHF2D9CsowY3wZzjKWYq011mDDv5OjezHfKhah9dJlF3aOmeSE0JW0vYefpw0jseyyN/yZo/Xh67x1K+lei3Z7Qyafl3AwTnTjGMrh4SeWA0int5y6RHNEhZT+gArGywLatqvbOMQRKQnpO92DzZVTepKFyFOM5zoH3cAAZF72TgXHrIg6qbA93VhUBdr5V9A3dzMg7onuxgfEPDXFxGM+SdClscOeTIv6eL0eLLlMagTIloARSAu9W/xEBebUBKisqtSjT4abQoVNe9wCHTGmRHjJeY62O6bBIrs62ilbgPfdcmxK6upI+qcwkkgfoATsz3aLxVwWMTEkHyyEcIJerUdpi7AiXuOz0EN8X2AIPGtixSmDgYuVOn9FfsCN82cYvQlYQSU+Hb5CM9lkwgJn5iOevOAH7/Q/LYpvCyel3X5XE+6+9QYfJl2xanZSdWg9Cp6LaOwhb0tA6P4sp8bvvVczpL1qb7Y0FPqfpAgPzU43IC+NpV7sUK2BGEK3tQoR+si84dr9nH5gCaGD/sYHaTY0Qs0kLe4r/KrzlfZFrBRmDtc7B+zXh4uLPR06/pTzxsRMd1g8dBzYH2ZtPirAu0XfMq+rNTrfvyca7qSFD/VMxfN3zAcY7Xnu9EYt+mT/+hVzUiH/GJkyOyHsz/88XGjrbyTOOx8qg8bic94/a+hvEQtBL3W/E/7ddp/7QrnC6f1F0+78al5TCFlwHCbCy7HItblsIJ83mczOaC nT/rnzjX G7yInDuCixAkcjRwohsRHL3/HzjFPL286zdbRDeL8QG0gC1t4aAV5EwWrgiSpyDdcqxMCDq2VGUMXiEfE4OK/onLZmL9cymbIiSgWbO5cTGQt7Zko6wkmX9mS1U7jY512FJcU21NL68B8vSE5Qgrl4Y8TCHjXBQu4S2JUE1V9T4DyOapT+9YZUl7KmXU0u7DE05b+X8/ErVEQLMw9waaaxLy4vYOwjO2ccVBdP8IbFHG715fmJDqmPvZVnQgmYiIXhr9OMwMTWz/HzL0dV+cmMyFSQzjoY4ZO9Ma/YJ8/TvzqlYTcRD6XvHl6eu2anNpgsGqUiDWzvfSvq9NKiQ0nqLEabA== 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); }