• Logan Gunthorpe's avatar
    ntb_perf: Improve thread handling to increase robustness · da573eaa
    Logan Gunthorpe authored
    This commit accomplishes a few things:
    
    1) Properly prevent multiple sets of threads from running at once using
    a mutex. Lots of race issues existed with the thread_cleanup.
    
    2) The mutex allows us to ensure that threads are finished before
    tearing down the device or module.
    
    3) Don't use kthread_stop when the threads can exit by themselves, as
    this is counter-indicated by the kthread_create documentation. Threads
    now wait for kthread_stop to occur.
    
    4) Writing to the run file now blocks until the threads are complete.
    The test can then be safely interrupted by a SIGINT.
    
    Also, while I was at it:
    
    5) debugfs_run_write shouldn't return 0 in the early check cases as this
    could cause debugfs_run_write to loop undesirably.
    Signed-off-by: default avatarLogan Gunthorpe <logang@deltatee.com>
    Acked-by: default avatarDave Jiang <dave.jiang@intel.com>
    Signed-off-by: default avatarJon Mason <jdmason@kudzu.us>
    da573eaa
ntb_perf.c 18.5 KB