Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2069689pxa; Fri, 7 Aug 2020 02:14:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmgEEojFMzVas/iWCLHdHk4B5aW7Zz/f7zzNkg9kPIYT/4H6pw3JZR1u378fxbFWGS0ylV X-Received: by 2002:aa7:c544:: with SMTP id s4mr7877142edr.51.1596791662648; Fri, 07 Aug 2020 02:14:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596791662; cv=none; d=google.com; s=arc-20160816; b=xsT1KJJYNrifzP7ucFrhd1UVz4DmoyR29Wh8e9s1gVJ344WEspcWE3AwWTKNs9DZZx tJPZ4SFh0kCrSAd+74IqwwZQSTrZ1RJ8v+U6+XV6vdkunOp2TXi9IMkI0VtNP3WZfxms kXLTV0kDh4FrbsTfvoikU5ky8GepiU8rlHE9eGFlaxd1IMHAxX+quN/k5sku6YUNJo/8 oVZ/t7ReWSIkQWqL+0TBluTI/Fz6bv5nlx/vGSyN7aa3Wj+Cl5JOOIHoKFuqZ13/wVBt 1vM4NpWCTP66QmRM1WslZIXlRY6AK0cIDH3N1lcI+bSyNxCiaLldrFoIU1X/kifhbNCi 5mdg== 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=WRPyjemvvXuAM8IOpOJgywa/LY9kkGyrCayoKbuSfdQ=; b=yu1sdHsjdNDjnlva+GfVG2iBwPY022JDbKuehVNKBbnRxvTk4D7kFtrCFXJ8VqTPJr naAwLBcw/SO/i5Ae9IB1JKGUDC6qZ8IL6RP28zgcLTVyxNQTaZcot9RNg+kknTPk0ZCG sB4VrUBMEbo+xjZpwjWJgL0XlTw+9f5Z905TU/tZMP6hAxWJizHi1ZdSr9nBknz42Vxe pPBD2L4daDHPWJh5IRyZJUbizQQSghoryc0yrK1T1fa/DJPyTYhISWpA4lfU0jMi1lKb yLEt+9WwMYQiwFKBHYDKEYw9KrbBxAvjQmRprSb/hmdHhJD/fS/YeQTHiEo/IgXLogT9 EdNw== 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 k30si6594469edj.513.2020.08.07.02.13.58; Fri, 07 Aug 2020 02:14:22 -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 S1727976AbgHGJNW (ORCPT + 99 others); Fri, 7 Aug 2020 05:13:22 -0400 Received: from out30-43.freemail.mail.aliyun.com ([115.124.30.43]:37513 "EHLO out30-43.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727783AbgHGJNV (ORCPT ); Fri, 7 Aug 2020 05:13:21 -0400 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 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 --- 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 *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)