Received: by 2002:a05:7412:3210:b0:e2:908c:2ebd with SMTP id eu16csp839363rdb; Fri, 1 Sep 2023 05:56:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHlNf5M6rCYf4s8I8ZmDRmFjR6y/SZr9XSh2C+CK9tNLCs/2bwceKOdghhPtIO/mnV3ztTo X-Received: by 2002:a05:6808:128e:b0:3a8:73a9:396f with SMTP id a14-20020a056808128e00b003a873a9396fmr2991670oiw.15.1693573003883; Fri, 01 Sep 2023 05:56:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693573003; cv=none; d=google.com; s=arc-20160816; b=ZsU6MqW87YaHoPE8fB5BzL/AC5BopDfVT5Kc01qEmD3VxPqrYmNJ5tb0EXNpfFHukS kn4lKUt3hgMSYXCb1H+W5T4RSJ3TQHsEbVVansKWkNjN+jtNaZSK7SsS/xB6jmmc9ONS nsm4YZr9XDwx+pCy49TH0IBwpYjAlN2czSmUWvB6f7PmzMvsEPTeCxg5FAjqGOtNSg6T gHuOonNhefLwT186mZj194GwLAWwCjBPCKKEvjuPP5k01ojowDOC5uKh6zCdw18C/9E0 q+H1xnb5dfcQFF+EgFn2qcY0W0beNa6MTUtrYxmCe7OQ2zMyk300F7l+2aKVe9i9OojC DNsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=eTQIOlhLLxgFHEOHtZmBEeVJwoYS85yuxm+kwBs5E08=; fh=bBxpxZzNPCEk4t/udImYlcEv/473DayDyReksGOwvEQ=; b=whla0x0hSbHRULgqqf0X7SfluqqXA+gFTdiX1P9zradPI13Cmdw6HjWGO1GfpFjqZZ LsnwD86Hj+kWFlkAOpZEjaode7nuHUfVgJjEJX79FQ82G+FWpFm6dC1WqobVMQWkWTFM SqRbbOHjsWRxryzgbg7Xr/s2rMfMg4xlXwggS9hCV67I05MSwCUiZXmj845az9RcHq7G l+DZL23yxbzLzn6ht+sn7gEv+Yi1FfY1gShJr42btwf6ZAkFRGAHFcQeVc6/KHmrqN9p ngaaCKWOo6nGq8ngmobBY7lmgpDTGnVQPCIV0dLu3lq+N+uKPqkAW8oALR3Eo+FgLw7p iPsw== 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 f28-20020a63755c000000b0056fa1ac3722si2968384pgn.698.2023.09.01.05.56.29; Fri, 01 Sep 2023 05:56:43 -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 S243007AbjIAJRT (ORCPT + 99 others); Fri, 1 Sep 2023 05:17:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232025AbjIAJRS (ORCPT ); Fri, 1 Sep 2023 05:17:18 -0400 Received: from outbound-smtp36.blacknight.com (outbound-smtp36.blacknight.com [46.22.139.219]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 242C810D4 for ; Fri, 1 Sep 2023 02:17:15 -0700 (PDT) Received: from mail.blacknight.com (pemlinmail02.blacknight.ie [81.17.254.11]) by outbound-smtp36.blacknight.com (Postfix) with ESMTPS id 9C4EA21F4 for ; Fri, 1 Sep 2023 10:17:13 +0100 (IST) Received: (qmail 10766 invoked from network); 1 Sep 2023 09:17:13 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.20.191]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 1 Sep 2023 09:17:13 -0000 Date: Fri, 1 Sep 2023 10:17:11 +0100 From: Mel Gorman To: Kemeng Shi Cc: akpm@linux-foundation.org, baolin.wang@linux.alibaba.com, david@redhat.com, willy@infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 3/6] mm/compaction: correctly return failure with bogus compound_order in strict mode Message-ID: <20230901091711.rpykbvfsnrcuwqhn@techsingularity.net> References: <20230901155141.249860-1-shikemeng@huaweicloud.com> <20230901155141.249860-4-shikemeng@huaweicloud.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20230901155141.249860-4-shikemeng@huaweicloud.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS 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 On Fri, Sep 01, 2023 at 11:51:38PM +0800, Kemeng Shi wrote: > In strict mode, we should return 0 if there is any hole in pageblock. If > we successfully isolated pages at beginning at pageblock and then have a > bogus compound_order outside pageblock in next page. We will abort search > loop with blockpfn > end_pfn. Although we will limit blockpfn to end_pfn, > we will treat it as a successful isolation in strict mode as blockpfn is > not < end_pfn and return partial isolated pages. Then > isolate_freepages_range may success unexpectly with hole in isolated > range. > > Fixes: 9fcd6d2e052e ("mm, compaction: skip compound pages by order in free scanner") > Signed-off-by: Kemeng Shi > Reviewed-by: Baolin Wang > --- > mm/compaction.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/mm/compaction.c b/mm/compaction.c > index a40550a33aee..9ecbfbc695e5 100644 > --- a/mm/compaction.c > +++ b/mm/compaction.c > @@ -626,11 +626,12 @@ static unsigned long isolate_freepages_block(struct compact_control *cc, > if (PageCompound(page)) { > const unsigned int order = compound_order(page); > > - if (likely(order <= MAX_ORDER)) { > + if (blockpfn + (1UL << order) <= end_pfn) { > blockpfn += (1UL << order) - 1; > page += (1UL << order) - 1; > nr_scanned += (1UL << order) - 1; > } > + > goto isolate_fail; > } > > @@ -678,8 +679,7 @@ static unsigned long isolate_freepages_block(struct compact_control *cc, > spin_unlock_irqrestore(&cc->zone->lock, flags); > > /* > - * There is a tiny chance that we have read bogus compound_order(), > - * so be careful to not go outside of the pageblock. > + * Be careful to not go outside of the pageblock. > */ > if (unlikely(blockpfn > end_pfn)) > blockpfn = end_pfn; Is this check still necessary after the first hunk? -- Mel Gorman SUSE Labs