Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp371462rwo; Tue, 1 Aug 2023 19:11:29 -0700 (PDT) X-Google-Smtp-Source: APBJJlHjwCS4jqvmXReqwr2ZyNaCd6Auq/3F6h5Zhl1kzW+oJKFPlg6SPbxJKjOFFYaYhMtqF5yu X-Received: by 2002:a17:906:7382:b0:98e:2b01:ab97 with SMTP id f2-20020a170906738200b0098e2b01ab97mr3558685ejl.68.1690942289139; Tue, 01 Aug 2023 19:11:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690942289; cv=none; d=google.com; s=arc-20160816; b=QAwMRAeX0IBCs5jh2NcxwH0HcrsAAfoA52FC+LzUcutsgmbuvoGPgJhBRhdinJAjjL rSYUN5dP5JhLIIIQKTAbU3zCDpeVDaybXffcUV1gUDUy2eyJMyaCC5tIk73E04qzQGBl EOWbaqEDCVxirECBUFfpm3Ge6OOvUZgK11Maxo5bMzf6Qutke7hbALbtmUqe5fTTV/cz H1dLa2HyQDhtkTma7jZ3Jn/7JDFQPdEPXHS9X46eOhYr37KpyhnbjBjKnHDPMfdo3lTB T+1DG43Lc6JlU+1YUB88L5Ijbe2KPdpH8pm3DdOK87q5Emo88mDatGJwa0kuAeTz3Dtb 5Eiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=DqdNyMmgkaph5hGEpbl52NeKTlemxV2HXIlgdsl/9kg=; fh=zpCCF/J8Z0sUUNZfCNdnaRvm94yhXPVxl9PzV22VU6k=; b=0Dfe7hpCF+ls81qQVyphx+DlOmK+gSHqCybAOoBI2KFPcnhQQw4TGZgvPl/bP2SHMR nadBq2q7CB1aXP2Ea3/zuYLV/m59FjdvIThP6D6zqu5M1gAODVqComYbpCRZzPUVX+52 RzjBRNlWkar9T0I2BPvC8SFQQ5erXDw+IGgOyRU9EoSe4HCy7X8swH7wRIHmEOp5XgMx lJYa0OcvjaP8ckfRQ8N4229sKdFzzf5cqLxVa1+oeFq6GSCPjtJYYb7JzyXkyVT7HGlf ZcuNgo8+ePfSXLwRu4b8Uw9Aq6h3WP8+P5pXBZahxu1gHdrSarfM9eTEkgYBHIIj0dCh 5sNA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y20-20020a17090629d400b00988796c2019si862559eje.591.2023.08.01.19.11.04; Tue, 01 Aug 2023 19:11:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231193AbjHBBhc (ORCPT + 99 others); Tue, 1 Aug 2023 21:37:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230230AbjHBBha (ORCPT ); Tue, 1 Aug 2023 21:37:30 -0400 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73E892701 for ; Tue, 1 Aug 2023 18:37:29 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4RFvjd6zVbz4f3mHb for ; Wed, 2 Aug 2023 09:37:25 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP4 (Coremail) with SMTP id gCh0CgAXzrFTs8lkvrtvPQ--.56352S3; Wed, 02 Aug 2023 09:37:26 +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 1/8] mm/compaction: avoid missing last page block in section after skip offline sections Date: Wed, 2 Aug 2023 17:37:34 +0800 Message-Id: <20230802093741.2333325-2-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20230802093741.2333325-1-shikemeng@huaweicloud.com> References: <20230802093741.2333325-1-shikemeng@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgAXzrFTs8lkvrtvPQ--.56352S3 X-Coremail-Antispam: 1UD129KBjvJXoW7Zw1ktF4UAF1DKr1kuFW5trb_yoW8ZF1Dpr yxCFy3Wrn0qa4Fga4Iyw1kuryYyrs3GF43JrW2yr18A3W5XFn2gF92yryqvryjg34fZFyj v3yvyFW8Cw47A37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBE14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2jI8I6cxK62vIxIIY0VWUZVW8XwA2048vs2IY02 0E87I2jVAFwI0_Jr4l82xGYIkIc2x26xkF7I0E14v26r1I6r4UM28lY4IEw2IIxxk0rwA2 F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjx v20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2 z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0V AKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1l Ox8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErc IFxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMI IF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0pR3PE3UUUUU = X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_00,DATE_IN_FUTURE_06_12, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 isolating free pages") Signed-off-by: Kemeng Shi --- mm/compaction.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index cd23da4d2a5b..a8cea916df9d 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -250,6 +250,11 @@ static unsigned long skip_offline_sections(unsigned long start_pfn) return 0; } +/* + * If the PFN falls into an offline section, return the end PFN of the + * next online section in reverse. If the PFN falls into an online section + * or if there is no next online section in reverse, return 0. + */ static unsigned long skip_offline_sections_reverse(unsigned long start_pfn) { unsigned long start_nr = pfn_to_section_nr(start_pfn); @@ -259,7 +264,7 @@ static unsigned long skip_offline_sections_reverse(unsigned long start_pfn) 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) + PAGES_PER_SECTION; } return 0; @@ -1668,8 +1673,7 @@ static void isolate_freepages(struct compact_control *cc) next_pfn = skip_offline_sections_reverse(block_start_pfn); if (next_pfn) - block_start_pfn = max(pageblock_start_pfn(next_pfn), - low_pfn); + block_start_pfn = max(next_pfn, low_pfn); continue; } -- 2.30.0