From patchwork Sat Aug 26 15:36:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13366514 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 8B881C83F17 for ; Sat, 26 Aug 2023 07:36:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7B67144014D; Sat, 26 Aug 2023 03:36:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 765E944014C; Sat, 26 Aug 2023 03:36:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5DFB144014D; Sat, 26 Aug 2023 03:36:40 -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 51DC144014C for ; Sat, 26 Aug 2023 03:36:40 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 26CD81C8CD0 for ; Sat, 26 Aug 2023 07:36:40 +0000 (UTC) X-FDA: 81165448560.14.13A01C9 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by imf01.hostedemail.com (Postfix) with ESMTP id DDF444000C for ; Sat, 26 Aug 2023 07:36:37 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; spf=none (imf01.hostedemail.com: domain of shikemeng@huaweicloud.com has no SPF policy when checking 45.249.212.51) smtp.mailfrom=shikemeng@huaweicloud.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1693035398; 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=KaHd+FWrzzZgHNzTJ4xbH3lDDDimVKsoC+a7FW5uAaE=; b=dzb9UHujd7BfKvW8Sb9nf5YS/XhbXEiAzK+RA0moYke3jveiqvpqicCUk2IWAAhWug2Pnj 9/5cEoiH8qYFDleyN62+VOq4LMjvks2gtlVxJbkDnJMHwo0VyVwPgGtjrcT8EBPqOO4C7R A4AK0kP0FTNwj2mGMXzM4ajxUZ0FaD0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1693035398; a=rsa-sha256; cv=none; b=MTaYHyGQ3oNaA3+QiysgNISWOMKokMS+SSvRNgdQfTkQ1zs9QgVIBW1y7TFwbpIEyF4sgE 9P5vMryQJgZqe8Zagg2sC0yY/JLGnl1Hoq6wq3WTSvycHbo+TUH0HzN82x3o5UVHrNmUo1 JqmUj1+hMVa7aaRxX3Cvu+7I12d7mIg= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; spf=none (imf01.hostedemail.com: domain of shikemeng@huaweicloud.com has no SPF policy when checking 45.249.212.51) smtp.mailfrom=shikemeng@huaweicloud.com; dmarc=none Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4RXpXs4684z4f3jYr for ; Sat, 26 Aug 2023 15:36:29 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP1 (Coremail) with SMTP id cCh0CgDHQi98q+lk6GgZBg--.2153S3; 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 1/7] mm/compaction: use correct list in move_freelist_{head}/{tail} Date: Sat, 26 Aug 2023 23:36:11 +0800 Message-Id: <20230826153617.4019189-2-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--.2153S3 X-Coremail-Antispam: 1UD129KBjvJXoW7Zr4kCr1fGFWUXw1DXrWDJwb_yoW8Jw47pr y5Cr4UXr1UArW0yFnrXa1q9348KF42vrWjkrZ8uFWDAFn8trW2qF9ayF4UZ3sxXrWjkrWY vrsrKF43GrW7Ar7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBC14x267AKxVW5JVWrJwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2jI8I6cxK62vIxIIY0VWUZVW8XwA2048vs2IY02 0E87I2jVAFwI0_Jr4l82xGYIkIc2x26xkF7I0E14v26r1I6r4UM28lY4IEw2IIxxk0rwA2 F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjx v20xvEc7CjxVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2 jsIEc7CjxVAFwI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4 CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvj eVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I 1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWU JVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7V AKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42 IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjTRCeHDUUUUU X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: DDF444000C X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 3ygcjktanpkab811i54t9jiyx3u1311p X-HE-Tag: 1693035397-302486 X-HE-Meta: U2FsdGVkX1/RlWmlYeAB0VPNgC8npEFuD6KZh9PRP/thmqYo7Au8+WslLQlGFRefYf1xpeLVxKynbgQPLh0PKiHF1Apj6Z8we5yNVKjW/fZEKnDWmYcmcJLnNoQMaHj0o+nSa2msiR5lpMbJUELBSQi/FNYOnXz0ngDSXVtNEPUHCfyaAxG0RIGS3+qc3j0crS6EDJ7fZDishTAnhr8JjXavaOJdeWEuv5R3+W9ZRNm2zYeNGP32v9Rpm0Wev9jAGCxkaOGsq4tflogSV8+HuHVKH4aRxc0szHD3XXmTk75OTb5/esYMGd/QdQgX8bI7lFavFDDDSQmcBq+t+q1RODkjnBlZa8dSyvpsgX/RBWrSrrDHdcV601KbZxt3NpGbHs+/jR8fvGIfrKkT0gDk9gIDyZVqkceScxDgBYYkdXpnxXDqxdIEQTd+Q58h8KoJJqtvCwHSD/TZdzmmMH3F+etx3cJUvfHjWkmBFEPru1zBxdypIc+8phm0pcMHEeZzr9uXCWjHrzba/2FJymx8G3h0/McyPUw4VlI5KuuLONfIyQWagqRNDdRNVA5pOn7QY3oFwG8vDBq5+Hf+dqQjFtDA3PdwRr6Q2p55BY2INhwplduy+3rTh4HnlVUC5ohgj/m0t/X1mJ2yg3ZfpXbIKQ9rjl7yX+tmqbH5zZM/vwzpq/X/hsH7fFgJNBhnQm5P/Z6hm3C3HhEB5BioARsqTPERD79RuBqAxqYGqkX1Z72HRzEmxHvjWFSlKHt2q6FDMaenoCpwA6ylwXNN8GjXBIaIvqtAzTCTNNhTPc99ub9X6fW6djIUmISIfMMVryCpcFEIPZcEErnY8kihyXhmbBu3ClTnwEoIvlcqStpH43NplaqxdZzDYpxEsREHTXJgoHtYQOmrJnvkHEvs2veI2fZBaeMNKoGTH5LkqegE/LmABvKuQW05ZzQpIEct2teT3fq8Xrx4mheOUMb/mzj r8Jou4Xz 5ggMk+OOFxCzaq6nLwvIFhIOX7u2o+kvvfefgWXnF9vRceaoNgivH5L5/BZHzovY5/eyECGItZsimuBdxDMETP9Tnfq9BJPpZ9Ro2Xig3ZynRQqEXZBI5qV46DlJA50ryjIbEqafgU4gwwfZrRToPonb/OBbu9rV3LvlkUm49DEiTf/UcujrjJ1wO/+c/r8LXwhpKW3GFxee58aQ7R4TsZ+GJY9onIvg1uAcEfjKoSHJxNiHDHM8Dh5ijhAL+bhYVfSGMw+It4/46R8ptbIip0GxfExKqexY6LEvW 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: The freepage is chained with buddy_list in freelist head. Use buddy_list instead of lru to correct the list operation. Signed-off-by: Kemeng Shi Reviewed-by: Baolin Wang Acked-by: Mel Gorman --- mm/compaction.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index 38c8d216c6a3..e3ee1bc1c0ad 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1395,8 +1395,8 @@ move_freelist_head(struct list_head *freelist, struct page *freepage) { LIST_HEAD(sublist); - if (!list_is_last(freelist, &freepage->lru)) { - list_cut_before(&sublist, freelist, &freepage->lru); + if (!list_is_last(freelist, &freepage->buddy_list)) { + list_cut_before(&sublist, freelist, &freepage->buddy_list); list_splice_tail(&sublist, freelist); } } @@ -1412,8 +1412,8 @@ move_freelist_tail(struct list_head *freelist, struct page *freepage) { LIST_HEAD(sublist); - if (!list_is_first(freelist, &freepage->lru)) { - list_cut_position(&sublist, freelist, &freepage->lru); + if (!list_is_first(freelist, &freepage->buddy_list)) { + list_cut_position(&sublist, freelist, &freepage->buddy_list); list_splice_tail(&sublist, freelist); } } 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); } From patchwork Sat Aug 26 15:36:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13366515 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 45E17C83F01 for ; Sat, 26 Aug 2023 07:36:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D0CD0440150; Sat, 26 Aug 2023 03:36:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CBDBC44014C; Sat, 26 Aug 2023 03:36:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B5DC6440150; Sat, 26 Aug 2023 03:36:45 -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 AA0A944014C for ; Sat, 26 Aug 2023 03:36:45 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 66E1B1C8CD8 for ; Sat, 26 Aug 2023 07:36:45 +0000 (UTC) X-FDA: 81165448770.03.8662FDC Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by imf26.hostedemail.com (Postfix) with ESMTP id 0105014000E for ; Sat, 26 Aug 2023 07:36:42 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; spf=none (imf26.hostedemail.com: domain of shikemeng@huaweicloud.com has no SPF policy when checking 45.249.212.51) smtp.mailfrom=shikemeng@huaweicloud.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1693035403; 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=AjXZUiTH42XzAW/K/LgNIkF4R91T1F6yHcSixziYi1o=; b=XRe+Mef/4CtqnnnaAAjRpf7pVp/Lg+E/ZjoHeMu+HOvpnESFgq6rku9/OLiBsP+Y7Rlnhe IlbaF3/43Ty5LOE8KeeLtCYx3ZyoVcoNIxAOEL679dH7I8yTUu0RUtmSF6gDRxghA5gmkG rscnQ18ZL/2nJbQfyZEa7fcsHVDp+aM= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; spf=none (imf26.hostedemail.com: domain of shikemeng@huaweicloud.com has no SPF policy when checking 45.249.212.51) smtp.mailfrom=shikemeng@huaweicloud.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1693035403; a=rsa-sha256; cv=none; b=wACnid4O8hJN7o2bSFZSOzWrgkX/AlqoelemcfXOemSZpL+U7+JQujgsYDfU1/EAdBfKLN OVep7unO3hdAQW54ACZ8X7SfF99KFNMm6MXqDiuI41CRr0FcbutXmSSJFVJ9nnOwFt1cYF KkqtLY6HD33jRgH0rmWn7OOHumpRr5Y= Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4RXpXt74SVz4f3lDK for ; Sat, 26 Aug 2023 15:36:30 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP1 (Coremail) with SMTP id cCh0CgDHQi98q+lk6GgZBg--.2153S9; Sat, 26 Aug 2023 15:36:32 +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 7/7] mm/compaction: factor out code to test if we should run compaction for target order Date: Sat, 26 Aug 2023 23:36:17 +0800 Message-Id: <20230826153617.4019189-8-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--.2153S9 X-Coremail-Antispam: 1UD129KBjvJXoWxJFW8Gr43KrWxCw1fKr47XFb_yoW5tF4fpF yxur13t395XF13GrWxta18JF45Xw4xGF1Utwsrt3s7Aw1ayayvv3Wkta4xAFWUXry3JF4j qFWFgF9rKanxAaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPY14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2jI8I6cxK62vIxIIY0VWUZVW8XwA2048vs2IY02 0E87I2jVAFwI0_JF0E3s1l82xGYIkIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0 rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6x IIjxv20xvEc7CjxVAFwI0_Cr0_Gr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK 6I8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4 xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8 JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20V AGYxC7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAF wI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc4 0Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1I6r4UMIIF0xvE2Ix0cI8IcVCY1x0267AK xVWxJVW8Jr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r 4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0pRvJPtU UUUU= X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 0105014000E X-Rspam-User: X-Stat-Signature: 6r5p98g97k5xia1gybuawucqymtm3ykt X-Rspamd-Server: rspam01 X-HE-Tag: 1693035402-841183 X-HE-Meta: U2FsdGVkX1+tOvvG6AAaz6ah7FZNCgUvX8U1meSWaelwUPiHWCyI857CnlaDHGLza2L3Kdltp8ELAJDquDDdQqeOUBD0YSH94oS14Wg3/51szOqXPx/lWBdPL2Esicge5Hkfx7uFxZAG/dwtS39pYYMlgC0E7Q3p02UFzzRc2d8MtSWYcQOk0j5D/2xFIIcbduz3YrN5+LC9KA3PTjnqk/qmDEVJB83WtmtyXCNDTgIvwzoeLK67tn34Ds7FseVPzdS14NRJRiNFiaLlVc+Eq9w/v44fAV4dVpBkPOjlX2lWH/MxVeCSyMMBg8p9PaEahFU5NzNKhZtF1hxxgiPhA7MoHUiu1CZJEC1YNRJDQdQUjuo8QjVDrP08fyDdQL3hPlmWBMnxQxQNyNy2V1cweJsnxD/YtGWu/lAyk/hXTvkyiAhJE7zSdO0g54MQdYUXLGCtRz/oEAV6bUtJsUI8Gzf0bNAXmXN0Vhmb1+NHf6vzxAl63Zb0jex7VYVfHbIqoOUkXja9LqnZflEDuxRM1flBCATheGNNh+Sdt0Xar8qIOcpHfLFBb8nrTYlo1NT26vz2HWfLiq0jHzCi8cti7EBgkG8UoMcmVEdTHvgrr+9xDAJvWAQv9tKIB7ys1FxF5ps5Z+1zp9+Y5DNG5PJnCZzExQtvoXgX0rZq059AGjBLqvCgleN6VTamHtAmWP9ckyMiB8acO1rYb4s1395M3hFYegsOEYWYhN0BQfynTLnbS2cBB2BsUjgG2cv3KXPE1WcAyDicsWzrVic+KoGacw3ndWneZmg+md51gixXMoRkYRmQ9xKzlZUa8PuvJ87qxWjEqIwFvrJfHji9UD1X/1A5uw+Q+u2kNf6SLqT4xfWE8T817Th2jjeAq7gMUJU85UN6y52fybNocxlvHw9Ha5ynAOGpOzLxDrnJFPZK8dSaP9WvEN73D+hXzOdem0Y+CZFjA2RuZPZJCA67YLp kBljXpCy 2tzRD586Eb29qC8v3GeJEo8z3lgvVbpuoebbc5X0W8WcoMd0EMivlCz9F4/h0m7e5aGoYJ54OcssncBjsLM7Xdji6A0hK0bxX+Yn0V6rj5EtdqG/kaK3F9xc28txQWnPdSmUa9M72XkUpZ+7rGFy7P6E3/8ZAuZ1CrgYvgsjtY5YAf8tDYmT2KaFSSpypUSBlte5Ba/gBGiSPtAk7JNXLaCfA295GE1RiDvJ/m2JE8YYnYD/CMypXklCxxZqMdKLez+bfsoA9RGjtfCqsmsfzyWWyqkZY3caZN5rb 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 runned. Factor these code out to remove repeat code. Signed-off-by: Kemeng Shi Reviewed-by: Baolin Wang --- mm/compaction.c | 63 ++++++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index 00b7bba6c72e..6f2b87b026b8 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -2374,6 +2374,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 runned + */ +static inline 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) { @@ -2399,19 +2423,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; } /* @@ -2917,14 +2933,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)) + if (compaction_suit_allocation_order(zone, + pgdat->kcompactd_max_order, + highest_zoneidx, ALLOC_WMARK_MIN) == + COMPACT_CONTINUE) return true; } @@ -2961,12 +2973,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)) + if (compaction_suit_allocation_order(zone, + cc.order, zoneid, ALLOC_WMARK_MIN) != + COMPACT_CONTINUE) continue; if (kthread_should_stop())