From patchwork Thu Aug 3 09:49:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13339109 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 DD177C001DE for ; Thu, 3 Aug 2023 01:48:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1556B280206; Wed, 2 Aug 2023 21:48:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0DE172801EB; Wed, 2 Aug 2023 21:48:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE929280206; Wed, 2 Aug 2023 21:48:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id DEFBF2801EB for ; Wed, 2 Aug 2023 21:48:54 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9AE4F1C972A for ; Thu, 3 Aug 2023 01:48:54 +0000 (UTC) X-FDA: 81081109788.02.BBCAEC8 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by imf19.hostedemail.com (Postfix) with ESMTP id 0556D1A000C for ; Thu, 3 Aug 2023 01:48:50 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=none; dmarc=none; spf=none (imf19.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=1691027331; a=rsa-sha256; cv=none; b=RRbvsYcucU7qRUBBT+95xHJ1KP6y2glhNb879NDxsXEc5rPbbW2Hmvu9BLJaG+LEo5T6lU lbtvg+qp/4mpOepZzhlphPCrwjHu9T05+WE+uremQLctlfdGa2R1Drg3Eqp0YAg3mTSjZS 58RGaXNqODwFfT7u3Yi2MwZdnxfrc9w= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; dmarc=none; spf=none (imf19.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=1691027331; 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=yy0FuSamKmAE0XgpaSnNLMHoQqjNrRZ1QCGJU4tki9I=; b=L5E4AhXdJZ34JvXQJ9kcSSKpY7QCfH+8pNhqoEM0xIxDkRtET3pyprazH0L2d+VQzKHGpD LuuKWVFKUXqe07iFPIVj0tXXfdfh8yWBp72yFaitViknZYKYao/ltUfLjTT+o1SdKX6sb4 Depk6Dcdt2f3FfzjwItiCO4+d8T6RiM= Received: from mail02.huawei.com (unknown [172.30.67.169]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4RGWwF2XK4z4f3lVp for ; Thu, 3 Aug 2023 09:48:45 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP3 (Coremail) with SMTP id _Ch0CgCXQiB7B8tkVa5vOQ--.12634S5; Thu, 03 Aug 2023 09:48:46 +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 Cc: shikemeng@huaweicloud.com Subject: [PATCH v2 3/4] mm/compaction: remove unnecessary cursor page in isolate_freepages_block Date: Thu, 3 Aug 2023 17:49:00 +0800 Message-Id: <20230803094901.2915942-4-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230803094901.2915942-1-shikemeng@huaweicloud.com> References: <20230803094901.2915942-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: _Ch0CgCXQiB7B8tkVa5vOQ--.12634S5 X-Coremail-Antispam: 1UD129KBjvJXoW7WrWxAFW3WrW3tr4kZr4fXwb_yoW8AF18pF yjkw1xAF409345WFy7t3ykCr17GrsxtanFkrs3JrWrZFyftFyI9r9Fyr1UCrW8Xr9rurZa v3yqkF97Kan5JaUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBE14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2jI8I6cxK62vIxIIY0VWUZVW8XwA2048vs2IY02 0E87I2jVAFwI0_JrWl82xGYIkIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2 F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjx v20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2 z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0V AKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1l Ox8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErc IFxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMI IF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0pRPEf5UUUUU = X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 0556D1A000C X-Stat-Signature: 1yxd8o5r8seraf1ziyae7m6obz9yp81r X-Rspam-User: X-HE-Tag: 1691027330-30779 X-HE-Meta: U2FsdGVkX1+1vfo9LmoKLghNNU6wB6fc9z+l2U29VLPgdZsuZOT16YtZd4nUX8pqOk/LORdGAs95cozSZMKCvbdgZmd9naay2ZYTPQzS2WNwL6j0VK5UHRAp4Rc077fC1kaNEgOgkTRXyKFmHHpHPGYn/TgOaGWzP0eyqwMDFKfJV/WhtM1phNfliiGWq7zKhsEkjlakchmv+0g3SpnP2+wg/BKaynXiPYKKxtX3A/Qo/Ar7BpkA3N6rkT9njRyh5Z3o5VkVuODwH0vj/N5UgxtXoE+uyW9XFM/JoHZCbIlZn2hm5ULR1xUtv5/3iFONLeRbMeXdRNVC3L38AZwVGKSOZG9NG31acH7LEyJRPtaRLM+J8fFcRb6GMaTkUBegH+bLOoO/psFP/PFB3TKsfAPJ675XOIvBCRkHVVe7rOOaMYJIYFugun4BPrHK7ZLx2kaXV3eqWkXQVJPsX3mnNdN2EC2BeA4qUgvQklWWtLBQmxI5md+qH1Fu2USPk0nMRcl1Rba/uJGWEAB65GGJl2BrUyYrvD94ENXewSbliejpfHvdOWTDvSsx18/jWtQlHEPSQG4I2Uqspbg7HrsXYn+VwrKempuIhAbVIedro8jBBW2aS7j7lSjArpppYVKl1kjXf3X70uugS4lU0KuY4oebME8btIOSnvhD4yTZGXuDbxZHnNwPC0rqRt2i+tqeRb1LplEwByepw+o35sUnaaa5Q9Q7DqGCnNpS42eDc9V4NcUpuw1cJEAiQg0mC8zuW1rXY7mUuuD+MV0zO0FLAYKYuU6SC25L7stuP3ZoEibsT0dY/fgWNivU0z5cFSH7KpdeURPKdzKlsOPvtMZTalcFbF1O/3Wd5bCDZpozC8zaUBJOE2ET3m/ULm6joUcI1uqg2fHDKozP21uPF7cJf0Mw7ceT94Eforgsn8nYl407dZPa+gXe6ZPIvAgYzFsnLPVGvEjHKda6Kx86Tw0 Fu8wPHiK MdupzYxyDDv4p8efUPM0JNG5e7zZtwA8keurWE0pDDDfZeprwafDVoDnMIorlospnGmBsRNJGbXuvuVNrBy3QrxdQvYNR82DViv0QCy5C3XR7sRSEIdsVUxxw6VmXhkzs4YWko4rq4zlAdzASvn4kOzDFa/Dsw4MGIsWVwjJPg+XQdErToMnkKO9bm9T+BfUX1KRqi85vg23UkHnnHerl0hfoj3J9Cpjo0DFhr0V5c4eAVhxHVF0AqGTdoXwfS+mBrkal5A3rTeJzCm3k10aPNrDPjSzo1W5ukwUS 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 cursor is only used for page forward currently. We can simply move page forward directly to remove unnecessary cursor. Signed-off-by: Kemeng Shi Reviewed-by: Baolin Wang --- mm/compaction.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index b7a05b9843ed..cb1dd5c5bf3f 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -584,7 +584,7 @@ static unsigned long isolate_freepages_block(struct compact_control *cc, bool strict) { int nr_scanned = 0, total_isolated = 0; - struct page *cursor; + struct page *page; unsigned long flags = 0; bool locked = false; unsigned long blockpfn = *start_pfn; @@ -594,12 +594,11 @@ static unsigned long isolate_freepages_block(struct compact_control *cc, if (strict) stride = 1; - cursor = pfn_to_page(blockpfn); + page = pfn_to_page(blockpfn); /* Isolate free pages. */ - for (; blockpfn < end_pfn; blockpfn += stride, cursor += stride) { + for (; blockpfn < end_pfn; blockpfn += stride, page += stride) { int isolated; - struct page *page = cursor; /* * Periodically drop the lock (if held) regardless of its @@ -624,7 +623,7 @@ static unsigned long isolate_freepages_block(struct compact_control *cc, if (likely(order <= MAX_ORDER)) { blockpfn += (1UL << order) - 1; - cursor += (1UL << order) - 1; + page += (1UL << order) - 1; nr_scanned += (1UL << order) - 1; } goto isolate_fail; @@ -661,7 +660,7 @@ static unsigned long isolate_freepages_block(struct compact_control *cc, } /* Advance to the end of split page */ blockpfn += isolated - 1; - cursor += isolated - 1; + page += isolated - 1; continue; isolate_fail: