From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.4 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77F31C433E0 for ; Thu, 4 Feb 2021 02:21:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 432BC64F67 for ; Thu, 4 Feb 2021 02:21:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234064AbhBDCU4 (ORCPT ); Wed, 3 Feb 2021 21:20:56 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:12119 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233311AbhBDCUx (ORCPT ); Wed, 3 Feb 2021 21:20:53 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4DWMfy4s4bz162ZX; Thu, 4 Feb 2021 10:18:50 +0800 (CST) Received: from [10.174.179.241] (10.174.179.241) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.498.0; Thu, 4 Feb 2021 10:20:06 +0800 Subject: Re: [PATCH 2/4] hugetlg: Break earlier in add_reservation_in_range() when we can To: Peter Xu CC: Wei Zhang , Matthew Wilcox , "Linus Torvalds" , Jason Gunthorpe , "Gal Pressman" , Christoph Hellwig , "Andrea Arcangeli" , Jan Kara , Kirill Shutemov , David Gibson , "Mike Rapoport" , Mike Kravetz , Kirill Tkhai , Jann Horn , "Andrew Morton" , , Linux-MM References: <20210203210832.113685-1-peterx@redhat.com> <20210203210832.113685-3-peterx@redhat.com> From: Miaohe Lin Message-ID: <22c64602-db2f-de36-ea54-5701f109368e@huawei.com> Date: Thu, 4 Feb 2021 10:20:05 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20210203210832.113685-3-peterx@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.241] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi: On 2021/2/4 5:08, Peter Xu wrote: > All the regions maintained in hugetlb reserved map is inclusive on "from" but > exclusive on "to". We can break earlier even if rg->from==t because it already > means no possible intersection. > > This does not need a Fixes in all cases because when it happens (rg->from==t) > we'll not break out of the loop while we should, however the next thing we'd do > is still add the last file_region we'd need and quit the loop in the next > round. So this change is not a bugfix (since the old code should still run > okay iiuc), but we'd better still touch it up to make it logically sane. > I think the difference is when we handle the rg->from == t case. Previous one is in the loop, now below the loop. But the result should be same. Thanks. Reviewed-by: Miaohe Lin > Signed-off-by: Peter Xu > --- > mm/hugetlb.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index d2859c2aecc9..9e6ea96bf33b 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -377,7 +377,7 @@ static long add_reservation_in_range(struct resv_map *resv, long f, long t, > /* When we find a region that starts beyond our range, we've > * finished. > */ > - if (rg->from > t) > + if (rg->from >= t) > break; > > /* Add an entry for last_accounted_offset -> rg->from, and >