lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAC=cRTN=vbrgOsH7PNNMV+Coyabp=H_XF99MUL00kfET=K-32w@mail.gmail.com>
Date:   Tue, 16 Aug 2022 16:48:41 +0800
From:   huang ying <huang.ying.caritas@...il.com>
To:     Kefeng Wang <wangkefeng.wang@...wei.com>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        linux-mm@...ck.org, linux-kernel@...r.kernel.org,
        Liu Shixin <liushixin2@...wei.com>,
        Huang Ying <ying.huang@...el.com>
Subject: Re: [PATCH RFC] mm, proc: add PcpFree to meminfo

On Tue, Aug 16, 2022 at 4:38 PM Kefeng Wang <wangkefeng.wang@...wei.com> wrote:
>
> From: Liu Shixin <liushixin2@...wei.com>
>
> The page on pcplist could be used, but not counted into memory free or
> avaliable, and pcp_free is only showed by show_mem(). Since commit
> d8a759b57035 ("mm, page_alloc: double zone's batchsize"), there is a
> significant decrease in the display of free memory, with a large number
> of cpus and nodes, the number of pages in the percpu list can be very
> large, so it is better to let user to know the pcp count.

Can you show some data?

Another choice is to count PCP free pages in MemFree.  Is that OK for
your use case too?

Best Regards,
Huang, Ying

> Signed-off-by: Liu Shixin <liushixin2@...wei.com>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@...wei.com>
> ---
>  drivers/base/node.c | 14 +++++++++++++-
>  fs/proc/meminfo.c   |  9 +++++++++
>  2 files changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/base/node.c b/drivers/base/node.c
> index eb0f43784c2b..846864e45db6 100644
> --- a/drivers/base/node.c
> +++ b/drivers/base/node.c
> @@ -375,6 +375,9 @@ static ssize_t node_read_meminfo(struct device *dev,
>         struct sysinfo i;
>         unsigned long sreclaimable, sunreclaimable;
>         unsigned long swapcached = 0;
> +       unsigned long free_pcp = 0;
> +       struct zone *zone;
> +       int cpu;
>
>         si_meminfo_node(&i, nid);
>         sreclaimable = node_page_state_pages(pgdat, NR_SLAB_RECLAIMABLE_B);
> @@ -382,9 +385,17 @@ static ssize_t node_read_meminfo(struct device *dev,
>  #ifdef CONFIG_SWAP
>         swapcached = node_page_state_pages(pgdat, NR_SWAPCACHE);
>  #endif
> +       for_each_populated_zone(zone) {
> +               if (zone_to_nid(zone) != nid)
> +                       continue;
> +               for_each_online_cpu(cpu)
> +                       free_pcp += per_cpu_ptr(zone->per_cpu_pageset, cpu)->count;
> +       }
> +
>         len = sysfs_emit_at(buf, len,
>                             "Node %d MemTotal:       %8lu kB\n"
>                             "Node %d MemFree:        %8lu kB\n"
> +                           "Node %d PcpFree:        %8lu kB\n"
>                             "Node %d MemUsed:        %8lu kB\n"
>                             "Node %d SwapCached:     %8lu kB\n"
>                             "Node %d Active:         %8lu kB\n"
> @@ -397,7 +408,8 @@ static ssize_t node_read_meminfo(struct device *dev,
>                             "Node %d Mlocked:        %8lu kB\n",
>                             nid, K(i.totalram),
>                             nid, K(i.freeram),
> -                           nid, K(i.totalram - i.freeram),
> +                           nid, K(free_pcp),
> +                           nid, K(i.totalram - i.freeram - free_pcp),
>                             nid, K(swapcached),
>                             nid, K(node_page_state(pgdat, NR_ACTIVE_ANON) +
>                                    node_page_state(pgdat, NR_ACTIVE_FILE)),
> diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
> index 6e89f0e2fd20..672c784dfc8a 100644
> --- a/fs/proc/meminfo.c
> +++ b/fs/proc/meminfo.c
> @@ -38,6 +38,9 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
>         unsigned long pages[NR_LRU_LISTS];
>         unsigned long sreclaimable, sunreclaim;
>         int lru;
> +       unsigned long free_pcp = 0;
> +       struct zone *zone;
> +       int cpu;
>
>         si_meminfo(&i);
>         si_swapinfo(&i);
> @@ -55,8 +58,14 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
>         sreclaimable = global_node_page_state_pages(NR_SLAB_RECLAIMABLE_B);
>         sunreclaim = global_node_page_state_pages(NR_SLAB_UNRECLAIMABLE_B);
>
> +       for_each_populated_zone(zone) {
> +               for_each_online_cpu(cpu)
> +                       free_pcp += per_cpu_ptr(zone->per_cpu_pageset, cpu)->count;
> +       }
> +
>         show_val_kb(m, "MemTotal:       ", i.totalram);
>         show_val_kb(m, "MemFree:        ", i.freeram);
> +       show_val_kb(m, "PcpFree:        ", free_pcp);
>         show_val_kb(m, "MemAvailable:   ", available);
>         show_val_kb(m, "Buffers:        ", i.bufferram);
>         show_val_kb(m, "Cached:         ", cached);
> --
> 2.35.3
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ