Re: [PATCH] mm: memcg: provide accurate stats for userspace reads
From: Waiman Long
Date: Tue Aug 15 2023 - 11:46:27 EST
On 8/14/23 20:35, Tejun Heo wrote:
Hello,
On Mon, Aug 14, 2023 at 05:28:22PM -0700, Yosry Ahmed wrote:
So, the original design used mutex for synchronize flushing with the idea
being that updates are high freq but reads are low freq and can be
relatively slow. Using rstats for mm internal operations changed this
assumption quite a bit and we ended up switching that mutex with a lock.
Naive question, do mutexes handle thundering herd problems better than
spinlocks? I would assume so but I am not sure.
I don't know. We can ask Waiman if that becomes a problem.
We had essentially solved the thundering herd problems for both
spinlocks and mutexes. Both types of lock waiters will spin in their own
cachelines (in the OSP wait queue in the case of mutex) except one that
is at the head of the queue. So there should be minimal cacheline
bouncing. One should certainly uses mutexes in sleep-able context or
when the critical section is long.
Cheers,
Longman