From patchwork Sat Jul 29 17:43:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13333058 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 B126AC04A6A for ; Sat, 29 Jul 2023 09:43:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 65EF48D0002; Sat, 29 Jul 2023 05:43:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C3608D0006; Sat, 29 Jul 2023 05:43:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C8518D0002; Sat, 29 Jul 2023 05:43:44 -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 2490A8D0001 for ; Sat, 29 Jul 2023 05:43:44 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E5EEC1201DA for ; Sat, 29 Jul 2023 09:43:43 +0000 (UTC) X-FDA: 81064162326.18.AFAE025 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by imf05.hostedemail.com (Postfix) with ESMTP id ED603100011 for ; Sat, 29 Jul 2023 09:43:40 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=none; spf=none (imf05.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=1690623822; 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=9meaUYhEJFtb8FcCU7b6xQzuXYdX0srDSO6ev7eCARE=; b=a3N21xGkg4cwZ06Nb88zdZZ2Ye3yEKhGe9x2UiuCrkZMCJPVyQ5Tw09mTX6Bce64Ct7AQy /TCVWBWMnXb5OwDfE9zWs5xSHIQC94jH9Kb4Rd0gzcrksHZvQjVnbbmmzZBOrE7CrunYqe Gu9Fh9khnHfeCUrrBpNfGoTUMIurPZ0= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; dmarc=none; spf=none (imf05.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=1690623822; a=rsa-sha256; cv=none; b=kgk1eaQatwQuyd86n0RL5mBrJdSd6OYBN8vdLjCaVsQYM/q3FbKMj8/d/NwU/Zb+jkbWxq a8gY7fwDRJPF7hPx7L/+0YpTKTMw89bZvhESSl/G4xbYcGOcDPe2FoUcKjOmowOR4i9pWb 9h8dNEmxGjppNRSNGHu+xd8e2Kt3KdA= Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4RCfhQ6fV4z4f3pJF for ; Sat, 29 Jul 2023 17:43:34 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP1 (Coremail) with SMTP id cCh0CgDHMy5D38RkAQcpOQ--.25635S6; Sat, 29 Jul 2023 17:43:35 +0800 (CST) From: Kemeng Shi To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org Cc: baolin.wang@linux.alibaba.com, mgorman@techsingularity.net, willy@infradead.org, david@redhat.com, shikemeng@huaweicloud.com Subject: [PATCH 4/5] mm/compaction: remove unnecessary cursor page in isolate_freepages_block Date: Sun, 30 Jul 2023 01:43:53 +0800 Message-Id: <20230729174354.2239980-5-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230729174354.2239980-1-shikemeng@huaweicloud.com> References: <20230729174354.2239980-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: cCh0CgDHMy5D38RkAQcpOQ--.25635S6 X-Coremail-Antispam: 1UD129KBjvJXoW7WrWxAFW3WF17CFWkXF1UKFg_yoW8Ww47pF yjkw1IyF40g345uFy7t3ykCr17Grs8KanrCr4fJrWrZFyftFyxZry2yr1UCrW8XrZrurZa 93yDKF97Kan5JaUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPY14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2jI8I6cxK62vIxIIY0VWUZVW8XwA2048vs2IY02 0E87I2jVAFwI0_JF0E3s1l82xGYIkIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0 rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6x IIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xv wVC2z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFc xC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_ Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2 IErcIFxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r 4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0pRvJPtU UUUU= X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: ED603100011 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 9d4ay7kmqr5dtt7w4c13wxzhq6mreyjy X-HE-Tag: 1690623820-218411 X-HE-Meta: U2FsdGVkX18CdWP1Jn8UD5pA1N5S/aUnghqMnXSDgBp8K9z36PvmuufjuN84K/Wjc2QYBSErHq+taJKiHRE5GctSjFZuLEpvCXspbkDqFjDvdCRhLlzZnagpqPXB4IfDci355TCJ2eKexzo3aJq7cZBYpF2ZcJcQV4cz+v84HVzSqqQsp/TvJECRi5VOji90Myt45ZWpMggHRgZfbD6/u60X9XmfA3yAQBJjTwXEdVUOSUIeB17NlKNZVrLdrQJcnbILKbHDGY+RSxXyuLztrPuhr7KznbULS9r/ERLva0aQRrTwztsJZUdpDu2DhEtfr4EfY+e9/D4sM39dMmvNMC0bdUTu5dRdpBMyA44cG1+/jKkTL6+7Z2FGudVCMqoXHsJQ9ClAffzZInTGpJyQj4a8mxVDFQp90EWP7mUtnNf/wG70iD/3vzJQ7FbrY2Mhx7EVNqPNob9JgwrB89id02Kvc++QK9ODowI2gHJIgMfJ24JIOGmRpIqmlH18pVrZDK+Hj2aFTks0dfGzpK5HEj2Xlyx9XgVUGUYs6G40Tm2h7WkDdmxop7Zvq8GFyeBkxDtLy/cUEF9Yxqt0ypl3TWsxlcMHTB24PEOBudiAcVa8b+qO0X26ohbv0HHb37N9vpKOmnvV4prBO5q0H7gWUC+mIxC4I3E4lpP738DsmKY9GPSOtDn9i08USGHuwVVtC1etieRo4whACQudscox84wI2VrnoRnsDVxjKI51c3iJjJNQ8I7/j5yH2X9fBhcJXkLhCh6AqLBZRs5BhyBUwez8hNToB36paBOxTsn7ak+EQFDndt02wYCVN9aeP3J8OZ0QRdOlAFFotUUYjsy9JGjDGq4Ajk2seJn6U7E+x7oBk0TS4tegJFM007vjLNoSyTVLXg5UbkZix0ypLADEow6nCSKGvWk80zwN+PVKgKN9ZoMdiuE0MoPS25Ki8G8FNgx/7V619cOvaox0Tgu teVGTnQt 29VRprLQ1Nj1psjX0OFKjgspeYqsRremb/TXyryKJNirURCkfk13fN9jS75oI8crzqmeOt4/NWZGUGKLqRz2ihS71aC2X0rXi/Os5GSD2hOYhMcTrcKqp1bbjX1kG6GxyCdGlR5v9DYa9yEJbdhhWvEch3eZFbIZqCK0DScvZr66vqwhysUb3qyt0SGuwmyU6fgJZr5ekBGGJQ/9PwiWYnh/PoLbtP99X80c+3rcknS397eeaKSvEHc0nbu8HNloFykZ8iDmXKup3r5VI6jqrYgmIZXaYBzc2kng9B4glcm7BCq06rD91IZN/DcM0LmKrD0HD 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 65791a74c5e8..cfb661f4ce23 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -589,7 +589,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; spinlock_t *locked = NULL; unsigned long blockpfn = *start_pfn; @@ -599,12 +599,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 @@ -628,7 +627,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; @@ -665,7 +664,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: