Go to file
Samiullah Khawaja 689883de94 net: stop napi kthreads when THREADED napi is disabled
Once the THREADED napi is disabled, the napi kthread should also be
stopped. Keeping the kthread intact after disabling THREADED napi makes
the PID of this kthread show up in the output of netlink 'napi-get' and
ps -ef output.

The is discussed in the patch below:
https://lore.kernel.org/all/20250502191548.559cc416@kernel.org

NAPI kthread should stop only if,

- There are no pending napi poll scheduled for this thread.
- There are no new napi poll scheduled for this thread while it has
  stopped.
- The ____napi_schedule can correctly fallback to the softirq for napi
  polling.

Since napi_schedule_prep provides mutual exclusion over STATE_SCHED bit,
it is safe to unset the STATE_THREADED when SCHED_THREADED is set or the
SCHED bit is not set. SCHED_THREADED being set means that SCHED is
already set and the kthread owns this napi.

To disable threaded napi, unset STATE_THREADED bit safely if
SCHED_THREADED is set or SCHED is unset. Once STATE_THREADED is unset
safely then wait for the kthread to unset the SCHED_THREADED bit so it
safe to stop the kthread.

Add a new test in nl_netdev to verify this behaviour.

Tested:
 ./tools/testing/selftests/net/nl_netdev.py
 TAP version 13
 1..6
 ok 1 nl_netdev.empty_check
 ok 2 nl_netdev.lo_check
 ok 3 nl_netdev.page_pool_check
 ok 4 nl_netdev.napi_list_check
 ok 5 nl_netdev.dev_set_threaded
 ok 6 nl_netdev.nsim_rxq_reset_down
 # Totals: pass:6 fail:0 xfail:0 xpass:0 skip:0 error:0

Ran neper for 300 seconds and did enable/disable of thread napi in a
loop continuously.

Signed-off-by: Samiullah Khawaja <skhawaja@google.com>
Link: https://patch.msgid.link/20250609173015.3851695-1-skhawaja@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2025-06-10 17:52:03 -07:00
Documentation linux-can-next-for-6.17-20250610 2025-06-10 15:44:47 -07:00
LICENSES
arch Notable changes: 2025-06-05 11:45:33 -07:00
block - dm: better error handling when reloading a table 2025-06-03 15:54:46 -07:00
certs
crypto
drivers net: dlink: enable RMON MMIO access on supported devices 2025-06-10 17:47:13 -07:00
fs four smb3 server fixes 2025-06-04 19:23:37 -07:00
include linux-can-next-for-6.17-20250610 2025-06-10 15:44:47 -07:00
init Rust changes for v6.16 2025-06-04 21:18:37 -07:00
io_uring
ipc
kernel sched_ext: Fixes for v6.16-rc1 2025-06-04 12:07:16 -07:00
lib
mm slab updates for 6.16 2025-06-04 08:59:59 -07:00
net net: stop napi kthreads when THREADED napi is disabled 2025-06-10 17:52:03 -07:00
rust Rust changes for v6.16 2025-06-04 21:18:37 -07:00
samples
scripts Rust changes for v6.16 2025-06-04 21:18:37 -07:00
security
sound soundwire updates for 6.16 2025-06-05 08:07:24 -07:00
tools net: stop napi kthreads when THREADED napi is disabled 2025-06-10 17:52:03 -07:00
usr
virt
.clang-format
.clippy.toml
.cocciconfig
.editorconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap Rust changes for v6.16 2025-06-04 21:18:37 -07:00
.pylintrc
.rustfmt.toml
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS MAINTAINERS: add entry for crypto library 2025-06-05 12:15:04 -07:00
Makefile
README

README

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the reStructuredText markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.