• Dmitry Yakunin's avatar
    cgroup, netclassid: periodically release file_lock on classid updating · 78604444
    Dmitry Yakunin authored
    [ Upstream commit 018d26fc ]
    
    In our production environment we have faced with problem that updating
    classid in cgroup with heavy tasks cause long freeze of the file tables
    in this tasks. By heavy tasks we understand tasks with many threads and
    opened sockets (e.g. balancers). This freeze leads to an increase number
    of client timeouts.
    
    This patch implements following logic to fix this issue:
    аfter iterating 1000 file descriptors file table lock will be released
    thus providing a time gap for socket creation/deletion.
    
    Now update is non atomic and socket may be skipped using calls:
    
    dup2(oldfd, newfd);
    close(oldfd);
    
    But this case is not typical. Moreover before this patch skip is possible
    too by hiding socket fd in unix socket buffer.
    
    New sockets will be allocated with updated classid because cgroup state
    is updated before start of the file descriptors iteration.
    
    So in common cases this patch has no side effects.
    Signed-off-by: default avatarDmitry Yakunin <zeil@yandex-team.ru>
    Reviewed-by: default avatarKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    78604444
netclassid_cgroup.c 3.53 KB