Re: [PATCH] percpu: fix race on alloc failed warning limit

From: Christoph Lameter (Ampere)
Date: Tue Sep 02 2025 - 13:40:12 EST


On Fri, 22 Aug 2025, Vlad Dumitrescu wrote:

> + if (do_warn && atomic_read(&warn_limit) > 0) {
> + int remaining = atomic_dec_return(&warn_limit);


The code creates a race condition since another atomic_dec_return() can
happen on another cpu between these two lines. warn_limit can go negative.

Use a single atomic operation instead?