• Luis R. Rodriguez's avatar
    kmod: throttle kmod thread limit · 6d7964a7
    Luis R. Rodriguez authored
    If we reach the limit of modprobe_limit threads running the next
    request_module() call will fail.  The original reason for adding a kill
    was to do away with possible issues with in old circumstances which would
    create a recursive series of request_module() calls.
    
    We can do better than just be super aggressive and reject calls once we've
    reached the limit by simply making pending callers wait until the
    threshold has been reduced, and then throttling them in, one by one.
    
    This throttling enables requests over the kmod concurrent limit to be
    processed once a pending request completes.  Only the first item queued up
    to wait is woken up.  The assumption here is once a task is woken it will
    have no other option to also kick the queue to check if there are more
    pending tasks -- regardless of whether or not it was successful.
    
    By throttling and processing only max kmod concurrent tasks we ensure we
    avoid unexpected fatal request_module() calls, and we keep memory
    consumption on module loading to a minimum.
    
    With x86_64 qemu, with 4 cores, 4 GiB of RAM it takes the following run
    time to run both tests:
    
    time ./kmod.sh -t 0008
    real    0m16.366s
    user    0m0.883s
    sys     0m8.916s
    
    time ./kmod.sh -t 0009
    real    0m50.803s
    user    0m0.791s
    sys     0m9.852s
    
    Link: http://lkml.kernel.org/r/20170628223155.26472-4-mcgrof@kernel.orgSigned-off-by: default avatarLuis R. Rodriguez <mcgrof@kernel.org>
    Reviewed-by: default avatarPetr Mladek <pmladek@suse.com>
    Cc: Jessica Yu <jeyu@redhat.com>
    Cc: Shuah Khan <shuah@kernel.org>
    Cc: Rusty Russell <rusty@rustcorp.com.au>
    Cc: Michal Marek <mmarek@suse.com>
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    6d7964a7
Name
Last commit
Last update
Documentation Loading commit data...
arch Loading commit data...
block Loading commit data...
certs Loading commit data...
crypto Loading commit data...
drivers Loading commit data...
firmware Loading commit data...
fs Loading commit data...
include Loading commit data...
init Loading commit data...
ipc Loading commit data...
kernel Loading commit data...
lib Loading commit data...
mm Loading commit data...
net Loading commit data...
samples Loading commit data...
scripts Loading commit data...
security Loading commit data...
sound Loading commit data...
tools Loading commit data...
usr Loading commit data...
virt Loading commit data...
.cocciconfig Loading commit data...
.get_maintainer.ignore Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.mailmap Loading commit data...
COPYING Loading commit data...
CREDITS Loading commit data...
Kbuild Loading commit data...
Kconfig Loading commit data...
MAINTAINERS Loading commit data...
Makefile Loading commit data...
README Loading commit data...