Re: [PATCH 08/22 v2] mm/vmstat: Avoid on each online CPU loops

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue 29-11-16 15:51:14, Sebastian Andrzej Siewior wrote:
> Both iterations over online cpus can be replaced by the proper node
> specific functions.
> 
> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Cc: Vlastimil Babka <vbabka@xxxxxxx>
> Cc: Mel Gorman <mgorman@xxxxxxxxxxxxxxxxxxx>
> Cc: Johannes Weiner <hannes@xxxxxxxxxxx>
> Cc: linux-mm@xxxxxxxxx
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>

Acked-by: Michal Hocko <mhocko@xxxxxxxx>

> ---
> v1…v2: take into account that we may have online nodes with no CPUs.
> 
>  mm/vmstat.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/mm/vmstat.c b/mm/vmstat.c
> index 0b63ffb5c407..5152cd1c490f 100644
> --- a/mm/vmstat.c
> +++ b/mm/vmstat.c
> @@ -1720,19 +1720,21 @@ static void __init start_shepherd_timer(void)
>  
>  static void __init init_cpu_node_state(void)
>  {
> -	int cpu;
> +	int node;
>  
> -	for_each_online_cpu(cpu)
> -		node_set_state(cpu_to_node(cpu), N_CPU);
> +	for_each_online_node(node) {
> +		if (cpumask_weight(cpumask_of_node(node)) > 0)
> +			node_set_state(node, N_CPU);
> +	}
>  }
>  
>  static void vmstat_cpu_dead(int node)
>  {
> -	int cpu;
> +	const struct cpumask *node_cpus;
>  
> -	for_each_online_cpu(cpu)
> -		if (cpu_to_node(cpu) == node)
> -			return;
> +	node_cpus = cpumask_of_node(node);
> +	if (cpumask_weight(node_cpus) > 0)
> +		return;
>  
>  	node_clear_state(node, N_CPU);
>  }
> -- 
> 2.10.2

-- 
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]