ethtool: provide the dim profile fine-tuning channel
Subsystems (8)
v11 cover ethtool: provide the dim profile fine-tuning channel
The NetDIM library provides excellent acceleration for many modern network cards. However, the default profiles of DIM limits its maximum capabilities for different NICs, so providing a way which the NIC can be custom configured is necessary.
Currently, the way is based on the commonly used "ethtool -C".
Please review, thank you very much!
Changelog
=====v10->v11:
- Fix and clean up some issues from Kuba, thanks.
- Rebase net-next/main
v9->v10:
- Collect dim related flags/mode/work into one place.
- Use rx_profile + tx_profile instead of four profiles.
- Add several helps.
- Update commit logs.
v8->v9:
- Fix the compilation error of conflicting names of rx_profile in dim.h and ice driver: in dim.h, rx_profile is replaced with dim_rx_profile. So does tx_profile.
v7->v8:
- Use kmemdup() instead of kzalloc()/memcpy() in dev_dim_profile_init().
v6->v7:
- A new wrapper struct pointer is used in struct net_device.
- Add IS_ENABLED(CONFIG_DIMLIB) to avoid compiler warnings.
- Profile fields changed from u16 to u32.
v5->v6:
- Place the profile in netdevice to bypass the driver.
The interaction code of ethtool <-> kernel has not changed at all,
only the interaction part of kernel <-> driver has changed.v4->v5:
- Update some snippets from Kuba.
v3->v4:
- Some tiny updates and patch 1 only add a new comment.
v2->v3:
- Break up the attributes to avoid the use of raw c structs.
- Use per-device profile instead of global profile in the driver.
v1->v2:
- Use ethtool tool instead of net-sysfs.
Heng Qi (4):
linux/dim: move useful macros to .h file
ethtool: provide customized dim profile management
dim: add new interfaces for initialization and getting results
virtio-net: support dim profile fine-tuning
Documentation/netlink/specs/ethtool.yaml | 31 +++ Documentation/networking/ethtool-netlink.rst | 4 + drivers/net/virtio_net.c | 48 +++- include/linux/dim.h | 117 ++++++++ include/linux/ethtool.h | 7 +- include/linux/netdevice.h | 5 + include/uapi/linux/ethtool_netlink.h | 22 ++ lib/dim/net_dim.c | 145 +++++++++- net/ethtool/coalesce.c | 278 ++++++++++++++++++- 9 files changed, 642 insertions(+), 15 deletions(-)
Signature · 1 line
2.32.0.3.g01195cf9f
PATCH v11 3/4 dim: add new interfaces for initialization and getting results
DIM-related mode and work have been collected in one same place, so new interfaces are added to provide convenience.
--- include/linux/dim.h | 48 ++++++++++++++++++++++++++++++++ lib/dim/net_dim.c | 68 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+)
include/linux/dim.h +48 -0
@@ -260,6 +260,54 @@ int net_dim_init_irq_moder(struct net_device *dev, u8 profile_flags,*/ void net_dim_free_irq_moder (struct net_device *dev); +/** +* net_dim_setting - initialize DIM's cq mode and schedule worker +* @dev: target network device +* @dim: DIM context +* @is_tx: true indicates the tx direction, false indicates the rx direction +*/ +void net_dim_setting (struct net_device *dev,struct dim *dim,bool is_tx); + +/** +* net_dim_work_cancel - synchronously cancel dim's worker +* @dim: DIM context +*/ +void net_dim_work_cancel (struct dim *dim); + +/** +* net_dim_get_rx_irq_moder - get DIM rx results based on profile_ix +* @dev: target network device +* @dim: DIM context +* +* Return: DIM irq moderation +*/ +struct dim_cq_moder +net_dim_get_rx_irq_moder (struct net_device *dev,struct dim *dim); + +/** +* net_dim_get_tx_irq_moder - get DIM tx results based on profile_ix +* @dev: target network device +* @dim: DIM context +* +* Return: DIM irq moderation +*/ +struct dim_cq_moder +net_dim_get_tx_irq_moder (struct net_device *dev,struct dim *dim); + +/** +* net_dim_set_rx_mode - set DIM rx cq mode +* @dev: target network device +* @rx_mode: target rx cq mode +*/ +void net_dim_set_rx_mode (struct net_device *dev,u8 rx_mode); + +/** +* net_dim_set_tx_mode - set DIM tx cq mode +* @dev: target network device +* @tx_mode: target tx cq mode +*/ +void net_dim_set_tx_mode (struct net_device *dev,u8 tx_mode); +/** * dim_on_top - check if current state is a good place to stop (top location) * @dim: DIM context
lib/dim/net_dim.c +68 -0
74 lines not on this page · raw message
Signature · 1 line
2.32.0.3.g01195cf9f
PATCH v11 2/4 ethtool: provide customized dim profile management
In reply to Heng QiThe NetDIM library, currently leveraged by an array of NICs, delivers excellent acceleration benefits. Nevertheless, NICs vary significantly in their dim profile list prerequisites.
Specifically, virtio-net backends may present diverse sw or hw device implementation, making a one-size-fits-all parameter list impractical. On Alibaba Cloud, the virtio DPU's performance under the default DIM profile falls short of expectations, partly due to a mismatch in parameter configuration.
I also noticed that ice/idpf/ena and other NICs have customized profilelist or placed some restrictions on dim capabilities.
Motivated by this, I tried adding new params for "ethtool -C" that provides a per-device control to modify and access a device's interrupt parameters.
Usage
========
The target NIC is named ethx.
Assume that ethx only declares support for rx profile setting (with DIM_PROFILE_RX flag set in profile_flags) and supports modification of usec and pkt fields.
1. Query the currently customized list of the device
$ ethtool -c ethx
...
rx-profile:
{.usec = 1, .pkts = 256, .comps = n/a,},
{.usec = 8, .pkts = 256, .comps = n/a,},
{.usec = 64, .pkts = 256, .comps = n/a,},
{.usec = 128, .pkts = 256, .comps = n/a,},
{.usec = 256, .pkts = 256, .comps = n/a,}
tx-profile: n/a2. Tune
$ ethtool -C ethx rx-profile 1,1,n_2,n,n_3,3,n_4,4,n_n,5,n
"n" means do not modify this field.
$ ethtool -c ethx
...
rx-profile:
{.usec = 1, .pkts = 1, .comps = n/a,},
{.usec = 2, .pkts = 256, .comps = n/a,},
{.usec = 3, .pkts = 3, .comps = n/a,},
{.usec = 4, .pkts = 4, .comps = n/a,},
{.usec = 256, .pkts = 5, .comps = n/a,}
tx-profile: n/a3. Hint
If the device does not support some type of customized dim profiles, the corresponding "n/a" will display.
If the "n/a" field is being modified, -EOPNOTSUPP will be reported.
--- Documentation/netlink/specs/ethtool.yaml | 31 +++ Documentation/networking/ethtool-netlink.rst | 4 + include/linux/dim.h | 62 +++++ include/linux/ethtool.h | 7 +- include/linux/netdevice.h | 5 + include/uapi/linux/ethtool_netlink.h | 22 ++ lib/dim/net_dim.c | 71 +++++ net/ethtool/coalesce.c | 278 ++++++++++++++++++- 8 files changed, 478 insertions(+), 2 deletions(-)
Documentation/netlink/specs/ethtool.yaml +31 -0
@@ -414,6 +414,26 @@ attribute-sets: name: combined-count type: u32 + - + name: irq-moderation + attributes: + - + name: usec + type: u32 + - + name: pkts + type: u32 + - + name: comps + type: u32 + - + name: profile + attributes: + - + name: irq-moderation + type: nest + multi-attr: true + nested-attributes: irq-moderation - name: coalesce attributes:
@@ -502,6 +522,15 @@ attribute-sets: - name: tx-aggr-time-usecs type: u32 + - + name: rx-profile + type: nest + nested-attributes: profile + - + name: tx-profile + type: nest + nested-attributes: profile + - name: pause-stat attributes:
@@ -1325,6 +1354,8 @@ operations: - tx-aggr-max-bytes - tx-aggr-max-frames - tx-aggr-time-usecs + - rx-profile + - tx-profile dump: *coalesce-get-op - name: coalesce-set
Documentation/networking/ethtool-netlink.rst +4 -0
@@ -1040,6 +1040,8 @@ Kernel response contents: ``ETHTOOL_A_COALESCE_TX_AGGR_MAX_BYTES`` u32 max aggr size, Tx ``ETHTOOL_A_COALESCE_TX_AGGR_MAX_FRAMES`` u32 max aggr packets, Tx ``ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS`` u32 time (us), aggr, Tx + ``ETHTOOL_A_COALESCE_RX_PROFILE`` nested profile of DIM, Rx + ``ETHTOOL_A_COALESCE_TX_PROFILE`` nested profile of DIM, Tx =========================================== ====== ======================= Attributes are only included in reply if their value is not zero or the
@@ -1105,6 +1107,8 @@ Request contents: ``ETHTOOL_A_COALESCE_TX_AGGR_MAX_BYTES`` u32 max aggr size, Tx ``ETHTOOL_A_COALESCE_TX_AGGR_MAX_FRAMES`` u32 max aggr packets, Tx ``ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS`` u32 time (us), aggr, Tx + ``ETHTOOL_A_COALESCE_RX_PROFILE`` nested profile of DIM, Rx + ``ETHTOOL_A_COALESCE_TX_PROFILE`` nested profile of DIM, Tx =========================================== ====== ======================= Request is rejected if it attributes declared as unsupported by driver (i.e.
include/linux/dim.h +62 -0
86 lines not on this page · raw message
include/linux/ethtool.h +6 -1
@@ -284,7 +284,9 @@ bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32,#define ETHTOOL_COALESCE_TX_AGGR_MAX_BYTES BIT(24)#define ETHTOOL_COALESCE_TX_AGGR_MAX_FRAMES BIT(25)#define ETHTOOL_COALESCE_TX_AGGR_TIME_USECS BIT(26) -#define ETHTOOL_COALESCE_ALL_PARAMS GENMASK(26, 0) +#define ETHTOOL_COALESCE_RX_PROFILE BIT(27) +#define ETHTOOL_COALESCE_TX_PROFILE BIT(28) +#define ETHTOOL_COALESCE_ALL_PARAMS GENMASK(28, 0)#define ETHTOOL_COALESCE_USECS \ (ETHTOOL_COALESCE_RX_USECS | ETHTOOL_COALESCE_TX_USECS)
@@ -316,6 +318,9 @@ bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32, (ETHTOOL_COALESCE_TX_AGGR_MAX_BYTES | \ETHTOOL_COALESCE_TX_AGGR_MAX_FRAMES | \ ETHTOOL_COALESCE_TX_AGGR_TIME_USECS) +#define ETHTOOL_COALESCE_PROFILE \ + (ETHTOOL_COALESCE_RX_PROFILE | \ + ETHTOOL_COALESCE_TX_PROFILE)#define ETHTOOL_STAT_NOT_SET (~0ULL)
include/linux/netdevice.h +5 -0
@@ -2400,6 +2400,11 @@ struct net_device {/** @page_pools: page pools created for this netdevice */ struct hlist_head page_pools;#endif + +#if IS_ENABLED (CONFIG_DIMLIB ) +/** @irq_moder: dim related parameters for this netdevice */ +struct dim_irq_moder *irq_moder; +#endif };#define to_net_dev (d) container_of(d, struct net_device, dev)
include/uapi/linux/ethtool_netlink.h +22 -0
@@ -416,12 +416,34 @@ enum {ETHTOOL_A_COALESCE_TX_AGGR_MAX_BYTES ,/* u32 */ ETHTOOL_A_COALESCE_TX_AGGR_MAX_FRAMES ,/* u32 */ ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS ,/* u32 */ +/* nest - _A_PROFILE_IRQ_MODERATION */ +ETHTOOL_A_COALESCE_RX_PROFILE , +/* nest - _A_PROFILE_IRQ_MODERATION */ +ETHTOOL_A_COALESCE_TX_PROFILE ,/* add new constants above here */ __ETHTOOL_A_COALESCE_CNT,ETHTOOL_A_COALESCE_MAX = (__ETHTOOL_A_COALESCE_CNT -1 ) }; +enum { +ETHTOOL_A_PROFILE_UNSPEC , +/* nest, _A_IRQ_MODERATION_* */ +ETHTOOL_A_PROFILE_IRQ_MODERATION , + __ETHTOOL_A_PROFILE_CNT, +ETHTOOL_A_PROFILE_MAX = (__ETHTOOL_A_PROFILE_CNT -1 ) +}; + +enum { +ETHTOOL_A_IRQ_MODERATION_UNSPEC , +ETHTOOL_A_IRQ_MODERATION_USEC ,/* u32 */ +ETHTOOL_A_IRQ_MODERATION_PKTS ,/* u32 */ +ETHTOOL_A_IRQ_MODERATION_COMPS ,/* u32 */ + + __ETHTOOL_A_IRQ_MODERATION_CNT, +ETHTOOL_A_IRQ_MODERATION_MAX = (__ETHTOOL_A_IRQ_MODERATION_CNT -1 ) +}; +/* PAUSE */ enum {
lib/dim/net_dim.c +71 -0
83 lines not on this page · raw message
net/ethtool/coalesce.c +277 -1
354 lines not on this page · raw message
Signature · 1 line
2.32.0.3.g01195cf9f
PATCH v11 4/4 virtio-net: support dim profile fine-tuning
In reply to Heng QiVirtio-net has different types of back-end device implementations. In order to effectively optimize the dim library's gains for different device implementations, let's use the new interface params to initialize and query dim results from a customized profile list.
--- drivers/net/virtio_net.c | 48 ++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 7 deletions(-)
drivers/net/virtio_net.c +41 -7
@@ -2446,7 +2446,7 @@ static int virtnet_open(struct net_device *dev)for (i--; i >=0 ; i--) {virtnet_disable_queue_pair (vi, i); -cancel_work_sync (&vi->rq[i].dim.work); +net_dim_work_cancel (&vi->rq[i].dim); }return err;
@@ -2612,7 +2612,7 @@ static int virtnet_rx_resize(struct virtnet_info *vi,if (running) {napi_disable (&rq->napi); -cancel_work_sync (&rq->dim.work); +net_dim_work_cancel (&rq->dim); } err =virtqueue_resize (rq->vq, ring_num, virtnet_rq_unmap_free_buf);
@@ -2874,7 +2874,7 @@ static int virtnet_close(struct net_device *dev)for (i =0 ; i < vi->max_queue_pairs; i++) {virtnet_disable_queue_pair (vi, i); -cancel_work_sync (&vi->rq[i].dim.work); +net_dim_work_cancel (&vi->rq[i].dim); }return 0 ;
@@ -4363,7 +4363,7 @@ static void virtnet_rx_dim_work(struct work_struct *work)if (!rq->dim_enabled)continue ; - update_moder =net_dim_get_rx_moderation (dim->mode, dim->profile_ix); + update_moder =net_dim_get_rx_irq_moder (dev, dim);if (update_moder.usec != rq->intr_coal.max_usecs || update_moder.pkts != rq->intr_coal.max_packets) { err = virtnet_send_rx_ctrl_coal_vq_cmd(vi, qnum,
@@ -5054,6 +5054,37 @@ static void virtnet_tx_timeout(struct net_device *dev, unsigned int txqueue) jiffies_to_usecs(jiffies - READ_ONCE(txq->trans_start))); } +static int virtnet_init_irq_moder (struct virtnet_info *vi) +{ +u8 profile_flags =0 , coal_flags =0 ; +struct net_device *dev = vi->dev; +int ret, i; + + profile_flags |=DIM_PROFILE_RX ; + coal_flags |=DIM_COALESCE_USEC |DIM_COALESCE_PKTS ; + ret =net_dim_init_irq_moder (dev, profile_flags, coal_flags, +DIM_CQ_PERIOD_MODE_START_FROM_EQE , +0 , virtnet_rx_dim_work,NULL ); + +if (ret) +return ret; + +for (i =0 ; i < vi->max_queue_pairs; i++) +net_dim_setting (vi->dev, &vi->rq[i].dim, false); + +return 0 ; +} + +static void virtnet_free_irq_moder (struct virtnet_info *vi) +{ +if (!virtio_has_feature (vi->vdev,VIRTIO_NET_F_VQ_NOTF_COAL )) +return ; + +rtnl_lock (); +net_dim_free_irq_moder (vi->dev); +rtnl_unlock (); +} +static const struct net_device_ops virtnet_netdev = { .ndo_open = virtnet_open, .ndo_stop = virtnet_close,
@@ -5333,9 +5364,6 @@ static int virtnet_alloc_queues(struct virtnet_info *vi) virtnet_poll_tx, napi_tx ? napi_weight : 0); -INIT_WORK (&vi->rq[i].dim.work, virtnet_rx_dim_work); - vi->rq[i].dim.mode =DIM_CQ_PERIOD_MODE_START_FROM_EQE ; -sg_init_table (vi->rq[i].sg,ARRAY_SIZE (vi->rq[i].sg));ewma_pkt_len_init (&vi->rq[i].mrg_avg_pkt_len);sg_init_table (vi->sq[i].sg,ARRAY_SIZE (vi->sq[i].sg));
@@ -5753,6 +5781,10 @@ static int virtnet_probe(struct virtio_device *vdev)for (i =0 ; i < vi->max_queue_pairs; i++)if (vi->sq[i].napi.weight) vi->sq[i].intr_coal.max_packets =1 ; + + err =virtnet_init_irq_moder (vi); +if (err) + goto free; }#ifdef CONFIG_SYSFS
@@ -5896,6 +5928,8 @@ static void virtnet_remove(struct virtio_device *vdev)disable_rx_mode_work (vi);flush_work (&vi->rx_mode_work); +virtnet_free_irq_moder (vi); +unregister_netdev (vi->dev);net_failover_destroy (vi->failover);
Signature · 1 line
2.32.0.3.g01195cf9f
PATCH v11 1/4 linux/dim: move useful macros to .h file
In reply to Heng QiUseful macros will be used effectively elsewhere.
These will be utilized in subsequent patches.
--- include/linux/dim.h | 7 +++++++ lib/dim/net_dim.c | 6 ------ 2 files changed, 7 insertions(+), 6 deletions(-)
include/linux/dim.h +7 -0
@@ -10,6 +10,13 @@#include <linux/types.h> #include <linux/workqueue.h> +/* Number of DIM profiles and period mode. */ +#define NET_DIM_PARAMS_NUM_PROFILES 5 +#define NET_DIM_DEFAULT_RX_CQ_PKTS_FROM_EQE 256 +#define NET_DIM_DEFAULT_TX_CQ_PKTS_FROM_EQE 128 +#define NET_DIM_DEF_PROFILE_CQE 1 +#define NET_DIM_DEF_PROFILE_EQE 1 +/* * Number of events between DIM iterations. * Causes a moderation of the algorithm run.
lib/dim/net_dim.c +0 -6
@@ -11,12 +11,6 @@* There are different set of profiles for RX/TX CQs. * Each profile size must be of NET_DIM_PARAMS_NUM_PROFILES */ -#define NET_DIM_PARAMS_NUM_PROFILES 5 -#define NET_DIM_DEFAULT_RX_CQ_PKTS_FROM_EQE 256 -#define NET_DIM_DEFAULT_TX_CQ_PKTS_FROM_EQE 128 -#define NET_DIM_DEF_PROFILE_CQE 1 -#define NET_DIM_DEF_PROFILE_EQE 1 -#define NET_DIM_RX_EQE_PROFILES { \ {.usec = 1, .pkts = NET_DIM_DEFAULT_RX_CQ_PKTS_FROM_EQE,}, \ {.usec = 8, .pkts = NET_DIM_DEFAULT_RX_CQ_PKTS_FROM_EQE,}, \
Signature · 1 line
2.32.0.3.g01195cf9f
kernel test robot
build botRe: [PATCH net-next v11 2/4] ethtool: provide customized dim profile management
In reply to Heng Qikernel test robot noticed the following build warnings:
Hi Heng,
kernel test robot noticed the following build warnings:
[auto build test WARNING on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Heng-Qi/linux-dim-move-useful-macros-to-h-file/20240501-013413 base: net-next/main patch link: https://lore.kernel.org/r/20240430173136.15807-3-hengqi%40linux.alibaba.com patch subject: [PATCH net-next v11 2/4] ethtool: provide customized dim profile management config: openrisc-defconfig (https://download.01.org/0day-ci/archive/20240501/[email protected]/config) compiler: or1k-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240501/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
net/ethtool/coalesce.c: In function 'ethnl_update_profile':
net/ethtool/coalesce.c:453:46: error: 'struct net_device' has no member named 'irq_moder'
453 | struct dim_irq_moder *irq_moder = dev->irq_moder;
| ^~
net/ethtool/coalesce.c: At top level:
>> net/ethtool/coalesce.c:446:12: warning: 'ethnl_update_profile' defined but not used [-Wunused-function]
446 | static int ethnl_update_profile(struct net_device *dev,
| ^~~~~~~~~~~~~~~~~~~~
>> net/ethtool/coalesce.c:151:12: warning: 'coalesce_put_profile' defined but not used [-Wunused-function] 151 | static int coalesce_put_profile(struct sk_buff *skb, u16 attr_type,
| ^~~~~~~~~~~~~~~~~~~~
vim +/ethnl_update_profile +446 net/ethtool/coalesce.c
424
425 /**
426 * ethnl_update_profile - get a profile nest with child nests from userspace.
427 * @dev: netdevice to update the profile
428 * @dst: profile get from the driver and modified by ethnl_update_profile.
429 * @nests: nest attr ETHTOOL_A_COALESCE_*X_PROFILE to set profile.
430 * @extack: Netlink extended ack
431 *
432 * Layout of nests:
433 * Nested ETHTOOL_A_COALESCE_*X_PROFILE attr
434 * Nested ETHTOOL_A_PROFILE_IRQ_MODERATION attr
435 * ETHTOOL_A_IRQ_MODERATION_USEC attr
436 * ETHTOOL_A_IRQ_MODERATION_PKTS attr
437 * ETHTOOL_A_IRQ_MODERATION_COMPS attr
438 * ...
439 * Nested ETHTOOL_A_PROFILE_IRQ_MODERATION attr
440 * ETHTOOL_A_IRQ_MODERATION_USEC attr
441 * ETHTOOL_A_IRQ_MODERATION_PKTS attr
442 * ETHTOOL_A_IRQ_MODERATION_COMPS attr
443 *
444 * Return: 0 on success or a negative error code.
445 */
> 446 static int ethnl_update_profile(struct net_device *dev,
447 struct dim_cq_moder __rcu **dst,
448 const struct nlattr *nests,
449 struct netlink_ext_ack *extack)
450 {
451 int len_irq_moder = ARRAY_SIZE(coalesce_irq_moderation_policy);
452 struct nlattr *tb[ARRAY_SIZE(coalesce_irq_moderation_policy)];
> 453 struct dim_irq_moder *irq_moder = dev->irq_moder;
454 struct dim_cq_moder *new_profile, *old_profile;
455 int ret, rem, i = 0, len;
456 struct nlattr *nest;
457
458 if (!nests)
459 return 0;
460
461 if (!*dst)
462 return -EOPNOTSUPP;
463
464 old_profile = rtnl_dereference(*dst);
465 len = NET_DIM_PARAMS_NUM_PROFILES * sizeof(*old_profile);
466 new_profile = kmemdup(old_profile, len, GFP_KERNEL);
467 if (!new_profile)
468 return -ENOMEM;
469
470 nla_for_each_nested_type(nest, ETHTOOL_A_PROFILE_IRQ_MODERATION,
471 nests, rem) {
472 ret = nla_parse_nested(tb, len_irq_moder - 1, nest,
473 coalesce_irq_moderation_policy,
474 extack);
475 if (ret)
476 goto err_out;
477
478 ret = ethnl_update_irq_moder(irq_moder, &new_profile[i].usec,
479 ETHTOOL_A_IRQ_MODERATION_USEC,
480 tb, DIM_COALESCE_USEC,
481 extack);
482 if (ret)
483 goto err_out;
484
485 ret = ethnl_update_irq_moder(irq_moder, &new_profile[i].pkts,
486 ETHTOOL_A_IRQ_MODERATION_PKTS,
487 tb, DIM_COALESCE_PKTS,
488 extack);
489 if (ret)
490 goto err_out;
491
492 ret = ethnl_update_irq_moder(irq_moder, &new_profile[i].comps,
493 ETHTOOL_A_IRQ_MODERATION_COMPS,
494 tb, DIM_COALESCE_COMPS,
495 extack); 496 if (ret)
497 goto err_out;
498
499 i++;
500 }
501
502 rcu_assign_pointer(*dst, new_profile);
503 kfree_rcu(old_profile, rcu);
504
505 return 0;
506
507 err_out:
508 kfree(new_profile);
509 return ret;
510 }
511
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH net-next v11 2/4] ethtool: provide customized dim profile management
Quoted 25 lines · kernel test robot
Hi Heng,
kernel test robot noticed the following build warnings:
[auto build test WARNING on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Heng-Qi/linux-dim-move-useful-macros-to-h-file/20240501-013413 base: net-next/main patch link: https://lore.kernel.org/r/20240430173136.15807-3-hengqi%40linux.alibaba.com patch subject: [PATCH net-next v11 2/4] ethtool: provide customized dim profile management config: openrisc-defconfig (https://download.01.org/0day-ci/archive/20240501/[email protected]/config) compiler: or1k-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240501/[email protected]/reproduce)If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/All warnings (new ones prefixed by >>):
net/ethtool/coalesce.c: In function 'ethnl_update_profile':
net/ethtool/coalesce.c:453:46: error: 'structnet_device' has no member named 'irq_moder'453 | struct dim_irq_moder *irq_moder = dev->irq_moder; | ^~
Quoted 8 lines
net/ethtool/coalesce.c: At top level:Quoted 1 line
Quoted 1 line
net/ethtool/coalesce.c:446:12: warning: 'ethnl_update_profile' defined but not used [-Wunused-function]446 | static int ethnl_update_profile(struct
net_device*dev,
| ^~~~~~~~~~~~~~~~~~~~Quoted 1 line
Quoted 1 line
net/ethtool/coalesce.c:151:12: warning: 'coalesce_put_profile' defined but not used [-Wunused-function]151 | static int coalesce_put_profile(struct
sk_buff*skb, u16attr_type,
| ^~~~~~~~~~~~~~~~~~~~
This is a known minor issue, to reduce the use of 'IS_ENABLED(CONFIG_DIMLIB)' mentioned in v10. Since the calls of ethnl_update_profile() and coalesce_put_profile() will only occur when IS_ENABLED(CONFIG_DIMLIB) returns true, the robot's warning can be ignored the code is safe.
All NIPA test cases running on my local pass successfully on V11.
Alternatively, I remake the series to have IS_ENABLED(CONFIG_DIMLIB) back, up to Kuba (and others). :)
Thanks.
Quoted 95 lines
vim +/ethnl_update_profile +446
net/ethtool/coalesce.c424
425 /**
426 *ethnl_update_profile- get a profile nest with child nests from userspace.
427 * @dev: netdevice to update the profile
428 * @dst: profile get from the driver and modified byethnl_update_profile.
429 * @nests: nest attr ETHTOOL_A_COALESCE_*X_PROFILE to set profile.
430 * @extack: Netlink extended ack
431 *
432 * Layout of nests:
433 * Nested ETHTOOL_A_COALESCE_*X_PROFILE attr
434 * NestedETHTOOL_A_PROFILE_IRQ_MODERATIONattr435 * ETHTOOL_A_IRQ_MODERATION_USEC attr 436 * ETHTOOL_A_IRQ_MODERATION_PKTS attr 437 * ETHTOOL_A_IRQ_MODERATION_COMPS attr 438 * ... 439 * Nested ETHTOOL_A_PROFILE_IRQ_MODERATION attr 440 * ETHTOOL_A_IRQ_MODERATION_USEC attr 441 * ETHTOOL_A_IRQ_MODERATION_PKTS attr 442 * ETHTOOL_A_IRQ_MODERATION_COMPS attr443 *
444 * Return: 0 on success or a negative error code.
445 */Quoted 1 line
446 static int ethnl_update_profile(struct
net_device*dev,447 struct
dim_cq_moder__rcu**dst,
448 const struct nlattr *nests,
449 structnetlink_ext_ack*extack)450 { 451 int len_irq_moder = ARRAY_SIZE(coalesce_irq_moderation_policy); 452 struct nlattr *tb[ARRAY_SIZE(coalesce_irq_moderation_policy)];Quoted 1 line
453 struct
dim_irq_moder*irq_moder=dev->irq_moder;454 struct dim_cq_moder *new_profile, *old_profile; 455 int ret, rem, i = 0, len; 456 struct nlattr *nest; 457 458 if (!nests) 459 return 0; 460 461 if (!*dst) 462 return -EOPNOTSUPP; 463 464 old_profile = rtnl_dereference(*dst); 465 len = NET_DIM_PARAMS_NUM_PROFILES * sizeof(*old_profile); 466 new_profile = kmemdup(old_profile, len, GFP_KERNEL); 467 if (!new_profile) 468 return -ENOMEM; 469 470 nla_for_each_nested_type(nest, ETHTOOL_A_PROFILE_IRQ_MODERATION, 471 nests, rem) { 472 ret = nla_parse_nested(tb, len_irq_moder - 1, nest, 473 coalesce_irq_moderation_policy, 474 extack); 475 if (ret) 476 goto err_out; 477 478 ret = ethnl_update_irq_moder(irq_moder, &new_profile[i].usec, 479 ETHTOOL_A_IRQ_MODERATION_USEC, 480 tb, DIM_COALESCE_USEC, 481 extack); 482 if (ret) 483 goto err_out; 484 485 ret = ethnl_update_irq_moder(irq_moder, &new_profile[i].pkts, 486 ETHTOOL_A_IRQ_MODERATION_PKTS, 487 tb, DIM_COALESCE_PKTS, 488 extack); 489 if (ret) 490 goto err_out; 491 492 ret = ethnl_update_irq_moder(irq_moder, &new_profile[i].comps, 493 ETHTOOL_A_IRQ_MODERATION_COMPS, 494 tb, DIM_COALESCE_COMPS, 495 extack); 496 if (ret) 497 goto err_out; 498 499 i++; 500 } 501 502 rcu_assign_pointer(*dst, new_profile); 503 kfree_rcu(old_profile, rcu); 504 505 return 0; 506 507 err_out: 508 kfree(new_profile); 509 return ret; 510 } 511Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Michael S. Tsirkin
maintainerRe: [PATCH net-next v11 2/4] ethtool: provide customized dim profile management
Quoted 35 lines · Heng Qi
Quoted 25 lines · kernel test robot
Hi Heng,
kernel test robot noticed the following build warnings:
[auto build test WARNING on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Heng-Qi/linux-dim-move-useful-macros-to-h-file/20240501-013413 base: net-next/main patch link: https://lore.kernel.org/r/20240430173136.15807-3-hengqi%40linux.alibaba.com patch subject: [PATCH net-next v11 2/4] ethtool: provide customized dim profile management config: openrisc-defconfig (https://download.01.org/0day-ci/archive/20240501/[email protected]/config) compiler: or1k-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240501/[email protected]/reproduce)If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/All warnings (new ones prefixed by >>):
net/ethtool/coalesce.c: In function 'ethnl_update_profile':
net/ethtool/coalesce.c:453:46: error: 'structnet_device' has no member named 'irq_moder'453 | struct dim_irq_moder *irq_moder = dev->irq_moder; | ^~Quoted 8 lines
net/ethtool/coalesce.c: At top level:Quoted 1 line
Quoted 1 line
net/ethtool/coalesce.c:446:12: warning: 'ethnl_update_profile' defined but not used [-Wunused-function]446 | static int ethnl_update_profile(struct
net_device*dev,
| ^~~~~~~~~~~~~~~~~~~~Quoted 1 line
Quoted 1 line
net/ethtool/coalesce.c:151:12: warning: 'coalesce_put_profile' defined but not used [-Wunused-function]151 | static int coalesce_put_profile(struct
sk_buff*skb, u16attr_type,
| ^~~~~~~~~~~~~~~~~~~~
Quoted 5 lines
This is a known minor issue,
to reduce the use of 'IS_ENABLED(CONFIG_DIMLIB)'
mentioned in v10. Since the calls ofethnl_update_profile()andcoalesce_put_profile()will only occur whenIS_ENABLED(CONFIG_DIMLIB)returns true, the robot's warning can be ignored the code is safe.
I don't get it. The build seems to fail. How is this a minor issue?
Quoted 102 lines
All NIPA test cases running on my local pass successfully on V11.
Alternatively, I remake the series to have
IS_ENABLED(CONFIG_DIMLIB)back, up to Kuba (and others). :)Thanks.
Quoted 95 lines
vim +/ethnl_update_profile +446
net/ethtool/coalesce.c424
425 /**
426 *ethnl_update_profile- get a profile nest with child nests from userspace.
427 * @dev: netdevice to update the profile
428 * @dst: profile get from the driver and modified byethnl_update_profile.
429 * @nests: nest attr ETHTOOL_A_COALESCE_*X_PROFILE to set profile.
430 * @extack: Netlink extended ack
431 *
432 * Layout of nests:
433 * Nested ETHTOOL_A_COALESCE_*X_PROFILE attr
434 * NestedETHTOOL_A_PROFILE_IRQ_MODERATIONattr435 * ETHTOOL_A_IRQ_MODERATION_USEC attr 436 * ETHTOOL_A_IRQ_MODERATION_PKTS attr 437 * ETHTOOL_A_IRQ_MODERATION_COMPS attr 438 * ... 439 * Nested ETHTOOL_A_PROFILE_IRQ_MODERATION attr 440 * ETHTOOL_A_IRQ_MODERATION_USEC attr 441 * ETHTOOL_A_IRQ_MODERATION_PKTS attr 442 * ETHTOOL_A_IRQ_MODERATION_COMPS attr443 *
444 * Return: 0 on success or a negative error code.
445 */Quoted 1 line
446 static int ethnl_update_profile(struct
net_device*dev,447 struct
dim_cq_moder__rcu**dst,
448 const struct nlattr *nests,
449 structnetlink_ext_ack*extack)450 { 451 int len_irq_moder = ARRAY_SIZE(coalesce_irq_moderation_policy); 452 struct nlattr *tb[ARRAY_SIZE(coalesce_irq_moderation_policy)];Quoted 1 line
453 struct
dim_irq_moder*irq_moder=dev->irq_moder;454 struct dim_cq_moder *new_profile, *old_profile; 455 int ret, rem, i = 0, len; 456 struct nlattr *nest; 457 458 if (!nests) 459 return 0; 460 461 if (!*dst) 462 return -EOPNOTSUPP; 463 464 old_profile = rtnl_dereference(*dst); 465 len = NET_DIM_PARAMS_NUM_PROFILES * sizeof(*old_profile); 466 new_profile = kmemdup(old_profile, len, GFP_KERNEL); 467 if (!new_profile) 468 return -ENOMEM; 469 470 nla_for_each_nested_type(nest, ETHTOOL_A_PROFILE_IRQ_MODERATION, 471 nests, rem) { 472 ret = nla_parse_nested(tb, len_irq_moder - 1, nest, 473 coalesce_irq_moderation_policy, 474 extack); 475 if (ret) 476 goto err_out; 477 478 ret = ethnl_update_irq_moder(irq_moder, &new_profile[i].usec, 479 ETHTOOL_A_IRQ_MODERATION_USEC, 480 tb, DIM_COALESCE_USEC, 481 extack); 482 if (ret) 483 goto err_out; 484 485 ret = ethnl_update_irq_moder(irq_moder, &new_profile[i].pkts, 486 ETHTOOL_A_IRQ_MODERATION_PKTS, 487 tb, DIM_COALESCE_PKTS, 488 extack); 489 if (ret) 490 goto err_out; 491 492 ret = ethnl_update_irq_moder(irq_moder, &new_profile[i].comps, 493 ETHTOOL_A_IRQ_MODERATION_COMPS, 494 tb, DIM_COALESCE_COMPS, 495 extack); 496 if (ret) 497 goto err_out; 498 499 i++; 500 } 501 502 rcu_assign_pointer(*dst, new_profile); 503 kfree_rcu(old_profile, rcu); 504 505 return 0; 506 507 err_out: 508 kfree(new_profile); 509 return ret; 510 } 511Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH net-next v11 2/4] ethtool: provide customized dim profile management
In reply to Heng Qikernel test robot noticed the following build errors:
Hi Heng,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Heng-Qi/linux-dim-move-useful-macros-to-h-file/20240501-013413 base: net-next/main patch link: https://lore.kernel.org/r/20240430173136.15807-3-hengqi%40linux.alibaba.com patch subject: [PATCH net-next v11 2/4] ethtool: provide customized dim profile management config: openrisc-defconfig (https://download.01.org/0day-ci/archive/20240501/[email protected]/config) compiler: or1k-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240501/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
net/ethtool/coalesce.c: In function 'ethnl_update_profile':
>> net/ethtool/coalesce.c:453:46: error: 'struct net_device' has no member named 'irq_moder'
453 | struct dim_irq_moder *irq_moder = dev->irq_moder;
| ^~ net/ethtool/coalesce.c: At top level:
net/ethtool/coalesce.c:446:12: warning: 'ethnl_update_profile' defined but not used [-Wunused-function]
446 | static int ethnl_update_profile(struct net_device *dev,
| ^~~~~~~~~~~~~~~~~~~~
net/ethtool/coalesce.c:151:12: warning: 'coalesce_put_profile' defined but not used [-Wunused-function]
151 | static int coalesce_put_profile(struct sk_buff *skb, u16 attr_type,
| ^~~~~~~~~~~~~~~~~~~~
vim +453 net/ethtool/coalesce.c
424
425 /**
426 * ethnl_update_profile - get a profile nest with child nests from userspace.
427 * @dev: netdevice to update the profile
428 * @dst: profile get from the driver and modified by ethnl_update_profile.
429 * @nests: nest attr ETHTOOL_A_COALESCE_*X_PROFILE to set profile.
430 * @extack: Netlink extended ack
431 *
432 * Layout of nests:
433 * Nested ETHTOOL_A_COALESCE_*X_PROFILE attr
434 * Nested ETHTOOL_A_PROFILE_IRQ_MODERATION attr
435 * ETHTOOL_A_IRQ_MODERATION_USEC attr
436 * ETHTOOL_A_IRQ_MODERATION_PKTS attr
437 * ETHTOOL_A_IRQ_MODERATION_COMPS attr
438 * ...
439 * Nested ETHTOOL_A_PROFILE_IRQ_MODERATION attr
440 * ETHTOOL_A_IRQ_MODERATION_USEC attr
441 * ETHTOOL_A_IRQ_MODERATION_PKTS attr
442 * ETHTOOL_A_IRQ_MODERATION_COMPS attr
443 *
444 * Return: 0 on success or a negative error code.
445 */
446 static int ethnl_update_profile(struct net_device *dev,
447 struct dim_cq_moder __rcu **dst,
448 const struct nlattr *nests,
449 struct netlink_ext_ack *extack)
450 {
451 int len_irq_moder = ARRAY_SIZE(coalesce_irq_moderation_policy);
452 struct nlattr *tb[ARRAY_SIZE(coalesce_irq_moderation_policy)];
> 453 struct dim_irq_moder *irq_moder = dev->irq_moder;
454 struct dim_cq_moder *new_profile, *old_profile;
455 int ret, rem, i = 0, len;
456 struct nlattr *nest;
457
458 if (!nests)
459 return 0;
460
461 if (!*dst)
462 return -EOPNOTSUPP;
463
464 old_profile = rtnl_dereference(*dst);
465 len = NET_DIM_PARAMS_NUM_PROFILES * sizeof(*old_profile);
466 new_profile = kmemdup(old_profile, len, GFP_KERNEL);
467 if (!new_profile)
468 return -ENOMEM;
469
470 nla_for_each_nested_type(nest, ETHTOOL_A_PROFILE_IRQ_MODERATION,
471 nests, rem) {
472 ret = nla_parse_nested(tb, len_irq_moder - 1, nest,
473 coalesce_irq_moderation_policy,
474 extack);
475 if (ret)
476 goto err_out;
477
478 ret = ethnl_update_irq_moder(irq_moder, &new_profile[i].usec,
479 ETHTOOL_A_IRQ_MODERATION_USEC,
480 tb, DIM_COALESCE_USEC,
481 extack);
482 if (ret)
483 goto err_out;
484
485 ret = ethnl_update_irq_moder(irq_moder, &new_profile[i].pkts,
486 ETHTOOL_A_IRQ_MODERATION_PKTS,
487 tb, DIM_COALESCE_PKTS,
488 extack);
489 if (ret)
490 goto err_out;
491
492 ret = ethnl_update_irq_moder(irq_moder, &new_profile[i].comps,
493 ETHTOOL_A_IRQ_MODERATION_COMPS,
494 tb, DIM_COALESCE_COMPS,
495 extack); 496 if (ret)
497 goto err_out;
498
499 i++;
500 }
501
502 rcu_assign_pointer(*dst, new_profile);
503 kfree_rcu(old_profile, rcu);
504
505 return 0;
506
507 err_out:
508 kfree(new_profile);
509 return ret;
510 }
511
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH net-next v11 2/4] ethtool: provide customized dim profile management
In reply to Heng Qikernel test robot noticed the following build errors:
Hi Heng,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Heng-Qi/linux-dim-move-useful-macros-to-h-file/20240501-013413 base: net-next/main patch link: https://lore.kernel.org/r/20240430173136.15807-3-hengqi%40linux.alibaba.com patch subject: [PATCH net-next v11 2/4] ethtool: provide customized dim profile management config: um-allmodconfig (https://download.01.org/0day-ci/archive/20240501/[email protected]/config) compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project 37ae4ad0eef338776c7e2cffb3896153d43dcd90) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240501/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from net/ethtool/coalesce.c:3:
In file included from include/linux/dim.h:12:
In file included from include/linux/netdevice.h:38:
In file included from include/net/net_namespace.h:43:
In file included from include/linux/skbuff.h:17:
In file included from include/linux/bvec.h:10:
In file included from include/linux/highmem.h:8:
In file included from include/linux/cacheflush.h:5:
In file included from arch/um/include/asm/cacheflush.h:4:
In file included from arch/um/include/asm/tlbflush.h:9:
In file included from include/linux/mm.h:2208:
include/linux/vmstat.h:522:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
522 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
In file included from net/ethtool/coalesce.c:3:
In file included from include/linux/dim.h:12:
In file included from include/linux/netdevice.h:38:
In file included from include/net/net_namespace.h:43:
In file included from include/linux/skbuff.h:17:
In file included from include/linux/bvec.h:10:
In file included from include/linux/highmem.h:12:
In file included from include/linux/hardirq.h:11:
In file included from arch/um/include/asm/hardirq.h:5:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/um/include/asm/io.h:24:
include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
547 | val = __raw_readb(PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
560 | val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
| ^
In file included from net/ethtool/coalesce.c:3:
In file included from include/linux/dim.h:12:
In file included from include/linux/netdevice.h:38:
In file included from include/net/net_namespace.h:43:
In file included from include/linux/skbuff.h:17:
In file included from include/linux/bvec.h:10:
In file included from include/linux/highmem.h:12:
In file included from include/linux/hardirq.h:11:
In file included from arch/um/include/asm/hardirq.h:5:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/um/include/asm/io.h:24:
include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
573 | val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
| ^
In file included from net/ethtool/coalesce.c:3:
In file included from include/linux/dim.h:12:
In file included from include/linux/netdevice.h:38:
In file included from include/net/net_namespace.h:43:
In file included from include/linux/skbuff.h:17:
In file included from include/linux/bvec.h:10:
In file included from include/linux/highmem.h:12:
In file included from include/linux/hardirq.h:11:
In file included from arch/um/include/asm/hardirq.h:5:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/um/include/asm/io.h:24:
include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
584 | __raw_writeb(value, PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
594 | __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
604 | __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:692:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
692 | readsb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:700:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
700 | readsw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:708:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
708 | readsl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:717:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
717 | writesb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:726:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
726 | writesw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:735:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
735 | writesl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
>> net/ethtool/coalesce.c:453:41: error: no member named 'irq_moder' in 'struct net_device' 453 | struct dim_irq_moder *irq_moder = dev->irq_moder;
| ~~~ ^
13 warnings and 1 error generated.
vim +453 net/ethtool/coalesce.c
424
425 /**
426 * ethnl_update_profile - get a profile nest with child nests from userspace.
427 * @dev: netdevice to update the profile
428 * @dst: profile get from the driver and modified by ethnl_update_profile.
429 * @nests: nest attr ETHTOOL_A_COALESCE_*X_PROFILE to set profile.
430 * @extack: Netlink extended ack
431 *
432 * Layout of nests:
433 * Nested ETHTOOL_A_COALESCE_*X_PROFILE attr
434 * Nested ETHTOOL_A_PROFILE_IRQ_MODERATION attr
435 * ETHTOOL_A_IRQ_MODERATION_USEC attr
436 * ETHTOOL_A_IRQ_MODERATION_PKTS attr
437 * ETHTOOL_A_IRQ_MODERATION_COMPS attr
438 * ...
439 * Nested ETHTOOL_A_PROFILE_IRQ_MODERATION attr
440 * ETHTOOL_A_IRQ_MODERATION_USEC attr
441 * ETHTOOL_A_IRQ_MODERATION_PKTS attr
442 * ETHTOOL_A_IRQ_MODERATION_COMPS attr
443 *
444 * Return: 0 on success or a negative error code.
445 */
446 static int ethnl_update_profile(struct net_device *dev,
447 struct dim_cq_moder __rcu **dst,
448 const struct nlattr *nests,
449 struct netlink_ext_ack *extack)
450 {
451 int len_irq_moder = ARRAY_SIZE(coalesce_irq_moderation_policy);
452 struct nlattr *tb[ARRAY_SIZE(coalesce_irq_moderation_policy)];
> 453 struct dim_irq_moder *irq_moder = dev->irq_moder;
454 struct dim_cq_moder *new_profile, *old_profile;
455 int ret, rem, i = 0, len;
456 struct nlattr *nest;
457
458 if (!nests)
459 return 0;
460
461 if (!*dst)
462 return -EOPNOTSUPP;
463
464 old_profile = rtnl_dereference(*dst);
465 len = NET_DIM_PARAMS_NUM_PROFILES * sizeof(*old_profile);
466 new_profile = kmemdup(old_profile, len, GFP_KERNEL);
467 if (!new_profile)
468 return -ENOMEM;
469
470 nla_for_each_nested_type(nest, ETHTOOL_A_PROFILE_IRQ_MODERATION,
471 nests, rem) {
472 ret = nla_parse_nested(tb, len_irq_moder - 1, nest,
473 coalesce_irq_moderation_policy,
474 extack);
475 if (ret)
476 goto err_out;
477
478 ret = ethnl_update_irq_moder(irq_moder, &new_profile[i].usec,
479 ETHTOOL_A_IRQ_MODERATION_USEC,
480 tb, DIM_COALESCE_USEC,
481 extack);
482 if (ret)
483 goto err_out;
484
485 ret = ethnl_update_irq_moder(irq_moder, &new_profile[i].pkts,
486 ETHTOOL_A_IRQ_MODERATION_PKTS,
487 tb, DIM_COALESCE_PKTS,
488 extack);
489 if (ret)
490 goto err_out;
491
492 ret = ethnl_update_irq_moder(irq_moder, &new_profile[i].comps,
493 ETHTOOL_A_IRQ_MODERATION_COMPS,
494 tb, DIM_COALESCE_COMPS,
495 extack); 496 if (ret)
497 goto err_out;
498
499 i++;
500 }
501
502 rcu_assign_pointer(*dst, new_profile);
503 kfree_rcu(old_profile, rcu);
504
505 return 0;
506
507 err_out:
508 kfree(new_profile);
509 return ret;
510 }
511
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Jakub Kicinski
maintainerRe: [PATCH net-next v11 2/4] ethtool: provide customized dim profile management
In reply to Heng QiQuoted 14 lines · On Wed, 1 May 2024 12:45:36 +0800 Heng Qi wrote:
Quoted 1 line
net/ethtool/coalesce.c: At top level:[...]
Quoted 2 lines
446 | static int ethnl_update_profile(struct
net_device*dev,
| ^~~~~~~~~~~~~~~~~~~~[...]
Quoted 3 lines
151 | static int coalesce_put_profile(struct
sk_buff*skb, u16attr_type,
| ^~~~~~~~~~~~~~~~~~~~This is a known minor issue, to reduce the use of '
IS_ENABLED(CONFIG_DIMLIB)' mentioned in v10. Since the calls ofethnl_update_profile()andcoalesce_put_profile()will only occur whenIS_ENABLED(CONFIG_DIMLIB)returns true, the robot's warning can be ignored the code is safe.
Quoted 4 lines
All NIPA test cases running on my local pass successfully on V11.
Alternatively, I remake the series to have
IS_ENABLED(CONFIG_DIMLIB)back, up to Kuba (and others). :)
You should remove the ifdef around the member in struct net_device. It's too much code complication to save one pointer in the struct.
Re: [PATCH net-next v11 2/4] ethtool: provide customized dim profile management
Quoted 15 lines · Jakub Kicinski
Quoted 14 lines · On Wed, 1 May 2024 12:45:36 +0800 Heng Qi wrote:
Quoted 1 line
net/ethtool/coalesce.c: At top level:[...]
Quoted 2 lines
446 | static int ethnl_update_profile(struct
net_device*dev,
| ^~~~~~~~~~~~~~~~~~~~[...]
Quoted 3 lines
151 | static int coalesce_put_profile(struct
sk_buff*skb, u16attr_type,
| ^~~~~~~~~~~~~~~~~~~~This is a known minor issue, to reduce the use of '
IS_ENABLED(CONFIG_DIMLIB)' mentioned in v10. Since the calls ofethnl_update_profile()andcoalesce_put_profile()will only occur whenIS_ENABLED(CONFIG_DIMLIB)returns true, the robot's warning can be ignored the code is safe.
Quoted 7 lines
Quoted 4 lines
All NIPA test cases running on my local pass successfully on V11.
Alternatively, I remake the series to have
IS_ENABLED(CONFIG_DIMLIB)back, up to Kuba (and others). :)You should remove the ifdef around the member in struct
net_device. It's too much code complication to save one pointer in the struct.
Makes sense.
Thanks.
Michael S. Tsirkin
maintainerRe: [PATCH net-next v11 2/4] ethtool: provide customized dim profile management
Quoted 21 lines · Heng Qi
Quoted 20 lines · Jakub Kicinski
Quoted 18 lines · On Wed, 1 May 2024 12:45:36 +0800 Heng Qi wrote:
Quoted 1 line
net/ethtool/coalesce.c: At top level:[...]
Quoted 2 lines
446 | static int ethnl_update_profile(struct
net_device*dev,
| ^~~~~~~~~~~~~~~~~~~~[...]
Quoted 3 lines
151 | static int coalesce_put_profile(struct
sk_buff*skb, u16attr_type,
| ^~~~~~~~~~~~~~~~~~~~This is a known minor issue, to reduce the use of '
IS_ENABLED(CONFIG_DIMLIB)' mentioned in v10. Since the calls ofethnl_update_profile()andcoalesce_put_profile()will only occur whenIS_ENABLED(CONFIG_DIMLIB)returns true, the robot's warning can be ignored the code is safe.All NIPA test cases running on my local pass successfully on V11.
Alternatively, I remake the series to have
IS_ENABLED(CONFIG_DIMLIB)back, up to Kuba (and others). :)
Quoted 6 lines
Quoted 2 lines
You should remove the ifdef around the member in struct
net_device. It's too much code complication to save one pointer in the struct.Makes sense.
Thanks.
if you really want to you can add a comment
/* only used if IS_ENABLED(CONFIG_DIMLIB) */
Re: [PATCH net-next v11 2/4] ethtool: provide customized dim profile management
Quoted 25 lines · Michael S. Tsirkin
Quoted 24 lines · Heng Qi
Quoted 22 lines · Jakub Kicinski
Quoted 14 lines · On Wed, 1 May 2024 12:45:36 +0800 Heng Qi wrote:
Quoted 1 line
net/ethtool/coalesce.c: At top level:[...]
Quoted 2 lines
446 | static int ethnl_update_profile(struct
net_device*dev,
| ^~~~~~~~~~~~~~~~~~~~[...]
Quoted 3 lines
151 | static int coalesce_put_profile(struct
sk_buff*skb, u16attr_type,
| ^~~~~~~~~~~~~~~~~~~~This is a known minor issue, to reduce the use of '
IS_ENABLED(CONFIG_DIMLIB)' mentioned in v10. Since the calls ofethnl_update_profile()andcoalesce_put_profile()will only occur whenIS_ENABLED(CONFIG_DIMLIB)returns true, the robot's warning can be ignored the code is safe.Quoted 4 lines
All NIPA test cases running on my local pass successfully on V11.
Alternatively, I remake the series to have
IS_ENABLED(CONFIG_DIMLIB)back, up to Kuba (and others). :)You should remove the ifdef around the member in struct
net_device. It's too much code complication to save one pointer in the struct.
Quoted 7 lines
Quoted 3 lines
Makes sense.
Thanks.
if you really want to you can add a comment
/* only used ifIS_ENABLED(CONFIG_DIMLIB)*/
Ok, I'll add this.
Thanks.
Simon Horman
reviewerRe: [PATCH net-next v11 2/4] ethtool: provide customized dim profile management
In reply to Heng QiOn Wed, May 01, 2024 at 01:31:34AM +0800, Heng Qi wrote:
...
Quoted 1 line
include/linux/dim.h +0
-0
...
Quoted 7 lines
include/linux/dim.h +3
-0@@ -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
include/linux/dim.h enum dim_step_result { · line 249
Quoted 10 lines
include/linux/dim.h +10
-0+* @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
...
Quoted 1 line
net/ethtool/coalesce.c +0
-0
...
net/ethtool/coalesce.c static int coalesce_fill_reply(struct sk_buff *skb, · line 221
Quoted 11 lines
net/ethtool/coalesce.c +6
-0@@ -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.
Quoted 34 lines
net/ethtool/coalesce.c +27
-0if (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 ; }
...
Re: [PATCH net-next v11 2/4] ethtool: provide customized dim profile management
Quoted 12 lines · Simon Horman
On Wed, May 01, 2024 at 01:31:34AM +0800, Heng Qi wrote:
...
Quoted 1 line
include/linux/dim.h +0
-0...
Quoted 4 lines
include/linux/dim.h +0
-0@@ -198,6 +234,32 @@ enum dim_step_result { DIM_ON_EDGE, };
Quoted 15 lines
include/linux/dim.h enum dim_step_result { · line 249
Quoted 13 lines
include/linux/dim.h +13
-0+/** +* 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,
Hi Simon,
Quoted 8 lines
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.
Quoted 4 lines
I suggest the following alternative:
* @rx_dim_work: Rx worker called after dim decision
* @tx_dim_work: Tx worker called after dim decision
Will update this.
Quoted 30 lines
Exercised using Sphinx 7.2.6
...
Quoted 1 line
net/ethtool/coalesce.c +0
-0...
net/ethtool/coalesce.c static int coalesce_fill_reply(struct sk_buff *skb, · line 221
Quoted 11 lines
net/ethtool/coalesce.c +6
-0@@ -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_ENABLEDcondition, 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:
Quoted 8 lines
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;
Note: The line above depends on the line below. :)
However, even so, I will try to make a change to keep "xmas tree order".
Quoted 10 lines
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 thatCONFIG_DIMLIBis not enabled. In general I'd recommend that approach over sprinklingIS_ENABLEDor #ifdef inside functions. Because in my experience it tends to lead to more readable code.
As discussed in the previous replies, IS_ENABLED(CONFIG_DIMLIB) will be removed in the next version, so we'll do not have this problem, but your suggestion is good.
Thanks.
Quoted 42 lines
In any case, the following tool is helpful for isolating reverse xmas tree issues.
https://github.com/ecree-solarflare/xmastree
Quoted 34 lines
net/ethtool/coalesce.c +27
-0if (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 ; }...