[RFC,2/2] net: remove __skb_frag_set_page()

Message ID 20230508123922.39284-3-linyunsheng@huawei.com
State New
Headers
Series introduce skb_frag_fill_page_desc() |

Commit Message

Yunsheng Lin May 8, 2023, 12:39 p.m. UTC
  The remaining users calling __skb_frag_set_page() with
page being NULL seems to doing defensive programming, as
shinfo->nr_frags is already decremented, so remove them.

Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
---
 drivers/net/ethernet/broadcom/bnx2.c      |  1 -
 drivers/net/ethernet/broadcom/bnxt/bnxt.c |  1 -
 include/linux/skbuff.h                    | 12 ------------
 3 files changed, 14 deletions(-)
  

Comments

Simon Horman May 8, 2023, 2:31 p.m. UTC | #1
On Mon, May 08, 2023 at 08:39:22PM +0800, Yunsheng Lin wrote:
> The remaining users calling __skb_frag_set_page() with
> page being NULL seems to doing defensive programming, as
> shinfo->nr_frags is already decremented, so remove them.
> 
> Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>

...

> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index efaff5018af8..f3f08660ec30 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -1105,7 +1105,6 @@ static u32 __bnxt_rx_agg_pages(struct bnxt *bp,
>  			unsigned int nr_frags;
>  
>  			nr_frags = --shinfo->nr_frags;

Hi Yunsheng,

nr_frags is now  unused, other than being set on the line above.
Probably this local variable can be removed.

> -			__skb_frag_set_page(&shinfo->frags[nr_frags], NULL);
>  			cons_rx_buf->page = page;
>  

...
  
Yunsheng Lin May 9, 2023, 12:51 a.m. UTC | #2
On 2023/5/8 22:31, Simon Horman wrote:
> On Mon, May 08, 2023 at 08:39:22PM +0800, Yunsheng Lin wrote:
>> The remaining users calling __skb_frag_set_page() with
>> page being NULL seems to doing defensive programming, as
>> shinfo->nr_frags is already decremented, so remove them.
>>
>> Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
> 
> ...
> 
>> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
>> index efaff5018af8..f3f08660ec30 100644
>> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
>> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
>> @@ -1105,7 +1105,6 @@ static u32 __bnxt_rx_agg_pages(struct bnxt *bp,
>>  			unsigned int nr_frags;
>>  
>>  			nr_frags = --shinfo->nr_frags;
> 
> Hi Yunsheng,
> 
> nr_frags is now  unused, other than being set on the line above.
> Probably this local variable can be removed.

Yes, will remove that.
Thanks.
  

Patch

diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c
index 466e1d62bcf6..0d917a9699c5 100644
--- a/drivers/net/ethernet/broadcom/bnx2.c
+++ b/drivers/net/ethernet/broadcom/bnx2.c
@@ -2955,7 +2955,6 @@  bnx2_reuse_rx_skb_pages(struct bnx2 *bp, struct bnx2_rx_ring_info *rxr,
 		shinfo = skb_shinfo(skb);
 		shinfo->nr_frags--;
 		page = skb_frag_page(&shinfo->frags[shinfo->nr_frags]);
-		__skb_frag_set_page(&shinfo->frags[shinfo->nr_frags], NULL);
 
 		cons_rx_pg->page = page;
 		dev_kfree_skb(skb);
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index efaff5018af8..f3f08660ec30 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -1105,7 +1105,6 @@  static u32 __bnxt_rx_agg_pages(struct bnxt *bp,
 			unsigned int nr_frags;
 
 			nr_frags = --shinfo->nr_frags;
-			__skb_frag_set_page(&shinfo->frags[nr_frags], NULL);
 			cons_rx_buf->page = page;
 
 			/* Update prod since possibly some pages have been
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 0d1027ea81e0..a3c448757b4e 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -3491,18 +3491,6 @@  static inline void skb_frag_page_copy(skb_frag_t *fragto,
 	fragto->bv_page = fragfrom->bv_page;
 }
 
-/**
- * __skb_frag_set_page - sets the page contained in a paged fragment
- * @frag: the paged fragment
- * @page: the page to set
- *
- * Sets the fragment @frag to contain @page.
- */
-static inline void __skb_frag_set_page(skb_frag_t *frag, struct page *page)
-{
-	frag->bv_page = page;
-}
-
 bool skb_page_frag_refill(unsigned int sz, struct page_frag *pfrag, gfp_t prio);
 
 /**