• Christoph Lameter's avatar
    [PATCH] Fix longstanding load balancing bug in the scheduler · 0a2966b4
    Christoph Lameter authored
    The scheduler will stop load balancing if the most busy processor contains
    processes pinned via processor affinity.
    
    The scheduler currently only does one search for busiest cpu.  If it cannot
    pull any tasks away from the busiest cpu because they were pinned then the
    scheduler goes into a corner and sulks leaving the idle processors idle.
    
    F.e.  If you have processor 0 busy running four tasks pinned via taskset,
    there are none on processor 1 and one just started two processes on
    processor 2 then the scheduler will not move one of the two processes away
    from processor 2.
    
    This patch fixes that issue by forcing the scheduler to come out of its
    corner and retrying the load balancing by considering other processors for
    load balancing.
    
    This patch was originally developed by John Hawkes and discussed at
    
        http://marc.theaimsgroup.com/?l=linux-kernel&m=113901368523205&w=2.
    
    I have removed extraneous material and gone back to equipping struct rq
    with the cpu the queue is associated with since this makes the patch much
    easier and it is likely that others in the future will have the same
    difficulty of figuring out which processor owns which runqueue.
    
    The overhead added through these patches is a single word on the stack if
    the kernel is configured to support 32 cpus or less (32 bit).  For 32 bit
    environments the maximum number of cpus that can be configued is 255 which
    would result in the use of 32 bytes additional on the stack.  On IA64 up to
    1k cpus can be configured which will result in the use of 128 additional
    bytes on the stack.  The maximum additional cache footprint is one
    cacheline.  Typically memory use will be much less than a cacheline and the
    additional cpumask will be placed on the stack in a cacheline that already
    contains other local variable.
    Signed-off-by: default avatarChristoph Lameter <clameter@sgi.com>
    Cc: John Hawkes <hawkes@sgi.com>
    Cc: "Siddha, Suresh B" <suresh.b.siddha@intel.com>
    Cc: Ingo Molnar <mingo@elte.hu>
    Cc: Nick Piggin <nickpiggin@yahoo.com.au>
    Cc: Peter Williams <pwil3058@bigpond.net.au>
    Cc: <stable@kernel.org>
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    0a2966b4
sched.c 173 KB