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 41681C433DB for ; Thu, 4 Feb 2021 02:20:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6824F64F55 for ; Thu, 4 Feb 2021 02:20:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6824F64F55 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AD3936B0005; Wed, 3 Feb 2021 21:20:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A83206B006C; Wed, 3 Feb 2021 21:20:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8ADDE6B006E; Wed, 3 Feb 2021 21:20:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0102.hostedemail.com [216.40.44.102]) by kanga.kvack.org (Postfix) with ESMTP id 715676B0005 for ; Wed, 3 Feb 2021 21:20:16 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 2E761181AEF10 for ; Thu, 4 Feb 2021 02:20:16 +0000 (UTC) X-FDA: 77778980832.18.AE484C8 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf07.hostedemail.com (Postfix) with ESMTP id BFFFCA00008E for ; Thu, 4 Feb 2021 02:20:14 +0000 (UTC) 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 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: BFFFCA00008E X-Stat-Signature: 4kriczaznzfgaueiki3uxmrhxwwxd4zc Received-SPF: none (huawei.com>: No applicable sender policy available) receiver=imf07; identity=mailfrom; envelope-from=""; helo=szxga04-in.huawei.com; client-ip=45.249.212.190 X-HE-DKIM-Result: none/none X-HE-Tag: 1612405214-508497 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: 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 >