* [PATCH v3 1/2] net: page_pool: check page pool ethtool stats @ 2023-10-15 12:37 Sven Auhagen 2023-10-15 17:27 ` Leon Romanovsky 0 siblings, 1 reply; 4+ messages in thread From: Sven Auhagen @ 2023-10-15 12:37 UTC (permalink / raw) To: netdev Cc: thomas.petazzoni, brouer, lorenzo, Paulo.DaSilva, ilias.apalodimas, mcroce If the page_pool variable is null while passing it to the page_pool_get_stats function we receive a kernel error. Check if the page_pool variable is at least valid. Signed-off-by: Sven Auhagen <sven.auhagen@voleatech.de> Reported-by: Paulo Da Silva <Paulo.DaSilva@kyberna.com> --- net/core/page_pool.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/core/page_pool.c b/net/core/page_pool.c index 2396c99bedea..4c5dca6b4a16 100644 --- a/net/core/page_pool.c +++ b/net/core/page_pool.c @@ -65,6 +65,9 @@ bool page_pool_get_stats(struct page_pool *pool, if (!stats) return false; + if (!pool) + return false; + /* The caller is responsible to initialize stats. */ stats->alloc_stats.fast += pool->alloc_stats.fast; stats->alloc_stats.slow += pool->alloc_stats.slow; -- 2.42.0 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3 1/2] net: page_pool: check page pool ethtool stats 2023-10-15 12:37 [PATCH v3 1/2] net: page_pool: check page pool ethtool stats Sven Auhagen @ 2023-10-15 17:27 ` Leon Romanovsky 2023-10-25 2:12 ` Sven Auhagen 0 siblings, 1 reply; 4+ messages in thread From: Leon Romanovsky @ 2023-10-15 17:27 UTC (permalink / raw) To: Sven Auhagen Cc: netdev, thomas.petazzoni, brouer, lorenzo, Paulo.DaSilva, ilias.apalodimas, mcroce On Sun, Oct 15, 2023 at 02:37:27PM +0200, Sven Auhagen wrote: > If the page_pool variable is null while passing it to > the page_pool_get_stats function we receive a kernel error. > > Check if the page_pool variable is at least valid. > > Signed-off-by: Sven Auhagen <sven.auhagen@voleatech.de> > Reported-by: Paulo Da Silva <Paulo.DaSilva@kyberna.com> > --- > net/core/page_pool.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/net/core/page_pool.c b/net/core/page_pool.c > index 2396c99bedea..4c5dca6b4a16 100644 > --- a/net/core/page_pool.c > +++ b/net/core/page_pool.c > @@ -65,6 +65,9 @@ bool page_pool_get_stats(struct page_pool *pool, > if (!stats) > return false; > > + if (!pool) > + return false; > + I would argue that both pool and stats shouldn't be NULL and must be checked by caller. This API call named get-stats-from-pool. Thanks > /* The caller is responsible to initialize stats. */ > stats->alloc_stats.fast += pool->alloc_stats.fast; > stats->alloc_stats.slow += pool->alloc_stats.slow; > -- > 2.42.0 > > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3 1/2] net: page_pool: check page pool ethtool stats 2023-10-15 17:27 ` Leon Romanovsky @ 2023-10-25 2:12 ` Sven Auhagen 2023-10-25 2:28 ` Yunsheng Lin 0 siblings, 1 reply; 4+ messages in thread From: Sven Auhagen @ 2023-10-25 2:12 UTC (permalink / raw) To: Leon Romanovsky Cc: netdev, thomas.petazzoni, brouer, lorenzo, Paulo.DaSilva, ilias.apalodimas, mcroce On Sun, Oct 15, 2023 at 08:27:10PM +0300, Leon Romanovsky wrote: > On Sun, Oct 15, 2023 at 02:37:27PM +0200, Sven Auhagen wrote: > > If the page_pool variable is null while passing it to > > the page_pool_get_stats function we receive a kernel error. > > > > Check if the page_pool variable is at least valid. > > > > Signed-off-by: Sven Auhagen <sven.auhagen@voleatech.de> > > Reported-by: Paulo Da Silva <Paulo.DaSilva@kyberna.com> > > --- > > net/core/page_pool.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/net/core/page_pool.c b/net/core/page_pool.c > > index 2396c99bedea..4c5dca6b4a16 100644 > > --- a/net/core/page_pool.c > > +++ b/net/core/page_pool.c > > @@ -65,6 +65,9 @@ bool page_pool_get_stats(struct page_pool *pool, > > if (!stats) > > return false; > > > > + if (!pool) > > + return false; > > + > > I would argue that both pool and stats shouldn't be NULL and must be > checked by caller. This API call named get-stats-from-pool. > > Thanks I can do it either way, I only need to know which version to send. Can someone let me know how to proceed with the patch? Best Sven > > > /* The caller is responsible to initialize stats. */ > > stats->alloc_stats.fast += pool->alloc_stats.fast; > > stats->alloc_stats.slow += pool->alloc_stats.slow; > > -- > > 2.42.0 > > > > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3 1/2] net: page_pool: check page pool ethtool stats 2023-10-25 2:12 ` Sven Auhagen @ 2023-10-25 2:28 ` Yunsheng Lin 0 siblings, 0 replies; 4+ messages in thread From: Yunsheng Lin @ 2023-10-25 2:28 UTC (permalink / raw) To: Sven Auhagen, Leon Romanovsky Cc: netdev, thomas.petazzoni, brouer, lorenzo, Paulo.DaSilva, ilias.apalodimas, mcroce On 2023/10/25 10:12, Sven Auhagen wrote: > On Sun, Oct 15, 2023 at 08:27:10PM +0300, Leon Romanovsky wrote: >> On Sun, Oct 15, 2023 at 02:37:27PM +0200, Sven Auhagen wrote: >>> If the page_pool variable is null while passing it to >>> the page_pool_get_stats function we receive a kernel error. >>> >>> Check if the page_pool variable is at least valid. >>> >>> Signed-off-by: Sven Auhagen <sven.auhagen@voleatech.de> >>> Reported-by: Paulo Da Silva <Paulo.DaSilva@kyberna.com> >>> --- >>> net/core/page_pool.c | 3 +++ >>> 1 file changed, 3 insertions(+) >>> >>> diff --git a/net/core/page_pool.c b/net/core/page_pool.c >>> index 2396c99bedea..4c5dca6b4a16 100644 >>> --- a/net/core/page_pool.c >>> +++ b/net/core/page_pool.c >>> @@ -65,6 +65,9 @@ bool page_pool_get_stats(struct page_pool *pool, >>> if (!stats) >>> return false; >>> >>> + if (!pool) >>> + return false; >>> + >> >> I would argue that both pool and stats shouldn't be NULL and must be >> checked by caller. This API call named get-stats-from-pool. >> >> Thanks > > I can do it either way, I only need to know which version to send. > Can someone let me know how to proceed with the patch? From the message in v1, it seems more appropriate to check it in the driver, because: 1. if the driver only support page pool, then the check is not really necessary. 2. if the driver support both page_pool API and alloc_pages() API, then a check is already needed in the driver to switch between those two API, it might be better to reuse that check. "First the page pool is only available if the bm is not used. The page pool is also not allocated when the port is stopped. It can also be not allocated in case of errors." > > Best > Sven > >> >>> /* The caller is responsible to initialize stats. */ >>> stats->alloc_stats.fast += pool->alloc_stats.fast; >>> stats->alloc_stats.slow += pool->alloc_stats.slow; >>> -- >>> 2.42.0 >>> >>> > > . > ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-10-25 2:28 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-10-15 12:37 [PATCH v3 1/2] net: page_pool: check page pool ethtool stats Sven Auhagen 2023-10-15 17:27 ` Leon Romanovsky 2023-10-25 2:12 ` Sven Auhagen 2023-10-25 2:28 ` Yunsheng Lin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).