OSDN Git Service

cgroup, netclassid: periodically release file_lock on classid updating
authorDmitry Yakunin <zeil@yandex-team.ru>
Thu, 5 Mar 2020 14:45:57 +0000 (17:45 +0300)
committerDavid S. Miller <davem@davemloft.net>
Tue, 10 Mar 2020 01:13:39 +0000 (18:13 -0700)
commit018d26fcd12a75fb9b5fe233762aa3f2f0854b88
treef98360092168d5b65b481823b992f689966e9ff3
parentce9a4186f9ac475c415ffd20348176a4ea366670
cgroup, netclassid: periodically release file_lock on classid updating

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: Dmitry Yakunin <zeil@yandex-team.ru>
Reviewed-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/netclassid_cgroup.c