selftests: drv-net: devmem: Skip when hugetlbfs isn't supported
Subsystems (3)
PATCH 1/1 selftests: drv-net: devmem: Skip when hugetlbfs isn't supported
The devmem selftest requires accessing /proc/sys/vm/nr_hugepages, which is only available when hugetlbfs is supported. This isn't the case on all CPU architectures, for example it isn't supported on ARM 32-bits on cores that don't support LPAE.
On these devices, the devmem kselftest doesn't skip gracefully, it hits an exception while trying to open the nr_hugepages file :
# Exception| _reserve_hugepages() # Exception| ~~~~~~~~~~~~~~~~~~^^ # Exception| File "/usr/lib/kselftests/drivers/net/hw/devmem_lib.py", line 36, in _reserve_hugepages # Exception| with open(NR_HUGEPAGES_FILE, 'r+', encoding='utf-8') as f: # Exception| ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ # Exception| FileNotFoundError: [Errno 2] No such file or directory: '/proc/sys/vm/nr_hugepages'
Let's check if the file exists before trying to open it, and return immediately if we can't.
The _reserve_hugepages() runs as part of the "require_devmem()", that skips if devmem itself isn't supported. Before the blamed commit, this check was done prior to accessing nr_hugepages, so the problem wasn't showing.
This has been found by trying to run the selftest on stmmac, on an Altera CycloneV SoC (Cortex A9, doesn't support hugepages).
--- tools/testing/selftests/drivers/net/hw/devmem_lib.py | 2 ++ 1 file changed, 2 insertions(+)
tools/testing/selftests/drivers/net/hw/devmem_lib.py +2 -0
@@ -33,6 +33,8 @@ def _restore_nr_hugepages(nr_hugepages): def _reserve_hugepages(want=64): """Raise nr_hugepages to @want and arrange for it to be restored.""" + if not os.path.exists(NR_HUGEPAGES_FILE): + return with open(NR_HUGEPAGES_FILE, 'r+', encoding='utf-8') as f: nr_hugepages = int(f.read().strip()) if nr_hugepages >= want:
Signature · 1 line
2.56.0
Quoted 37 lines · Maxime Chevallier
The devmem selftest requires accessing
/proc/sys/vm/nr_hugepages, which is only available when hugetlbfs is supported. This isn't the case on all CPU architectures, for example it isn't supported on ARM 32-bits on cores that don't support LPAE.On these devices, the devmem kselftest doesn't skip gracefully, it hits an exception while trying to open the
nr_hugepagesfile :# Exception| _reserve_hugepages() # Exception| ~~~~~~~~~~~~~~~~~~^^ # Exception| File "/usr/lib/kselftests/drivers/net/hw/devmem_lib.py", line 36, in _reserve_hugepages # Exception| with open(NR_HUGEPAGES_FILE, 'r+', encoding='utf-8') as f: # Exception| ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ # Exception| FileNotFoundError: [Errno 2] No such file or directory: '/proc/sys/vm/nr_hugepages'Let's check if the file exists before trying to open it, and return immediately if we can't.
The
_reserve_hugepages()runs as part of the "require_devmem()", that skips if devmem itself isn't supported. Before the blamed commit, this check was done prior to accessingnr_hugepages, so the problem wasn't showing.This has been found by trying to run the selftest on stmmac, on an Altera CycloneV SoC (Cortex A9, doesn't support hugepages).
Fixes 8ac4255c1e0c ("selftests/net: devmem.py: add check_rx_large_niov")Signed-off-by Maxime Chevallier <[email protected]>--- tools/testing/selftests/drivers/net/hw/devmem_lib.py | 2 ++ 1 file changed, 2 insertions(+)tools/testing/selftests/drivers/net/hw/devmem_lib.py +0
-0
tools/testing/selftests/drivers/net/hw/devmem_lib.py def _restore_nr_hugepages(nr_hugepages): · line 37
Quoted 5 lines
tools/testing/selftests/drivers/net/hw/devmem_lib.py +2
-0@@ -33,6 +33,8 @@ def _restore_nr_hugepages(nr_hugepages): def _reserve_hugepages(want=64): """Raise nr_hugepages to @want and arrange for it to be restored.""" + if not os.path.exists(NR_HUGEPAGES_FILE): + return
Maybe raise a KsftSkipEx() would be more robust? No biggie...
Quoted 23 lines · Maxime Chevallier
The devmem selftest requires accessing
/proc/sys/vm/nr_hugepages, which is only available when hugetlbfs is supported. This isn't the case on all CPU architectures, for example it isn't supported on ARM 32-bits on cores that don't support LPAE.On these devices, the devmem kselftest doesn't skip gracefully, it hits an exception while trying to open the
nr_hugepagesfile :# Exception| _reserve_hugepages() # Exception| ~~~~~~~~~~~~~~~~~~^^ # Exception| File "/usr/lib/kselftests/drivers/net/hw/devmem_lib.py", line 36, in _reserve_hugepages # Exception| with open(NR_HUGEPAGES_FILE, 'r+', encoding='utf-8') as f: # Exception| ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ # Exception| FileNotFoundError: [Errno 2] No such file or directory: '/proc/sys/vm/nr_hugepages'Let's check if the file exists before trying to open it, and return immediately if we can't.
The
_reserve_hugepages()runs as part of the "require_devmem()", that skips if devmem itself isn't supported. Before the blamed commit, this check was done prior to accessingnr_hugepages, so the problem wasn't showing.
Quoted 5 lines
This has been found by trying to run the selftest on stmmac, on an Altera CycloneV SoC (Cortex A9, doesn't support hugepages).
Fixes 8ac4255c1e0c ("selftests/net: devmem.py: add check_rx_large_niov")Signed-off-by Maxime Chevallier <[email protected]>
Jakub Kicinski
maintainerQuoted 6 lines · On Wed, 21 Oct 2026 11:08:51 +0200 Maxime Chevallier wrote:
The devmem selftest requires accessing
/proc/sys/vm/nr_hugepages, which is only available when hugetlbfs is supported. This isn't the case on all CPU architectures, for example it isn't supported on ARM 32-bits on cores that don't support LPAE.On these devices, the devmem kselftest doesn't skip gracefully
We don't require graceful skipping. If anything IMO hiding the stack traces isn't great.
If the check is extraneous and makes us fail some tests which don't actually require huge pages please make that clear in the commit message. Otherwise the net benefit of the changes is unclear.
Signature · 1 line
pw-bot: cr
Quoted 6 lines · Jakub Kicinski
Quoted 5 lines · On Wed, 21 Oct 2026 11:08:51 +0200 Maxime Chevallier wrote:
The devmem selftest requires accessing
/proc/sys/vm/nr_hugepages, which is only available when hugetlbfs is supported. This isn't the case on all CPU architectures, for example it isn't supported on ARM 32-bits on cores that don't support LPAE.
Quoted 8 lines
Quoted 1 line
On these devices, the devmem kselftest doesn't skip gracefully
We don't require graceful skipping. If anything IMO hiding the stack traces isn't great.
If the check is extraneous and makes us fail some tests which don't actually require huge pages please make that clear in the commit message. Otherwise the net benefit of the changes is unclear.
hugetlbfs isn't required for devmem AFAICS, but the blamed commit moved the access to nr_hugepages before the actual "is devmem actually supported" test.
I don't expect the full test suite to gracefully run/skip for devmem on these arm32 platforms TBH, it's likely that devmem is only something that's been used on platforms that support hugetlbfs anyways, but strictly speaking both features are unrelated.
Maxime
Jakub Kicinski
maintainerQuoted 16 lines · On Mon, 26 Oct 2026 10:38:50 +0100 Maxime Chevallier wrote:
Quoted 6 lines · Jakub Kicinski
Quoted 5 lines · On Wed, 21 Oct 2026 11:08:51 +0200 Maxime Chevallier wrote:
The devmem selftest requires accessing
/proc/sys/vm/nr_hugepages, which is only available when hugetlbfs is supported. This isn't the case on all CPU architectures, for example it isn't supported on ARM 32-bits on cores that don't support LPAE.Quoted 8 lines
Quoted 1 line
On these devices, the devmem kselftest doesn't skip gracefully
We don't require graceful skipping. If anything IMO hiding the stack traces isn't great.
If the check is extraneous and makes us fail some tests which don't actually require huge pages please make that clear in the commit message. Otherwise the net benefit of the changes is unclear.
Quoted 8 lines
hugetlbfs isn't required for devmem AFAICS, but the blamed commit moved the access to
nr_hugepagesbefore the actual "is devmem actually supported" test.I don't expect the full test suite to gracefully run/skip for devmem on these arm32 platforms TBH, it's likely that devmem is only something that's been used on platforms that support hugetlbfs anyways, but strictly speaking both features are unrelated.
For max clarity I should have simply asked - does it make any test which previously failed pass on any of your platforms? (incl. some WIP patches that'd add devmem support) That's basically the criteria I think we should use.
Quoted 26 lines · Jakub Kicinski
Quoted 16 lines · On Mon, 26 Oct 2026 10:38:50 +0100 Maxime Chevallier wrote:
Quoted 6 lines · Jakub Kicinski
Quoted 5 lines · On Wed, 21 Oct 2026 11:08:51 +0200 Maxime Chevallier wrote:
The devmem selftest requires accessing
/proc/sys/vm/nr_hugepages, which is only available when hugetlbfs is supported. This isn't the case on all CPU architectures, for example it isn't supported on ARM 32-bits on cores that don't support LPAE.Quoted 8 lines
Quoted 1 line
On these devices, the devmem kselftest doesn't skip gracefully
We don't require graceful skipping. If anything IMO hiding the stack traces isn't great.
If the check is extraneous and makes us fail some tests which don't actually require huge pages please make that clear in the commit message. Otherwise the net benefit of the changes is unclear.
Quoted 8 lines
hugetlbfs isn't required for devmem AFAICS, but the blamed commit moved the access to
nr_hugepagesbefore the actual "is devmem actually supported" test.I don't expect the full test suite to gracefully run/skip for devmem on these arm32 platforms TBH, it's likely that devmem is only something that's been used on platforms that support hugetlbfs anyways, but strictly speaking both features are unrelated.
Quoted 4 lines
For max clarity I should have simply asked - does it make any test which previously failed pass on any of your platforms? (incl. some WIP patches that'd add devmem support) That's basically the criteria I think we should use.
I see, then we can drop that patch. It would go from a "file not found" python exception trace to a skip. This is a nice criteria for me to follow, I'll move on to other tests :)
Maxime