diff mbox series

[net-next] net: skb: move skb_pp_recycle() to skbuff.c

Message ID 20221021025822.64381-1-linyunsheng@huawei.com (mailing list archive)
State Accepted
Commit 4727bab4e9bbeafeff6acdfcb077a7a548cbde30
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: skb: move skb_pp_recycle() to skbuff.c | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 5327 this patch: 5327
netdev/cc_maintainers warning 2 maintainers not CCed: edumazet@google.com imagedong@tencent.com
netdev/build_clang success Errors and warnings before: 1121 this patch: 1121
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
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: 5509 this patch: 5509
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 25 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Yunsheng Lin Oct. 21, 2022, 2:58 a.m. UTC
skb_pp_recycle() is only used by skb_free_head() in
skbuff.c, so move it to skbuff.c.

Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
---
 include/linux/skbuff.h | 7 -------
 net/core/skbuff.c      | 7 +++++++
 2 files changed, 7 insertions(+), 7 deletions(-)

Comments

Ilias Apalodimas Oct. 21, 2022, 6:02 a.m. UTC | #1
Hi Yungsheng

On Fri, 21 Oct 2022 at 05:58, Yunsheng Lin <linyunsheng@huawei.com> wrote:
>
> skb_pp_recycle() is only used by skb_free_head() in
> skbuff.c, so move it to skbuff.c.
>
> Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
> ---
>  include/linux/skbuff.h | 7 -------
>  net/core/skbuff.c      | 7 +++++++
>  2 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
> index 9fcf534f2d92..28a7b5fbc7b7 100644
> --- a/include/linux/skbuff.h
> +++ b/include/linux/skbuff.h
> @@ -5048,12 +5048,5 @@ static inline void skb_mark_for_recycle(struct sk_buff *skb)
>  }
>  #endif
>
> -static inline bool skb_pp_recycle(struct sk_buff *skb, void *data)
> -{
> -       if (!IS_ENABLED(CONFIG_PAGE_POOL) || !skb->pp_recycle)
> -               return false;
> -       return page_pool_return_skb_page(virt_to_page(data));
> -}
> -
>  #endif /* __KERNEL__ */
>  #endif /* _LINUX_SKBUFF_H */
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 1d9719e72f9d..9b3b19816d2d 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -748,6 +748,13 @@ static void skb_clone_fraglist(struct sk_buff *skb)
>                 skb_get(list);
>  }
>
> +static bool skb_pp_recycle(struct sk_buff *skb, void *data)
> +{
> +       if (!IS_ENABLED(CONFIG_PAGE_POOL) || !skb->pp_recycle)
> +               return false;
> +       return page_pool_return_skb_page(virt_to_page(data));
> +}
> +

Any particular reason you are removing the inline hint here?  Doing it
like this will add an extra function call for every packet (assuming
the compiler decided to inline the previous version)

Thanks
/Ilias
>  static void skb_free_head(struct sk_buff *skb)
>  {
>         unsigned char *head = skb->head;
> --
> 2.33.0
>
Jakub Kicinski Oct. 21, 2022, 3:51 p.m. UTC | #2
On Fri, 21 Oct 2022 09:02:36 +0300 Ilias Apalodimas wrote:
> > +static bool skb_pp_recycle(struct sk_buff *skb, void *data)
> > +{
> > +       if (!IS_ENABLED(CONFIG_PAGE_POOL) || !skb->pp_recycle)
> > +               return false;
> > +       return page_pool_return_skb_page(virt_to_page(data));
> > +}
> 
> Any particular reason you are removing the inline hint here? 

It's recommended in networking to avoid using the inline keyword
unless someone actually checked the compiler output and found the
compiler is being stupid. I don't know the full history of this
recommendation tho.

> Doing it like this will add an extra function call for every packet
> (assuming the compiler decided to inline the previous version)

Should be fine, tiny static function with one caller, I'd bet it's
always inlined, even with -Os.
Ilias Apalodimas Oct. 21, 2022, 4:46 p.m. UTC | #3
Hi Jakub 
On Fri, Oct 21, 2022 at 08:51:38AM -0700, Jakub Kicinski wrote:
> On Fri, 21 Oct 2022 09:02:36 +0300 Ilias Apalodimas wrote:
> > > +static bool skb_pp_recycle(struct sk_buff *skb, void *data)
> > > +{
> > > +       if (!IS_ENABLED(CONFIG_PAGE_POOL) || !skb->pp_recycle)
> > > +               return false;
> > > +       return page_pool_return_skb_page(virt_to_page(data));
> > > +}
> > 
> > Any particular reason you are removing the inline hint here? 
> 
> It's recommended in networking to avoid using the inline keyword
> unless someone actually checked the compiler output and found the
> compiler is being stupid. I don't know the full history of this
> recommendation tho.
> 

Ah thanks, didn't know that.  IIRC there was no particular reason.
Probably because the majority of the functions in that header are static
inlines.

> > Doing it like this will add an extra function call for every packet
> > (assuming the compiler decided to inline the previous version)
> 
> Should be fine, tiny static function with one caller, I'd bet it's
> always inlined, even with -Os.

Well it's compilers -- I wouldn't bet,  but fair enough

Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

Thanks
/Ilias
patchwork-bot+netdevbpf@kernel.org Oct. 24, 2022, 1:26 p.m. UTC | #4
Hello:

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

On Fri, 21 Oct 2022 10:58:22 +0800 you wrote:
> skb_pp_recycle() is only used by skb_free_head() in
> skbuff.c, so move it to skbuff.c.
> 
> Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
> ---
>  include/linux/skbuff.h | 7 -------
>  net/core/skbuff.c      | 7 +++++++
>  2 files changed, 7 insertions(+), 7 deletions(-)

Here is the summary with links:
  - [net-next] net: skb: move skb_pp_recycle() to skbuff.c
    https://git.kernel.org/netdev/net-next/c/4727bab4e9bb

You are awesome, thank you!
diff mbox series

Patch

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 9fcf534f2d92..28a7b5fbc7b7 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -5048,12 +5048,5 @@  static inline void skb_mark_for_recycle(struct sk_buff *skb)
 }
 #endif
 
-static inline bool skb_pp_recycle(struct sk_buff *skb, void *data)
-{
-	if (!IS_ENABLED(CONFIG_PAGE_POOL) || !skb->pp_recycle)
-		return false;
-	return page_pool_return_skb_page(virt_to_page(data));
-}
-
 #endif	/* __KERNEL__ */
 #endif	/* _LINUX_SKBUFF_H */
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 1d9719e72f9d..9b3b19816d2d 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -748,6 +748,13 @@  static void skb_clone_fraglist(struct sk_buff *skb)
 		skb_get(list);
 }
 
+static bool skb_pp_recycle(struct sk_buff *skb, void *data)
+{
+	if (!IS_ENABLED(CONFIG_PAGE_POOL) || !skb->pp_recycle)
+		return false;
+	return page_pool_return_skb_page(virt_to_page(data));
+}
+
 static void skb_free_head(struct sk_buff *skb)
 {
 	unsigned char *head = skb->head;