On 26 Nov 2001, Robert Love wrote:
> On Mon, 2001-11-26 at 22:52, Davide Libenzi wrote:
> > As I said in reply to Ingo patch, it'd be better to expose "number" cpu
> > masks not "logical" ( like cpus_allowed ).
> > In this way the users can use 0..N-1 ( N == number of cpus phisically
> > available ) w/out having to know the internal mapping between logical and
> > number ids.
>
> Do you mean you don't like using a bitmask ?
No no, I love binary math :)
> 00000001 = first CPU, its not logical, its physical.
If You set this directly to cpus_allowed You're going to set the logical
one.
This because cpus_allowed is logical, because it's used like, ie:
int this_cpu = p->processor;
if (p->cpus_allowed & (1 << this_cpu)) ...
and p->processor is logical.
Something like :
unsigned long num2log_mask(unsigned long cmsk) {
unsigned long msk = 0;
int ii;
for (ii = 0; ii < smp_num_cpus; ii++)
if (cmsk & (1 << ii))
msk |= (1 << cpu_logical_map(ii));
return msk;
}
unsigned long log2num_mask(unsigned long cmsk) {
unsigned long msk = 0;
int ii;
for (ii = 0; ii < smp_num_cpus; ii++)
if (cmsk & (1 << ii))
msk |= (1 << cpu_number_map(ii));
return msk;
}
You use num2log_mask() on the user input mask to set cpus_allowed and
log2num_mask() to return the map to the user.
- Davide
-
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 : Fri Nov 30 2001 - 21:00:25 EST