From: Jakub Kicinski <kuba@kernel.org>
To: Samiullah Khawaja <skhawaja@google.com>
Cc: "David S . Miller " <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>,
willemb@google.com, almasrymina@google.com,
netdev@vger.kernel.org, Joe Damato <joe@dama.to>
Subject: Re: [PATCH net-next v2] net: Update threaded state in napi config in netif_set_threaded
Date: Wed, 30 Jul 2025 17:55:41 -0700 [thread overview]
Message-ID: <20250730175541.37cfac15@kernel.org> (raw)
In-Reply-To: <20250730182511.4059693-1-skhawaja@google.com>
On Wed, 30 Jul 2025 18:25:11 +0000 Samiullah Khawaja wrote:
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 1c6e755841ce..1abba4fc1eec 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -7023,6 +7023,9 @@ int netif_set_threaded(struct net_device *dev,
> * This should not cause hiccups/stalls to the live traffic.
> */
> list_for_each_entry(napi, &dev->napi_list, dev_list) {
> + if (napi->config)
> + napi->config->threaded = threaded;
> +
> if (!threaded && napi->thread)
> napi_stop_kthread(napi);
> else
Could we possibly just call napi_set_threaded() instead of having the
body of this loop? The first "if (threaded)" in napi_set_threaded()
should do nothing.. and the rest is pretty much copy & paste.
The barrier is not a concern, it's a control path. WDYT?
The test needs to be added to a Makefile, a few more comments on the
contents..
> +def enable_dev_threaded_disable_napi_threaded(cfg, nl) -> None:
> + """
> + Test that when napi threaded is enabled at device level and
> + then disabled at napi level for one napi, the threaded state
> + of all napis is preserved after a change in number of queues.
> + """
> +
> + ip(f"link set dev {cfg.ifname} up")
Why the up? Env should ifup the netdevsim for you..
> + napis = nl.napi_get({'ifindex': cfg.ifindex}, dump=True)
> + ksft_eq(len(napis), 2)
So.. the tests under drivers/net are supposed to be run on HW devices
and netdevsim (both must work). Not sure if running this on real HW
adds much value TBH, up to you if you care about that.
If you don't move the test to net/, and use NetdevSimDev() directly.
If you do let's allow any number of queues >= 2, so ksft_ge() here.
Real drivers are unlikely to have exactly 2 queues.
> + napi0_id = napis[0]['id']
> + napi1_id = napis[1]['id']
> +
> + threaded = cmd(f"cat /sys/class/net/{cfg.ifname}/threaded").stdout
> + defer(_set_threaded_state, cfg, threaded)
> +
> + # set threaded
> + _set_threaded_state(cfg, 1)
> +
> + # check napi threaded is set for both napis
> + _assert_napi_threaded_enabled(nl, napi0_id)
> + _assert_napi_threaded_enabled(nl, napi1_id)
> +
> + # disable threaded for napi1
> + nl.napi_set({'id': napi1_id, 'threaded': 'disabled'})
> +
> + cmd(f"ethtool -L {cfg.ifname} combined 1")
> + cmd(f"ethtool -L {cfg.ifname} combined 2")
And if you decide to keep this in drivers/net it would be good to defer
resetting the queue count to original value too. You can do (untested):
cur = ethtool(f"-l {cfg.ifname}", json=True).get("combined")
or simply assume there is as many queues as there was napis earlier.
And then a defer(ethtool..
> + _assert_napi_threaded_enabled(nl, napi0_id)
> + _assert_napi_threaded_disabled(nl, napi1_id)
--
pw-bot: cr
next prev parent reply other threads:[~2025-07-31 0:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-30 18:25 [PATCH net-next v2] net: Update threaded state in napi config in netif_set_threaded Samiullah Khawaja
2025-07-31 0:55 ` Jakub Kicinski [this message]
2025-07-31 23:39 ` Samiullah Khawaja
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=20250730175541.37cfac15@kernel.org \
--to=kuba@kernel.org \
--cc=almasrymina@google.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=joe@dama.to \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=skhawaja@google.com \
--cc=willemb@google.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;
as well as URLs for NNTP newsgroup(s).