diff mbox series

[net-next,v1] page_pool: remove WARN_ON() with OR

Message ID 20240605161924.3162588-1-dw@davidwei.uk (mailing list archive)
State Accepted
Commit 3e61103b2f7887af0be402a79b9c70425ceba3e3
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v1] page_pool: remove WARN_ON() with OR | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 903 this patch: 903
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 905 this patch: 905
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 success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 907 this patch: 907
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
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-2024-06-07--09-00 (tests: 1041)

Commit Message

David Wei June 5, 2024, 4:19 p.m. UTC
Having an OR in WARN_ON() makes me sad because it's impossible to tell
which condition is true when triggered.

Split a WARN_ON() with an OR in page_pool_disable_direct_recycling().

Signed-off-by: David Wei <dw@davidwei.uk>
---
 net/core/page_pool.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Mina Almasry June 5, 2024, 4:30 p.m. UTC | #1
On Wed, Jun 5, 2024 at 9:20 AM David Wei <dw@davidwei.uk> wrote:
>
> Having an OR in WARN_ON() makes me sad because it's impossible to tell
> which condition is true when triggered.
>
> Split a WARN_ON() with an OR in page_pool_disable_direct_recycling().
>
> Signed-off-by: David Wei <dw@davidwei.uk>

Reviewed-by: Mina Almasry <almasrymina@google.com>

> ---
>  net/core/page_pool.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/core/page_pool.c b/net/core/page_pool.c
> index f4444b4e39e6..3927a0a7fa9a 100644
> --- a/net/core/page_pool.c
> +++ b/net/core/page_pool.c
> @@ -1027,8 +1027,8 @@ static void page_pool_disable_direct_recycling(struct page_pool *pool)
>         /* To avoid races with recycling and additional barriers make sure
>          * pool and NAPI are unlinked when NAPI is disabled.
>          */
> -       WARN_ON(!test_bit(NAPI_STATE_SCHED, &pool->p.napi->state) ||
> -               READ_ONCE(pool->p.napi->list_owner) != -1);
> +       WARN_ON(!test_bit(NAPI_STATE_SCHED, &pool->p.napi->state));
> +       WARN_ON(READ_ONCE(pool->p.napi->list_owner) != -1);
>
>         WRITE_ONCE(pool->p.napi, NULL);
>  }
> --
> 2.43.0
>
>
Somnath Kotur June 6, 2024, 8:58 a.m. UTC | #2
On Wed, Jun 5, 2024 at 10:01 PM Mina Almasry <almasrymina@google.com> wrote:
>
> On Wed, Jun 5, 2024 at 9:20 AM David Wei <dw@davidwei.uk> wrote:
> >
> > Having an OR in WARN_ON() makes me sad because it's impossible to tell
> > which condition is true when triggered.
> >
> > Split a WARN_ON() with an OR in page_pool_disable_direct_recycling().
> >
> > Signed-off-by: David Wei <dw@davidwei.uk>
>
> Reviewed-by: Mina Almasry <almasrymina@google.com>
>
Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
> > ---
> >  net/core/page_pool.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/net/core/page_pool.c b/net/core/page_pool.c
> > index f4444b4e39e6..3927a0a7fa9a 100644
> > --- a/net/core/page_pool.c
> > +++ b/net/core/page_pool.c
> > @@ -1027,8 +1027,8 @@ static void page_pool_disable_direct_recycling(struct page_pool *pool)
> >         /* To avoid races with recycling and additional barriers make sure
> >          * pool and NAPI are unlinked when NAPI is disabled.
> >          */
> > -       WARN_ON(!test_bit(NAPI_STATE_SCHED, &pool->p.napi->state) ||
> > -               READ_ONCE(pool->p.napi->list_owner) != -1);
> > +       WARN_ON(!test_bit(NAPI_STATE_SCHED, &pool->p.napi->state));
> > +       WARN_ON(READ_ONCE(pool->p.napi->list_owner) != -1);
> >
> >         WRITE_ONCE(pool->p.napi, NULL);
> >  }
> > --
> > 2.43.0
> >
> >
>
>
> --
> Thanks,
> Mina
>
Jesper Dangaard Brouer June 9, 2024, 7:31 a.m. UTC | #3
On 06/06/2024 10.58, Somnath Kotur wrote:
> On Wed, Jun 5, 2024 at 10:01 PM Mina Almasry <almasrymina@google.com> wrote:
>>
>> On Wed, Jun 5, 2024 at 9:20 AM David Wei <dw@davidwei.uk> wrote:
>>>
>>> Having an OR in WARN_ON() makes me sad because it's impossible to tell
>>> which condition is true when triggered.
>>>
>>> Split a WARN_ON() with an OR in page_pool_disable_direct_recycling().
>>>
>>> Signed-off-by: David Wei <dw@davidwei.uk>
>>
>> Reviewed-by: Mina Almasry <almasrymina@google.com>
>>
> Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>


LGTM

Acked-by: Jesper Dangaard Brouer <hawk@kernel.org>

>>> ---
>>>   net/core/page_pool.c | 4 ++--
>>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/net/core/page_pool.c b/net/core/page_pool.c
>>> index f4444b4e39e6..3927a0a7fa9a 100644
>>> --- a/net/core/page_pool.c
>>> +++ b/net/core/page_pool.c
>>> @@ -1027,8 +1027,8 @@ static void page_pool_disable_direct_recycling(struct page_pool *pool)
>>>          /* To avoid races with recycling and additional barriers make sure
>>>           * pool and NAPI are unlinked when NAPI is disabled.
>>>           */
>>> -       WARN_ON(!test_bit(NAPI_STATE_SCHED, &pool->p.napi->state) ||
>>> -               READ_ONCE(pool->p.napi->list_owner) != -1);
>>> +       WARN_ON(!test_bit(NAPI_STATE_SCHED, &pool->p.napi->state));
>>> +       WARN_ON(READ_ONCE(pool->p.napi->list_owner) != -1);
>>>
>>>          WRITE_ONCE(pool->p.napi, NULL);
>>>   }
>>> --
patchwork-bot+netdevbpf@kernel.org June 9, 2024, 3 p.m. UTC | #4
Hello:

This patch was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:

On Wed,  5 Jun 2024 09:19:24 -0700 you wrote:
> Having an OR in WARN_ON() makes me sad because it's impossible to tell
> which condition is true when triggered.
> 
> Split a WARN_ON() with an OR in page_pool_disable_direct_recycling().
> 
> Signed-off-by: David Wei <dw@davidwei.uk>
> 
> [...]

Here is the summary with links:
  - [net-next,v1] page_pool: remove WARN_ON() with OR
    https://git.kernel.org/netdev/net-next/c/3e61103b2f78

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/core/page_pool.c b/net/core/page_pool.c
index f4444b4e39e6..3927a0a7fa9a 100644
--- a/net/core/page_pool.c
+++ b/net/core/page_pool.c
@@ -1027,8 +1027,8 @@  static void page_pool_disable_direct_recycling(struct page_pool *pool)
 	/* To avoid races with recycling and additional barriers make sure
 	 * pool and NAPI are unlinked when NAPI is disabled.
 	 */
-	WARN_ON(!test_bit(NAPI_STATE_SCHED, &pool->p.napi->state) ||
-		READ_ONCE(pool->p.napi->list_owner) != -1);
+	WARN_ON(!test_bit(NAPI_STATE_SCHED, &pool->p.napi->state));
+	WARN_ON(READ_ONCE(pool->p.napi->list_owner) != -1);
 
 	WRITE_ONCE(pool->p.napi, NULL);
 }