Re: [BUG] Memory ordering between kmalloc() and kfree()? it's confusing!
From: Christoph Lameter (Ampere)
Date: Thu Feb 26 2026 - 14:07:08 EST
On Fri, 27 Feb 2026, Harry Yoo wrote:
> Ah, alloc/free slowpaths do use cmpxchg128 or spinlock and
> don't mess things up.
>
> But fastpath allocs/frees are served from percpu array that is protected
> by a local_lock. local_lock has a compiler barrier in it, but that's
> not enough.
Well if objects are coming from different folios then that is an issue.
The prior slub approach had no per cpu linked lists and restricted
allocations to the objects of a single page that was only used by a
specific cpu. locks were used when that page changed. There was no need
for further synchronization since accesses were known to only refer to a
single page frame and there was only one cpu accessing.