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=-13.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,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 0CA28C433DF for ; Fri, 7 Aug 2020 09:13:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B955E22CF6 for ; Fri, 7 Aug 2020 09:13:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B955E22CF6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CB9358D009A; Fri, 7 Aug 2020 05:13:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C6DA78D0099; Fri, 7 Aug 2020 05:13:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE5768D009A; Fri, 7 Aug 2020 05:13:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0214.hostedemail.com [216.40.44.214]) by kanga.kvack.org (Postfix) with ESMTP id 944468D0097 for ; Fri, 7 Aug 2020 05:13:29 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 52AC5824934B for ; Fri, 7 Aug 2020 09:13:29 +0000 (UTC) X-FDA: 77123209338.11.dock27_400e55f26fbf Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id 25653180F8B80 for ; Fri, 7 Aug 2020 09:13:29 +0000 (UTC) X-HE-Tag: dock27_400e55f26fbf X-Filterd-Recvd-Size: 5323 Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com [115.124.30.133]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Fri, 7 Aug 2020 09:13:26 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04397;MF=richard.weiyang@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0U5.Rnv1_1596791597; Received: from localhost(mailfrom:richard.weiyang@linux.alibaba.com fp:SMTPD_---0U5.Rnv1_1596791597) by smtp.aliyun-inc.com(127.0.0.1); Fri, 07 Aug 2020 17:13:17 +0800 From: Wei Yang To: mike.kravetz@oracle.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wei Yang Subject: [PATCH 04/10] mm/hugetlb: count file_region to be added when regions_needed != NULL Date: Fri, 7 Aug 2020 17:12:45 +0800 Message-Id: <20200807091251.12129-5-richard.weiyang@linux.alibaba.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20200807091251.12129-1-richard.weiyang@linux.alibaba.com> References: <20200807091251.12129-1-richard.weiyang@linux.alibaba.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 25653180F8B80 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 Content-Transfer-Encoding: quoted-printable 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: There are only two cases of function add_reservation_in_range() * count file_region and return the number in regions_needed * do the real list operation without counting This means it is not necessary to have two parameters to classify these two cases. Just use regions_needed to separate them. Signed-off-by: Wei Yang --- mm/hugetlb.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 929256c130f9..d775e514eb2e 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -321,16 +321,17 @@ static void coalesce_file_region(struct resv_map *r= esv, struct file_region *rg) } } =20 -/* Must be called with resv->lock held. Calling this with count_only =3D= =3D true - * will count the number of pages to be added but will not modify the li= nked - * list. If regions_needed !=3D NULL and count_only =3D=3D true, then re= gions_needed - * will indicate the number of file_regions needed in the cache to carry= out to - * add the regions for this range. +/* + * Must be called with resv->lock held. + * + * Calling this with regions_needed !=3D NULL will count the number of p= ages + * to be added but will not modify the linked list. And regions_needed w= ill + * indicate the number of file_regions needed in the cache to carry out = to add + * the regions for this range. */ static long add_reservation_in_range(struct resv_map *resv, long f, long= t, struct hugetlb_cgroup *h_cg, - struct hstate *h, long *regions_needed, - bool count_only) + struct hstate *h, long *regions_needed) { long add =3D 0; struct list_head *head =3D &resv->regions; @@ -366,14 +367,14 @@ static long add_reservation_in_range(struct resv_ma= p *resv, long f, long t, */ if (rg->from > last_accounted_offset) { add +=3D rg->from - last_accounted_offset; - if (!count_only) { + if (!regions_needed) { nrg =3D get_file_region_entry_from_cache( resv, last_accounted_offset, rg->from); record_hugetlb_cgroup_uncharge_info(h_cg, h, resv, nrg); list_add(&nrg->link, rg->link.prev); coalesce_file_region(resv, nrg); - } else if (regions_needed) + } else *regions_needed +=3D 1; } =20 @@ -385,13 +386,13 @@ static long add_reservation_in_range(struct resv_ma= p *resv, long f, long t, */ if (last_accounted_offset < t) { add +=3D t - last_accounted_offset; - if (!count_only) { + if (!regions_needed) { nrg =3D get_file_region_entry_from_cache( resv, last_accounted_offset, t); record_hugetlb_cgroup_uncharge_info(h_cg, h, resv, nrg); list_add(&nrg->link, rg->link.prev); coalesce_file_region(resv, nrg); - } else if (regions_needed) + } else *regions_needed +=3D 1; } =20 @@ -484,8 +485,8 @@ static long region_add(struct resv_map *resv, long f,= long t, retry: =20 /* Count how many regions are actually needed to execute this add. */ - add_reservation_in_range(resv, f, t, NULL, NULL, &actual_regions_needed= , - true); + add_reservation_in_range(resv, f, t, NULL, NULL, + &actual_regions_needed); =20 /* * Check for sufficient descriptors in the cache to accommodate @@ -513,7 +514,7 @@ static long region_add(struct resv_map *resv, long f,= long t, goto retry; } =20 - add =3D add_reservation_in_range(resv, f, t, h_cg, h, NULL, false); + add =3D add_reservation_in_range(resv, f, t, h_cg, h, NULL); =20 resv->adds_in_progress -=3D in_regions_needed; =20 @@ -549,9 +550,9 @@ static long region_chg(struct resv_map *resv, long f,= long t, =20 spin_lock(&resv->lock); =20 - /* Count how many hugepages in this range are NOT respresented. */ + /* Count how many hugepages in this range are NOT represented. */ chg =3D add_reservation_in_range(resv, f, t, NULL, NULL, - out_regions_needed, true); + out_regions_needed); =20 if (*out_regions_needed =3D=3D 0) *out_regions_needed =3D 1; --=20 2.20.1 (Apple Git-117)