• Peter W Morreale's avatar
    mm: fix pdflush thread creation upper bound · a56ed663
    Peter W Morreale authored
    Fix a race on creating pdflush threads.  Without the patch, it is possible
    to create more than MAX_PDFLUSH_THREADS threads, and this has been
    observed in practice on IO loaded SMP machines.
    
    The fix involves moving the lock around to protect the check against the
    thread count and correctly dealing with thread creation failure.
    
    This fix also _mostly_ repairs a race condition on how quickly the threads
    are created.  The original intent was to create a pdflush thread (up to
    the max allowed) every second.  Without this patch is is possible to
    create NCPUS pdflush threads concurrently.  The 'mostly' caveat is because
    an assumption is made that thread creation will be successful.  If we fail
    to create the thread, the miss is not considered fatal.  (we will try
    again in 1 second)
    Signed-off-by: default avatarPeter W Morreale <pmorreale@novell.com>
    Reviewed-by: default avatarRik van Riel <riel@redhat.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    a56ed663
pdflush.c 7 KB