diff mbox series

[net] net: page_pool: replace ASSERT_RTNL() in page_pool_init()

Message ID 20250324014639.4105332-1-dw@davidwei.uk (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net] net: page_pool: replace ASSERT_RTNL() in page_pool_init() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 2 maintainers not CCed: ilias.apalodimas@linaro.org horms@kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes fail Problems with Fixes tag: 1
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch warning WARNING: Unknown commit id '1d22d3060b9b', maybe rebased or not pulled?
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 3 this patch: 3
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2025-03-24--12-00 (tests: 896)

Commit Message

David Wei March 24, 2025, 1:46 a.m. UTC
Replace a stray ASSERT_RTNL() in page_pool_init() with
netdev_assert_locked().

Fixes: 1d22d3060b9b ("net: drop rtnl_lock for queue_mgmt operations")
Signed-off-by: David Wei <dw@davidwei.uk>
---
 net/core/page_pool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stanislav Fomichev March 24, 2025, 2:39 a.m. UTC | #1
On 03/23, David Wei wrote:
> Replace a stray ASSERT_RTNL() in page_pool_init() with
> netdev_assert_locked().
> 
> Fixes: 1d22d3060b9b ("net: drop rtnl_lock for queue_mgmt operations")
> Signed-off-by: David Wei <dw@davidwei.uk>
> ---
>  net/core/page_pool.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/core/page_pool.c b/net/core/page_pool.c
> index f5e908c9e7ad..2f469b02ea31 100644
> --- a/net/core/page_pool.c
> +++ b/net/core/page_pool.c
> @@ -281,7 +281,7 @@ static int page_pool_init(struct page_pool *pool,
>  		 * configuration doesn't change while we're initializing
>  		 * the page_pool.
>  		 */
> -		ASSERT_RTNL();
> +		netdev_assert_locked(params->netdev);
>  		rxq = __netif_get_rx_queue(pool->slow.netdev,
>  					   pool->slow.queue_idx);
>  		pool->mp_priv = rxq->mp_params.mp_priv;

Not sure we can do this unconditionally. Since we still have plenty of
drivers that might not use netdev instance lock (yet). Probably should
be something like the following?

if (netdev_need_ops_lock(params->netdev))
	netdev_assert_locked(params->netdev);
else
	ASSERT_RTNL();

?

We should probably wait for https://lore.kernel.org/netdev/20250312223507.805719-11-kuba@kernel.org/T/#m2053ac617759a9005806e56a7df97c378b76ec77
to land and use netdev_ops_assert_locked instead?
Andrew Lunn March 24, 2025, 2:18 p.m. UTC | #2
On Sun, Mar 23, 2025 at 06:46:39PM -0700, David Wei wrote:
> Replace a stray ASSERT_RTNL() in page_pool_init() with
> netdev_assert_locked().
> 
> Fixes: 1d22d3060b9b ("net: drop rtnl_lock for queue_mgmt operations")
> Signed-off-by: David Wei <dw@davidwei.uk>
> ---
>  net/core/page_pool.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/core/page_pool.c b/net/core/page_pool.c
> index f5e908c9e7ad..2f469b02ea31 100644
> --- a/net/core/page_pool.c
> +++ b/net/core/page_pool.c
> @@ -281,7 +281,7 @@ static int page_pool_init(struct page_pool *pool,
>  		 * configuration doesn't change while we're initializing
>  		 * the page_pool.
>  		 */
> -		ASSERT_RTNL();
> +		netdev_assert_locked(params->netdev);

Adding a bit more context:

        if (pool->slow.flags & PP_FLAG_ALLOW_UNREADABLE_NETMEM) {
                /* We rely on rtnl_lock()ing to make sure netdev_rx_queue
                 * configuration doesn't change while we're initializing
                 * the page_pool.
                 */
                ASSERT_RTNL();

If ASSERT_RTNL() is now wrong, you also need to update the comment.

	Andrew
David Wei March 24, 2025, 6:24 p.m. UTC | #3
On 2025-03-23 19:39, Stanislav Fomichev wrote:
> On 03/23, David Wei wrote:
>> Replace a stray ASSERT_RTNL() in page_pool_init() with
>> netdev_assert_locked().
>>
>> Fixes: 1d22d3060b9b ("net: drop rtnl_lock for queue_mgmt operations")
>> Signed-off-by: David Wei <dw@davidwei.uk>
>> ---
>>  net/core/page_pool.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/net/core/page_pool.c b/net/core/page_pool.c
>> index f5e908c9e7ad..2f469b02ea31 100644
>> --- a/net/core/page_pool.c
>> +++ b/net/core/page_pool.c
>> @@ -281,7 +281,7 @@ static int page_pool_init(struct page_pool *pool,
>>  		 * configuration doesn't change while we're initializing
>>  		 * the page_pool.
>>  		 */
>> -		ASSERT_RTNL();
>> +		netdev_assert_locked(params->netdev);
>>  		rxq = __netif_get_rx_queue(pool->slow.netdev,
>>  					   pool->slow.queue_idx);
>>  		pool->mp_priv = rxq->mp_params.mp_priv;
> 
> Not sure we can do this unconditionally. Since we still have plenty of
> drivers that might not use netdev instance lock (yet). Probably should
> be something like the following?
> 
> if (netdev_need_ops_lock(params->netdev))
> 	netdev_assert_locked(params->netdev);
> else
> 	ASSERT_RTNL();
> 
> ?
> 
> We should probably wait for https://lore.kernel.org/netdev/20250312223507.805719-11-kuba@kernel.org/T/#m2053ac617759a9005806e56a7df97c378b76ec77
> to land and use netdev_ops_assert_locked instead?

Ah I didn't realise that migration hasn't entirely happened. Yes, I'll
wait for netdev_ops_assert_locked() first.
David Wei March 24, 2025, 6:25 p.m. UTC | #4
On 2025-03-24 07:18, Andrew Lunn wrote:
> On Sun, Mar 23, 2025 at 06:46:39PM -0700, David Wei wrote:
>> Replace a stray ASSERT_RTNL() in page_pool_init() with
>> netdev_assert_locked().
>>
>> Fixes: 1d22d3060b9b ("net: drop rtnl_lock for queue_mgmt operations")
>> Signed-off-by: David Wei <dw@davidwei.uk>
>> ---
>>  net/core/page_pool.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/net/core/page_pool.c b/net/core/page_pool.c
>> index f5e908c9e7ad..2f469b02ea31 100644
>> --- a/net/core/page_pool.c
>> +++ b/net/core/page_pool.c
>> @@ -281,7 +281,7 @@ static int page_pool_init(struct page_pool *pool,
>>  		 * configuration doesn't change while we're initializing
>>  		 * the page_pool.
>>  		 */
>> -		ASSERT_RTNL();
>> +		netdev_assert_locked(params->netdev);
> 
> Adding a bit more context:
> 
>         if (pool->slow.flags & PP_FLAG_ALLOW_UNREADABLE_NETMEM) {
>                 /* We rely on rtnl_lock()ing to make sure netdev_rx_queue
>                  * configuration doesn't change while we're initializing
>                  * the page_pool.
>                  */
>                 ASSERT_RTNL();
> 
> If ASSERT_RTNL() is now wrong, you also need to update the comment.

Thanks, I'll update the docs too after switching to
netdev_ops_assert_locked().

> 
> 	Andrew
diff mbox series

Patch

diff --git a/net/core/page_pool.c b/net/core/page_pool.c
index f5e908c9e7ad..2f469b02ea31 100644
--- a/net/core/page_pool.c
+++ b/net/core/page_pool.c
@@ -281,7 +281,7 @@  static int page_pool_init(struct page_pool *pool,
 		 * configuration doesn't change while we're initializing
 		 * the page_pool.
 		 */
-		ASSERT_RTNL();
+		netdev_assert_locked(params->netdev);
 		rxq = __netif_get_rx_queue(pool->slow.netdev,
 					   pool->slow.queue_idx);
 		pool->mp_priv = rxq->mp_params.mp_priv;