From patchwork Fri Feb 5 16:54:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12070461 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 98D53C433DB for ; Fri, 5 Feb 2021 16:53:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0ED7B64EE0 for ; Fri, 5 Feb 2021 16:53:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0ED7B64EE0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9B0916B0073; Fri, 5 Feb 2021 11:53:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 95F716B0074; Fri, 5 Feb 2021 11:53:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 78CBC6B0075; Fri, 5 Feb 2021 11:53:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0192.hostedemail.com [216.40.44.192]) by kanga.kvack.org (Postfix) with ESMTP id 4FB156B0073 for ; Fri, 5 Feb 2021 11:53:39 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 7CEE43626 for ; Fri, 5 Feb 2021 16:53:38 +0000 (UTC) X-FDA: 77784810516.19.moon67_320d083275e6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id 442ED1AD1B3 for ; Fri, 5 Feb 2021 16:53:38 +0000 (UTC) X-HE-Tag: moon67_320d083275e6 X-Filterd-Recvd-Size: 5403 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Fri, 5 Feb 2021 16:53:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612544016; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Co5gWVPolRGWSV6qsroagZOgnBTQI/bBXcBdWtmnAnQ=; b=VIRV7vaZHlv32/h4swlP5iUUoCtIJ8y9H7vxK/nFD/n68Hls9dJzR4Luh3HVdyE+BFlb86 PrchROI6OPIAW5pt7OMTSSFgoGsDE6HUPpoFjIKDrtm9o3ORgyYJAeTfABJSzD7Eggo5Pb WdgF3JjrTdllMs7g017AIqqdvceHX0o= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-490-ZRSwxjlMMnGh9qUNsWIFHQ-1; Fri, 05 Feb 2021 11:53:35 -0500 X-MC-Unique: ZRSwxjlMMnGh9qUNsWIFHQ-1 Received: by mail-qt1-f199.google.com with SMTP id c19so5696864qtp.2 for ; Fri, 05 Feb 2021 08:53:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Co5gWVPolRGWSV6qsroagZOgnBTQI/bBXcBdWtmnAnQ=; b=msQpR/S1sQ9EGtnYqNFdgioVW/MonzfE6JyD+3Ryll/EZtVyNFL5Im9e3Vq65Dxh8Q UxL97JmZxHtBjm7Hd2rvlrzLLoS3MxTluUSg/pAvkdiwoE5O2WtzpX+bj5cto7ifo1Xj zGcFQrG74rzHYJ6mtZlzPj6/vPdG7Y/dV9AktBsmhMRcT5z7A/IWdBIcmCqjbJXjPfg8 dXTnukoWhWgrJCqVj2I8bOQjBmCCXyLm71lVJOScI1XPJzKzS94RX7xzO80aVshdp7NX upsq6mck2MCXKcqxf1GauyM4KovWMRRYd4E1ymgvzVo0WuOnY727qxEnU+EOIe7zmykv QWBg== X-Gm-Message-State: AOAM530O7IiiPQw6fPQ9g2YpZ6BXrksUBf6K2keQlAy4dGjE1bbBzK5L fq3CqgRx+APfxvlmpbO2Dhi8DuMuPDQGhwWvJ80KFi99V4oU3cyn3ViMb8ql6TS4zr+10EcFZaa jDAY5st/57DGpZwThu4stgkcnz/ZF1o3opKKOPqTtmGC63OS5aIblNtU9WNDR X-Received: by 2002:aed:3aa2:: with SMTP id o31mr822984qte.353.1612544014574; Fri, 05 Feb 2021 08:53:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJyKc6PYm/orcl/kVkLHYNyCRK5wd2QouIxAqDztwVwMw7bYTeEXrpzk1qdQmoRBmevHeSICGw== X-Received: by 2002:aed:3aa2:: with SMTP id o31mr822948qte.353.1612544014300; Fri, 05 Feb 2021 08:53:34 -0800 (PST) Received: from xz-x1.redhat.com (bras-vprn-toroon474qw-lp130-20-174-93-89-182.dsl.bell.ca. [174.93.89.182]) by smtp.gmail.com with ESMTPSA id 12sm9618893qkg.39.2021.02.05.08.53.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 08:53:33 -0800 (PST) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Gal Pressman , Andrea Arcangeli , Christoph Hellwig , Miaohe Lin , Kirill Shutemov , Jann Horn , Matthew Wilcox , Jan Kara , Jason Gunthorpe , Linus Torvalds , Mike Rapoport , David Gibson , Mike Kravetz , peterx@redhat.com, Kirill Tkhai , Wei Zhang , Andrew Morton Subject: [PATCH v3 2/5] hugetlg: Break earlier in add_reservation_in_range() when we can Date: Fri, 5 Feb 2021 11:54:03 -0500 Message-Id: <20210205165406.4655-3-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210205165406.4655-1-peterx@redhat.com> References: <20210205165406.4655-1-peterx@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=peterx@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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: 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. Reviewed-by: Mike Kravetz 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 ec8e29c805fe..71ccec5c3817 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -387,7 +387,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