Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm/page_alloc: make percpu_pagelist_high_fraction reads lock-free

When page isolation loops indefinitely during memory offline, reading
/proc/sys/vm/percpu_pagelist_high_fraction blocks on pcp_batch_high_lock,
causing hung task warnings.

Make procfs reads lock-free since percpu_pagelist_high_fraction is a
simple integer with naturally atomic reads, writers still serialize via
the mutex.

This prevents hung task warnings when reading the procfs file during
long-running memory offline operations.

[akpm@linux-foundation.org: add comment, per Michal]
Link: https://lkml.kernel.org/r/aS_y9AuJQFydLEXo@tiehlicka
Link: https://lkml.kernel.org/r/20251201060009.1420792-1-aboorvad@linux.ibm.com
Signed-off-by: Aboorva Devarajan <aboorvad@linux.ibm.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Brendan Jackman <jackmanb@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Zi Yan <ziy@nvidia.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Aboorva Devarajan and committed by
Andrew Morton
b9efe36b a38be546

+9 -1
+9 -1
mm/page_alloc.c
··· 6667 6667 int old_percpu_pagelist_high_fraction; 6668 6668 int ret; 6669 6669 6670 + /* 6671 + * Avoid using pcp_batch_high_lock for reads as the value is read 6672 + * atomically and a race with offlining is harmless. 6673 + */ 6674 + 6675 + if (!write) 6676 + return proc_dointvec_minmax(table, write, buffer, length, ppos); 6677 + 6670 6678 mutex_lock(&pcp_batch_high_lock); 6671 6679 old_percpu_pagelist_high_fraction = percpu_pagelist_high_fraction; 6672 6680 6673 6681 ret = proc_dointvec_minmax(table, write, buffer, length, ppos); 6674 - if (!write || ret < 0) 6682 + if (ret < 0) 6675 6683 goto out; 6676 6684 6677 6685 /* Sanity checking to avoid pcp imbalance */