From patchwork Thu Feb 4 14:50:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12067471 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 54068C433E0 for ; Thu, 4 Feb 2021 14:50:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D300164F58 for ; Thu, 4 Feb 2021 14:50:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D300164F58 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 67B646B0070; Thu, 4 Feb 2021 09:50:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 659E46B006C; Thu, 4 Feb 2021 09:50:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 458B36B0072; Thu, 4 Feb 2021 09:50:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0191.hostedemail.com [216.40.44.191]) by kanga.kvack.org (Postfix) with ESMTP id 26B486B006C for ; Thu, 4 Feb 2021 09:50:43 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id E136D181AC9CC for ; Thu, 4 Feb 2021 14:50:42 +0000 (UTC) X-FDA: 77780871924.24.E1090AC Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf02.hostedemail.com (Postfix) with ESMTP id 7E07640001DB for ; Thu, 4 Feb 2021 14:50:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612450241; 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=BFhiSabHbTK6awvWbCXdRee7Kg5oltAX0WknJbnHBPY=; b=OLTp2Jtb3Fh1niGKi1ZpnyVYHpypXoj4uXwpuBptZgfnEafl9GeS56remMy4PAWf0xXLe9 d/I+CzIuid+Ng9rJXFlHTRcLlwMRuaAgaCcWAt1LlLA9YsZbcjmecvBlYw4MQ9dOYAwvuS TqUr0H6MZwq7h3HQgsCa3kz7INnP+gc= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-517-P5nW2M21M4KSRbnVoPwYAw-1; Thu, 04 Feb 2021 09:50:40 -0500 X-MC-Unique: P5nW2M21M4KSRbnVoPwYAw-1 Received: by mail-qt1-f198.google.com with SMTP id z19so2709365qtv.20 for ; Thu, 04 Feb 2021 06:50:40 -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=BFhiSabHbTK6awvWbCXdRee7Kg5oltAX0WknJbnHBPY=; b=OmxqzXIHvu5cRGLRewVLAfx2lmbmzQawCx5FywKivj2uOAyJAWgVtt0FnriKgue7vE rPX/5RMJDXtOs5kkXgNOTsyUBjOczTLm2/3IyOIHuNIui8dLeDQ4YFzy1eIUmM+2Qus5 +mL+WalvPDzq9A04p5m0ow0vRKJzjhcAvrWugCZCu2TdaxvR6RLqQnm/XtP6lY9WC4nv 12nI1eeplQC8t1YskdMzdMKJPFy6SAO6qTl8W5Syj4IDWcGU/pq1cuPzAuPGV9WUEVtF tU7q3u2eKeYbjuNf3mtQzXWXOHXSUdcGbLe+3h6h060eq14BFu3yWlnZMAnOltQxdrL7 WnQA== X-Gm-Message-State: AOAM533cgM/+mx6r0ea+GvnPtwjqJ5NW0bEXKWkOU7wTbGrLEMyD3YW9 m9H+47yDDMms2tp1gYWqZNgbu2hB7FjU5lQWwfe5VNthurN3Lhe4/Hj5ZrI6zyd5hJNdSybwvQO YBfFaHLWLauxjSQM1AfVO3YKUYZv15/dfwno/0xOp9P9lb02L77cnjWmFXhhh X-Received: by 2002:a0c:ea22:: with SMTP id t2mr7988258qvp.49.1612450239469; Thu, 04 Feb 2021 06:50:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJyPUkNyHWb+UWJMNEc3cGhB+rAC8gjZRsIwVoa3hAW/lFIuyqXBQa1vuvjUS9s3w6r1pDZpIg== X-Received: by 2002:a0c:ea22:: with SMTP id t2mr7988208qvp.49.1612450239176; Thu, 04 Feb 2021 06:50:39 -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 e14sm4697589qte.18.2021.02.04.06.50.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 06:50:38 -0800 (PST) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Kirill Shutemov , Wei Zhang , Mike Rapoport , Matthew Wilcox , Miaohe Lin , Andrea Arcangeli , peterx@redhat.com, Gal Pressman , Jan Kara , Jann Horn , Andrew Morton , Kirill Tkhai , Linus Torvalds , Mike Kravetz , Jason Gunthorpe , David Gibson , Christoph Hellwig Subject: [PATCH v2 2/4] hugetlg: Break earlier in add_reservation_in_range() when we can Date: Thu, 4 Feb 2021 09:50:31 -0500 Message-Id: <20210204145033.136755-3-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210204145033.136755-1-peterx@redhat.com> References: <20210204145033.136755-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-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 7E07640001DB X-Stat-Signature: sqh595tt58od4ce63tfkheknzz6seiii Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf02; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=216.205.24.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1612450241-507847 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 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