diff mbox series

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

Message ID 20181129235532.9328-1-richard.weiyang@gmail.com (mailing list archive)
State New, archived
Headers show
Series [v2] mm, show_mem: drop pgdat_resize_lock in show_mem() | expand

Commit Message

Wei Yang Nov. 29, 2018, 11:55 p.m. UTC
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>

---
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(-)

Comments

Michal Hocko Nov. 30, 2018, 8:17 a.m. UTC | #1
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
>
Oscar Salvador Nov. 30, 2018, 8:54 a.m. UTC | #2
On 2018-11-30 00:55, 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>

Reviewed-by: Oscar Salvador <osalvador@suse.de>
diff mbox series

Patch

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);