Re: [PATCH v1] mm/shrinker: simplify shrinker_memcg_alloc() using guard()
From: Qi Zheng
Date: Tue May 12 2026 - 05:20:15 EST
On 5/12/26 4:55 PM, wangxuewen wrote:
Use guard(mutex) to automatically handle shrinker_mutex locking and
unlocking in shrinker_memcg_alloc(). This removes the explicit
mutex_unlock() call, the goto-based error path, and the redundant
ret variable, resulting in cleaner and more concise code.
I'm inclined to use guard() only for newly added code. If we were to
convert existing code, there would be countless places across the
kernel that need updating.