[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YrK05aLPyfwVusN8@FVFYT0MHHV2J.usts.net>
Date: Wed, 22 Jun 2022 14:21:25 +0800
From: Muchun Song <songmuchun@...edance.com>
To: Gang Li <ligang.bdlg@...edance.com>
Cc: Mike Kravetz <mike.kravetz@...cle.com>,
Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1] mm, hugetlb: skip irrelevant nodes in
hugetlb_show_meminfo()
On Wed, Jun 22, 2022 at 12:00:42PM +0800, Gang Li wrote:
> show_free_areas() allows to filter out node specific data which is
> irrelevant to the allocation request. But hugetlb_show_meminfo() still
> show hugetlb on all nodes, which is redundant and unnecessary.
>
> Use show_mem_node_skip() to skip irrelevant nodes in
> hugetlb_show_meminfo().
>
> Signed-off-by: Gang Li <ligang.bdlg@...edance.com>
> ---
> include/linux/hugetlb.h | 4 ++--
> include/linux/mm.h | 1 +
> mm/hugetlb.c | 7 +++++--
> mm/page_alloc.c | 4 ++--
> 4 files changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
> index 642a39016f9a..1913ac6bf10a 100644
> --- a/include/linux/hugetlb.h
> +++ b/include/linux/hugetlb.h
> @@ -155,7 +155,7 @@ void __unmap_hugepage_range_final(struct mmu_gather *tlb,
> struct page *ref_page, zap_flags_t zap_flags);
> void hugetlb_report_meminfo(struct seq_file *);
> int hugetlb_report_node_meminfo(char *buf, int len, int nid);
> -void hugetlb_show_meminfo(void);
> +void hugetlb_show_meminfo(unsigned int filter, nodemask_t *nodemask);
> unsigned long hugetlb_total_pages(void);
> vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
> unsigned long address, unsigned int flags);
> @@ -300,7 +300,7 @@ static inline int hugetlb_report_node_meminfo(char *buf, int len, int nid)
> return 0;
> }
>
> -static inline void hugetlb_show_meminfo(void)
> +static inline void hugetlb_show_meminfo(unsigned int filter, nodemask_t *nodemask)
> {
> }
>
> diff --git a/include/linux/mm.h b/include/linux/mm.h
> index 764dc0fdae5e..f72c1b21cde3 100644
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -1873,6 +1873,7 @@ extern void pagefault_out_of_memory(void);
> */
> #define SHOW_MEM_FILTER_NODES (0x0001u) /* disallowed nodes */
>
> +extern bool show_mem_node_skip(unsigned int flags, int nid, nodemask_t *nodemask);
Exporting this to the only user of HugeTLB is not a good idea.
> extern void show_free_areas(unsigned int flags, nodemask_t *nodemask);
>
> #ifdef CONFIG_MMU
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 98492733cc64..632826e6fea5 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -4486,7 +4486,7 @@ int hugetlb_report_node_meminfo(char *buf, int len, int nid)
> nid, h->surplus_huge_pages_node[nid]);
> }
>
> -void hugetlb_show_meminfo(void)
> +void hugetlb_show_meminfo(unsigned int filter, nodemask_t *nodemask)
> {
I suggest making this function show meminfo for a specific node.
like hugetlb_show_meminfo_node(int nid) which only show meminfo
for node @nid.
> struct hstate *h;
> int nid;
> @@ -4494,7 +4494,9 @@ void hugetlb_show_meminfo(void)
> if (!hugepages_supported())
> return;
>
> - for_each_node_state(nid, N_MEMORY)
> + for_each_node_state(nid, N_MEMORY) {
> + if (show_mem_node_skip(filter, nid, nodemask))
> + continue;
> for_each_hstate(h)
> pr_info("Node %d hugepages_total=%u hugepages_free=%u hugepages_surp=%u hugepages_size=%lukB\n",
> nid,
> @@ -4502,6 +4504,7 @@ void hugetlb_show_meminfo(void)
> h->free_huge_pages_node[nid],
> h->surplus_huge_pages_node[nid],
> huge_page_size(h) / SZ_1K);
> + }
> }
>
> void hugetlb_report_usage(struct seq_file *m, struct mm_struct *mm)
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 84781094b478..5896b5a9101f 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -5951,7 +5951,7 @@ void si_meminfo_node(struct sysinfo *val, int nid)
> * Determine whether the node should be displayed or not, depending on whether
> * SHOW_MEM_FILTER_NODES was passed to show_free_areas().
> */
> -static bool show_mem_node_skip(unsigned int flags, int nid, nodemask_t *nodemask)
> +bool show_mem_node_skip(unsigned int flags, int nid, nodemask_t *nodemask)
> {
> if (!(flags & SHOW_MEM_FILTER_NODES))
> return false;
> @@ -6196,7 +6196,7 @@ void show_free_areas(unsigned int filter, nodemask_t *nodemask)
> printk(KERN_CONT "= %lukB\n", K(total));
> }
>
Just like the above case. We can check nid here instead of in hugetlb_show_meminfo().
Then you do not need to export show_mem_node_skip().
for_each_online_node(nid) {
if (show_mem_node_skip(filter, nid, nodemask))
continue;
hugetlb_show_meminfo_node(nid);
}
Thanks.
> - hugetlb_show_meminfo();
> + hugetlb_show_meminfo(filter, nodemask);
>
> printk("%ld total pagecache pages\n", global_node_page_state(NR_FILE_PAGES));
>
> --
> 2.20.1
>
>
Powered by blists - more mailing lists