From: "Björn Töpel" <bjorn@kernel.org>
To: Maxime Chevallier <maxime.chevallier@bootlin.com>,
Andrew Lunn <andrew@lunn.ch>, Jakub Kicinski <kuba@kernel.org>,
davem@davemloft.net, Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
Russell King <linux@armlinux.org.uk>,
Shuah Khan <skhan@linuxfoundation.org>,
Bobby Eshleman <bobbyeshleman@meta.com>,
Stanislav Fomichev <sdf@fomichev.me>,
Breno Leitao <leitao@debian.org>
Cc: Maxime Chevallier <maxime.chevallier@bootlin.com>,
thomas.petazzoni@bootlin.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net] selftests: drv-net: devmem: Skip when hugetlbfs isn't supported
Date: Wed, 21 Oct 2026 11:47:21 +0200 [thread overview]
Message-ID: <87qzhj75cm.fsf@all.your.base.are.belong.to.us> (raw)
In-Reply-To: <20261021090852.996899-1-maxime.chevallier@bootlin.com>
Maxime Chevallier <maxime.chevallier@bootlin.com> writes:
> 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).
>
> Fixes: 8ac4255c1e0c ("selftests/net: devmem.py: add check_rx_large_niov")
> Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
> ---
> tools/testing/selftests/drivers/net/hw/devmem_lib.py | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/tools/testing/selftests/drivers/net/hw/devmem_lib.py b/tools/testing/selftests/drivers/net/hw/devmem_lib.py
> index 3554954a6691..24637fb180ca 100644
> --- a/tools/testing/selftests/drivers/net/hw/devmem_lib.py
> +++ b/tools/testing/selftests/drivers/net/hw/devmem_lib.py
> @@ -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...
Reviewed-by: Björn Töpel <bjorn@kernel.org>
prev parent reply other threads:[~2026-10-21 9:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 9:08 Maxime Chevallier
2026-10-21 9:47 ` Björn Töpel [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87qzhj75cm.fsf@all.your.base.are.belong.to.us \
--to=bjorn@kernel.org \
--cc=andrew@lunn.ch \
--cc=bobbyeshleman@meta.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=maxime.chevallier@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
--cc=skhan@linuxfoundation.org \
--cc=thomas.petazzoni@bootlin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®