• Li Zhong's avatar
    Fix a dead loop in async_synchronize_full() · 5b5f4aa5
    Li Zhong authored
    [Fixed upstream by commits 2955b47d and
    a4683487 from Dan Williams, but they are much
    more intrusive than this tiny fix, according to Andrew - gregkh]
    
    This patch tries to fix a dead loop in  async_synchronize_full(), which
    could be seen when preemption is disabled on a single cpu machine.
    
    void async_synchronize_full(void)
    {
            do {
                    async_synchronize_cookie(next_cookie);
            } while (!list_empty(&async_running) || !
    list_empty(&async_pending));
    }
    
    async_synchronize_cookie() calls async_synchronize_cookie_domain() with
    &async_running as the default domain to synchronize.
    
    However, there might be some works in the async_pending list from other
    domains. On a single cpu system, without preemption, there is no chance
    for the other works to finish, so async_synchronize_full() enters a dead
    loop.
    
    It seems async_synchronize_full() wants to synchronize all entries in
    all running lists(domains), so maybe we could just check the entry_count
    to know whether all works are finished.
    
    Currently, async_synchronize_cookie_domain() expects a non-NULL running
    list ( if NULL, there would be NULL pointer dereference ), so maybe a
    NULL pointer could be used as an indication for the functions to
    synchronize all works in all domains.
    Reported-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
    Signed-off-by: default avatarLi Zhong <zhong@linux.vnet.ibm.com>
    Tested-by: default avatarPaul E. McKenney <paulmck@linux.vnet.ibm.com>
    Tested-by: default avatarChristian Kujau <lists@nerdbynature.de>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: Dan Williams <dan.j.williams@gmail.com>
    Cc: Christian Kujau <lists@nerdbynature.de>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: Cong Wang <xiyou.wangcong@gmail.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
    5b5f4aa5
async.c 9.19 KB