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 9B653C433E6 for ; Mon, 31 Aug 2020 02:24:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 651232071B for ; Mon, 31 Aug 2020 02:24:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 651232071B 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 0FA676B000C; Sun, 30 Aug 2020 22:24:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0AB1B6B000D; Sun, 30 Aug 2020 22:24:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F062D6B000E; Sun, 30 Aug 2020 22:24:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0170.hostedemail.com [216.40.44.170]) by kanga.kvack.org (Postfix) with ESMTP id D926B6B000C for ; Sun, 30 Aug 2020 22:24:37 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id A732A1E11 for ; Mon, 31 Aug 2020 02:24:37 +0000 (UTC) X-FDA: 77209270194.08.hair30_490611e2708c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin08.hostedemail.com (Postfix) with ESMTP id 8086B1819E785 for ; Mon, 31 Aug 2020 02:24:37 +0000 (UTC) X-HE-Tag: hair30_490611e2708c X-Filterd-Recvd-Size: 5434 Received: from out30-43.freemail.mail.aliyun.com (out30-43.freemail.mail.aliyun.com [115.124.30.43]) by imf42.hostedemail.com (Postfix) with ESMTP for ; Mon, 31 Aug 2020 02:24:35 +0000 (UTC) X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01358;MF=richard.weiyang@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0U7IV37f_1598840639; Received: from localhost(mailfrom:richard.weiyang@linux.alibaba.com fp:SMTPD_---0U7IV37f_1598840639) by smtp.aliyun-inc.com(127.0.0.1); Mon, 31 Aug 2020 10:23:59 +0800 From: Wei Yang To: mike.kravetz@oracle.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, bhe@redhat.com, Wei Yang Subject: [Patch v3 4/7] mm/hugetlb: count file_region to be added when regions_needed != NULL Date: Mon, 31 Aug 2020 10:23:48 +0800 Message-Id: <20200831022351.20916-5-richard.weiyang@linux.alibaba.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20200831022351.20916-1-richard.weiyang@linux.alibaba.com> References: <20200831022351.20916-1-richard.weiyang@linux.alibaba.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 8086B1819E785 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000011, 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 Reviewed-by: Baoquan He Reviewed-by: Mike Kravetz --- mm/hugetlb.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index a02bf430de6f..441b7f7c623e 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)