From patchwork Wed Feb 3 21:08:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12065379 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.6 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,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 BE8F0C433DB for ; Wed, 3 Feb 2021 21:08:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6499A64F5F for ; Wed, 3 Feb 2021 21:08:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6499A64F5F 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 446666B0070; Wed, 3 Feb 2021 16:08:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3D0196B0071; Wed, 3 Feb 2021 16:08:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1FE446B0072; Wed, 3 Feb 2021 16:08:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0119.hostedemail.com [216.40.44.119]) by kanga.kvack.org (Postfix) with ESMTP id DA0416B0071 for ; Wed, 3 Feb 2021 16:08:44 -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 96D55181AEF15 for ; Wed, 3 Feb 2021 21:08:44 +0000 (UTC) X-FDA: 77778195768.18.feet99_4508bbc275d6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id 7781A100ED0D0 for ; Wed, 3 Feb 2021 21:08:44 +0000 (UTC) X-HE-Tag: feet99_4508bbc275d6 X-Filterd-Recvd-Size: 5219 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf44.hostedemail.com (Postfix) with ESMTP for ; Wed, 3 Feb 2021 21:08:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612386523; 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=anQ4NxVMrC5prvoBF/9r6AhuqrJJE/i32bJ7Mv18iJk=; b=TQ48rzCefnyrVgoooN9lZm3MOkrMZx76CfkiPpkk9zDmjtV03izRojpKt9R7heM75Z5Yzx XenDCEslRRYU0QubkQSrQnikLTVb0X7uR2HS2QWgoaQctx7XdBkiny21RS/3vPJ5LQbr9S u+tpnYJcdhu/aHO66b9KE8uGsN4t7rE= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-297-er7gTkjdOwCEzW0wP4WAag-1; Wed, 03 Feb 2021 16:08:39 -0500 X-MC-Unique: er7gTkjdOwCEzW0wP4WAag-1 Received: by mail-qv1-f71.google.com with SMTP id d26so492473qve.7 for ; Wed, 03 Feb 2021 13:08:39 -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=anQ4NxVMrC5prvoBF/9r6AhuqrJJE/i32bJ7Mv18iJk=; b=XT/et+93NS1Wu/eq9DPppa6ewcxA7hwAR0WW8FQfHBWUwlUZ9TqN/C2+YFyJBDLUEu wU26rUzDWKTuW9YJ01zoRQd2WzH0sYmwswHILmRjuV6OgXOl7WVzH2WYAKnbYS0SxceC XW9EdpF4OXSes09caCM9OmQx7kskVlC+jdgZi0cBF1cvKO2qnrhOOIutwmeVmK6FW+7T eQUgmfBrroT44DBCswZ2aWJcjQAQPspwy8O5Qrr/9h1ZM5IBw28P2ATAMejBhehpJXAF 6j3qMk29WE2J73qfB6PNLh4O10KXpkE2QX65R0g676M7GA0URrz9pmuPmq+w+hg2DC7m xj/Q== X-Gm-Message-State: AOAM533f30m+V/57ebBE5tMFSL5e4o7WqsRXn51wLfGsKPsnHjRFZZkU ako8gyK3wmGHN637QjUzpHksdW5bNCUow2MyC7JFYoyo9sSkHoBSZsWpM7P2kiUCiqy0MJ/SCih ErvBL8tgX6Uo= X-Received: by 2002:a37:2784:: with SMTP id n126mr4598375qkn.328.1612386519200; Wed, 03 Feb 2021 13:08:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJz9Tlp/gYAwyauborxxPzXq74J5tG7yADTxCpGSxaHSHAC9pDiZhS+5nbNdTuqIMFlTfXHzVg== X-Received: by 2002:a37:2784:: with SMTP id n126mr4598351qkn.328.1612386518990; Wed, 03 Feb 2021 13:08:38 -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 t6sm2507659qti.2.2021.02.03.13.08.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Feb 2021 13:08:38 -0800 (PST) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Wei Zhang , Matthew Wilcox , Linus Torvalds , Jason Gunthorpe , Gal Pressman , peterx@redhat.com, Christoph Hellwig , Andrea Arcangeli , Jan Kara , Kirill Shutemov , David Gibson , Mike Rapoport , Mike Kravetz , Kirill Tkhai , Jann Horn , Andrew Morton Subject: [PATCH 2/4] hugetlg: Break earlier in add_reservation_in_range() when we can Date: Wed, 3 Feb 2021 16:08:30 -0500 Message-Id: <20210203210832.113685-3-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210203210832.113685-1-peterx@redhat.com> References: <20210203210832.113685-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. Signed-off-by: Peter Xu Reviewed-by: Mike Kravetz Reviewed-by: Miaohe Lin --- 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