[v2,1/8] mm/compaction: avoid missing last page block in section after skip offline sections
Message ID | 20230802093741.2333325-2-shikemeng@huaweicloud.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp139237vqx; Tue, 1 Aug 2023 18:49:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlEPBnhufT6a0qf7g7PkD5bRm/0RyD/pegtI2ZoztembXm7tus1uv6ecuVQ4c3gLFaJPOSVe X-Received: by 2002:a17:906:5308:b0:994:577:f9dd with SMTP id h8-20020a170906530800b009940577f9ddmr3952494ejo.9.1690940945720; Tue, 01 Aug 2023 18:49:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690940945; cv=none; d=google.com; s=arc-20160816; b=ihb51lEPT8DaUZ9e5/AfLr8jc51zNRZob+HZQJo40OtcNa6vvAEEpSiVLvlphNt1A7 MNddBm67QfgFAP7Av7cusw9yZGUyt8lViW737ASPtITDQAH4CCBOuBbqDG+uB54SyiRO lv/VuLTYT/1LGM79k0SMVIrBIz9DAR1rFh6puJDJwspKZm94NBcQyeZ9HL8dwXoatnCS YRqUNmDvVcUPULAtkJUlA3hqZzaVoN4FAgk4npr4RdWGB07BUnu/SAuiFsPiPdqoJPwh btATjz1/bqPx1YoPr2xyjIvjrJGi29qRXM7V/hZ89uAJtEc95fpyPA/jB4SXHhn3MteL iR3A== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qt7-20020a170906ece700b0099bcb3ad50csi1352323ejb.504.2023.08.01.18.48.38; Tue, 01 Aug 2023 18:49:05 -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 S231230AbjHBBhc (ORCPT <rfc822;maxi.paulin@gmail.com> + 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <linux-kernel@vger.kernel.org>; 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 <linux-kernel@vger.kernel.org>; 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 <shikemeng@huaweicloud.com> 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773080092922063430 X-GMAIL-MSGID: 1773080092922063430 |
Series |
Fixes and cleanups to compaction
|
|
Commit Message
Kemeng Shi
Aug. 2, 2023, 9:37 a.m. UTC
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 <shikemeng@huaweicloud.com>
---
mm/compaction.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
Comments
On 02.08.23 11:37, Kemeng Shi wrote: > 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 <shikemeng@huaweicloud.com> > --- > 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; > } Acked-by: David Hildenbrand <david@redhat.com>
On 8/2/2023 5:37 PM, Kemeng Shi wrote: > 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") The changes look good to me. But the commit id is not stable, since it is not merged into mm-stable branch yet. Not sure how to handle this patch, squash it into the original patch? Andrew, what do you prefer? > Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com> > --- > 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; > }
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; }