Fix _get_page_size()
PATCH 1/1 Fix _get_page_size()
There is no CONFIG_PAGE_SHIFT stored in /boot/config-uname -r on RHEL systems (maybe all systems?). As a result, tests that make use of _get_page_size() were doing the wrong thing. For example, throtl/002 used it to calculate I/O sizes for direct IO. Those sizes ended up not being a multiple of the logical block size, and hence throtl/002 was failing.
common/rc +1 -6
@@ -562,13 +562,8 @@ _have_systemctl_unit() { return 0 } -# Get system page size from kernel conguration _get_page_size() { - local page_shift - - page_shift=$(_get_kernel_option PAGE_SHIFT) - - echo $((1<< page_shift)) + getconf PAGE_SIZE } # Check if the system page size matches the required size (in bytes).
CC+: Omar, Chaitanya,
Quoted 9 lines · Jeff Moyer
There is no
CONFIG_PAGE_SHIFTstored in/boot/config-uname -ron RHEL systems (maybe all systems?). As a result, tests that make use of_get_page_size()were doing the wrong thing. For example, throtl/002 used it to calculate I/O sizes for direct IO. Those sizes ended up not being a multiple of the logical block size, and hence throtl/002 was failing.Fixes 8eca9fa ("common/rc, scsi/011, zbd/010: introduce _page_size_equals() helper")Signed-off-by Jeff Moyer <[email protected]>
Thanks for finding this out. When I applied the commit in the Fixes tag, I had checked my Fedora system's /boot/config-* files and had found CONFIG_PAGE_SHIFT defined. I wanted to avoid the dependency to getconf, and chose the way to rely on CONFIG_PAGE_SHIFT. But that is not an option for other distros. Today I checked my Debian system, and CONFIG_PAGE_SHIFT was not defined either. Now I see that we should not use CONFIG_PAGE_SHIFT.
Quoted 11 lines
common/rc +0
-1@@ -562,13 +562,8 @@ _have_systemctl_unit() { return 0 } -# Get system page size from kernel conguration
common/rc _have_systemctl_unit() { · line 569
Quoted 10 lines
common/rc +1
-5_get_page_size() { - local page_shift - - page_shift=$(_get_kernel_option PAGE_SHIFT) - - echo $((1<< page_shift)) + getconf PAGE_SIZE } # Check if the system page size matches the required size (in bytes).
The patch above should work, but it creates a new dependeny on the tool getconf. There are 6 test cases that require page size and getconf. Then, we need to check that getconf command is available for the test cases.
$ git grep _page_size
common/rc:_get_page_size() {
common/rc:# Example: _page_size_equals 4096
common/rc:_page_size_equals() {
common/rc: current_size=$(_get_page_size)
tests/scsi/011: _page_size_equals 4096
tests/throtl/002: page_size=$(_get_page_size)
tests/throtl/003: page_size=$(_get_page_size)
tests/throtl/007: page_size=$(_get_page_size)
tests/zbd/010: _page_size_equals 4096
tests/zbd/014: page_size=$(_get_page_size)Havind said that, I think now Linux eco-system is in the phase to add variety of page sizes, and I expect more test cases that depend on page sizes will be added in near future. So, this could be the good timing to add getconf to the blktests minimal requirement list described in README.md. This means that blktests users will need to install glibc-common package for Fedora, or libc-bin package for Debian.
This is a rather fundamental change, so I would like to ask opinions from other blktests users, especially Omar and Chaitanya. What do you think about the idea to add getconf to the requirement list?
Quoted 3 lines · Shin'ichiro Kawasaki
This is a rather fundamental change, so I would like to ask opinions from other blktests users, especially Omar and Chaitanya. What do you think about the idea to add getconf to the requirement list?
CONFIG_PAGE_SHIFT was introduced in the Linux kernel in February 2024 (commit ba89f9c8ccba ("arch: consolidate existing CONFIG_PAGE_SIZE_*KB definitions")). Older kernels had CONFIG_PAGE_SIZE_4KB, CONFIG_PAGE_SIZE_16KB, etc. This means that it is possible to derive the kernel page size from the kernel configuration file for all upstream and distro kernels, isn't it?
Thanks,
Bart.
Quoted 11 lines · Bart Van Assche
Quoted 3 lines · Shin'ichiro Kawasaki
This is a rather fundamental change, so I would like to ask opinions from other blktests users, especially Omar and Chaitanya. What do you think about the idea to add getconf to the requirement list?
CONFIG_PAGE_SHIFTwas introduced in the Linux kernel in February 2024 (commitba89f9c8ccba("arch: consolidate existing CONFIG_PAGE_SIZE_*KB definitions")). Older kernels hadCONFIG_PAGE_SIZE_4KB,CONFIG_PAGE_SIZE_16KB, etc. This means that it is possible to derive the kernel page size from the kernel configuration file for all upstream and distro kernels, isn't it?
I checked the commit is in the tag v6.9. My Debian bookworm system has kernel v6.1, then the config file at /boot does not have CONFIG_PAGE_SHIFT as expected. But it does not have CONFIG_PAGE_SIZE_* either... I'm still afraid that kernel config file approach is not reliable.
$ uname -a Linux testnode3 6.1.0-49-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64 GNU/Linux $ grep PAGE_S /boot/config-6.1.0-49-amd64 CONFIG_PAGE_SIZE_LESS_THAN_64KB=y CONFIG_PAGE_SIZE_LESS_THAN_256KB=y
Quoted 13 lines · Shin'ichiro Kawasaki
Quoted 11 lines · Bart Van Assche
Quoted 3 lines · Shin'ichiro Kawasaki
This is a rather fundamental change, so I would like to ask opinions from other blktests users, especially Omar and Chaitanya. What do you think about the idea to add getconf to the requirement list?
CONFIG_PAGE_SHIFTwas introduced in the Linux kernel in February 2024 (commitba89f9c8ccba("arch: consolidate existing CONFIG_PAGE_SIZE_*KB definitions")). Older kernels hadCONFIG_PAGE_SIZE_4KB,CONFIG_PAGE_SIZE_16KB, etc. This means that it is possible to derive the kernel page size from the kernel configuration file for all upstream and distro kernels, isn't it?
Quoted 4 lines
I checked the commit is in the tag v6.9. My Debian bookworm system has kernel v6.1, then the config file at /boot does not have
CONFIG_PAGE_SHIFTas expected. But it does not have CONFIG_PAGE_SIZE_* either... I'm still afraid that kernel config file approach is not reliable.
Right, for older kernels CONFIG_PAGE_SIZE_*KB is only available for some but not for all supported architectures.
It is not clear to me where the desire to avoid the dependency on getconf comes from? As far as I know it is available on all Linux distro's. Since it is typically included in the C library package it should not introduce a new dependency.
Thanks,
Bart.
Quoted 19 lines · Bart Van Assche
Quoted 13 lines · Shin'ichiro Kawasaki
Quoted 11 lines · Bart Van Assche
Quoted 3 lines · Shin'ichiro Kawasaki
This is a rather fundamental change, so I would like to ask opinions from other blktests users, especially Omar and Chaitanya. What do you think about the idea to add getconf to the requirement list?
CONFIG_PAGE_SHIFTwas introduced in the Linux kernel in February 2024 (commitba89f9c8ccba("arch: consolidate existing CONFIG_PAGE_SIZE_*KB definitions")). Older kernels hadCONFIG_PAGE_SIZE_4KB,CONFIG_PAGE_SIZE_16KB, etc. This means that it is possible to derive the kernel page size from the kernel configuration file for all upstream and distro kernels, isn't it?Quoted 4 lines
I checked the commit is in the tag v6.9. My Debian bookworm system has kernel v6.1, then the config file at /boot does not have
CONFIG_PAGE_SHIFTas expected. But it does not have CONFIG_PAGE_SIZE_* either... I'm still afraid that kernel config file approach is not reliable.
Quoted 7 lines
Right, for older kernels CONFIG_PAGE_SIZE_*KB is only available for some but not for all supported architectures.
It is not clear to me where the desire to avoid the dependency on getconf comes from? As far as I know it is available on all Linux distro's. Since it is typically included in the C library package it should not introduce a new dependency.
I think less dependent is the better in general, and wanted to confirm that it is fine for everybody. If there is no voice to object, I will create a patch to add getconf to the requirement list.
Quoted 23 lines · Shin'ichiro Kawasaki
Quoted 22 lines · Bart Van Assche
Quoted 13 lines · Shin'ichiro Kawasaki
Quoted 11 lines · Bart Van Assche
Quoted 3 lines · Shin'ichiro Kawasaki
This is a rather fundamental change, so I would like to ask opinions from other blktests users, especially Omar and Chaitanya. What do you think about the idea to add getconf to the requirement list?
CONFIG_PAGE_SHIFTwas introduced in the Linux kernel in February 2024 (commitba89f9c8ccba("arch: consolidate existing CONFIG_PAGE_SIZE_*KB definitions")). Older kernels hadCONFIG_PAGE_SIZE_4KB,CONFIG_PAGE_SIZE_16KB, etc. This means that it is possible to derive the kernel page size from the kernel configuration file for all upstream and distro kernels, isn't it?Quoted 4 lines
I checked the commit is in the tag v6.9. My Debian bookworm system has kernel v6.1, then the config file at /boot does not have
CONFIG_PAGE_SHIFTas expected. But it does not have CONFIG_PAGE_SIZE_* either... I'm still afraid that kernel config file approach is not reliable.Right, for older kernels CONFIG_PAGE_SIZE_*KB is only available for some but not for all supported architectures.
Quoted 8 lines
Quoted 4 lines
It is not clear to me where the desire to avoid the dependency on getconf comes from? As far as I know it is available on all Linux distro's. Since it is typically included in the C library package it should not introduce a new dependency.
I think less dependent is the better in general, and wanted to confirm that it is fine for everybody. If there is no voice to object, I will create a patch to add getconf to the requirement list.
I agree with Bart, getconf is ubiquitous enough that it's not worth trying to hack around its absence. In my opinion, parsing kernel config options should be a last resort. If anyone complains about the getconf dependency in the future, I think it'd be better to add a simple src/pagesize.c file that uses sysconf(_SC_PAGESIZE), but I don't expect that to be necessary.
Omar
Quoted 33 lines · Omar Sandoval
Quoted 23 lines · Shin'ichiro Kawasaki
Quoted 22 lines · Bart Van Assche
Quoted 13 lines · Shin'ichiro Kawasaki
Quoted 11 lines · Bart Van Assche
Quoted 3 lines · Shin'ichiro Kawasaki
This is a rather fundamental change, so I would like to ask opinions from other blktests users, especially Omar and Chaitanya. What do you think about the idea to add getconf to the requirement list?
CONFIG_PAGE_SHIFTwas introduced in the Linux kernel in February 2024 (commitba89f9c8ccba("arch: consolidate existing CONFIG_PAGE_SIZE_*KB definitions")). Older kernels hadCONFIG_PAGE_SIZE_4KB,CONFIG_PAGE_SIZE_16KB, etc. This means that it is possible to derive the kernel page size from the kernel configuration file for all upstream and distro kernels, isn't it?Quoted 4 lines
I checked the commit is in the tag v6.9. My Debian bookworm system has kernel v6.1, then the config file at /boot does not have
CONFIG_PAGE_SHIFTas expected. But it does not have CONFIG_PAGE_SIZE_* either... I'm still afraid that kernel config file approach is not reliable.Right, for older kernels CONFIG_PAGE_SIZE_*KB is only available for some but not for all supported architectures.
Quoted 8 lines
Quoted 4 lines
It is not clear to me where the desire to avoid the dependency on getconf comes from? As far as I know it is available on all Linux distro's. Since it is typically included in the C library package it should not introduce a new dependency.
I think less dependent is the better in general, and wanted to confirm that it is fine for everybody. If there is no voice to object, I will create a patch to add getconf to the requirement list.
Quoted 6 lines
I agree with Bart, getconf is ubiquitous enough that it's not worth trying to hack around its absence. In my opinion, parsing kernel config options should be a last resort. If anyone complains about the getconf dependency in the future, I think it'd be better to add a simple
src/pagesize.cfile that usessysconf(_SC_PAGESIZE), but I don't expect that to be necessary.
Omar, thank you for the comment. It's good to have the plan B idea of "src/pagesize.c". I will prepare the patch to add getconf to the requirement list as the plan A.
Quoted 9 lines · Jeff Moyer
There is no
CONFIG_PAGE_SHIFTstored in/boot/config-uname -ron RHEL systems (maybe all systems?). As a result, tests that make use of_get_page_size()were doing the wrong thing. For example, throtl/002 used it to calculate I/O sizes for direct IO. Those sizes ended up not being a multiple of the logical block size, and hence throtl/002 was failing.Fixes 8eca9fa ("common/rc, scsi/011, zbd/010: introduce _page_size_equals() helper")Signed-off-by Jeff Moyer <[email protected]>
FYI, I applied the patch together with the other patch to require the getconf command. Thanks!