Re: cpusets not cpu hotplug aware

From: Paul Jackson
Date: Wed Aug 23 2006 - 22:52:19 EST


Simon,

Take note below of my proposal to make the 'cpus' and 'mems'
of the top cpuset read-only. Holler if that hurts.

Nathan wrote:
> +static int cpuset_handle_cpuhp(struct notifier_block *nb,
> + unsigned long phase, void *_cpu)
> +{
> + unsigned long cpu = (unsigned long)_cpu;
> +
> + mutex_lock(&manage_mutex);
> + mutex_lock(&callback_mutex);
> +
> + switch (phase) {
> + case CPU_ONLINE:
> + cpu_set(cpu, top_cpuset.cpus_allowed);
> + break;
> + case CPU_DEAD:
> + cpu_clear(cpu, top_cpuset.cpus_allowed);
> + break;
> + }
> +
> + mutex_unlock(&callback_mutex);
> + mutex_unlock(&manage_mutex);
> +
> + return 0;
> +}
> +

Andrew commented:
> I must say, that's a pretty simple patch.

Not simple enough ;).

How about (uncompiled, untested, unanything):

=================================================================
/*
* The top_cpuset tracks what CPUs and Memory Nodes are online,
* period. This is necessary in order to make cpusets transparent
* (of no affect) on systems that are actively using CPU hotplug
* but making no active use of cpusets.
*
* This handles CPU hotplug (cpuhp) events. If someday Memory
* Nodes can be hotplugged (dynamically changing node_online_map)
* then we should handle that too, perhaps in a similar way.
*/

#ifdef CONFIG_HOTPLUG_CPU
static int cpuset_handle_cpuhp(struct notifier_block *nb,
unsigned long phase, void *cpu)
{
mutex_lock(&manage_mutex);
mutex_lock(&callback_mutex);

top_cpuset.cpus_allowed = cpu_online_map;

mutex_unlock(&callback_mutex);
mutex_unlock(&manage_mutex);

return 0;
}
#endif

... plus the hotcpu_notifier() initializer.
=================================================================

However I get to spend the few lines of code I saved here elsewhere,
adding special case code so that the top_cpuset's 'cpus' and 'mems'
files are read-only.

The new rule is simple:

The top cpuset's cpus and mems track what is online.

The user is no longer in direct control of these two cpuset settings.

And I should add a few lines to Documentation/cpusets.txt, describing
this.

When I return from my son's 18-th birthday party this evening, I will
see what I can whip up.

Thanks, Nathan.

--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj@xxxxxxx> 1.925.600.0401
-
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/