From: Nam Cao <namcao@linutronix.de>
To: Kuniyuki Iwashima <kuniyu@google.com>, Jakub Kicinski <kuba@kernel.org>
Cc: "David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-rt-devel@lists.linux.dev
Subject: Re: [PATCH net-next v4 1/1] af_unix: Do not wait for garbage collector in sendmsg()
Date: Sat, 08 Aug 2026 06:07:42 +0200 [thread overview]
Message-ID: <871pc9b6gh.fsf@yellow.woof> (raw)
In-Reply-To: <CAAVpQUC5mY9gZH=LmRvdZb1F+QbxGPuNBgSXvHh6pTzZO5QSNQ@mail.gmail.com>
Kuniyuki Iwashima <kuniyu@google.com> writes:
> On Fri, Aug 7, 2026 at 6:07 PM Jakub Kicinski <kuba@kernel.org> wrote:
>>
>> On Tue, 4 Aug 2026 08:46:16 +0200 Nam Cao wrote:
>> > AF_UNIX sockets' sendmsg() schedules and blocks on the garbage collector if
>> > user has too many inflight unix sockets and there is cyclic reference in
>> > the system. This causes real-time issues, as cyclic reference can be
>> > created by any task in the system, and high priority tasks who do need to
>> > send lots of AF_UNIX sockets get blocked by the garbage collector which
>> > runs as workqueue, causing a priority inversion scenario.
>>
>> Hi Kuniyuki! Any thoughts?
>
> flush_work() makes an insane process slow down by itself and
> the sane users (whose peers receive fd in timely manner) can
> likely acquire the gc lock before insane users.
As mentioned in the cover letter, our definition of "sane users" is
quite arbitrary. I acknowledge that it likely cover most users out
there, possibly all of them. But we can never tell for sure.
> The commit message assumes the GC is low priority,
GC runs as workqueue and thus is low priority.
> and it will be easier to trigger OOM and soft lockup without the
> penalty.
Sorry, perhaps I am still confused somewhere, but how can OOM or soft
lockup be triggered?
At best (or worst?), a task can make the GC iterates over RLIMIT_NOFILE
inflight sockets, so there wouldn't be a soft lockup.
And the number of inflight sockets is capped at RLIMIT_NOFILE, so there
wouldn't be an OOM issue either.
> If priority inversion on RT kernel is the only problem here, there will
> be more flush_work() instances triggered from userspace,
Yes, you are correct and this happens often. The solution usually is
avoiding workqueue. Some times we replace the workqueue with a dedicated
kthread, other times we drop the workqueue and execute the work
synchronously. Otherwise we accept that such API is not real-time-safe
and should not be used by real-time application (we have on-going work
in run-time verification monitors that tell user if they are using an
unsafe API).
> and the real problem is that flush_work() does not implement priority
> inheritance like mutex.
This idea has been brought up in the past. Unfortunately it is no easy
feat.
Nam
prev parent reply other threads:[~2026-08-08 4:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-04 6:46 [PATCH net-next v4 0/1] af_unix: Fix priority inversion issue Nam Cao
2026-08-04 6:46 ` [PATCH net-next v4 1/1] af_unix: Do not wait for garbage collector in sendmsg() Nam Cao
2026-08-08 1:07 ` Jakub Kicinski
2026-08-08 1:40 ` Kuniyuki Iwashima
2026-08-08 4:07 ` Nam Cao [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871pc9b6gh.fsf@yellow.woof \
--to=namcao@linutronix.de \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.