Re: [PATCH 3/3] mm: memcg: use non-unified stats flushing for userspace reads

From: Waiman Long
Date: Mon Aug 28 2023 - 13:28:59 EST



On 8/28/23 13:07, Yosry Ahmed wrote:

Here I agree with you. Let's go with the approach which is easy to
undo for now. Though I prefer the new explicit interface for flushing,
that step would be very hard to undo. Let's reevaluate if the proposed
approach shows negative impact on production traffic and I think
Cloudflare folks can give us the results soon.
Do you prefer we also switch to using a mutex (with preemption
disabled) to avoid the scenario Michal described where flushers give
up the lock and sleep resulting in an unbounded wait time in the worst
case?

Locking with mutex with preemption disabled is an oxymoron. Use spinlock if you want to have preemption disabled. The purpose of usiing mutex is to allow the lock owner to sleep, but you can't sleep with preemption disabled. You need to enable preemption first. You can disable preemption for a short time in a non-sleeping section of the lock critical section, but I would not recommend disabling preemption for the whole critical section.

Cheers,
Longman