Re: [PATCH net-next v2 5/5] net: netconsole: Defer netpoll cleanup to avoid lock release during list traversal
From: Jakub Kicinski
Date: Wed Aug 07 2024 - 09:54:33 EST
On Wed, 7 Aug 2024 02:16:51 -0700 Breno Leitao wrote:
> Current issue:
> - The `target_list_lock` spinlock is held while iterating over
> target_list() entries.
> - Mid-loop, the lock is released to call __netpoll_cleanup(), then
> reacquired.
> - This practice compromises the protection provided by
> `target_list_lock`.
>
> Reason for current design:
> 1. __netpoll_cleanup() may sleep, incompatible with holding a spinlock.
> 2. target_list_lock must be a spinlock because write_msg() cannot sleep.
> (See commit b5427c27173e ("[NET] netconsole: Support multiple logging
> targets"))
>
> Defer the cleanup of the netpoll structure to outside the
> target_list_lock() protected area. Create another list
> (target_cleanup_list) to hold the entries that need to be cleaned up,
> and clean them using a mutex (target_cleanup_list_lock).
Haven't looked closely but in the configs CI uses this breaks the build:
drivers/net/netconsole.c:251:13: error: ‘netconsole_process_cleanups’ defined but not used [-Werror=unused-function]
251 | static void netconsole_process_cleanups(void)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
--
pw-bot: cr