diff mbox series

[net-next,11/12] net: hns3: do not allocate linear data for fraglist skb

Message ID 1571210231-29154-12-git-send-email-tanhuazhong@huawei.com
State Changes Requested
Delegated to: David Miller
Headers show
Series net: hns3: add some bugfixes and optimizations | expand

Commit Message

tanhuazhong Oct. 16, 2019, 7:17 a.m. UTC
From: Yunsheng Lin <linyunsheng@huawei.com>

Currently, napi_alloc_skb() is used to allocate skb for fraglist
when the head skb is not enough to hold the remaining data, and
the remaining data is added to the frags part of the fraglist skb,
leaving the linear part unused.

So this patch passes length of 0 to allocate fraglist skb with
zero size of linear data.

Fixes: 81ae0e0491f3 ("net: hns3: Add skb chain when num of RX buf exceeds MAX_SKB_FRAGS")
Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Jakub Kicinski Oct. 16, 2019, 5:18 p.m. UTC | #1
On Wed, 16 Oct 2019 15:17:10 +0800, Huazhong Tan wrote:
> From: Yunsheng Lin <linyunsheng@huawei.com>
> 
> Currently, napi_alloc_skb() is used to allocate skb for fraglist
> when the head skb is not enough to hold the remaining data, and
> the remaining data is added to the frags part of the fraglist skb,
> leaving the linear part unused.
> 
> So this patch passes length of 0 to allocate fraglist skb with
> zero size of linear data.
> 
> Fixes: 81ae0e0491f3 ("net: hns3: Add skb chain when num of RX buf exceeds MAX_SKB_FRAGS")
> Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
> Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>

Is this really a fix? I just wastes memory, right?

> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> index 6172eb2..14111af 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
> @@ -2866,8 +2866,7 @@ static int hns3_add_frag(struct hns3_enet_ring *ring, struct hns3_desc *desc,
>  			return -ENXIO;
>  
>  		if (unlikely(ring->frag_num >= MAX_SKB_FRAGS)) {
> -			new_skb = napi_alloc_skb(&ring->tqp_vector->napi,
> -						 HNS3_RX_HEAD_SIZE);
> +			new_skb = napi_alloc_skb(&ring->tqp_vector->napi, 0);
>  			if (unlikely(!new_skb)) {
>  				hns3_rl_err(ring_to_netdev(ring),
>  					    "alloc rx fraglist skb fail\n");
tanhuazhong Oct. 17, 2019, 12:54 a.m. UTC | #2
On 2019/10/17 1:18, Jakub Kicinski wrote:
> On Wed, 16 Oct 2019 15:17:10 +0800, Huazhong Tan wrote:
>> From: Yunsheng Lin <linyunsheng@huawei.com>
>>
>> Currently, napi_alloc_skb() is used to allocate skb for fraglist
>> when the head skb is not enough to hold the remaining data, and
>> the remaining data is added to the frags part of the fraglist skb,
>> leaving the linear part unused.
>>
>> So this patch passes length of 0 to allocate fraglist skb with
>> zero size of linear data.
>>
>> Fixes: 81ae0e0491f3 ("net: hns3: Add skb chain when num of RX buf exceeds MAX_SKB_FRAGS")
>> Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
>> Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
> 
> Is this really a fix? I just wastes memory, right?

It is a minor optimizations. This fix tag is a mistake.
Thanks.

> 
>> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
>> index 6172eb2..14111af 100644
>> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
>> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
>> @@ -2866,8 +2866,7 @@ static int hns3_add_frag(struct hns3_enet_ring *ring, struct hns3_desc *desc,
>>   			return -ENXIO;
>>   
>>   		if (unlikely(ring->frag_num >= MAX_SKB_FRAGS)) {
>> -			new_skb = napi_alloc_skb(&ring->tqp_vector->napi,
>> -						 HNS3_RX_HEAD_SIZE);
>> +			new_skb = napi_alloc_skb(&ring->tqp_vector->napi, 0);
>>   			if (unlikely(!new_skb)) {
>>   				hns3_rl_err(ring_to_netdev(ring),
>>   					    "alloc rx fraglist skb fail\n");
> 
> 
> .
>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 6172eb2..14111af 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -2866,8 +2866,7 @@  static int hns3_add_frag(struct hns3_enet_ring *ring, struct hns3_desc *desc,
 			return -ENXIO;
 
 		if (unlikely(ring->frag_num >= MAX_SKB_FRAGS)) {
-			new_skb = napi_alloc_skb(&ring->tqp_vector->napi,
-						 HNS3_RX_HEAD_SIZE);
+			new_skb = napi_alloc_skb(&ring->tqp_vector->napi, 0);
 			if (unlikely(!new_skb)) {
 				hns3_rl_err(ring_to_netdev(ring),
 					    "alloc rx fraglist skb fail\n");