[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231020104728.2060-1-hdanton@sina.com>
Date: Fri, 20 Oct 2023 18:47:28 +0800
From: Hillf Danton <hdanton@...a.com>
To: Ivan Babrou <ivan@...udflare.com>
Cc: Linux Kernel Network Developers <netdev@...r.kernel.org>,
kernel-team <kernel-team@...udflare.com>,
Eric Dumazet <edumazet@...gle.com>,
Paolo Abeni <pabeni@...hat.com>,
linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: wait_for_unix_gc can cause CPU overload for well behaved programs
On Thu, 19 Oct 2023 15:35:01 -0700 Ivan Babrou <ivan@...udflare.com>
> 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.
See if the diff below works for you, which prevents concurrent spinning
of unix_gc_lock, a variant of spin_trylock().
Hillf
--- x/net/unix/garbage.c
+++ y/net/unix/garbage.c
@@ -211,15 +211,10 @@ void unix_gc(void)
struct list_head cursor;
LIST_HEAD(not_cycle_list);
+ if (test_and_set_bit(0, &gc_in_progress))
+ return;
spin_lock(&unix_gc_lock);
- /* Avoid a recursive GC. */
- if (gc_in_progress)
- goto out;
-
- /* Paired with READ_ONCE() in wait_for_unix_gc(). */
- WRITE_ONCE(gc_in_progress, true);
-
/* First, select candidates for garbage collection. Only
* in-flight sockets are considered, and from those only ones
* which don't have any external reference.
--
Powered by blists - more mailing lists