From nobody Tue Feb 10 01:58:56 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D613C04A94 for ; Fri, 28 Jul 2023 09:13:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234891AbjG1JNi (ORCPT ); Fri, 28 Jul 2023 05:13:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235309AbjG1JMi (ORCPT ); Fri, 28 Jul 2023 05:12:38 -0400 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1167244AE for ; Fri, 28 Jul 2023 02:10:19 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4RC20R4vVwz4f3m8Y for ; Fri, 28 Jul 2023 17:10:15 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP4 (Coremail) with SMTP id gCh0CgA3n7L1hcNkCrD+Ow--.32454S3; Fri, 28 Jul 2023 17:10:16 +0800 (CST) From: Kemeng Shi To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, baolin.wang@linux.alibaba.com, mgorman@techsingularity.net, willy@infradead.org, david@redhat.com Cc: shikemeng@huaweicloud.com Subject: [PATCH 1/8] mm/compaction: avoid missing last page block in section after skip offline sections Date: Sat, 29 Jul 2023 01:10:30 +0800 Message-Id: <20230728171037.2219226-2-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230728171037.2219226-1-shikemeng@huaweicloud.com> References: <20230728171037.2219226-1-shikemeng@huaweicloud.com> MIME-Version: 1.0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_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIx AIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7sRi6pBUUUUUU= = X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" skip_offline_sections_reverse will return the last pfn in found online section. Then we set block_start_pfn to start of page block which contains the last pfn in section. Then we continue, move one page block forward and ignore the last page block in the online section. Make block_start_pfn point to first page block after online section to fix this: 1. make skip_offline_sections_reverse return end pfn of online section, i.e. pfn of page block after online section. 2. assign block_start_pfn with next_pfn. Fixes: f63224525309 ("mm: compaction: skip the memory hole rapidly when iso= lating free pages") Signed-off-by: Kemeng Shi --- mm/compaction.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index 9b7a0a69e19f..ce7841363b12 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -259,7 +259,7 @@ static unsigned long skip_offline_sections_reverse(unsi= gned long start_pfn) =20 while (start_nr-- > 0) { if (online_section_nr(start_nr)) - return section_nr_to_pfn(start_nr) + PAGES_PER_SECTION - 1; + return section_nr_to_pfn(start_nr + 1); } =20 return 0; @@ -1670,8 +1670,7 @@ static void isolate_freepages(struct compact_control = *cc) =20 next_pfn =3D skip_offline_sections_reverse(block_start_pfn); if (next_pfn) - block_start_pfn =3D max(pageblock_start_pfn(next_pfn), - low_pfn); + block_start_pfn =3D max(next_pfn, low_pfn); =20 continue; } --=20 2.30.0