Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1389535pxk; Mon, 31 Aug 2020 18:51:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyC2H6lZ3PRh2gkS0ZU7UGq0xP4ZFmPk3agHAsNw/mppx1MrzmV9nqr+A2YnJRXICNHNRwf X-Received: by 2002:a17:906:eb11:: with SMTP id mb17mr3401873ejb.255.1598925078267; Mon, 31 Aug 2020 18:51:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598925078; cv=none; d=google.com; s=arc-20160816; b=U2ySd08SI3WtNcja/yN+BGFr3AU1EjaFQwDynzlmQllkC0esU8gOSLFGVOB0mfiOHP NLU5Q6n0OwrQepedt61fLJx1/CzVNL8y+MP4wVojiFFMVn1b3sKCKaFUMuNn+jnD1/U9 3HIsn4LDIrGYW/Q2hgA/aRND/Td53/9mZeC3TyEfW2mUaIAGIBkc4U3WPO/qBeTZ2ZR3 YxFP5/E5jQ06dpixnII13BbQBfEup2H5LM6dtKFttzvdSBO9mH8nstxR5ez0kWpNAEk4 QuyvcTeDuq84/I9JiXVakkIna/brt7u1H0orPU29V40R1ErkUZfBqhWofw8cXsajcoZF WYMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=3Z2+NO22vgSOHIV3Ota/ZXqLh+7H/6RPeTOB5msG3Dc=; b=HIHCZT/XtlUL6Zdy6JXFxNQgWbKKyocZGb1K23Jq5IkgwCu+UW4lN89RVuyGmwsoSN eEd6CyJw9LQmm8xAP6olS83WFXkBvSMjYFPBFGEnyleufUOvMQFrxRQI34Fw2mwexkZp Xzn0GVjt9pPOsRbnjTXuV+e9Wtau4wL/smIQqztoem/p/dgZrdRIgrlI1qG7lm2DuVeb P46amXbdUBhELEhuvDiAmejCqpsZ/DNQhr9VPWJoYCss2MQYfEJrJbm+XGXhJxGHWHf2 fe3QvxR5Dk84BPYvCwSyFklr9EHN/uGC0hgKnr5DmJGy0zn0JqJgxUXHLHnwqsrP3R5K GnxQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o16si6443302ejc.319.2020.08.31.18.50.54; Mon, 31 Aug 2020 18:51:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726771AbgIABrK (ORCPT + 99 others); Mon, 31 Aug 2020 21:47:10 -0400 Received: from out30-132.freemail.mail.aliyun.com ([115.124.30.132]:40048 "EHLO out30-132.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726226AbgIABqq (ORCPT ); Mon, 31 Aug 2020 21:46:46 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R171e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07484;MF=richard.weiyang@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0U7Txiaw_1598924804; Received: from localhost(mailfrom:richard.weiyang@linux.alibaba.com fp:SMTPD_---0U7Txiaw_1598924804) by smtp.aliyun-inc.com(127.0.0.1); Tue, 01 Sep 2020 09:46:44 +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 v4 4/7] mm/hugetlb: count file_region to be added when regions_needed != NULL Date: Tue, 1 Sep 2020 09:46:33 +0800 Message-Id: <20200901014636.29737-5-richard.weiyang@linux.alibaba.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20200901014636.29737-1-richard.weiyang@linux.alibaba.com> References: <20200901014636.29737-1-richard.weiyang@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 *resv, struct file_region *rg) } } -/* Must be called with resv->lock held. Calling this with count_only == true - * will count the number of pages to be added but will not modify the linked - * list. If regions_needed != NULL and count_only == true, then regions_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 != NULL will count the number of pages + * to be added but will not modify the linked list. And regions_needed will + * 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 = 0; struct list_head *head = &resv->regions; @@ -366,14 +367,14 @@ static long add_reservation_in_range(struct resv_map *resv, long f, long t, */ if (rg->from > last_accounted_offset) { add += rg->from - last_accounted_offset; - if (!count_only) { + if (!regions_needed) { nrg = 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 += 1; } @@ -385,13 +386,13 @@ static long add_reservation_in_range(struct resv_map *resv, long f, long t, */ if (last_accounted_offset < t) { add += t - last_accounted_offset; - if (!count_only) { + if (!regions_needed) { nrg = 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 += 1; } @@ -484,8 +485,8 @@ static long region_add(struct resv_map *resv, long f, long t, retry: /* 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); /* * 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; } - add = add_reservation_in_range(resv, f, t, h_cg, h, NULL, false); + add = add_reservation_in_range(resv, f, t, h_cg, h, NULL); resv->adds_in_progress -= in_regions_needed; @@ -549,9 +550,9 @@ static long region_chg(struct resv_map *resv, long f, long t, spin_lock(&resv->lock); - /* Count how many hugepages in this range are NOT respresented. */ + /* Count how many hugepages in this range are NOT represented. */ chg = add_reservation_in_range(resv, f, t, NULL, NULL, - out_regions_needed, true); + out_regions_needed); if (*out_regions_needed == 0) *out_regions_needed = 1; -- 2.20.1 (Apple Git-117)