Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1557112ybh; Tue, 14 Jul 2020 00:35:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyaMDRMA4FrhGua9ugTA1MpLKHd4FR2jJBfE53wC1L6j/YEp/TZw3S3D7rb/zQDUbTSiqBm X-Received: by 2002:a05:6402:17f6:: with SMTP id t22mr3271491edy.141.1594712129420; Tue, 14 Jul 2020 00:35:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594712129; cv=none; d=google.com; s=arc-20160816; b=lSMWYUANSrVtd02G4aAkBMTYqb85V0BBLUnMLyOt9QGG2IY9MY1SERKP9vR+fSyiDC aJRNHwy0Vy1xw9Ygp+PDWuOLRuZhx9kq/OREFRXE2Vki6FSj9nM6opNU4xSFwi/f316h mc0n0Y4QC198U2eNz4sTb4a9q3c1r8FLPn6PJkovc7l66xNFx3LGmp6G2nIK2RKlwxRw SzTCyCBZQIqNHooo7lodly3ubCJTG16iJvZ3FuoaBT0bhvWIv1kWYXE+EiPbQmifoIaK zwcyK2wc1w+bTrpMPVEWlQQXebNu4Bq7ToqjO/ZDU1L2REb58GEUCUVBtD4LA1oCQqZO oSnw== 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 :message-id:date:subject:cc:to:from; bh=l067IusJGpqX3Y+4EsGS+fS+SbdbTX1S0qmyBNikn6E=; b=CgTM5RBm+TwmyOfpAuFFeNtpT/QwdmCKgsVH86hDRrROAhDq+q+Zg8i7A+U/kcY+pO Xf04cWyi7T72eiRC+0wdhTs7sc+pdF8pjPfMiIN7Aiht5UCkRSqiF96owXM/LdBO91ta 3boidd4bSvZBjbIlWNOxDCw/Oz9SbMKTLCel0FRKZVUIN4g/PL+XmxjkB5Okk8LtMMot rdyIG1/GT+9StiSkho59U9idwZUSffylxVCO6lPptgXFy8UfgoU8Q5daCLpj0UeHG39S uCTVnkc+GBquIMgNQANkkE/PgCsBeodrvfmoz0eslTsffw6IF6qKReUNdAnDycUDbfX2 vpKg== 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 h1si10200563ejc.200.2020.07.14.00.35.06; Tue, 14 Jul 2020 00:35:29 -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 S1726722AbgGNHeN (ORCPT + 99 others); Tue, 14 Jul 2020 03:34:13 -0400 Received: from out4436.biz.mail.alibaba.com ([47.88.44.36]:6966 "EHLO out4436.biz.mail.alibaba.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725781AbgGNHeN (ORCPT ); Tue, 14 Jul 2020 03:34:13 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R371e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01419;MF=richard.weiyang@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0U2hiN69_1594712046; Received: from localhost(mailfrom:richard.weiyang@linux.alibaba.com fp:SMTPD_---0U2hiN69_1594712046) by smtp.aliyun-inc.com(127.0.0.1); Tue, 14 Jul 2020 15:34:07 +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] mm/hugetlb: hide nr_nodes in the internal of for_each_node_mask_to_[alloc|free] Date: Tue, 14 Jul 2020 15:34:04 +0800 Message-Id: <20200714073404.84863-1-richard.weiyang@linux.alibaba.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) 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 The second parameter of for_each_node_mask_to_[alloc|free] is a loop variant, which is not used outside of loop iteration. Let's hide this. Signed-off-by: Wei Yang --- mm/hugetlb.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 57ece74e3aae..9c3d15fb317e 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1196,17 +1196,19 @@ static int hstate_next_node_to_free(struct hstate *h, nodemask_t *nodes_allowed) return nid; } -#define for_each_node_mask_to_alloc(hs, nr_nodes, node, mask) \ - for (nr_nodes = nodes_weight(*mask); \ - nr_nodes > 0 && \ +#define for_each_node_mask_to_alloc(hs, node, mask) \ + int __nr_nodes; \ + for (__nr_nodes = nodes_weight(*mask); \ + __nr_nodes > 0 && \ ((node = hstate_next_node_to_alloc(hs, mask)) || 1); \ - nr_nodes--) + __nr_nodes--) -#define for_each_node_mask_to_free(hs, nr_nodes, node, mask) \ - for (nr_nodes = nodes_weight(*mask); \ - nr_nodes > 0 && \ +#define for_each_node_mask_to_free(hs, node, mask) \ + int __nr_nodes; \ + for (__nr_nodes = nodes_weight(*mask); \ + __nr_nodes > 0 && \ ((node = hstate_next_node_to_free(hs, mask)) || 1); \ - nr_nodes--) + __nr_nodes--) #ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE static void destroy_compound_gigantic_page(struct page *page, @@ -1403,7 +1405,7 @@ static void __free_huge_page(struct page *page) * reservation. If the page was associated with a subpool, there * would have been a page reserved in the subpool before allocation * via hugepage_subpool_get_pages(). Since we are 'restoring' the - * reservtion, do not call hugepage_subpool_put_pages() as this will + * reservation, do not call hugepage_subpool_put_pages() as this will * remove the reserved page from the subpool. */ if (!restore_reserve) { @@ -1760,10 +1762,10 @@ static int alloc_pool_huge_page(struct hstate *h, nodemask_t *nodes_allowed, nodemask_t *node_alloc_noretry) { struct page *page; - int nr_nodes, node; + int node; gfp_t gfp_mask = htlb_alloc_mask(h) | __GFP_THISNODE; - for_each_node_mask_to_alloc(h, nr_nodes, node, nodes_allowed) { + for_each_node_mask_to_alloc(h, node, nodes_allowed) { page = alloc_fresh_huge_page(h, gfp_mask, node, nodes_allowed, node_alloc_noretry); if (page) @@ -1787,10 +1789,10 @@ static int alloc_pool_huge_page(struct hstate *h, nodemask_t *nodes_allowed, static int free_pool_huge_page(struct hstate *h, nodemask_t *nodes_allowed, bool acct_surplus) { - int nr_nodes, node; + int node; int ret = 0; - for_each_node_mask_to_free(h, nr_nodes, node, nodes_allowed) { + for_each_node_mask_to_free(h, node, nodes_allowed) { /* * If we're returning unused surplus pages, only examine * nodes with surplus pages. @@ -2481,9 +2483,9 @@ int alloc_bootmem_huge_page(struct hstate *h) int __alloc_bootmem_huge_page(struct hstate *h) { struct huge_bootmem_page *m; - int nr_nodes, node; + int node; - for_each_node_mask_to_alloc(h, nr_nodes, node, &node_states[N_MEMORY]) { + for_each_node_mask_to_alloc(h, node, &node_states[N_MEMORY]) { void *addr; addr = memblock_alloc_try_nid_raw( @@ -2662,17 +2664,17 @@ static inline void try_to_free_low(struct hstate *h, unsigned long count, static int adjust_pool_surplus(struct hstate *h, nodemask_t *nodes_allowed, int delta) { - int nr_nodes, node; + int node; VM_BUG_ON(delta != -1 && delta != 1); if (delta < 0) { - for_each_node_mask_to_alloc(h, nr_nodes, node, nodes_allowed) { + for_each_node_mask_to_alloc(h, node, nodes_allowed) { if (h->surplus_huge_pages_node[node]) goto found; } } else { - for_each_node_mask_to_free(h, nr_nodes, node, nodes_allowed) { + for_each_node_mask_to_free(h, node, nodes_allowed) { if (h->surplus_huge_pages_node[node] < h->nr_huge_pages_node[node]) goto found; -- 2.20.1 (Apple Git-117)