All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Kravetz <mike.kravetz@oracle.com>
To: Muchun Song <songmuchun@bytedance.com>
Cc: david@redhat.com, akpm@linux-foundation.org, corbet@lwn.net,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	linux-doc@vger.kernel.org, duanxiongchun@bytedance.com
Subject: Re: [PATCH v2 6/8] mm: hugetlb_vmemmap: improve hugetlb_vmemmap code readability
Date: Tue, 28 Jun 2022 17:23:21 -0700	[thread overview]
Message-ID: <YrubeXg8tSxJeGxj@monkey> (raw)
In-Reply-To: <20220628092235.91270-7-songmuchun@bytedance.com>

On 06/28/22 17:22, Muchun Song wrote:
> There is a discussion about the name of hugetlb_vmemmap_alloc/free in
> thread [1].  The suggestion suggested by David is rename "alloc/free"
> to "optimize/restore" to make functionalities clearer to users,
> "optimize" means the function will optimize vmemmap pages, while
> "restore" means restoring its vmemmap pages discared before. This
> commit does this.
> 
> Another discussion is the confusion RESERVE_VMEMMAP_NR isn't used
> explicitly for vmemmap_addr but implicitly for vmemmap_end in
> hugetlb_vmemmap_alloc/free.  David suggested we can compute what
> hugetlb_vmemmap_init() does now at runtime.  We do not need to worry
> for the overhead of computing at runtime since the calculation is
> simple enough and those functions are not in a hot path.  This commit
> has the following improvements:
> 
>   1) The function suffixed name ("optimize/restore") is more expressive.
>   2) The logic becomes less weird in hugetlb_vmemmap_optimize/restore().
>   3) The hugetlb_vmemmap_init() does not need to be exported anymore.
>   4) A ->optimize_vmemmap_pages field in struct hstate is killed.
>   5) There is only one place where checks is_power_of_2(sizeof(struct
>      page)) instead of two places.
>   6) Add more comments for hugetlb_vmemmap_optimize/restore().
>   7) For external users, hugetlb_optimize_vmemmap_pages() is used for
>      detecting if the HugeTLB's vmemmap pages is optimizable originally.
>      In this commit, it is killed and we introduce a new helper
>      hugetlb_vmemmap_optimizable() to replace it.  The name is more
>      expressive.
> 
> Link: https://lore.kernel.org/all/20220404074652.68024-2-songmuchun@bytedance.com/ [1]
> Signed-off-by: Muchun Song <songmuchun@bytedance.com>
> ---
>  include/linux/hugetlb.h |   7 +--
>  include/linux/sysctl.h  |   4 ++
>  mm/hugetlb.c            |  15 ++---
>  mm/hugetlb_vmemmap.c    | 143 ++++++++++++++++++++----------------------------
>  mm/hugetlb_vmemmap.h    |  41 +++++++++-----
>  5 files changed, 102 insertions(+), 108 deletions(-)

Thanks!  I like the removal of hugetlb_vmemmap_init and printing directly
from report_hugepages.  Still need to look at your your command parsing
patches.

> @@ -3191,8 +3191,10 @@ static void __init report_hugepages(void)
>  		char buf[32];
>  
>  		string_get_size(huge_page_size(h), 1, STRING_UNITS_2, buf, 32);
> -		pr_info("HugeTLB registered %s page size, pre-allocated %ld pages\n",
> +		pr_info("HugeTLB: registered %s page size, pre-allocated %ld pages\n",
>  			buf, h->free_huge_pages);
> +		pr_info("HugeTLB: %d KiB vmemmap can be freed for a %s page\n",
> +			hugetlb_vmemmap_optimizable_size(h) / SZ_1K, buf);
>  	}
>  }

My first thought was "Why report vmemmap freed pages if not enabled?".
However, since it can be enabled at runtime it is best always print.

Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>

-- 
Mike Kravetz

  reply	other threads:[~2022-06-29  0:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-28  9:22 [PATCH v2 0/8] Simplify hugetlb vmemmap and improve its readability Muchun Song
2022-06-28  9:22 ` [PATCH v2 1/8] mm: hugetlb_vmemmap: delete hugetlb_optimize_vmemmap_enabled() Muchun Song
2022-06-28  9:22 ` [PATCH v2 2/8] mm: hugetlb_vmemmap: optimize vmemmap_optimize_mode handling Muchun Song
2022-06-28  9:22 ` [PATCH v2 3/8] mm: hugetlb_vmemmap: introduce the name HVO Muchun Song
2022-06-28  9:22 ` [PATCH v2 4/8] mm: hugetlb_vmemmap: move vmemmap code related to HugeTLB to hugetlb_vmemmap.c Muchun Song
2022-06-28  9:22 ` [PATCH v2 5/8] mm: hugetlb_vmemmap: replace early_param() with core_param() Muchun Song
2022-06-28  9:22 ` [PATCH v2 6/8] mm: hugetlb_vmemmap: improve hugetlb_vmemmap code readability Muchun Song
2022-06-29  0:23   ` Mike Kravetz [this message]
2022-06-29  5:55     ` Muchun Song
2022-06-28  9:22 ` [PATCH v2 7/8] mm: hugetlb_vmemmap: move code comments to vmemmap_dedup.rst Muchun Song
2022-06-28  9:22 ` [PATCH v2 8/8] mm: hugetlb_vmemmap: use PTRS_PER_PTE instead of PMD_SIZE / PAGE_SIZE Muchun Song
2022-06-29  0:39   ` Mike Kravetz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YrubeXg8tSxJeGxj@monkey \
    --to=mike.kravetz@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=corbet@lwn.net \
    --cc=david@redhat.com \
    --cc=duanxiongchun@bytedance.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=songmuchun@bytedance.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.