Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp907827pxa; Thu, 27 Aug 2020 20:35:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2L+8eae6UFVxYQKFUT1ms/Qg1K3xvOCupDQOkq5uVyLQPFBjxe2G/eCxvfkv2kReyAUtj X-Received: by 2002:a50:fa94:: with SMTP id w20mr23759180edr.82.1598585747879; Thu, 27 Aug 2020 20:35:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598585747; cv=none; d=google.com; s=arc-20160816; b=TcbA6wSFJJ5NPQ0xgJM4UN6AdxDbU2N4/kT3RhyTpbjbfBVthY7TWCeOFxLaFOZr8W zoAw44TMVMxRq/KSpBA/HZwNnkjFjpFFg5UUvfWI6f1LiBB9F6J7PLiO3sFwBto7qk9n NmRB7ED1j3GxN+eJa5ABycwb7eGH++GXEqVJ+46AyugLCoRggvSN4ljDyUQ8NV2JmvHm 53Jf4t1EgW34w6D3Cj2fqmHHyo1bYprEV3kt69cEiihp5KQqiD1ZFybb7yNGdUQ55hAy U2oQI3adjkOW+6vtXgz6DuUt12u1fmpuYJQtwwtgpQ449djoBkB0FgrmOdSG4Aafn9D5 57Ww== 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=CW3OevKN0RgZTyTVkfPwQMpXOO+1m3GmsN+VbWPYj04=; b=H0DXlct7g+mKsQDdXHinJcWDXMMRnQtAtPQlVHUFCSG8rOgnz1FxgbJVOXM/f+7Tt/ 19oBETYoACoobDVAJ88FRdB4eKhvfK8958L0PKSydo4FHxlyBpebMYXH04kg1txFGSgJ 2r/SVoJJCCigiYsINvVMw7TdclS8rNMyimHDAKr9QFWpvjokKh1C7AwuJZVYe+OAy50k vNubkimlH9caqm/GCnADf591nyHt+EQeB+L7FHKVCAc8gKGiF2EpeLWW+XSfFQ1kazEe 7MIatKL9ddb6r7xOIHwPxobyju47jeW4pUxGJ2V2IUorsrrfulI75eBb4Umh5PnS2Zvp ZEfA== 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 v16si3094422ejk.264.2020.08.27.20.35.25; Thu, 27 Aug 2020 20:35:47 -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 S1728381AbgH1Ddt (ORCPT + 99 others); Thu, 27 Aug 2020 23:33:49 -0400 Received: from out30-133.freemail.mail.aliyun.com ([115.124.30.133]:47031 "EHLO out30-133.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728115AbgH1Ddq (ORCPT ); Thu, 27 Aug 2020 23:33:46 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01353;MF=richard.weiyang@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0U736V1d_1598585572; Received: from localhost(mailfrom:richard.weiyang@linux.alibaba.com fp:SMTPD_---0U736V1d_1598585572) by smtp.aliyun-inc.com(127.0.0.1); Fri, 28 Aug 2020 11:32:52 +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 v2 4/7] mm/hugetlb: count file_region to be added when regions_needed != NULL Date: Fri, 28 Aug 2020 11:32:39 +0800 Message-Id: <20200828033242.8787-5-richard.weiyang@linux.alibaba.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20200828033242.8787-1-richard.weiyang@linux.alibaba.com> References: <20200828033242.8787-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 cbe67428bf99..bbccbfeb8601 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -319,16 +319,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; @@ -364,14 +365,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; } @@ -383,13 +384,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; } @@ -482,8 +483,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 @@ -511,7 +512,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; @@ -547,9 +548,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)