Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp5739143ioo; Wed, 1 Jun 2022 11:30:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQTJOcN89Mqk5QkaXkogIl6uvgyiKN0NaRTtD1vIddtTbnu0k1/p5uXpg5Lj8QmR20Y2yM X-Received: by 2002:a17:902:eb90:b0:163:e4c1:b2fc with SMTP id q16-20020a170902eb9000b00163e4c1b2fcmr698370plg.159.1654108200332; Wed, 01 Jun 2022 11:30:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654108200; cv=none; d=google.com; s=arc-20160816; b=xTSnfcRdXodaNqLCv0aG9t3zmhY/8SLeZsbxeQNzd4p9OwAMu0NiJOPp4H8d+XKTcp NAnWT6R31RwKmZXTxiGUqzhLW99MRkkimnNkj3nNod3ZdE49hR7NcyeZ9HCe+d/tGkcC 7DHceyQfq+peaetd+2VmZkYt/B6X5NIKQ5zr4KQRW3guzZ2YieYhOw2OZuXnQqGcaTwX xzWusdt+JVwgOGyF12xk10p2hkCtE6i3+L2fjJCLWMHMmWDpASt+KKFXkr1lYWkB1/A3 SOj6fNt8KJq0rh7A1Bp0nfUlnzP40uct9P6abxv9T4bBWghk39NXNf+OcE76A5bjgB3l vQyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ygjUxfkqHRj2c+XbYZgzwfLNN/gLk7A7fF4S+oHb6+U=; b=g66OhogovU0/Ntzvwfg7PuTaTF1p3dmRHUBhqRDhLR2u3+aLrDOx948LDTfn47adad vkGR9qmMgF/Nq9mkAo0qZ+RllXiidriav7j0bXrZq+rseswEXbe9WluMQgrx60cIulZ/ NxcR+2BR2eqtC3pgiFHTkXz561UJcSh9JvzEkK9JtA3xzqDXv9voGo5NxLIp8mOfA9V3 f4TViHoOoAG82tB+v4q98XPszfOJufyKIYoDhsi06Fdv6CkYP18y3CQvRDzbBT+o/y0Y uEV/7JLXc759VOs/Gl8qtTU+Wbxg+/L5kxQDvzOrSs6q91fuEuk6Tf2QJlw3a2bwpLvg 9yNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=bgpwLbbe; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id pl5-20020a17090b268500b001e299f85017si5949420pjb.63.2022.06.01.11.29.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 11:30:00 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=bgpwLbbe; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B0A745DD1D; Wed, 1 Jun 2022 11:29:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352265AbiFAKsh (ORCPT + 99 others); Wed, 1 Jun 2022 06:48:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352676AbiFAKsa (ORCPT ); Wed, 1 Jun 2022 06:48:30 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5937013E3C for ; Wed, 1 Jun 2022 03:48:19 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id i1so1426202plg.7 for ; Wed, 01 Jun 2022 03:48:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ygjUxfkqHRj2c+XbYZgzwfLNN/gLk7A7fF4S+oHb6+U=; b=bgpwLbbe1FlcWjVnusaNYiEwx0t2E4qplUZnv6r7lVSq/8qBCdgRYzAhIbF2V40Fqb kJVgd2FD5tULhTVIaS6h0kPX+cKe+Gtkl5g9Zl/AXqaXskOFlcOuuFoFlxfnUeicwmcf RNSjY99gv5VcKQR5EagRSgaW15uApuc6u5SZa4Px4pn3Toa0q0SSsbeS3KNouNwY26mc JCXOwkFFVtFYXHd1dSvb3o96GHcIitjb3xYSwVYlYOqdf3e6oGJ7MY45Crc/e7U5XayD YeHODFHb6Jc6DUcZ8GlzwSrFBvZt5iGJJbalseM3gJAV45pZWE7D5vS7B7M0ff99j2ix hQhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ygjUxfkqHRj2c+XbYZgzwfLNN/gLk7A7fF4S+oHb6+U=; b=jm44A8HlwCTW5a5oDmgsBlEJW5kTb2UtzwuWYqMtiq76FnewFi+kZvDt7jLtAGwG2X +j13Tff9s4Ly2t9jUQspRUW1u9rPkw5L4mylaJ0+X9IVdq/J1IZoJMkUMLyiXvYtXIeN EXOlotAASQcqW4jn5cC8FoSueILoMmR39l533uhsdFIZPTJaS13/R8asF252btPLWQHV tVJPr29o5PT01aBOEoU1Z46e7cfHSkkxQLkweeUUvJ+dnXzwnB4q6o7U/NeltQn1UiAH eqrAMxBiV52VHtdWJWoSMnijtyVfpYUPwXi/BpofLDfqkxBCj5oyYMPCyUHtuh7yX9Fr NliA== X-Gm-Message-State: AOAM530kp1ez7njHdP74V9lNeHkEuYZMcWN/2YZPvHw25d1dL0Cg7TKB iJ/YmjYzsbd437zIsbqV36HvjQ== X-Received: by 2002:a17:90a:de0b:b0:1e3:33e9:6665 with SMTP id m11-20020a17090ade0b00b001e333e96665mr9204009pjv.27.1654080498895; Wed, 01 Jun 2022 03:48:18 -0700 (PDT) Received: from localhost ([2408:8207:18da:2310:f9bc:fb5f:5b66:a80e]) by smtp.gmail.com with ESMTPSA id n4-20020a170903404400b001616b71e5e3sm1166040pla.171.2022.06.01.03.48.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 03:48:18 -0700 (PDT) Date: Wed, 1 Jun 2022 18:48:13 +0800 From: Muchun Song To: David Hildenbrand , mike.kravetz@oracle.com Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, smuchun@bytedance.com Subject: Re: [PATCH 1/3] mm: hugetlb_vmemmap: cleanup hugetlb_vmemmap related functions Message-ID: References: <20220404074652.68024-1-songmuchun@bytedance.com> <20220404074652.68024-2-songmuchun@bytedance.com> <087817e3-98ce-09f6-9ae9-68e544f43775@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <087817e3-98ce-09f6-9ae9-68e544f43775@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 01, 2022 at 11:28:44AM +0200, David Hildenbrand wrote: > On 04.04.22 09:46, Muchun Song wrote: > > The word of "free" is not expressive enough to express the feature of optimizing > > vmemmap pages associated with each HugeTLB, rename this keywork to "optimeze". > > And some function names are prefixed with "huge_page" instead of "hugetlb", it is > > easily to be confused with THP. In this patch , cheanup related functions to make > > code more clear and expressive. > > No strong opinion (I remember I kicked of the discussion), but I was > wondering if instead of alloc vs. free we could be using something like > optimize vs. restore/rollback. > > E.g., hugetlb_vmemmap_optimize() vs. hugetlb_vmemmap_restore(). > I think it is a good suggestion. > > Maybe there are other suggestions? > > > > > Signed-off-by: Muchun Song > > --- > > include/linux/hugetlb.h | 2 +- > > mm/hugetlb.c | 10 +++++----- > > mm/hugetlb_vmemmap.c | 42 ++++++++++++++++++++---------------------- > > mm/hugetlb_vmemmap.h | 20 ++++++++++---------- > > 4 files changed, 36 insertions(+), 38 deletions(-) > > > > diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h > > index 53c1b6082a4c..c16fbb1228a3 100644 > > --- a/include/linux/hugetlb.h > > +++ b/include/linux/hugetlb.h > > @@ -618,7 +618,7 @@ struct hstate { > > unsigned int free_huge_pages_node[MAX_NUMNODES]; > > unsigned int surplus_huge_pages_node[MAX_NUMNODES]; > > #ifdef CONFIG_HUGETLB_PAGE_FREE_VMEMMAP > > - unsigned int nr_free_vmemmap_pages; > > + unsigned int optimize_vmemmap_pages; > > I suggest converting that into a bool and just calling it > > "bool optimize_vmemmap_pages". > > You can easily compute what hugetlb_vmemmap_init() at runtime from the > page and RESERVE_VMEMMAP_NR, right? > Right. A little overhead, but hugetlb_vmemmap_alloc() is not hot path, maybe we can accept the increased overhead of calculating at runtime. Hi Mike, Do you have any objections on this? If no, I think we can do this in a separate patch. > At least the calculation in alloc_huge_page_vmemmap() and > free_huge_page_vmemmap() become *less* weird for me if the magic value > RESERVE_VMEMMAP_NR isn't used explicitly for vmemmap_addr but implicitly > for vmemmap_end. > > > #endif > > #ifdef CONFIG_CGROUP_HUGETLB > > /* cgroup control files */ > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > > index dd642cfc538b..1f9fbdddc86b 100644 > > --- a/mm/hugetlb.c > > +++ b/mm/hugetlb.c > > @@ -1540,7 +1540,7 @@ static void __update_and_free_page(struct hstate *h, struct page *page) > > if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported()) > > return; > > > > - if (alloc_huge_page_vmemmap(h, page)) { > > + if (hugetlb_vmemmap_alloc(h, page)) { > > spin_lock_irq(&hugetlb_lock); > > /* > > * If we cannot allocate vmemmap pages, just refuse to free the > > @@ -1617,7 +1617,7 @@ static DECLARE_WORK(free_hpage_work, free_hpage_workfn); > > > > static inline void flush_free_hpage_work(struct hstate *h) > > { > > - if (free_vmemmap_pages_per_hpage(h)) > > + if (hugetlb_optimize_vmemmap_pages(h)) > > It might be reasonable to call that hugetlb_should_optimize_vmemmap() > then, letting it return a bool. > How about the name of "hugetlb_vmemmap_optimizable()"? "should" seems to tell the user that this hugetlb should be optimized, however, optimization also depends on "hugetlb_free_vmemmap=on". "optimizable" seems to be more appropriate, right? Thanks.