Re: [PATCH] set_cpus_allowed() for 2.4

From: Mikael Pettersson (mikpe@csd.uu.se)
Date: Mon Dec 02 2002 - 12:12:05 EST


On November 4, Christoph Hellwig wrote:
> +void set_cpus_allowed(struct task_struct *p, unsigned long new_mask)
> +{
> + new_mask &= cpu_online_map;
> + BUG_ON(!new_mask);
> +
> + p->cpus_allowed = new_mask;
> +
> + /*
> + * If the task is on a no-longer-allowed processor, we need to move
> + * it. If the task is not current, then set need_resched and send
> + * its processor an IPI to reschedule.
> + */
> + if (!(p->cpus_runnable & p->cpus_allowed)) {
> + if (p != current) {
> + p->need_resched = 1;
> + smp_send_reschedule(p->processor);
> + }
> + /*
> + * Wait until we are on a legal processor. If the task is
> + * current, then we should be on a legal processor the next
> + * time we reschedule. Otherwise, we need to wait for the IPI.
> + */
> + while (!(p->cpus_runnable & p->cpus_allowed))
> + schedule();
> + }
> +}

Is this implementation of set_cpus_allowed() Ok for all 2.4 kernels,
even if they (like RH8.0's) use a non-vanilla scheduler?

I'm asking because I need to put a set_cpus_allowed() implementation
in my performance counters driver's compat layer. If it makes any
difference, I'll only use set_cpus_allowed(p, new_mask) when p == current
or p is stopped and under ptrace() control by current.

/Mikael
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Dec 07 2002 - 22:00:13 EST