]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests/cgroup: rename PAGE_SIZE to BUF_SIZE in cgroup_util
authorLi Wang <li.wang@linux.dev>
Fri, 24 Apr 2026 04:00:55 +0000 (12:00 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 29 May 2026 04:04:46 +0000 (21:04 -0700)
commit6e9f5c2eecd107cf9a10fd22d311b2c49026f474
tree7019ddca6ebddc0e14c77dada1607b3a68d8c431
parentb19ee588e159c71f0d314246a944dcfc3e2a6009
selftests/cgroup: rename PAGE_SIZE to BUF_SIZE in cgroup_util

The cgroup utility code defines a local PAGE_SIZE macro hardcoded to 4096,
which is used primarily as a generic buffer size for reading cgroup and
proc files.  This naming is misleading because the value has nothing to do
with the actual page size of the system.  On architectures with larger
pages (e.g., 64K on arm64 or ppc64), the name suggests a relationship that
does not exist.  Additionally, the name can shadow or conflict with
PAGE_SIZE definitions from system headers, leading to confusion or subtle
bugs.

To resolve this, rename the macro to BUF_SIZE to accurately reflect its
purpose as a general I/O buffer size.

Furthermore, test_memcontrol currently relies on this hardcoded 4K value
to stride through memory and trigger page faults.  Update this logic to
use the actual system page size dynamically.  This micro-optimizes the
memory faulting process by ensuring it iterates correctly and efficiently
based on the underlying architecture's true page size.  (This part from
Waiman)

Link: https://lore.kernel.org/20260424040059.12940-5-li.wang@linux.dev
Signed-off-by: Li Wang <li.wang@linux.dev>
Signed-off-by: Waiman Long <longman@redhat.com>
Acked-by: Nhat Pham <nphamcs@gmail.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Michal Koutný <mkoutny@suse.com>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Tejun Heo <tj@kernel.org>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Yosry Ahmed <yosryahmed@google.com>
Cc: Chengming Zhou <chengming.zhou@linux.dev>
Cc: Jiayuan Chen <jiayuan.chen@linux.dev>
Cc: Yosry Ahmed <yosry@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
tools/testing/selftests/cgroup/lib/cgroup_util.c
tools/testing/selftests/cgroup/lib/include/cgroup_util.h
tools/testing/selftests/cgroup/test_core.c
tools/testing/selftests/cgroup/test_freezer.c
tools/testing/selftests/cgroup/test_memcontrol.c