Re: [RFC PATCH 09/10] memcg: trylock stock for objcg
From: Sebastian Andrzej Siewior
Date: Fri Mar 14 2025 - 07:47:10 EST
On 2025-03-13 23:15:10 [-0700], Shakeel Butt wrote:
> To make objcg stock functions work without disabling irq, we need to
> convert those function to use localtry_trylock_irqsave() instead of
> localtry_lock_irqsave(). This patch for now just does the conversion and
> later patch will eliminate the irq disabling code.
>
> Signed-off-by: Shakeel Butt <shakeel.butt@xxxxxxxxx>
> ---
> mm/memcontrol.c | 14 +++++++++++---
> 1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index c803d2f5e322..ba5d004049d3 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -2764,7 +2764,11 @@ static void mod_objcg_state(struct obj_cgroup *objcg, struct pglist_data *pgdat,
> unsigned long flags;
> int *bytes;
>
> - localtry_lock_irqsave(&memcg_stock.stock_lock, flags);
> + if (!localtry_trylock_irqsave(&memcg_stock.stock_lock, flags)) {
Don't you need to change the of memcg_stock.stock_lock? Didn't we
introduce an explicit different type for this trylock feature?
> + __mod_objcg_mlstate(objcg, pgdat, idx, nr);
> + return;
> + }
> +
> stock = this_cpu_ptr(&memcg_stock);
>
> /*
Sebastian