Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B453C10F25 for ; Tue, 10 Mar 2020 01:14:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 35FEE24649 for ; Tue, 10 Mar 2020 01:14:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726482AbgCJBOY convert rfc822-to-8bit (ORCPT ); Mon, 9 Mar 2020 21:14:24 -0400 Received: from shards.monkeyblade.net ([23.128.96.9]:34458 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726193AbgCJBOV (ORCPT ); Mon, 9 Mar 2020 21:14:21 -0400 Received: from localhost (unknown [IPv6:2601:601:9f00:477::3d5]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id 55B8A15A04E39; Mon, 9 Mar 2020 18:14:21 -0700 (PDT) Date: Mon, 09 Mar 2020 18:14:20 -0700 (PDT) Message-Id: <20200309.181420.880934692451984316.davem@davemloft.net> To: zeil@yandex-team.ru Cc: netdev@vger.kernel.org, khlebnikov@yandex-team.ru Subject: Re: [PATCH net] cgroup, netclassid: periodically release file_lock on classid updating From: David Miller In-Reply-To: <20200305144557.GA78822@yandex-team.ru> References: <20200305144557.GA78822@yandex-team.ru> X-Mailer: Mew version 6.8 on Emacs 26.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=koi8-r Content-Transfer-Encoding: 8BIT X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Mon, 09 Mar 2020 18:14:21 -0700 (PDT) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Dmitry Yakunin Date: Thu, 5 Mar 2020 17:45:57 +0300 > 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 > Reviewed-by: Konstantin Khlebnikov Applied and queued up for -stable, thank you.