From: Simon Horman <horms@kernel.org>
To: Heng Qi <hengqi@linux.alibaba.com>
Cc: netdev@vger.kernel.org, virtualization@lists.linux.dev,
Jakub Kicinski <kuba@kernel.org>,
"David S . Miller" <davem@davemloft.net>,
Paolo Abeni <pabeni@redhat.com>,
Eric Dumazet <edumazet@google.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>,
Tal Gilboa <talgi@nvidia.com>, Jonathan Corbet <corbet@lwn.net>,
linux-doc@vger.kernel.org,
Maxime Chevallier <maxime.chevallier@bootlin.com>,
Jiri Pirko <jiri@resnulli.us>,
Paul Greenwalt <paul.greenwalt@intel.com>,
Ahmed Zaki <ahmed.zaki@intel.com>,
Vladimir Oltean <vladimir.oltean@nxp.com>,
Kory Maincent <kory.maincent@bootlin.com>,
Andrew Lunn <andrew@lunn.ch>,
justinstitt@google.com
Subject: Re: [PATCH net-next v11 2/4] ethtool: provide customized dim profile management
Date: Fri, 3 May 2024 14:52:44 +0100 [thread overview]
Message-ID: <20240503135244.GV2821784@kernel.org> (raw)
In-Reply-To: <20240430173136.15807-3-hengqi@linux.alibaba.com>
On Wed, May 01, 2024 at 01:31:34AM +0800, Heng Qi wrote:
...
> diff --git a/include/linux/dim.h b/include/linux/dim.h
...
> @@ -198,6 +234,32 @@ enum dim_step_result {
> DIM_ON_EDGE,
> };
>
> +/**
> + * net_dim_init_irq_moder - collect information to initialize irq moderation
> + * @dev: target network device
> + * @profile_flags: Rx or Tx profile modification capability
> + * @coal_flags: irq moderation params flags
> + * @rx_mode: CQ period mode for Rx
> + * @tx_mode: CQ period mode for Tx
> + * @rx_dim_work: Rx worker called after dim decision
> + * void (*rx_dim_work)(struct work_struct *work);
> + *
> + * @tx_dim_work: Tx worker called after dim decision
> + * void (*tx_dim_work)(struct work_struct *work);
> + *
Hi Heng Qi,
The above seems to result in make htmldocs issuing the following warnings:
.../net_dim:175: ./include/linux/dim.h:244: WARNING: Inline emphasis start-string without end-string.
.../net_dim:175: ./include/linux/dim.h:244: WARNING: Inline emphasis start-string without end-string.
.../net_dim:175: ./include/linux/dim.h:247: WARNING: Inline emphasis start-string without end-string.
.../net_dim:175: ./include/linux/dim.h:247: WARNING: Inline emphasis start-string without end-string.
I suggest the following alternative:
* @rx_dim_work: Rx worker called after dim decision
* @tx_dim_work: Tx worker called after dim decision
Exercised using Sphinx 7.2.6
...
> diff --git a/net/ethtool/coalesce.c b/net/ethtool/coalesce.c
...
> @@ -134,6 +212,12 @@ static int coalesce_fill_reply(struct sk_buff *skb,
> const struct coalesce_reply_data *data = COALESCE_REPDATA(reply_base);
> const struct kernel_ethtool_coalesce *kcoal = &data->kernel_coalesce;
> const struct ethtool_coalesce *coal = &data->coalesce;
> +#if IS_ENABLED(CONFIG_DIMLIB)
> + struct net_device *dev = req_base->dev;
> + struct dim_irq_moder *moder = dev->irq_moder;
> + u8 coal_flags;
> + int ret;
> +#endif
> u32 supported = data->supported_params;
It's a minor nit, but here goes: please consider using reverse xmas tree
order - longest line to shortest - for local variable declarations in
Networking code.
In this case, I appreciate that it's not strictly possible without
introducing more than one IS_ENABLED condition, which seems worse.
So, as that condition breaks the visual flow, what I suggest in this
case is having a second block of local variable declarations, like this:
const struct coalesce_reply_data *data = COALESCE_REPDATA(reply_base);
const struct kernel_ethtool_coalesce *kcoal = &data->kernel_coalesce;
const struct ethtool_coalesce *coal = &data->coalesce;
u32 supported = data->supported_params;
#if IS_ENABLED(CONFIG_DIMLIB)
struct dim_irq_moder *moder = dev->irq_moder;
struct net_device *dev = req_base->dev;
u8 coal_flags;
int ret;
#endif
Or better still, if it can be done cleanly, moving all the IS_ENABLED()
code in this function into a separate function, with an no-op
implementation in the case that CONFIG_DIMLIB is not enabled. In general
I'd recommend that approach over sprinkling IS_ENABLED or #ifdef inside
functions. Because in my experience it tends to lead to more readable code.
In any case, the following tool is helpful for isolating
reverse xmas tree issues.
https://github.com/ecree-solarflare/xmastree
> if (coalesce_put_u32(skb, ETHTOOL_A_COALESCE_RX_USECS,
> @@ -192,11 +276,49 @@ static int coalesce_fill_reply(struct sk_buff *skb,
> kcoal->tx_aggr_time_usecs, supported))
> return -EMSGSIZE;
>
> +#if IS_ENABLED(CONFIG_DIMLIB)
> + if (!moder)
> + return 0;
> +
> + coal_flags = moder->coal_flags;
> + rcu_read_lock();
> + if (moder->profile_flags & DIM_PROFILE_RX) {
> + ret = coalesce_put_profile(skb, ETHTOOL_A_COALESCE_RX_PROFILE,
> + rcu_dereference(moder->rx_profile),
> + coal_flags);
> + if (ret) {
> + rcu_read_unlock();
> + return ret;
> + }
> + }
> +
> + if (moder->profile_flags & DIM_PROFILE_TX) {
> + ret = coalesce_put_profile(skb, ETHTOOL_A_COALESCE_TX_PROFILE,
> + rcu_dereference(moder->tx_profile),
> + coal_flags);
> + if (ret) {
> + rcu_read_unlock();
> + return ret;
> + }
> + }
> + rcu_read_unlock();
> +#endif
> return 0;
> }
...
next prev parent reply other threads:[~2024-05-03 13:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-30 17:31 [PATCH net-next v11 0/4] ethtool: provide the dim profile fine-tuning channel Heng Qi
2024-04-30 17:31 ` [PATCH net-next v11 1/4] linux/dim: move useful macros to .h file Heng Qi
2024-04-30 17:31 ` [PATCH net-next v11 2/4] ethtool: provide customized dim profile management Heng Qi
2024-05-01 2:36 ` kernel test robot
2024-05-01 4:45 ` Heng Qi
2024-05-01 5:55 ` Michael S. Tsirkin
2024-05-01 14:44 ` Jakub Kicinski
2024-05-01 15:11 ` Heng Qi
2024-05-01 15:48 ` Michael S. Tsirkin
2024-05-01 16:19 ` Heng Qi
2024-05-01 8:06 ` kernel test robot
2024-05-01 8:27 ` kernel test robot
2024-05-03 13:52 ` Simon Horman [this message]
2024-05-04 6:32 ` Heng Qi
2024-04-30 17:31 ` [PATCH net-next v11 3/4] dim: add new interfaces for initialization and getting results Heng Qi
2024-04-30 17:31 ` [PATCH net-next v11 4/4] virtio-net: support dim profile fine-tuning 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=20240503135244.GV2821784@kernel.org \
--to=horms@kernel.org \
--cc=ahmed.zaki@intel.com \
--cc=aleksander.lobakin@intel.com \
--cc=andrew@lunn.ch \
--cc=bcreeley@amd.com \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hengqi@linux.alibaba.com \
--cc=jasowang@redhat.com \
--cc=jiri@resnulli.us \
--cc=justinstitt@google.com \
--cc=kory.maincent@bootlin.com \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=maxime.chevallier@bootlin.com \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=paul.greenwalt@intel.com \
--cc=rkannoth@marvell.com \
--cc=talgi@nvidia.com \
--cc=virtualization@lists.linux.dev \
--cc=vladimir.oltean@nxp.com \
--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 NNTP newsgroup(s).