Virtualization Archive mirror
 help / color / mirror / Atom feed
From: Heng Qi <hengqi@linux.alibaba.com>
To: Simon Horman <horms@kernel.org>
Cc: netdev@vger.kernel.org, virtualization@lists.linux.dev,
	Jakub Kicinski <kuba@kernel.org>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>, Jason Wang <jasowang@redhat.com>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	Brett Creeley <bcreeley@amd.com>,
	Ratheesh Kannoth <rkannoth@marvell.com>,
	Alexander Lobakin <aleksander.lobakin@intel.com>,
	Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Subject: Re: [PATCH net-next v7 2/4] ethtool: provide customized dim profile management
Date: Tue, 16 Apr 2024 10:27:21 +0800	[thread overview]
Message-ID: <e8d84e95-cab4-447c-b8f2-54444e80e556@linux.alibaba.com> (raw)
In-Reply-To: <20240415200343.GG2320920@kernel.org>



在 2024/4/16 上午4:03, Simon Horman 写道:
> On Mon, Apr 15, 2024 at 05:36:36PM +0800, Heng Qi wrote:
>
> ...
>
>> @@ -10229,6 +10230,61 @@ static void netdev_do_free_pcpu_stats(struct net_device *dev)
>>   	}
>>   }
>>   
>> +static int dev_dim_profile_init(struct net_device *dev)
>> +{
>> +#if IS_ENABLED(CONFIG_DIMLIB)
>> +	u32 supported = dev->ethtool_ops->supported_coalesce_params;
>> +	struct netdev_profile_moder *moder;
>> +	int length;
>> +
>> +	dev->moderation = kzalloc(sizeof(*dev->moderation), GFP_KERNEL);
>> +	if (!dev->moderation)
>> +		goto err_moder;
>> +
>> +	moder = dev->moderation;
>> +	length = NET_DIM_PARAMS_NUM_PROFILES * sizeof(*moder->rx_eqe_profile);
>> +
>> +	if (supported & ETHTOOL_COALESCE_RX_EQE_PROFILE) {
>> +		moder->rx_eqe_profile = kzalloc(length, GFP_KERNEL);
>> +		if (!moder->rx_eqe_profile)
>> +			goto err_rx_eqe;
>> +		memcpy(moder->rx_eqe_profile, rx_profile[0], length);
>> +	}
>> +	if (supported & ETHTOOL_COALESCE_RX_CQE_PROFILE) {
>> +		moder->rx_cqe_profile = kzalloc(length, GFP_KERNEL);
>> +		if (!moder->rx_cqe_profile)
>> +			goto err_rx_cqe;
>> +		memcpy(moder->rx_cqe_profile, rx_profile[1], length);
>> +	}
>> +	if (supported & ETHTOOL_COALESCE_TX_EQE_PROFILE) {
>> +		moder->tx_eqe_profile = kzalloc(length, GFP_KERNEL);
>> +		if (!moder->tx_eqe_profile)
>> +			goto err_tx_eqe;
>> +		memcpy(moder->tx_eqe_profile, tx_profile[0], length);
>> +	}
>> +	if (supported & ETHTOOL_COALESCE_TX_CQE_PROFILE) {
>> +		moder->tx_cqe_profile = kzalloc(length, GFP_KERNEL);
>> +		if (!moder->tx_cqe_profile)
>> +			goto err_tx_cqe;
>> +		memcpy(moder->tx_cqe_profile, tx_profile[1], length);
>> +	}
> nit: Coccinelle suggests that the kzalloc()/memcpy() pattern above
>       could be replaced with calls to kmemdup()

Good idea.

Thanks.

>> +#endif
>> +	return 0;
>> +
>> +#if IS_ENABLED(CONFIG_DIMLIB)
>> +err_tx_cqe:
>> +	kfree(moder->tx_eqe_profile);
>> +err_tx_eqe:
>> +	kfree(moder->rx_cqe_profile);
>> +err_rx_cqe:
>> +	kfree(moder->rx_eqe_profile);
>> +err_rx_eqe:
>> +	kfree(moder);
>> +err_moder:
>> +	return -ENOMEM;
>> +#endif
>> +}
>> +
>>   /**
>>    * register_netdevice() - register a network device
>>    * @dev: device to register
> ...


  reply	other threads:[~2024-04-16  2:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-15  9:36 [PATCH net-next v7 0/4] ethtool: provide the dim profile fine-tuning channel Heng Qi
2024-04-15  9:36 ` [PATCH net-next v7 1/4] linux/dim: move useful macros to .h file Heng Qi
2024-04-15  9:36 ` [PATCH net-next v7 2/4] ethtool: provide customized dim profile management Heng Qi
2024-04-15 12:19   ` kernel test robot
2024-04-15 12:51   ` kernel test robot
2024-04-15 20:03   ` Simon Horman
2024-04-16  2:27     ` Heng Qi [this message]
2024-04-15  9:36 ` [PATCH net-next v7 3/4] virtio-net: refactor dim initialization/destruction Heng Qi
2024-04-15  9:36 ` [PATCH net-next v7 4/4] virtio-net: support dim profile fine-tuning Heng Qi
2024-04-15 13:35 ` [PATCH net-next v7 0/4] ethtool: provide the dim profile fine-tuning channel Heng Qi

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=e8d84e95-cab4-447c-b8f2-54444e80e556@linux.alibaba.com \
    --to=hengqi@linux.alibaba.com \
    --cc=aleksander.lobakin@intel.com \
    --cc=bcreeley@amd.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jasowang@redhat.com \
    --cc=kuba@kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rkannoth@marvell.com \
    --cc=virtualization@lists.linux.dev \
    --cc=xuanzhuo@linux.alibaba.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 read-only IMAP folder(s) and NNTP newsgroup(s).