Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2095640yba; Wed, 3 Apr 2019 00:53:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqz5HPUWrKA1ZuqURaFjamvOIz1puNvvCcxAK/tPAZkPljmtKjNfL/a9S5sRrNuO5Oh4L8sq X-Received: by 2002:a65:6108:: with SMTP id z8mr57413046pgu.106.1554278021281; Wed, 03 Apr 2019 00:53:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554278021; cv=none; d=google.com; s=arc-20160816; b=NcrPEre9yZyNXG3MjCi2p2xHM9magbFrCtW+J2Tn3/hpUuod8ynpHKaMvOtejpPNk+ tfdJhkrR1AESHvemeW2kYvMICMiDdsSnKc7yUL/A4Oky0TtQY+vjjBNoBusf33kQetC9 UgWxuinEfRpLyfnD7azWOjkENb9tMbSz5fWQ2ZLnyaDuKw37paJSI63tnDkRTt9dM+fB BP40q+Hb7xU+/isMiY/Z3zJ1wAXAhPZXz/oy3A0S7ybfe16gyavuqCHvSunq20Cv2KcR BXYm1TfKNZ4T+lKa2xYqx1h+SPAb7m4Q+SXWk2aTVjgzMBQvCCyQRck3I6cFVlQGFPno 39Vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=QkoDa2dGXwK7WBiyvUEZ6Uc0h9UePx3gLP/Qj7FxubQ=; b=iXi/T5g7Td4rqH/pzxAiqZoqU34WlqCyoUZYyfZu/GF9eggxwsBpyce/bVfbBhrHDh lX6NYtZor1ul48n4SUO7vDpr/vfS2yaoa/DGVaDIUOsm2ssy1DURKwU4ku7BpazDc+3/ H8kSmxI8RwF7HrTS8mgpJb8GedB1vzpvETrry4A7dXBgNESt7xz6C1/E5/aAJ6hhtpFX Fc562ueAf0fccd4/1re33Z408DQ14ct9T8r5owMPCqfubPl1I+77pl7ek7IIxOqcIOxU N4NSuBDUZt5InKsPGsaqzBjf9NoFBK2oW8rjfY7WQxwBauCC1mcYobsry5uQ5t4xl5v0 E9MQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u22si5630293plq.193.2019.04.03.00.53.26; Wed, 03 Apr 2019 00:53:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728814AbfDCHwl (ORCPT + 99 others); Wed, 3 Apr 2019 03:52:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46696 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725936AbfDCHwl (ORCPT ); Wed, 3 Apr 2019 03:52:41 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 83F573DE; Wed, 3 Apr 2019 07:52:40 +0000 (UTC) Received: from localhost (ovpn-12-31.pek2.redhat.com [10.72.12.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A9F1F1001DDD; Wed, 3 Apr 2019 07:52:39 +0000 (UTC) Date: Wed, 3 Apr 2019 15:52:36 +0800 From: Baoquan He To: Oscar Salvador Cc: akpm@linux-foundation.org, mike.kravetz@oracle.com, n-horiguchi@ah.jp.nec.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/hugetlb: Get rid of NODEMASK_ALLOC Message-ID: <20190403075236.GB31828@MiWiFi-R3L-srv> References: <20190402133415.21983-1-osalvador@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190402133415.21983-1-osalvador@suse.de> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 03 Apr 2019 07:52:40 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/02/19 at 03:34pm, Oscar Salvador wrote: > NODEMASK_ALLOC is used to allocate a nodemask bitmap, ant it does it by ~ and > first determining whether it should be allocated in the stack or dinamically dynamically^^ > depending on NODES_SHIFT. > Right now, it goes the dynamic path whenever the nodemask_t is above 32 > bytes. > > Although we could bump it to a reasonable value, the largest a nodemask_t > can get is 128 bytes, so since __nr_hugepages_store_common is called from > a rather shore stack we can just get rid of the NODEMASK_ALLOC call here. > > This reduces some code churn and complexity. > > Signed-off-by: Oscar Salvador > --- > mm/hugetlb.c | 36 +++++++++++------------------------- > 1 file changed, 11 insertions(+), 25 deletions(-) > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index f79ae4e42159..9cb2f91af897 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -2447,44 +2447,30 @@ static ssize_t __nr_hugepages_store_common(bool obey_mempolicy, > unsigned long count, size_t len) > { > int err; > - NODEMASK_ALLOC(nodemask_t, nodes_allowed, GFP_KERNEL | __GFP_NORETRY); > + nodemask_t nodes_allowed, *n_mask; > > - if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported()) { > - err = -EINVAL; > - goto out; > - } > + if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported()) > + return -EINVAL; > > if (nid == NUMA_NO_NODE) { > /* > * global hstate attribute > */ > if (!(obey_mempolicy && > - init_nodemask_of_mempolicy(nodes_allowed))) { > - NODEMASK_FREE(nodes_allowed); > - nodes_allowed = &node_states[N_MEMORY]; > - } > - } else if (nodes_allowed) { > + init_nodemask_of_mempolicy(&nodes_allowed))) > + n_mask = &node_states[N_MEMORY]; > + else > + n_mask = &nodes_allowed; > + } else { > /* > * Node specific request. count adjustment happens in > * set_max_huge_pages() after acquiring hugetlb_lock. > */ > - init_nodemask_of_node(nodes_allowed, nid); > - } else { > - /* > - * Node specific request, but we could not allocate the few > - * words required for a node mask. We are unlikely to hit > - * this condition. Since we can not pass down the appropriate > - * node mask, just return ENOMEM. > - */ > - err = -ENOMEM; > - goto out; > + init_nodemask_of_node(&nodes_allowed, nid); > + n_mask = &nodes_allowed; > } > > - err = set_max_huge_pages(h, count, nid, nodes_allowed); > - > -out: > - if (nodes_allowed != &node_states[N_MEMORY]) > - NODEMASK_FREE(nodes_allowed); > + err = set_max_huge_pages(h, count, nid, n_mask); > > return err ? err : len; > } > -- > 2.13.7 >