Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp658009rdb; Thu, 19 Oct 2023 15:36:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGzGWn4RGpDz1mYxHHkQgGufI6McKzdsCpPBg4+TASi3csa7u5+xPkI1Bks7whyBzPR5dVq X-Received: by 2002:a92:c9d1:0:b0:34c:b981:52d4 with SMTP id k17-20020a92c9d1000000b0034cb98152d4mr311979ilq.31.1697754987405; Thu, 19 Oct 2023 15:36:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697754987; cv=none; d=google.com; s=arc-20160816; b=H5bJpqkd4VyP8t89Wy9gBYvypL6NRoItOX3npXe0iwCmhDviag6ZCO5Bnph5c7mh4t XBKD/g0LcWT5cNTBip7gP9uVsZFRvzjX6FbV4afFXSz0tWxDMA13qppAJ8I60NZctb1p 371oBWMrrRKo7d9I6jDNZa4gmrA4Vpgb8D1LqJgtGTdvB0p32qHQZb6ZY7aUweXL9QvU HOR3IO+usUgc5mB2Yg7lizuuFr9/qyAbfHmpZYiVQfYk9GNY009IJefGKSDcuIDd6lTA F/lyua34nRd1vCl5SGI82RfDXMEKKiaiel+JOk2AdOxhoUa1e6x6KDKvTGv8or0zX9vS 2KCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:mime-version :dkim-signature; bh=6L6sBoVhtv+gisMW9vrcDKOjCxepeY7VRUU0FAAL42c=; fh=axKz86X2DS+IVS6CkRz02JMoGcyuD3mqs3U3MzNPkTY=; b=zmyiAuOzpY3p9B+H0O7OIvG/J2yOfe5A38I1TSR1PyrvwdYlrrX4wMJwZtFQf3CF8B vNmuhzcHg6bjdJSScfClN8n0gpjeTNYAybah47Alz+juHWbKFoJI6nDChZv614bC8q6+ LINWx9ndSwBM/SyVKkIuyBsh6SLiaONDF+3T36TUbHvyXx8j3eGhhYGUuM6basHFMUPT hjaktPONphfoqZeN9IdoLs6VPWczhig7YbDkABCN0RRQiHZnmswEPmz6qC5Z/FQQ+SRM Gh7zgY32imN7Bz5eYGri/RL5RweaIgclm6NbS8zlNRZnSHnWLX6ZfKCzIg/2JHLmx3oP lXaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google09082023 header.b=EhCfFpyE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id x29-20020aa7957d000000b006be077531adsi550058pfq.125.2023.10.19.15.36.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 15:36:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google09082023 header.b=EhCfFpyE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id BDC9780620AF; Thu, 19 Oct 2023 15:35:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346634AbjJSWfR (ORCPT + 99 others); Thu, 19 Oct 2023 18:35:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235549AbjJSWfP (ORCPT ); Thu, 19 Oct 2023 18:35:15 -0400 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE441124 for ; Thu, 19 Oct 2023 15:35:13 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-53e84912038so189359a12.1 for ; Thu, 19 Oct 2023 15:35:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1697754912; x=1698359712; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=6L6sBoVhtv+gisMW9vrcDKOjCxepeY7VRUU0FAAL42c=; b=EhCfFpyEpKRg9lDWjoX55C9LCtMdInS280r1So6+Owc2vxXYpxOYNTT9egQA3sqz/C EIeA2nFS25MKMJfaG33Qk2W2NSurFXUrgr9cQCj37SBeNdGnUDB5pZbNICa0yka1FF/o V8sBJuZ7UBcNzs55L34D5T+7KP4314RJQoyhcfqmJib5d3gPjPOGNIMGDFEtlRRT9bSC 4+Dd3IBVUC+5QQwCWju8A6IEkQJa9PWjM5PoWGxtkmna6uCUKiM7P35+ILf9A3COnzfN nGnBbMpaQ06ecEW0nZI1112tGCtGXRlWImr9zVNmcQ3ahrGwnOsCI5UOrBf5qubtuab+ EkSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697754912; x=1698359712; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=6L6sBoVhtv+gisMW9vrcDKOjCxepeY7VRUU0FAAL42c=; b=J9FnW4PAmTtpX610/pB8xm5P2DF85amJpGlZJ1Ci/Yb3qpsDeRJroGfoA6am3ErANN vfMHe3NHL3rhQ2zK2fdHebclF1oQXF3NCTagU5LH/Zq94RhbedmHRtS7MxbhMDqi0tr0 DhOMsE03j0TvsXaEh7FbeQp7PogqgN/TD8dQ3ZN7oFREemznv31UnfmmzE1Qho7Me88e 3kQz4wF6uMuOuhrLnTfXLTlN+tUa0Cl2ijhhCHNG99IxyAvPtahKqUDecG/zLHd4a6Vb 5+RYZbCLKi16Gmre95DiP6Si8QZgFHM93ThS9cAcq7fCYTnxjedcojdLxm0pGoQYT0E/ JnhA== X-Gm-Message-State: AOJu0Ywk335F/rXeKp+rKbqTitzLOGGaMwPb7E9JP4eT4+8Oap7KEvn/ DYBg4IxUTQaXe/Tltozjlta+fKHOQ80bl3CL3ZXM4Q== X-Received: by 2002:a50:cd1b:0:b0:530:a186:f8a8 with SMTP id z27-20020a50cd1b000000b00530a186f8a8mr190751edi.37.1697754912395; Thu, 19 Oct 2023 15:35:12 -0700 (PDT) MIME-Version: 1.0 From: Ivan Babrou Date: Thu, 19 Oct 2023 15:35:01 -0700 Message-ID: Subject: wait_for_unix_gc can cause CPU overload for well behaved programs To: Linux Kernel Network Developers Cc: kernel-team , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 19 Oct 2023 15:35:26 -0700 (PDT) Hello, We have observed this issue twice (2019 and 2023): a well behaved service that doesn't pass any file descriptors around starts to spend a ton of CPU time in wait_for_unix_gc. The cause of this is that the unix send path unconditionally calls wait_for_unix_gc, which is a global garbage collection. If any misbehaved program exists on a system, it can force extra work for well behaved programs. This behavior is not new: 9915672d4127 ("af_unix: limit unix_tot_inflight") is from 2010. I managed to come up with a repro for this behavior: * https://gist.github.com/bobrik/82e5722261920c9f23d9402b88a0bb27 It also includes a flamegraph illustrating the issue. It's all in one program for convenience, but in reality the offender not picking up SCM_RIGHTS messages and the suffering program just minding its own business are separate. It is also non-trivial to find the offender when this happens as it can be completely idle while wrecking havoc for the rest of the system. I don't think it's fair to penalize every unix_stream_sendmsg like this. The 16k threshold also doesn't feel very flexible, surely computers are bigger these days and can handle more.