Re: [PATCH] proc: Avoid a thundering herd of threads freeing proc dentries
From: Eric W. Biederman
Date: Fri Jun 19 2020 - 18:47:12 EST
Junxiao Bi <junxiao.bi@xxxxxxxxxx> writes:
> On 6/19/20 10:24 AM, ebiederm@xxxxxxxxxxxx wrote:
>
>> Junxiao Bi <junxiao.bi@xxxxxxxxxx> writes:
>>
>>> Hi Eric,
>>>
>>> The patch didn't improve lock contention.
>> Which raises the question where is the lock contention coming from.
>>
>> Especially with my first variant. Only the last thread to be reaped
>> would free up anything in the cache.
>>
>> Can you comment out the call to proc_flush_pid entirely?
>
> Still high lock contention. Collect the following hot path.
A different location this time.
I know of at least exit_signal and exit_notify that take thread wide
locks, and it looks like exit_mm is another. Those don't use the same
locks as flushing proc.
So I think you are simply seeing a result of the thundering herd of
threads shutting down at once. Given that thread shutdown is fundamentally
a slow path there is only so much that can be done.
If you are up for a project to working through this thundering herd I
expect I can help some. It will be a long process of cleaning up
the entire thread exit process with an eye to performance.
To make incremental progress we are going to need a way to understand
the impact of various changes. Such as my change to reduce the dentry
lock contention when a process is removed from proc. I have the feeling
that made a real world improvement on your test (as the lock no longer
shows up in your profile). Unfortunately whatever that improvement was
it was not relfected in now you read your numbers.
Eric