From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12274C43331 for ; Fri, 27 Mar 2020 08:06:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D294720714 for ; Fri, 27 Mar 2020 08:06:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D294720714 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 70CAE6B0010; Fri, 27 Mar 2020 04:06:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6BDC16B0032; Fri, 27 Mar 2020 04:06:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B5776B0036; Fri, 27 Mar 2020 04:06:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0214.hostedemail.com [216.40.44.214]) by kanga.kvack.org (Postfix) with ESMTP id 3E4706B0010 for ; Fri, 27 Mar 2020 04:06:14 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id BBE39181AD0A4 for ; Fri, 27 Mar 2020 08:06:13 +0000 (UTC) X-FDA: 76640409426.26.bat79_3657b6188803b X-HE-Tag: bat79_3657b6188803b X-Filterd-Recvd-Size: 5338 Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by imf15.hostedemail.com (Postfix) with ESMTP for ; Fri, 27 Mar 2020 08:06:13 +0000 (UTC) Received: by mail-wm1-f66.google.com with SMTP id b12so10470150wmj.3 for ; Fri, 27 Mar 2020 01:06:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=+hDXOm5WCnsUpdgGd5tCD0aAXh23Ryn8Dpip6SfJKPc=; b=Hw24dSSTUGtBSD8A/pXEApcbMUZFZkhnlYRdBh+K/HffrZbepHSHrp3LPZ0+lunMt6 vD2yNxLaILmmrTyG+kjKhooZxJ7K3zFEoCj/FQp3BaVokvZ5WJKlj/DfYCC0XmHBl73S Z07u38DuvC/zjpau+GBshzpqkmp8LaCMvDqq0AIyzfV05l1ScbAJW1BfcPssvanwZYgS BI+AWyzindfzQM+iTwmoSqsFJOLNPIKlH0D1EqtHOj05bu6ztsawat2QEOe5LRy+8NCS O4dGJv4qQMaIV3hRc+iOLzSxfvO3IbtoVE22QuG/00ReN4SAJ9L61bIqA24F6aV33sS9 T4fA== X-Gm-Message-State: ANhLgQ3aLu2Po2wJDo4zXQx4ngYzINb09h71Db5Gcsu5TP7//qtStuBV N+6Ez/Q71qvoKbns0ujTMY4= X-Google-Smtp-Source: ADFU+vvnAH4CRXXIAOBtQnVbBi/VjSxTmWVj5FtZIhmC1Z9N3RoP18VJ1K/CRLtKMZm+FgtwydUveg== X-Received: by 2002:a1c:a908:: with SMTP id s8mr4293370wme.133.1585296372162; Fri, 27 Mar 2020 01:06:12 -0700 (PDT) Received: from localhost (ip-37-188-135-150.eurotel.cz. [37.188.135.150]) by smtp.gmail.com with ESMTPSA id p13sm7363912wru.3.2020.03.27.01.06.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Mar 2020 01:06:11 -0700 (PDT) Date: Fri, 27 Mar 2020 09:06:10 +0100 From: Michal Hocko To: Aslan Bakirov Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, kernel-team@fb.com, riel@surriel.com, guro@fb.com, hannes@cmpxchg.org Subject: Re: [PATCH 2/2] mm: hugetlb: Use node interface of cma Message-ID: <20200327080610.GV27965@dhcp22.suse.cz> References: <20200326212718.3798742-1-aslan@fb.com> <20200326212718.3798742-2-aslan@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200326212718.3798742-2-aslan@fb.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu 26-03-20 14:27:18, Aslan Bakirov wrote: > With introduction of numa node interface for CMA, this patch is for using that > interface for allocating memory on numa nodes if NUMA is configured. > This will be more efficient and cleaner because first, instead of iterating > mem range of each numa node, cma_declare_contigueous_nid() will do > its own address finding if we pass 0 for both min_pfn and max_pfn, > second, it can also handle caseswhere NUMA is not configured > by passing NUMA_NO_NODE as an argument. > > In addition, checking if desired size of memory is available or not, > is happening in cma_declare_contiguous_nid() because base and > limit will be determined there, since 0(any) for base and > 0(any) for limit is passed as argument to the function. This looks much better than the original patch. Can we simply squash your and Roman's patch in the mmotm tree and post it for the review in one piece? It would be slightly easier to review that way. > Signed-off-by: Aslan Bakirov Thanks! > --- > mm/hugetlb.c | 40 +++++++++++----------------------------- > 1 file changed, 11 insertions(+), 29 deletions(-) > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index b9f0c903c4cf..62989220c4ff 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -5573,42 +5573,24 @@ void __init hugetlb_cma_reserve(int order) > > reserved = 0; > for_each_node_state(nid, N_ONLINE) { > - unsigned long min_pfn = 0, max_pfn = 0; > int res; > -#ifdef CONFIG_NUMA > - unsigned long start_pfn, end_pfn; > - int i; > > - for_each_mem_pfn_range(i, nid, &start_pfn, &end_pfn, NULL) { > - if (!min_pfn) > - min_pfn = start_pfn; > - max_pfn = end_pfn; > - } > -#else > - min_pfn = min_low_pfn; > - max_pfn = max_low_pfn; > -#endif > size = min(per_node, hugetlb_cma_size - reserved); > size = round_up(size, PAGE_SIZE << order); > - > - if (size > ((max_pfn - min_pfn) << PAGE_SHIFT) / 2) { > - pr_warn("hugetlb_cma: cma_area is too big, please try less than %lu MiB\n", > - round_down(((max_pfn - min_pfn) << PAGE_SHIFT) * > - nr_online_nodes / 2 / SZ_1M, > - PAGE_SIZE << order)); > - break; > - } > - > - res = cma_declare_contiguous(PFN_PHYS(min_pfn), size, > - PFN_PHYS(max_pfn), > + > + > +#ifndef CONFIG_NUMA > + nid = NUMA_NO_NODE > +#endif > + res = cma_declare_contiguous_nid(0, size, > + 0, > PAGE_SIZE << order, > 0, false, > - "hugetlb", &hugetlb_cma[nid]); > + "hugetlb", &hugetlb_cma[nid], nid); > + > if (res) { > - phys_addr_t begpa = PFN_PHYS(min_pfn); > - phys_addr_t endpa = PFN_PHYS(max_pfn); > - pr_warn("%s: reservation failed: err %d, node %d, [%pap, %pap)\n", > - __func__, res, nid, &begpa, &endpa); > + pr_warn("%s: reservation failed: err %d, node %d\n", > + __func__, res, nid); > break; > } > > -- > 2.17.1 -- Michal Hocko SUSE Labs