Open MPI logo

PLPA Users' Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all PLPA Users mailing list

From: Jeff Squyres (jsquyres_at_[hidden])
Date: 2006-02-15 09:36:18


I think you're looking at an older version of PLPA -- this issue was
raised in mid-January (see http://www.open-mpi.org/community/lists/
plpa-users/2006/01/0012.php) and I released v1.0.1 with cpusetsize
clarified to be in units of bytes (and fixed a few of the tests as
you noted). I also added a short bit in the README about the units
of cpusetsize:

    The units of cpusetsize is number of bytes. This should normally
    just be sizeof(*cpuset), but is made available as a parameter to
    allow for future expansion of the PLPA (stay tuned).

Can you verify that you're at the most recent version (1.0.2)?

On Feb 12, 2006, at 11:17 AM, Bert Wesarg wrote:

> Hello list,
>
> i'm a little confused by the 'cpusetsize' argument to
> sched_setaffinity().
> i found the following in your code
>
> from plpa-1.0.2/src/libplpa/plpa_dispatch.c:
>> 32: case PLPA_PROBE_OK:
>> 33: /* This shouldn't happen, but check anyway */
>> 34: if (cpusetsize > PLPA_BITMASK_NUM_ELEMENTS) {
> here 'cpusetsize' is asumed to be a number of 'unsigned long int'
> for the
> 'struct cpu_set_t'
>
>> 35: return EINVAL;
>> 36: }
>
>> 48: if (cpusetsize < PLPA_NAME(len)) {
> 'cpusetsize' and 'len' is assumed to be the number of bits
>
>> 49: memset(&tmp, 0, sizeof(tmp));
>> 50: for (i = 0; i < cpusetsize * 8; ++i) {
> 'cpusetsize' is assumed to be a number of bytes
>
>> 51: if (PLPA_CPU_ISSET(i, cpuset)) {
>> 52: PLPA_CPU_SET(i, &tmp);
>> 53: }
>> 54: }
>> 55: }
>
>> 63: else if (cpusetsize > PLPA_NAME(len)) {
> same as in line 48
>
>> 64: for (i = PLPA_NAME(len); i < cpusetsize * 8; ++i) {
> 'len' number of bits, 'cpusetsize' number of bytes
>
>> 65: if (PLPA_CPU_ISSET(i, cpuset)) {
>> 66: return EINVAL;
>> 67: }
>
>> 71: memset(&tmp, 0, sizeof(tmp));
>> 72: for (i = 0; i < PLPA_NAME(len); ++i) {
> 'len' is assumed to be the number of bits
>
>> 73: if (PLPA_CPU_ISSET(i, cpuset)) {
>> 74: PLPA_CPU_SET(i, &tmp);
>> 75: }
>> 76: }
>> 77: }
>> 78:
>> 79: /* Otherwise, the user supplied a buffer that is
>> exactly the
>> 80: right size. Just for clarity of code, copy the user's
>> 81: buffer into the temporary and use that. */
>> 82: else {
>> 83: memcpy(&tmp, cpuset, cpusetsize);
> 'cpusetsize' number of bytes
>> 84: }
>> 85:
>> 86: /* Now do the syscall */
>> 87: ret = syscall(__NR_sched_setaffinity, 0, PLPA_NAME
>> (len), &tmp);
> at least my kernel (2.6.14) expects the 'len' parameter to be the
> number
> of bytes (sizeof(cpu_set_t)):
>
> from kernel/sched.c:
> static int get_user_cpu_mask(unsigned long __user *user_mask_ptr,
> unsigned
> len,
> cpumask_t *new_mask)
> {
> if (len < sizeof(cpumask_t)) {
> memset(new_mask, 0, sizeof(cpumask_t));
> } else if (len > sizeof(cpumask_t)) {
> len = sizeof(cpumask_t);
> }
> return copy_from_user(new_mask, user_mask_ptr, len) ? -EFAULT : 0;
> }
>
> /**
> * sys_sched_setaffinity - set the cpu affinity of a process
> * @pid: pid of the process
> * @len: length in bytes of the bitmask pointed to by user_mask_ptr
> * @user_mask_ptr: user-space pointer to the new cpu mask
> */
> asmlinkage long sys_sched_setaffinity(pid_t pid, unsigned int len,
> unsigned long __user *user_mask_ptr)
> {
> cpumask_t new_mask;
> int retval;
>
> retval = get_user_cpu_mask(user_mask_ptr, len, &new_mask);
> if (retval)
> return retval;
>
> return sched_setaffinity(pid, new_mask);
> }
>
> i count 3 'definitions' for 'cpusetsize'! my question is wich
> 'definition'
> should i use for the call to PLPA_NAME(sched_setaffinity)()? i
> can't find
> even a definition in any documentation from the package!
>
> best regards
> bert wesarg
>
> _______________________________________________
> plpa-users mailing list
> plpa-users_at_[hidden]
> http://www.open-mpi.org/mailman/listinfo.cgi/plpa-users

-- 
{+} Jeff Squyres
{+} The Open MPI Project
{+} http://www.open-mpi.org/