From patchwork Sat Jul 29 17:43:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13333059 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 915E1C001E0 for ; Sat, 29 Jul 2023 09:43:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A32418D0003; Sat, 29 Jul 2023 05:43:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9E2A68D0001; 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 773368D0003; Sat, 29 Jul 2023 05:43:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 590938D0001 for ; Sat, 29 Jul 2023 05:43:44 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 300DDC06CC for ; Sat, 29 Jul 2023 09:43:44 +0000 (UTC) X-FDA: 81064162368.15.AC22A94 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by imf23.hostedemail.com (Postfix) with ESMTP id 39344140008 for ; Sat, 29 Jul 2023 09:43:40 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; dmarc=none; spf=none (imf23.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=IZ/ybrQMSLoGamzR3ER5S8lsGGrYKsbtPQsucYnFdD8=; b=SPONGLeOqRbyS+EksdcwhmJNSXGRaet+sVtHI2TnUl7Gjovq9Zv8c4rOp/f5DUiI5tCYhq Mx6ZvwqdfD1dR9/UPhrpo1OJ2OwDn7mbgkxqyuBbljvkdzZTIQXELY99JJnPWdCe4hJDQp KJSTwm77nZZSAflj9TQSzZ5qPdbRgxs= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; dmarc=none; spf=none (imf23.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=tV+NBvn2dqvm1oyh2MGyxdvjVqK9b73Oz2CAazhSy38dRdrIlnowO7CQ4dxP7f9B+l2f2x UaCCZUve5YMhfXd8jK8AQGfFwprGWsGYGpY+8fEjS7CrlSr1jsmeGqebC58XnAgmlCcoG1 OFdGKZ6nMS7Kvlvf3DRLwJZjtxUMayg= Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4RCfhQ1yHTz4f403j 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--.25635S3; Sat, 29 Jul 2023 17:43:34 +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 1/5] mm/compaction: allow blockpfn outside of pageblock for high order buddy page Date: Sun, 30 Jul 2023 01:43:50 +0800 Message-Id: <20230729174354.2239980-2-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--.25635S3 X-Coremail-Antispam: 1UD129KBjvJXoW7KrW8Ar1kWryDXFyfWryxAFb_yoW8KryDpa 47K3W29F1DuayYvFy7JrWkuF1jkwsYyF4jyrW5Kr18ZF9Yg3Z2k3sFyr1jvryjqr1fAFZ0 vr4DKFZ7CrsrZa7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBE14x267AKxVW5JVWrJwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2jI8I6cxK62vIxIIY0VWUZVW8XwA2048vs2IY02 0E87I2jVAFwI0_Jr4l82xGYIkIc2x26xkF7I0E14v26r1I6r4UM28lY4IEw2IIxxk0rwA2 F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjx v20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2 z280aVCY1x0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0V AKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1l Ox8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErc IFxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMI IF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0pRxhLUUUUUU = X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ X-CFilter-Loop: Reflected X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 39344140008 X-Stat-Signature: 5g6mdr4u3fpxztyrxyd35raxq7hyoj91 X-HE-Tag: 1690623820-990136 X-HE-Meta: U2FsdGVkX1+1IqvG6OUPDAHdbt6kKeZGtDcYhX/rfe05SVjo/9va3eTngJ1xtZv4sTe5GqUgT28EBcwUybBFtOtFnl/x3R7PAIzoGOQpR4BEovziEU3j3+qT1l0dTogVdJDY1iPMoQBJPpgFXfOY26lXTy1CnKeSNXTds3rY2fcrtB09wqi95DBymLU7S/BlVrv9k3jq2wmc/4qZ8jQ0mikjPZawj42TK9YDR43yOBrrEDtcNLxNfq8SMHbJDJGncOkgtdcIUSMcrhZhCVvq2gxFc8PWiqrpF6BPGeCkLpa0Ska1/Ne595htazpkTY3WaIiFl+UcB6XPsg77MSnLj6Chc6BmpuXx/qnWMx92tR++F2RyH7vUUFMKkCUjvBoUMzm3jF2HMZkXZcbNrSpIl+d/tcUY0Em4cXqbUH0xfKpV1VTAQ9+52/KpDOhPvXlu0aqvVvWL1GDG9NN1biAfWQgnkLEW4+xOKjeYvEZZc3cUCVRyuyssLJATC6CkUHsLnN0UIQNLxLySg1L7AwUGVeypxjl0vIAEneVPIGBK+uuAtNGif+hV12wQ4zwsgo6hrXwDn+56WMts7xv8PvaAbYbuPqWKrO8J0qAqgf8F2K47TM244wdJl3q1R2SGYwgVvb30GWhqxuGE6mNz9Asr709mJLVL1636Z5i8LmEPyMfjPpIM9nrSxxM9pRhWt/RM1rQBCbmrmJVAuO9Oj+p7JHMM7kMaF2Ypuqris5oiJTcCNVjzfUXWKLzgoOpSBu9cqcUCKgZMiQmM2k+ccpWsKbY4ioFedGxntHtR2sW6O3BkflY0t42ExGGy+O/H6BDDJ7k1lCgyl8WkLfdZkF8Ob1Ys2nroKfLTK5ajLsXx4u2muhFuWpL0bMqQbuylXHXXVSyRMIB0+PBgCXrkchGdlyl8m/7ZKoMG5zyF/Ls7/WeC015jx20sfEzBccrxSvg/289LCzPv1EwCQGK5npD BwDrPRcf LiniGyH+RqaR68BIF2TiDQ/9yEWiY8g2s9Ld63WoDbssXDIzKWA6v2+iGKdGWFKwFueiUfqozwv212HaQaHlhVYM0LLm064kUKhaWMd9KC4+Buf7rWa/ck+Bi/p6KM45YLbMlF4R2JndR9dWgb8gItFFTupnD69TEG6o7T61A18o4o1F/xsl23pziiLv2QWoI1q15nDfMZgfjx10zDrI59arb+RxCJbnF6PtLy4UFxkRrl9bcEhG6ERGv+WQwXed4wm3bANvKT8I9DsU= 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: Commit 9fcd6d2e052ee ("mm, compaction: skip compound pages by order in free scanner") skiped compound pages to save iterations and limit blockpfn to reach outside of page block in case of bogus compound_order. While this also limit pfnblock outside page block in case a buddy page with order higher than page block is found. After this, isolate_freepages_range will fail unexpectedly as it will fail to isolate the page block which was isolated successfully by high order buddy page in previous page block and abort the free page isolation. Fix this by allow blockpfn outside of pageblock in case of high order buddy page. Fixes: 9fcd6d2e052ee ("mm, compaction: skip compound pages by order in free scanner") Signed-off-by: Kemeng Shi --- mm/compaction.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mm/compaction.c b/mm/compaction.c index 6841c0496223..d1d28d57e5bd 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -681,8 +681,10 @@ static unsigned long isolate_freepages_block(struct compact_control *cc, /* * There is a tiny chance that we have read bogus compound_order(), * so be careful to not go outside of the pageblock. + * Allow blockpfn outside pageblock in normal case that we isolate + * buddy page with order more than pageblock order. */ - if (unlikely(blockpfn > end_pfn)) + if (unlikely(blockpfn > end_pfn) && total_isolated <= pageblock_nr_pages) blockpfn = end_pfn; trace_mm_compaction_isolate_freepages(*start_pfn, blockpfn, @@ -1418,7 +1420,7 @@ fast_isolate_around(struct compact_control *cc, unsigned long pfn) isolate_freepages_block(cc, &start_pfn, end_pfn, &cc->freepages, 1, false); /* Skip this pageblock in the future as it's full or nearly full */ - if (start_pfn == end_pfn && !cc->no_set_skip_hint) + if (start_pfn >= end_pfn && !cc->no_set_skip_hint) set_pageblock_skip(page); } @@ -1687,7 +1689,7 @@ static void isolate_freepages(struct compact_control *cc) block_end_pfn, freelist, stride, false); /* Update the skip hint if the full pageblock was scanned */ - if (isolate_start_pfn == block_end_pfn) + if (isolate_start_pfn >= block_end_pfn) update_pageblock_skip(cc, page, block_start_pfn); /* Are enough freepages isolated? */