Re: [PATCH incremental] cpusets: initialize spread rotor lazily

From: David Rientjes
Date: Mon Apr 18 2011 - 21:15:33 EST


On Mon, 18 Apr 2011, Michal Hocko wrote:

> From: Michal Hocko <mhocko@xxxxxxx>
> Subject: cpusets: initialize spread mem/slab rotor lazily
>
> Kosaki Motohiro raised a concern that copy_process is hot path and we do
> not want to initialize cpuset_{mem,slab}_spread_rotor if they are not
> used most of the time.
>
> I think that we should rather initialize it lazily when rotors are used
> for the first time.
> This will also catch the case when we set up spread mem/slab later.
>
> Signed-off-by: Michal Hocko <mhocko@xxxxxxx>
> Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@xxxxxxxxxxxxxx>

Acked-by: David Rientjes <rientjes@xxxxxxxxxx>

Thanks Michal!

> Index: linus_tree/kernel/cpuset.c
> ===================================================================
> --- linus_tree.orig/kernel/cpuset.c 2011-04-18 10:33:15.000000000 +0200
> +++ linus_tree/kernel/cpuset.c 2011-04-18 23:24:02.000000000 +0200
> @@ -2460,11 +2460,19 @@ static int cpuset_spread_node(int *rotor
>
> int cpuset_mem_spread_node(void)
> {
> + if (current->cpuset_mem_spread_rotor == NUMA_NO_NODE)
> + current->cpuset_mem_spread_rotor =
> + node_random(&current->mems_allowed);
> +
> return cpuset_spread_node(&current->cpuset_mem_spread_rotor);
> }
>
> int cpuset_slab_spread_node(void)
> {
> + if (current->cpuset_slab_spread_rotor == NUMA_NO_NODE)
> + current->cpuset_slab_spread_rotor =
> + node_random(&current->mems_allowed);
> +
> return cpuset_spread_node(&current->cpuset_slab_spread_rotor);
> }
>
> Index: linus_tree/kernel/fork.c
> ===================================================================
> --- linus_tree.orig/kernel/fork.c 2011-04-18 10:33:15.000000000 +0200
> +++ linus_tree/kernel/fork.c 2011-04-18 10:33:56.000000000 +0200
> @@ -1126,8 +1126,8 @@ static struct task_struct *copy_process(
> mpol_fix_fork_child_flag(p);
> #endif
> #ifdef CONFIG_CPUSETS
> - p->cpuset_mem_spread_rotor = node_random(&p->mems_allowed);
> - p->cpuset_slab_spread_rotor = node_random(&p->mems_allowed);
> + p->cpuset_mem_spread_rotor = NUMA_NO_NODE;
> + p->cpuset_slab_spread_rotor = NUMA_NO_NODE;
> #endif
> #ifdef CONFIG_TRACE_IRQFLAGS
> p->irq_events = 0;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/