linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "wanghai (M)" <wanghai38@huawei.com>
To: Joe Perches <joe@perches.com>, <dchickles@marvell.com>,
	<sburla@marvell.com>, <fmanlunas@marvell.com>,
	<davem@davemloft.net>, <kuba@kernel.org>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net-next] liquidio: Remove unneeded cast from memory allocation
Date: Thu, 30 Jul 2020 14:19:02 +0800	[thread overview]
Message-ID: <192edb77-b811-7ec2-9722-a767fd29cdf0@huawei.com> (raw)
In-Reply-To: <4299fe666c93018a9a047575e5d68a0bb4dd269f.camel@perches.com>


在 2020/7/28 23:54, Joe Perches 写道:
> On Tue, 2020-07-28 at 21:38 +0800, wanghai (M) wrote:
>> Thanks for your explanation. I got it.
>>
>> Can it be modified like this?
> []
>> +++ b/drivers/net/ethernet/cavium/liquidio/octeon_device.c
>> @@ -1152,11 +1152,8 @@ octeon_register_dispatch_fn(struct octeon_device
>> *oct,
>>
>>                   dev_dbg(&oct->pci_dev->dev,
>>                           "Adding opcode to dispatch list linked list\n");
>> -               dispatch = (struct octeon_dispatch *)
>> -                          vmalloc(sizeof(struct octeon_dispatch));
>> +               dispatch = kmalloc(sizeof(struct octeon_dispatch),
>> GFP_KERNEL);
>>                   if (!dispatch) {
>> -                       dev_err(&oct->pci_dev->dev,
>> -                               "No memory to add dispatch function\n");
>>                           return 1;
>>                   }
>>                   dispatch->opcode = combined_opcode;
> Yes, but the free also needs to be changed.
>
> I think it's:
> ---
>   drivers/net/ethernet/cavium/liquidio/octeon_device.c | 11 ++++-------
>   1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_device.c b/drivers/net/ethernet/cavium/liquidio/octeon_device.c
> index 934115d18488..4ee4cb946e1d 100644
> --- a/drivers/net/ethernet/cavium/liquidio/octeon_device.c
> +++ b/drivers/net/ethernet/cavium/liquidio/octeon_device.c
> @@ -1056,7 +1056,7 @@ void octeon_delete_dispatch_list(struct octeon_device *oct)
>   
>   	list_for_each_safe(temp, tmp2, &freelist) {
>   		list_del(temp);
> -		vfree(temp);
> +		kfree(temp);
>   	}
>   }
>   
> @@ -1152,13 +1152,10 @@ octeon_register_dispatch_fn(struct octeon_device *oct,
>   
>   		dev_dbg(&oct->pci_dev->dev,
>   			"Adding opcode to dispatch list linked list\n");
> -		dispatch = (struct octeon_dispatch *)
> -			   vmalloc(sizeof(struct octeon_dispatch));
> -		if (!dispatch) {
> -			dev_err(&oct->pci_dev->dev,
> -				"No memory to add dispatch function\n");
> +		dispatch = kmalloc(sizeof(struct octeon_dispatch), GFP_KERNEL);
> +		if (!dispatch)
>   			return 1;
> -		}
> +
>   		dispatch->opcode = combined_opcode;
>   		dispatch->dispatch_fn = fn;
>   		dispatch->arg = fn_arg;
>
>
>
> .
Thanks for your suggestion. I just sent another patch for this.

"[PATCH net-next] liquidio: Replace vmalloc with kmalloc in 
octeon_register_dispatch_fn()"

>


  reply	other threads:[~2020-07-30  6:19 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-24 13:00 [PATCH net-next] liquidio: Remove unneeded cast from memory allocation Wang Hai
2020-07-24 21:29 ` Joe Perches
2020-07-28  8:42   ` wanghai (M)
2020-07-28  9:11     ` Joe Perches
2020-07-28 13:38       ` wanghai (M)
2020-07-28 15:54         ` Joe Perches
2020-07-30  6:19           ` wanghai (M) [this message]
2020-07-28 15:39 Derek Chickles
2020-07-28 15:56 ` Joe Perches
2020-07-28 16:32 Derek Chickles
2020-09-01 14:11 YueHaibing
2020-09-01 18:49 ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=192edb77-b811-7ec2-9722-a767fd29cdf0@huawei.com \
    --to=wanghai38@huawei.com \
    --cc=davem@davemloft.net \
    --cc=dchickles@marvell.com \
    --cc=fmanlunas@marvell.com \
    --cc=joe@perches.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sburla@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).