diff mbox series

[RFC,net-next,v2,1/2] net: veth: Page pool creation error handling for existing pools only

Message ID 20230801061932.10335-1-liangchen.linux@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [RFC,net-next,v2,1/2] net: veth: Page pool creation error handling for existing pools only | 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/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: 1328 this patch: 1328
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 1351 this patch: 1351
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: 1351 this patch: 1351
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Liang Chen Aug. 1, 2023, 6:19 a.m. UTC
The failure handling procedure destroys page pools for all queues,
including those that haven't had their page pool created yet. this patch
introduces necessary adjustments to prevent potential risks and
inconsistency with the error handling behavior.

Signed-off-by: Liang Chen <liangchen.linux@gmail.com>
---
 drivers/net/veth.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Simon Horman Aug. 1, 2023, 12:18 p.m. UTC | #1
On Tue, Aug 01, 2023 at 02:19:31PM +0800, Liang Chen wrote:
> The failure handling procedure destroys page pools for all queues,
> including those that haven't had their page pool created yet. this patch
> introduces necessary adjustments to prevent potential risks and
> inconsistency with the error handling behavior.
> 
> Signed-off-by: Liang Chen <liangchen.linux@gmail.com>

I wonder if this should this have a fixes tag and be targeted at 'net' as a
bugfix?
Jesper Dangaard Brouer Aug. 2, 2023, 8:56 a.m. UTC | #2
On 01/08/2023 08.19, Liang Chen wrote:
> The failure handling procedure destroys page pools for all queues,
> including those that haven't had their page pool created yet. this patch
> introduces necessary adjustments to prevent potential risks and
> inconsistency with the error handling behavior.
> 
> Signed-off-by: Liang Chen <liangchen.linux@gmail.com>
> ---
>   drivers/net/veth.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/veth.c b/drivers/net/veth.c
> index 614f3e3efab0..509e901da41d 100644
> --- a/drivers/net/veth.c
> +++ b/drivers/net/veth.c
> @@ -1081,8 +1081,9 @@ static int __veth_napi_enable_range(struct net_device *dev, int start, int end)
>   err_xdp_ring:
>   	for (i--; i >= start; i--)
>   		ptr_ring_cleanup(&priv->rq[i].xdp_ring, veth_ptr_free);
> +	i = end;
>   err_page_pool:
> -	for (i = start; i < end; i++) {
> +	for (i--; i >= start; i--) {

I'm not a fan of this coding style, that iterates backwards, but I can
see you just inherited the existing style in this function.

>   		page_pool_destroy(priv->rq[i].page_pool);
>   		priv->rq[i].page_pool = NULL;
>   	}

The page_pool_destroy() call handles(exits) if called with NULL.
So, I don't think this incorrect walking all (start to end) can trigger 
an actual bug.

Anyhow, I do think this is more correct, so you can append my ACK for 
the real submission.

Acked-by: Jesper Dangaard Brouer <hawk@kernel.org>
Liang Chen Aug. 11, 2023, 11:56 a.m. UTC | #3
On Tue, Aug 1, 2023 at 8:18 PM Simon Horman <horms@kernel.org> wrote:
>
> On Tue, Aug 01, 2023 at 02:19:31PM +0800, Liang Chen wrote:
> > The failure handling procedure destroys page pools for all queues,
> > including those that haven't had their page pool created yet. this patch
> > introduces necessary adjustments to prevent potential risks and
> > inconsistency with the error handling behavior.
> >
> > Signed-off-by: Liang Chen <liangchen.linux@gmail.com>
>
> I wonder if this should this have a fixes tag and be targeted at 'net' as a
> bugfix?

It doesn't trigger a real bug at the moment as page_pool_destroy
handles NULL argument. So may not be suitable for a fix tag.

Thanks,
Liang
Liang Chen Aug. 11, 2023, 12:02 p.m. UTC | #4
On Wed, Aug 2, 2023 at 4:56 PM Jesper Dangaard Brouer <hawk@kernel.org> wrote:
>
>
>
> On 01/08/2023 08.19, Liang Chen wrote:
> > The failure handling procedure destroys page pools for all queues,
> > including those that haven't had their page pool created yet. this patch
> > introduces necessary adjustments to prevent potential risks and
> > inconsistency with the error handling behavior.
> >
> > Signed-off-by: Liang Chen <liangchen.linux@gmail.com>
> > ---
> >   drivers/net/veth.c | 3 ++-
> >   1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/veth.c b/drivers/net/veth.c
> > index 614f3e3efab0..509e901da41d 100644
> > --- a/drivers/net/veth.c
> > +++ b/drivers/net/veth.c
> > @@ -1081,8 +1081,9 @@ static int __veth_napi_enable_range(struct net_device *dev, int start, int end)
> >   err_xdp_ring:
> >       for (i--; i >= start; i--)
> >               ptr_ring_cleanup(&priv->rq[i].xdp_ring, veth_ptr_free);
> > +     i = end;
> >   err_page_pool:
> > -     for (i = start; i < end; i++) {
> > +     for (i--; i >= start; i--) {
>
> I'm not a fan of this coding style, that iterates backwards, but I can
> see you just inherited the existing style in this function.
>
> >               page_pool_destroy(priv->rq[i].page_pool);
> >               priv->rq[i].page_pool = NULL;
> >       }
>
> The page_pool_destroy() call handles(exits) if called with NULL.
> So, I don't think this incorrect walking all (start to end) can trigger
> an actual bug.
>
> Anyhow, I do think this is more correct, so you can append my ACK for
> the real submission.
>
> Acked-by: Jesper Dangaard Brouer <hawk@kernel.org>
>

Thanks! I will separate this patch out and make a real submission,
since it's a small fix and not really coupled with the optimization
patch which still needs some further work after receiving feedback
from Yunsheng.

Thanks,
Liang
Jesper Dangaard Brouer Aug. 11, 2023, 4:35 p.m. UTC | #5
On 11/08/2023 14.02, Liang Chen wrote:
> On Wed, Aug 2, 2023 at 4:56 PM Jesper Dangaard Brouer <hawk@kernel.org> wrote:
>>
[...]
>>>                page_pool_destroy(priv->rq[i].page_pool);
>>>                priv->rq[i].page_pool = NULL;
>>>        }
>>
>> The page_pool_destroy() call handles(exits) if called with NULL.
>> So, I don't think this incorrect walking all (start to end) can trigger
>> an actual bug.
>>
>> Anyhow, I do think this is more correct, so you can append my ACK for
>> the real submission.
>>
>> Acked-by: Jesper Dangaard Brouer <hawk@kernel.org>
>>
> 
> Thanks! I will separate this patch out and make a real submission,
> since it's a small fix and not really coupled with the optimization
> patch which still needs some further work after receiving feedback
> from Yunsheng.

Sure, send it as a fix commit.  Given it is not super critical i think
it is okay to send for net-next, to avoid merge issues/conflicts with
your 2/2 optimization patch.  And for good order we should add a Fixes
tag, but IMHO net-next is still okay, given I don't think this can
trigger a bug.

That said, I do want to encourage you to work on 2/2 optimization patch.
I think this is a very important optimization and actually a fix for
then we introduced page_pool to veth. Well spotted! :-)

In 2/2 I keep getting confused by use of kfree_skb_partial() and if the
right conditions are meet.

--Jesper
Liang Chen Aug. 12, 2023, 2:16 a.m. UTC | #6
On Sat, Aug 12, 2023 at 12:35 AM Jesper Dangaard Brouer
<jbrouer@redhat.com> wrote:
>
>
>
> On 11/08/2023 14.02, Liang Chen wrote:
> > On Wed, Aug 2, 2023 at 4:56 PM Jesper Dangaard Brouer <hawk@kernel.org> wrote:
> >>
> [...]
> >>>                page_pool_destroy(priv->rq[i].page_pool);
> >>>                priv->rq[i].page_pool = NULL;
> >>>        }
> >>
> >> The page_pool_destroy() call handles(exits) if called with NULL.
> >> So, I don't think this incorrect walking all (start to end) can trigger
> >> an actual bug.
> >>
> >> Anyhow, I do think this is more correct, so you can append my ACK for
> >> the real submission.
> >>
> >> Acked-by: Jesper Dangaard Brouer <hawk@kernel.org>
> >>
> >
> > Thanks! I will separate this patch out and make a real submission,
> > since it's a small fix and not really coupled with the optimization
> > patch which still needs some further work after receiving feedback
> > from Yunsheng.
>
> Sure, send it as a fix commit.  Given it is not super critical i think
> it is okay to send for net-next, to avoid merge issues/conflicts with
> your 2/2 optimization patch.  And for good order we should add a Fixes
> tag, but IMHO net-next is still okay, given I don't think this can
> trigger a bug.
>
> That said, I do want to encourage you to work on 2/2 optimization patch.
> I think this is a very important optimization and actually a fix for
> then we introduced page_pool to veth. Well spotted! :-)
>
> In 2/2 I keep getting confused by use of kfree_skb_partial() and if the
> right conditions are meet.
>
> --Jesper
>

Thank you for the encouragement! The work for the optimization patch
is going on, and we will submit another version which hopefully will
give a further performance improvement.
diff mbox series

Patch

diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 614f3e3efab0..509e901da41d 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -1081,8 +1081,9 @@  static int __veth_napi_enable_range(struct net_device *dev, int start, int end)
 err_xdp_ring:
 	for (i--; i >= start; i--)
 		ptr_ring_cleanup(&priv->rq[i].xdp_ring, veth_ptr_free);
+	i = end;
 err_page_pool:
-	for (i = start; i < end; i++) {
+	for (i--; i >= start; i--) {
 		page_pool_destroy(priv->rq[i].page_pool);
 		priv->rq[i].page_pool = NULL;
 	}