From patchwork Wed Feb 17 23:35:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12092597 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 93716C433E6 for ; Wed, 17 Feb 2021 23:35:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 38C98600EF for ; Wed, 17 Feb 2021 23:35:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 38C98600EF 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 3DB386B006C; Wed, 17 Feb 2021 18:35:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 313586B006E; Wed, 17 Feb 2021 18:35:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 18D7B6B0070; Wed, 17 Feb 2021 18:35:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0165.hostedemail.com [216.40.44.165]) by kanga.kvack.org (Postfix) with ESMTP id ED0FB6B006C for ; Wed, 17 Feb 2021 18:35:56 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id BBA2E1E1A for ; Wed, 17 Feb 2021 23:35:56 +0000 (UTC) X-FDA: 77829369912.10.CD7EE08 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 177AF407F8DF for ; Wed, 17 Feb 2021 23:35:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613604955; 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=DOLBpO+jIc7m6kTzABHfMZhxUnbe7uQo4h61IVSpjcg=; b=OvL5+oGY2IjeIVaSXbH0Eo5pmJn2SLnvmwynLxYJPGdn/WNibHHi1YQ4IZM7tI+2HYQrss vU8llXlQL1YSK/r7Oawgk4TPukYoD/UtRkgTyeLuYAM5tkgFC0A0b129oAhwfIY9Agmrvg u1Y3vcJzTY7vsnDIsvjLENkl+C5jw+s= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-552-s92N21KJPN2xYncUDaENHw-1; Wed, 17 Feb 2021 18:35:54 -0500 X-MC-Unique: s92N21KJPN2xYncUDaENHw-1 Received: by mail-qk1-f199.google.com with SMTP id d66so129158qke.9 for ; Wed, 17 Feb 2021 15:35:54 -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=DOLBpO+jIc7m6kTzABHfMZhxUnbe7uQo4h61IVSpjcg=; b=PEXgSW/XiK/Sl2SZa4TCxattbWXsXgor0psXD+GFMzjmUp9UzgUAiIsa/x9ChppdPb 85Vic7U0gt/s4gIQL5eXX0cRVf8kE9k4WfWD62guutr+3DFBUZ5bfEX2xVGkck7Nq2yB zP15Ny/76A2vNferx42eYaRzfQU6kRbbhoAfMiaLACdfaCY4PRQpypDzcHvPuaA9OGGE YcuyJ11VsOabcJarRtvyLzmZbPqrTzXMKE3hTFT/yp/5AV6GCtMmG+7SbHnkKQ9nuBLp sousVYJxU/Ocfd+rbL1yrfBdIHSOUSvdIFi6+zYqpRtNRn13g3NN0Bo7nSsLoSIl3pGE Mo0g== X-Gm-Message-State: AOAM533sLD38pha9CiFaDd9yo3JZs7/f6exU9dY96wyJxrAiBb8XSGjb iJn6ve3XM6xtVyfxDmgBaZ5Nkiinebfz8dPks57qxI1PO6SjqGCnjGc6vIpUrdHeyPJTPbs33X4 auMK/Jaht+wbbWrfV0PXOz6SHgx/ymds03iIwW10avOFuoTp6JoDkLhgyJuEQ X-Received: by 2002:ac8:149a:: with SMTP id l26mr1755913qtj.210.1613604953503; Wed, 17 Feb 2021 15:35:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJzkPF9IdEx/0qho199ZELPwh7tKPt6adZyOrtuP5Au+UOQSOmMOTUV01IpIZiH6otG3JNuBHw== X-Received: by 2002:ac8:149a:: with SMTP id l26mr1755887qtj.210.1613604953196; Wed, 17 Feb 2021 15:35:53 -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 o5sm2739622qkh.59.2021.02.17.15.35.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Feb 2021 15:35:52 -0800 (PST) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Gal Pressman , Matthew Wilcox , Wei Zhang , peterx@redhat.com, Mike Kravetz , Mike Rapoport , Christoph Hellwig , Andrew Morton , Linus Torvalds , David Gibson , Jason Gunthorpe , Jann Horn , Kirill Tkhai , Kirill Shutemov , Miaohe Lin , Andrea Arcangeli , Jan Kara Subject: [PATCH v5 2/5] hugetlg: Break earlier in add_reservation_in_range() when we can Date: Wed, 17 Feb 2021 18:35:44 -0500 Message-Id: <20210217233547.93892-3-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210217233547.93892-1-peterx@redhat.com> References: <20210217233547.93892-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-Stat-Signature: ogxh15foze8bank6csxxje8j43af1dy1 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 177AF407F8DF Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf17; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=63.128.21.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1613604954-130166 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 e302ed715839..2ba4ea4ab46e 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