Re: [PATCH v2] mm, show_mem: drop pgdat_resize_lock in show_mem()

Michal Hocko
2018-11-30T08:17:59Z

On Fri 30-11-18 07:55:32, Wei Yang wrote:
> Function show_mem() is used to print system memory status when user
> requires or fail to allocate memory. Generally, this is a best effort
> information so any races with memory hotplug (or very theoretically an
> early initialization) should be tolerable and the worst that could
> happen is to print an imprecise node state.
>
> Drop the resize lock because this is the only place which might hold the
> lock from the interrupt context and so all other callers might use a
> simple spinlock. Even though this doesn't solve any real issue it makes
> the code easier to follow and tiny more effective.
>
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>

Acked-by: Michal Hocko <mhocko@suse.com>

>
> ---
> v2:
> * adjust the changelog to show the reason of this change
> * remove unused variable flags
> ---
> lib/show_mem.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/lib/show_mem.c b/lib/show_mem.c
> index 0beaa1d899aa..f4e029e1ddec 100644
> --- a/lib/show_mem.c
> +++ b/lib/show_mem.c
> @@ -18,10 +18,8 @@ void show_mem(unsigned int filter, nodemask_t *nodemask)
> show_free_areas(filter, nodemask);
>
> for_each_online_pgdat(pgdat) {
> - unsigned long flags;
> int zoneid;
>
> - pgdat_resize_lock(pgdat, &flags);
> for (zoneid = 0; zoneid < MAX_NR_ZONES; zoneid++) {
> struct zone *zone = &pgdat->node_zones[zoneid];
> if (!populated_zone(zone))
> @@ -33,7 +31,6 @@ void show_mem(unsigned int filter, nodemask_t *nodemask)
> if (is_highmem_idx(zoneid))
> highmem += zone->present_pages;
> }
> - pgdat_resize_unlock(pgdat, &flags);
> }
>
> printk("%lu pages RAM\n", total);
> --
> 2.15.1
>

--
Michal Hocko
SUSE Labs