The patch titled Subject: percpu: fix data race with pcpu_nr_empty_pop_pages has been added to the -mm mm-unstable branch. Its filename is percpu-fix-data-race-with-pcpu_nr_empty_pop_pages.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/percpu-fix-data-race-with-pcpu_nr_empty_pop_pages.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Dennis Zhou <dennis@xxxxxxxxxx> Subject: percpu: fix data race with pcpu_nr_empty_pop_pages Date: Mon, 7 Oct 2024 17:19:42 -0700 Fixes the data race by moving the read to be behind the pcpu_lock. This is okay because the code (initially) above it will not increase the empty populated page count because it is populating backing pages that already have allocations served out of them. Link: https://lkml.kernel.org/r/20241008001942.8114-1-dennis@xxxxxxxxxx Reported-by: kernel test robot <oliver.sang@xxxxxxxxx> Closes: https://lore.kernel.org/oe-lkp/202407191651.f24e499d-oliver.sang@xxxxxxxxx Signed-off-by: Dennis Zhou <dennis@xxxxxxxxxx> Cc: Christoph Lameter <cl@xxxxxxxxx> Cc: Tejun Heo <tj@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/percpu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/mm/percpu.c~percpu-fix-data-race-with-pcpu_nr_empty_pop_pages +++ a/mm/percpu.c @@ -1864,6 +1864,10 @@ restart: area_found: pcpu_stats_area_alloc(chunk, size); + + if (pcpu_nr_empty_pop_pages < PCPU_EMPTY_POP_PAGES_LOW) + pcpu_schedule_balance_work(); + spin_unlock_irqrestore(&pcpu_lock, flags); /* populate if not all pages are already there */ @@ -1891,9 +1895,6 @@ area_found: mutex_unlock(&pcpu_alloc_mutex); } - if (pcpu_nr_empty_pop_pages < PCPU_EMPTY_POP_PAGES_LOW) - pcpu_schedule_balance_work(); - /* clear the areas and return address relative to base address */ for_each_possible_cpu(cpu) memset((void *)pcpu_chunk_addr(chunk, cpu, 0) + off, 0, size); _ Patches currently in -mm which might be from dennis@xxxxxxxxxx are percpu-fix-data-race-with-pcpu_nr_empty_pop_pages.patch