[lkml]   [2004]   [Mar]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Patch in this message
    SubjectRe: sched_setaffinity usability

    * Ulrich Drepper <> wrote:

    > The sched_setaffinity syscall currently has a usability problem. The
    > size of cpumask_t is not visible outside the kernel and might change
    > from kernel to kernel. So, if the user uses a large CPU bitset and
    > passes it to the kernel it is not known at all whether all the bits
    > provided in the bitmap are used. The kernel simply copies the first
    > bytes, enough to fill in the cpumask_t object and ignores the rest.
    > A simple check for a too large bitset is not good. Programs which are
    > portable (to different kernels) and future safe should use large
    > bitmap sizes. Instead the user should only be notified about the size
    > problem if any nonzero bit is ignored.

    how about adding a new syscall, sys_sched_get_affinity_span(), which
    would be called by glibc first time one of the affinity syscalls are

    This syscall would be a prime target to be optimized away via the
    vsyscall DSO, so there's no overhead worry.

    something like the attached patch.

    or, maybe it would be better to introduce some sort of 'system
    constants' syscall that would be a generic umbrella for such things -
    and could easily be converted into a vsyscall. Or we could make it part
    of the .data section of the VDSO - thus no copying overhead, only one
    symbol lookup.


    --- linux/arch/i386/kernel/entry.S.orig
    +++ linux/arch/i386/kernel/entry.S
    @@ -908,5 +908,6 @@ ENTRY(sys_call_table)
    .long sys_utimes
    .long sys_fadvise64_64
    .long sys_ni_syscall /* sys_vserver */
    + .long sys_sched_get_affinity_span

    --- linux/kernel/sched.c.orig
    +++ linux/kernel/sched.c
    @@ -2793,6 +2793,17 @@ out_unlock:

    + * sys_sched_affinity_span - get the cpu affinity mask size possible
    + *
    + * returns the size of cpumask_t. Note that this is a hard upper limit
    + * for the # of CPUs.
    + */
    +asmlinkage long sys_sched_get_affinity_span(void)
    + return sizeof(cpumask_t);
    * sys_sched_yield - yield the current processor to other threads.
    * this function yields the current CPU by moving the calling thread
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at
     \ /
      Last update: 2005-03-22 14:01    [W:0.024 / U:10.156 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site