On Tue, May 25, 2021 at 1:40 AM Vlastimil Babka <vbabka@xxxxxxx> wrote: > In put_cpu_partial, we need a stable cpu, but being preempted is not an issue. > So, disable migration instead of preemption. I wouldn't say "not an issue", more like "you're not making it worse". >From what I can tell, the following race can already theoretically happen: task A: put_cpu_partial() calls preempt_disable() task A: oldpage = this_cpu_read(s->cpu_slab->partial) interrupt: kfree() reaches unfreeze_partials() and discards the page task B (on another CPU): reallocates page as page cache task A: reads page->pages and page->pobjects, which are actually halves of the pointer page->lru.prev task B (on another CPU): frees page interrupt: allocates page as SLUB page and places it on the percpu partial list task A: this_cpu_cmpxchg() succeeds which would cause page->pages and page->pobjects to end up containing halves of pointers that would then influence when put_cpu_partial() happens and show up in root-only sysfs files. Maybe that's acceptable, I don't know. But there should probably at least be a comment for now to point out that we're reading union fields of a page that might be in a completely different state. (Someone should probably fix that code sometime and get rid of page->pobjects entirely, given how inaccurate it is...)