lkml.org 
[lkml]   [2001]   [Nov]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] proc-based cpu affinity user interface
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/

\
 
 \ /
  Last update: 2005-03-22 13:13    [W:0.065 / U:1.648 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site