devlink: features, linecard and reporters locking cleanup
Subsystems (11)
Jiri Pirko
maintainerv3 cover devlink: features, linecard and reporters locking cleanup
From: Jiri Pirko <[email protected]>
This patchset does not change functionality.
In the first patch, no longer needed devlink features are removed.
Patches 2-7 removes linecards and reporters locks and reference counting, converting them to be protected by devlink instance lock as the rest of the objects.
Patches 8 and 9 convert linecards and reporters dumpit callbacks to recently introduced devlink_nl_instance_iter_dump() infra. Patch 10 removes no longer needed devlink_dump_for_each_instance_get() helper.
The last patch adds assertion to devl_is_registered() as dependency on other locks is removed.
---v2->v3:
- see individual patches for changelog, mainly original patch #4 was split into 3 patches for easier reviewv1->v2:
- patch 7 bits were unsquashed to patch 8
Jiri Pirko (11):
devlink: remove devlink features
devlink: remove linecards lock
devlink: remove linecard reference counting
devlink: protect health reporter operation with instance lock
devlink: remove reporters_lock
devlink: remove devl_port_health_reporter_destroy()
devlink: remove reporter reference counting
devlink: convert linecards dump to devlink_nl_instance_iter_dump()
devlink: convert reporters dump to devlink_nl_instance_iter_dump()
devlink: remove devlink_dump_for_each_instance_get() helper
devlink: add instance lock assertion in devl_is_registered()
.../net/ethernet/broadcom/bnxt/bnxt_devlink.c | 1 - .../hisilicon/hns3/hns3pf/hclge_devlink.c | 1 - .../hisilicon/hns3/hns3vf/hclgevf_devlink.c | 1 - drivers/net/ethernet/intel/ice/ice_devlink.c | 1 - drivers/net/ethernet/mellanox/mlx4/main.c | 1 - .../net/ethernet/mellanox/mlx5/core/devlink.c | 9 +- .../ethernet/mellanox/mlx5/core/en/health.c | 12 + .../mellanox/mlx5/core/en/reporter_rx.c | 6 +- .../mellanox/mlx5/core/en/reporter_tx.c | 6 +- drivers/net/ethernet/mellanox/mlxsw/core.c | 9 +- .../ethernet/mellanox/mlxsw/core_linecards.c | 8 +- drivers/net/netdevsim/dev.c | 1 - drivers/net/netdevsim/health.c | 20 +- include/net/devlink.h | 28 +- net/devlink/core.c | 23 - net/devlink/devl_internal.h | 21 +- net/devlink/leftover.c | 431 +++++++----------- net/devlink/netlink.c | 12 +- 18 files changed, 219 insertions(+), 372 deletions(-)
Signature · 1 line
2.39.0
Jiri Pirko
maintainerPATCH v3 1/11 devlink: remove devlink features
From: Jiri Pirko <[email protected]>
Devlink features were introduced to disallow devlink reload calls of userspace before the devlink was fully initialized. The reason for this workaround was the fact that devlink reload was originally called without devlink instance lock held.
However, with recent changes that converted devlink reload to be performed under devlink instance lock, this is redundant so remove devlink features entirely.
Note that mlx5 used this to enable devlink reload conditionally only when device didn't act as multi port slave. Move the multi port check into mlx5_devlink_reload_down() callback alongside with the other checks preventing the device from reload in certain states.
---v2->v3:
- removed devlink_set_features() prototype from include/net/devlink.h
--- .../net/ethernet/broadcom/bnxt/bnxt_devlink.c | 1 - .../hisilicon/hns3/hns3pf/hclge_devlink.c | 1 - .../hisilicon/hns3/hns3vf/hclgevf_devlink.c | 1 - drivers/net/ethernet/intel/ice/ice_devlink.c | 1 - drivers/net/ethernet/mellanox/mlx4/main.c | 1 - .../net/ethernet/mellanox/mlx5/core/devlink.c | 9 +++++---- drivers/net/ethernet/mellanox/mlxsw/core.c | 1 - drivers/net/netdevsim/dev.c | 1 - include/net/devlink.h | 2 +- net/devlink/core.c | 19 ------------------- net/devlink/devl_internal.h | 1 - net/devlink/leftover.c | 3 --- 12 files changed, 6 insertions(+), 35 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c +0 -1
@@ -1303,7 +1303,6 @@ int bnxt_dl_register(struct bnxt *bp)if (rc) goto err_dl_port_unreg; -devlink_set_features (dl,DEVLINK_F_RELOAD ); out:devlink_register (dl);return 0 ;
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c +0 -1
@@ -114,7 +114,6 @@ int hclge_devlink_init(struct hclge_dev *hdev) priv->hdev = hdev; hdev->devlink = devlink; -devlink_set_features (devlink,DEVLINK_F_RELOAD );devlink_register (devlink);return 0 ; }
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_devlink.c +0 -1
@@ -116,7 +116,6 @@ int hclgevf_devlink_init(struct hclgevf_dev *hdev) priv->hdev = hdev; hdev->devlink = devlink; -devlink_set_features (devlink,DEVLINK_F_RELOAD );devlink_register (devlink);return 0 ; }
drivers/net/ethernet/intel/ice/ice_devlink.c +0 -1
@@ -1376,7 +1376,6 @@ void ice_devlink_register(struct ice_pf *pf) {struct devlink *devlink =priv_to_devlink (pf); -devlink_set_features (devlink,DEVLINK_F_RELOAD );devlink_register (devlink); }
drivers/net/ethernet/mellanox/mlx4/main.c +0 -1
@@ -4031,7 +4031,6 @@ static int mlx4_init_one(struct pci_dev *pdev, const struct pci_device_id *id) goto err_params_unregister;pci_save_state (pdev); -devlink_set_features (devlink,DEVLINK_F_RELOAD );devl_unlock (devlink);devlink_register (devlink);return 0 ;
drivers/net/ethernet/mellanox/mlx5/core/devlink.c +5 -4
@@ -156,6 +156,11 @@ static int mlx5_devlink_reload_down(struct devlink *devlink, bool netns_change,return -EOPNOTSUPP ; } +if (mlx5_core_is_mp_slave (dev)) { +NL_SET_ERR_MSG_MOD (extack,"reload is unsupported for multi port slave" ); +return -EOPNOTSUPP ; + } +if (pci_num_vf (pdev)) {NL_SET_ERR_MSG_MOD (extack,"reload while VFs are present is unfavorable" ); }
@@ -871,7 +876,6 @@ void mlx5_devlink_traps_unregister(struct devlink *devlink)int mlx5_devlink_register (struct devlink *devlink) { -struct mlx5_core_dev *dev =devlink_priv (devlink);int err; err = devlink_params_register(devlink, mlx5_devlink_params,
@@ -889,9 +893,6 @@ int mlx5_devlink_register(struct devlink *devlink)if (err) goto max_uc_list_err; -if (!mlx5_core_is_mp_slave (dev)) -devlink_set_features (devlink,DEVLINK_F_RELOAD ); -return 0 ; max_uc_list_err:
drivers/net/ethernet/mellanox/mlxsw/core.c +0 -1
@@ -2211,7 +2211,6 @@ __mlxsw_core_bus_device_register(const struct mlxsw_bus_info *mlxsw_bus_info, }if (!reload) { -devlink_set_features (devlink,DEVLINK_F_RELOAD );devl_unlock (devlink);devlink_register (devlink); }
drivers/net/netdevsim/dev.c +0 -1
@@ -1609,7 +1609,6 @@ int nsim_drv_probe(struct nsim_bus_dev *nsim_bus_dev) goto err_hwstats_exit; nsim_dev->esw_mode =DEVLINK_ESWITCH_MODE_LEGACY ; -devlink_set_features (devlink,DEVLINK_F_RELOAD );devl_unlock (devlink);return 0 ;
include/net/devlink.h +1 -1
@@ -1646,7 +1646,7 @@ static inline struct devlink *devlink_alloc(const struct devlink_ops *ops, {return devlink_alloc_ns (ops, priv_size, &init_net, dev); } -void devlink_set_features (struct devlink *devlink,u64 features); +int devl_register (struct devlink *devlink);void devl_unregister (struct devlink *devlink);void devlink_register (struct devlink *devlink);
net/devlink/core.c +0 -19
@@ -114,23 +114,6 @@ struct devlink *devlinks_xa_find_get(struct net *net, unsigned long *indexp) goto retry; } -/** -* devlink_set_features - Set devlink supported features -* -* @devlink: devlink -* @features: devlink support features -* -* This interface allows us to set reload ops separatelly from -* the devlink_alloc. -*/ -void devlink_set_features (struct devlink *devlink,u64 features) -{ -WARN_ON (features &DEVLINK_F_RELOAD && - !devlink_reload_supported (devlink->ops)); - devlink->features = features; -} -EXPORT_SYMBOL_GPL (devlink_set_features); -/** * devl_register - Register devlink instance * @devlink: devlink
@@ -297,7 +280,6 @@ static void __net_exit devlink_pernet_pre_exit(struct net *net)* all devlink instances from this namespace into init_net. */ devlinks_xa_for_each_registered_get (net, index, devlink) { -WARN_ON (!(devlink->features &DEVLINK_F_RELOAD ));devl_lock (devlink); err =0 ;if (devl_is_registered (devlink))
@@ -307,7 +289,6 @@ static void __net_exit devlink_pernet_pre_exit(struct net *net) &actions_performed, NULL);devl_unlock (devlink);devlink_put (devlink); -if (err && err != -EOPNOTSUPP )pr_warn ("Failed to reload devlink instance into init_net\n" ); }
net/devlink/devl_internal.h +0 -1
@@ -39,7 +39,6 @@ struct devlink {struct list_head linecard_list;struct mutex linecards_lock;/* protects linecard_list */ const struct devlink_ops *ops; -u64 features;struct xarray snapshot_ids;struct devlink_dev_stats stats;struct device *dev;
net/devlink/leftover.c +0 -3
@@ -4429,9 +4429,6 @@ static int devlink_nl_cmd_reload(struct sk_buff *skb, struct genl_info *info)u32 actions_performed;int err; -if (!(devlink->features &DEVLINK_F_RELOAD )) -return -EOPNOTSUPP ; - err =devlink_resources_validate (devlink,NULL , info);if (err) {NL_SET_ERR_MSG_MOD (info->extack,"resources size validation failed" );
Signature · 1 line
2.39.0
Jakub Kicinski
maintainerRe: [patch net-next v3 01/11] devlink: remove devlink features
Quoted 4 lines · On Mon, 9 Jan 2023 19:31:10 +0100 Jiri Pirko wrote:
Note that mlx5 used this to enable devlink reload conditionally only when device didn't act as multi port slave. Move the multi port check into
mlx5_devlink_reload_down()callback alongside with the other checks preventing the device from reload in certain states.
Right, but this is not 100% equivalent because we generate the notifications _before_ we try to reload_down:
devlink_ns_change_notify(devlink, dest_net, curr_net, false); err = devlink->ops->reload_down(devlink, !!dest_net, action, limit, extack); if (err) return err;
IDK why, I haven't investigated.
Jiri Pirko
maintainerRe: [patch net-next v3 01/11] devlink: remove devlink features
Quoted 9 lines · Tue, Jan 10, 2023 at 01:55:00AM CET, [email protected] wrote:
Quoted 4 lines · On Mon, 9 Jan 2023 19:31:10 +0100 Jiri Pirko wrote:
Note that mlx5 used this to enable devlink reload conditionally only when device didn't act as multi port slave. Move the multi port check into
mlx5_devlink_reload_down()callback alongside with the other checks preventing the device from reload in certain states.Right, but this is not 100% equivalent because we generate the notifications _before_ we try to
reload_down:
Quoted 6 lines
devlink_ns_change_notify(devlink, dest_net, curr_net, false); err = devlink->ops->reload_down(devlink, !!dest_net, action, limit, extack); if (err) return err;IDK why, I haven't investigated.
Right, but that is done even in other cases where down can't be done. I I think there's a bug here, down DEL notification is sent before calling down which can potentially fail. I think the notification call should be moved after reload_down() call. Then the bahaviour would stay the same for the features case and will get fixed for the reload_down() reject cases. What do you think?
Jakub Kicinski
maintainerRe: [patch net-next v3 01/11] devlink: remove devlink features
Quoted 8 lines · On Tue, 10 Jan 2023 08:12:10 +0100 Jiri Pirko wrote:
Quoted 8 lines
Right, but this is not 100% equivalent because we generate the notifications _before_ we try to
reload_down:devlink_ns_change_notify(devlink, dest_net, curr_net, false); err = devlink->ops->reload_down(devlink, !!dest_net, action, limit, extack); if (err) return err;
Quoted 8 lines
Quoted 1 line
IDK why, I haven't investigated.
Right, but that is done even in other cases where down can't be done. I I think there's a bug here, down DEL notification is sent before calling down which can potentially fail. I think the notification call should be moved after
reload_down()call. Then the bahaviour would stay the same for the features case and will get fixed for thereload_down()reject cases. What do you think?
I was gonna say that it sounds reasonable, and that maybe we should be in fact using devlink_notify_register() instead of the custom instance-and-params-only devlink_ns_change_notify().
But then I looked at who added this counter-intuitive code and found out it's for a reason - see 05a7f4a8dff19.
So you gotta check if mlx5 still has this problem...
Re: [patch net-next v3 01/11] devlink: remove devlink features
Quoted 18 lines · Jakub Kicinski
Quoted 8 lines · On Tue, 10 Jan 2023 08:12:10 +0100 Jiri Pirko wrote:
Quoted 8 lines
Right, but this is not 100% equivalent because we generate the notifications _before_ we try to
reload_down:devlink_ns_change_notify(devlink, dest_net, curr_net, false); err = devlink->ops->reload_down(devlink, !!dest_net, action, limit, extack); if (err) return err;Quoted 8 lines
Quoted 1 line
IDK why, I haven't investigated.
Right, but that is done even in other cases where down can't be done. I I think there's a bug here, down DEL notification is sent before calling down which can potentially fail. I think the notification call should be moved after
reload_down()call. Then the bahaviour would stay the same for the features case and will get fixed for thereload_down()reject cases. What do you think?
Quoted 8 lines
I was gonna say that it sounds reasonable, and that maybe we should be in fact using
devlink_notify_register()instead of the custom instance-and-params-onlydevlink_ns_change_notify().But then I looked at who added this counter-intuitive code and found out it's for a reason - see
05a7f4a8dff19.So you gotta check if mlx5 still has this problem...
I don't see anything in the tree what will prevent the issue which I wrote in 05a7f4a8dff19.
Thanks
Jiri Pirko
maintainerRe: [patch net-next v3 01/11] devlink: remove devlink features
Quoted 23 lines · Wed, Jan 11, 2023 at 08:36:36AM CET, [email protected] wrote:
Quoted 22 lines · Jakub Kicinski
Quoted 8 lines · On Tue, 10 Jan 2023 08:12:10 +0100 Jiri Pirko wrote:
Quoted 8 lines
Right, but this is not 100% equivalent because we generate the notifications _before_ we try to
reload_down:devlink_ns_change_notify(devlink, dest_net, curr_net, false); err = devlink->ops->reload_down(devlink, !!dest_net, action, limit, extack); if (err) return err;Quoted 8 lines
Quoted 1 line
IDK why, I haven't investigated.
Right, but that is done even in other cases where down can't be done. I I think there's a bug here, down DEL notification is sent before calling down which can potentially fail. I think the notification call should be moved after
reload_down()call. Then the bahaviour would stay the same for the features case and will get fixed for thereload_down()reject cases. What do you think?I was gonna say that it sounds reasonable, and that maybe we should be in fact using
devlink_notify_register()instead of the custom instance-and-params-onlydevlink_ns_change_notify().
Quoted 7 lines
Quoted 4 lines
But then I looked at who added this counter-intuitive code and found out it's for a reason - see
05a7f4a8dff19.So you gotta check if mlx5 still has this problem...
I don't see anything in the tree what will prevent the issue which I wrote in
05a7f4a8dff19.
Okay. I will remove this patch from the set and address this in a separate patchset. Thanks!
Quoted 2 lines
Thanks
Re: [patch net-next v3 01/11] devlink: remove devlink features
Quoted 27 lines · Jiri Pirko
Quoted 26 lines · Wed, Jan 11, 2023 at 08:36:36AM CET, [email protected] wrote:
Quoted 25 lines · Jakub Kicinski
Quoted 8 lines · On Tue, 10 Jan 2023 08:12:10 +0100 Jiri Pirko wrote:
Quoted 8 lines
Right, but this is not 100% equivalent because we generate the notifications _before_ we try to
reload_down:devlink_ns_change_notify(devlink, dest_net, curr_net, false); err = devlink->ops->reload_down(devlink, !!dest_net, action, limit, extack); if (err) return err;Quoted 8 lines
Quoted 1 line
IDK why, I haven't investigated.
Right, but that is done even in other cases where down can't be done. I I think there's a bug here, down DEL notification is sent before calling down which can potentially fail. I think the notification call should be moved after
reload_down()call. Then the bahaviour would stay the same for the features case and will get fixed for thereload_down()reject cases. What do you think?I was gonna say that it sounds reasonable, and that maybe we should be in fact using
devlink_notify_register()instead of the custom instance-and-params-onlydevlink_ns_change_notify().But then I looked at who added this counter-intuitive code and found out it's for a reason - see
05a7f4a8dff19.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
So you gotta check if mlx5 still has this problem...
I don't see anything in the tree what will prevent the issue which I wrote in
05a7f4a8dff19.Okay. I will remove this patch from the set and address this in a separate patchset. Thanks!
BTW, I tried your v3 series and it caused to tests which changes switchdev mode to stuck.
I'll try v4 now.
Thanks
Quoted 3 lines
Quoted 3 lines
Thanks
Jiri Pirko
maintainerPATCH v3 2/11 devlink: remove linecards lock
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Similar to other devlink objects, convert the linecards list to be protected by devlink instance lock. Alongside with that rename the create/destroy() functions to devl_* to indicate the devlink instance lock needs to be held while calling them.
---v2->v3: fixed typo in patch description
--- .../ethernet/mellanox/mlxsw/core_linecards.c | 8 ++-- include/net/devlink.h | 6 +-- net/devlink/core.c | 2 - net/devlink/devl_internal.h | 1 - net/devlink/leftover.c | 41 +++++++------------ 5 files changed, 21 insertions(+), 37 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/core_linecards.c +4 -4
@@ -1259,9 +1259,9 @@ static int mlxsw_linecard_init(struct mlxsw_core *mlxsw_core, linecard->linecards = linecards;mutex_init (&linecard->lock); - devlink_linecard =devlink_linecard_create (priv_to_devlink (mlxsw_core), - slot_index, &mlxsw_linecard_ops, - linecard); + devlink_linecard =devl_linecard_create (priv_to_devlink (mlxsw_core), + slot_index, &mlxsw_linecard_ops, + linecard);if (IS_ERR (devlink_linecard))return PTR_ERR (devlink_linecard);
@@ -1285,7 +1285,7 @@ static void mlxsw_linecard_fini(struct mlxsw_core *mlxsw_core,if (linecard->active)mlxsw_linecard_active_clear (linecard);mlxsw_linecard_bdev_del (linecard); -devlink_linecard_destroy (linecard->devlink_linecard); +devl_linecard_destroy (linecard->devlink_linecard);mutex_destroy (&linecard->lock); }
include/net/devlink.h +3 -3
@@ -1687,9 +1687,9 @@ void devl_rate_nodes_destroy(struct devlink *devlink);void devlink_port_linecard_set (struct devlink_port *devlink_port,struct devlink_linecard *linecard);struct devlink_linecard * -devlink_linecard_create (struct devlink *devlink,unsigned int linecard_index, -const struct devlink_linecard_ops *ops,void *priv); -void devlink_linecard_destroy (struct devlink_linecard *linecard); +devl_linecard_create (struct devlink *devlink,unsigned int linecard_index, +const struct devlink_linecard_ops *ops,void *priv); +void devl_linecard_destroy (struct devlink_linecard *linecard);void devlink_linecard_provision_set (struct devlink_linecard *linecard,const char *type);void devlink_linecard_provision_clear (struct devlink_linecard *linecard);
net/devlink/core.c +0 -2
@@ -218,7 +218,6 @@ struct devlink *devlink_alloc_ns(const struct devlink_ops *ops,mutex_init (&devlink->lock);lockdep_set_class (&devlink->lock, &devlink->lock_key);mutex_init (&devlink->reporters_lock); -mutex_init (&devlink->linecards_lock);refcount_set (&devlink->refcount,1 );return devlink;
@@ -240,7 +239,6 @@ void devlink_free(struct devlink *devlink) {ASSERT_DEVLINK_NOT_REGISTERED (devlink); -mutex_destroy (&devlink->linecards_lock);mutex_destroy (&devlink->reporters_lock);mutex_destroy (&devlink->lock);lockdep_unregister_key (&devlink->lock_key);
net/devlink/devl_internal.h +0 -1
@@ -37,7 +37,6 @@ struct devlink {struct list_head trap_group_list;struct list_head trap_policer_list;struct list_head linecard_list; -struct mutex linecards_lock;/* protects linecard_list */ const struct devlink_ops *ops;struct xarray snapshot_ids;struct devlink_dev_stats stats;
net/devlink/leftover.c +14 -27
115 lines not on this page · raw message
Signature · 1 line
2.39.0
Jiri Pirko
maintainerPATCH v3 3/11 devlink: remove linecard reference counting
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
As long as the linecard life time is protected by devlink instance lock, the reference counting is no longer needed. Remove it.
---v2->v3:
- removed devlink_linecard_put() prototype from devl_internal.h
- fixed typo in patch description
--- net/devlink/devl_internal.h | 1 - net/devlink/leftover.c | 14 ++------------ net/devlink/netlink.c | 5 ----- 3 files changed, 2 insertions(+), 18 deletions(-)
net/devlink/devl_internal.h +0 -1
@@ -191,7 +191,6 @@ struct devlink_linecard;struct devlink_linecard *devlink_linecard_get_from_info (struct devlink *devlink,struct genl_info *info); -void devlink_linecard_put (struct devlink_linecard *linecard);/* Rates */ extern const struct devlink_gen_cmd devl_gen_rate_get;
net/devlink/leftover.c +2 -12
@@ -37,7 +37,6 @@ struct devlink_linecard {struct list_head list;struct devlink *devlink;unsigned int index; -refcount_t refcount;const struct devlink_linecard_ops *ops;void *priv;enum devlink_linecard_state state;
@@ -285,7 +284,6 @@ devlink_linecard_get_from_attrs(struct devlink *devlink, struct nlattr **attrs) linecard =devlink_linecard_get_by_index (devlink, linecard_index);if (!linecard)return ERR_PTR (-ENODEV ); -refcount_inc (&linecard->refcount);return linecard; }return ERR_PTR (-EINVAL );
@@ -297,14 +295,6 @@ devlink_linecard_get_from_info(struct devlink *devlink, struct genl_info *info)return devlink_linecard_get_from_attrs (devlink, info->attrs); } -void devlink_linecard_put (struct devlink_linecard *linecard) -{ -if (refcount_dec_and_test (&linecard->refcount)) { -mutex_destroy (&linecard->state_lock); -kfree (linecard); - } -} -struct devlink_sb {struct list_head list;unsigned int index;
@@ -10268,7 +10258,6 @@ devl_linecard_create(struct devlink *devlink, unsigned int linecard_index, }list_add_tail (&linecard->list, &devlink->linecard_list); -refcount_set (&linecard->refcount,1 );devlink_linecard_notify (linecard,DEVLINK_CMD_LINECARD_NEW );return linecard; }
@@ -10284,7 +10273,8 @@ void devl_linecard_destroy(struct devlink_linecard *linecard)devlink_linecard_notify (linecard,DEVLINK_CMD_LINECARD_DEL );list_del (&linecard->list);devlink_linecard_types_fini (linecard); -devlink_linecard_put (linecard); +mutex_destroy (&linecard->state_lock); +kfree (linecard); }EXPORT_SYMBOL_GPL (devl_linecard_destroy);
net/devlink/netlink.c +0 -5
@@ -170,14 +170,9 @@ static int devlink_nl_pre_doit(const struct genl_split_ops *ops,static void devlink_nl_post_doit (const struct genl_split_ops *ops,struct sk_buff *skb,struct genl_info *info) { -struct devlink_linecard *linecard;struct devlink *devlink; devlink = info->user_ptr[0 ]; -if (ops->internal_flags &DEVLINK_NL_FLAG_NEED_LINECARD ) { - linecard = info->user_ptr[1 ]; -devlink_linecard_put (linecard); - }devl_unlock (devlink);devlink_put (devlink); }
Signature · 1 line
2.39.0
Re: [patch net-next v3 03/11] devlink: remove linecard reference counting
Quoted 6 lines · Jiri Pirko
From: Jiri Pirko <[email protected]>
As long as the linecard life time is protected by devlink instance lock, the reference counting is no longer needed. Remove it.
Signed-off-by Jiri Pirko <[email protected]>
Jiri Pirko
maintainerPATCH v3 4/11 devlink: protect health reporter operation with instance lock
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Similar to other devlink objects, protect the reporters list by devlink instance lock. Alongside add unlocked versions of health reporter create/destroy functions and use them in drivers on call paths where the instance lock is held.
---v2->v3:
- split from v2 patch #4 - "devlink: remove reporters_lock", no change
--- .../ethernet/mellanox/mlx5/core/en/health.c | 12 +++ .../mellanox/mlx5/core/en/reporter_rx.c | 6 +- .../mellanox/mlx5/core/en/reporter_tx.c | 6 +- drivers/net/ethernet/mellanox/mlxsw/core.c | 8 +- drivers/net/netdevsim/health.c | 20 ++--- include/net/devlink.h | 18 +++-- net/devlink/leftover.c | 76 +++++++++++++------ 7 files changed, 97 insertions(+), 49 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/health.c +12 -0
@@ -137,14 +137,26 @@ int mlx5e_health_eq_diag_fmsg(struct mlx5_eq_comp *eq, struct devlink_fmsg *fmsgvoid mlx5e_health_create_reporters (struct mlx5e_priv *priv) { +struct devlink *devlink =priv_to_devlink (priv->mdev); + +if (!(priv->mdev->priv.flags &MLX5_PRIV_FLAGS_MLX5E_LOCKED_FLOW )) +devl_lock (devlink);mlx5e_reporter_tx_create (priv);mlx5e_reporter_rx_create (priv); +if (!(priv->mdev->priv.flags &MLX5_PRIV_FLAGS_MLX5E_LOCKED_FLOW )) +devl_unlock (devlink); }void mlx5e_health_destroy_reporters (struct mlx5e_priv *priv) { +struct devlink *devlink =priv_to_devlink (priv->mdev); + +if (!(priv->mdev->priv.flags &MLX5_PRIV_FLAGS_MLX5E_LOCKED_FLOW )) +devl_lock (devlink);mlx5e_reporter_rx_destroy (priv);mlx5e_reporter_tx_destroy (priv); +if (!(priv->mdev->priv.flags &MLX5_PRIV_FLAGS_MLX5E_LOCKED_FLOW )) +devl_unlock (devlink); }void mlx5e_health_channels_update (struct mlx5e_priv *priv)
drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c +3 -3
@@ -739,8 +739,8 @@ void mlx5e_reporter_rx_create(struct mlx5e_priv *priv)struct devlink_port *dl_port =mlx5e_devlink_get_dl_port (priv);struct devlink_health_reporter *reporter; - reporter =devlink_port_health_reporter_create (dl_port, &mlx5_rx_reporter_ops, -MLX5E_REPORTER_RX_GRACEFUL_PERIOD , priv); + reporter =devl_port_health_reporter_create (dl_port, &mlx5_rx_reporter_ops, +MLX5E_REPORTER_RX_GRACEFUL_PERIOD , priv);if (IS_ERR (reporter)) {netdev_warn (priv->netdev,"Failed to create rx reporter, err = %ld\n" ,PTR_ERR (reporter));
@@ -754,6 +754,6 @@ void mlx5e_reporter_rx_destroy(struct mlx5e_priv *priv)if (!priv->rx_reporter)return ; -devlink_port_health_reporter_destroy (priv->rx_reporter); +devl_port_health_reporter_destroy (priv->rx_reporter); priv->rx_reporter =NULL ; }
drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c +3 -3
@@ -593,8 +593,8 @@ void mlx5e_reporter_tx_create(struct mlx5e_priv *priv)struct devlink_port *dl_port =mlx5e_devlink_get_dl_port (priv);struct devlink_health_reporter *reporter; - reporter =devlink_port_health_reporter_create (dl_port, &mlx5_tx_reporter_ops, -MLX5_REPORTER_TX_GRACEFUL_PERIOD , priv); + reporter =devl_port_health_reporter_create (dl_port, &mlx5_tx_reporter_ops, +MLX5_REPORTER_TX_GRACEFUL_PERIOD , priv);if (IS_ERR (reporter)) { netdev_warn(priv->netdev, "Failed to create tx reporter, err = %ld\n",
@@ -609,6 +609,6 @@ void mlx5e_reporter_tx_destroy(struct mlx5e_priv *priv)if (!priv->tx_reporter)return ; -devlink_port_health_reporter_destroy (priv->tx_reporter); +devl_port_health_reporter_destroy (priv->tx_reporter); priv->tx_reporter =NULL ; }
drivers/net/ethernet/mellanox/mlxsw/core.c +4 -4
@@ -2051,8 +2051,8 @@ static int mlxsw_core_health_init(struct mlxsw_core *mlxsw_core)if (!(mlxsw_core->bus->features &MLXSW_BUS_F_TXRX ))return 0 ; - fw_fatal =devlink_health_reporter_create (devlink, &mlxsw_core_health_fw_fatal_ops, -0 , mlxsw_core); + fw_fatal =devl_health_reporter_create (devlink, &mlxsw_core_health_fw_fatal_ops, +0 , mlxsw_core);if (IS_ERR (fw_fatal)) {dev_err (mlxsw_core->bus_info->dev,"Failed to create fw fatal reporter" );return PTR_ERR (fw_fatal);
@@ -2072,7 +2072,7 @@ static int mlxsw_core_health_init(struct mlxsw_core *mlxsw_core) err_fw_fatal_config:mlxsw_core_trap_unregister (mlxsw_core, &mlxsw_core_health_listener, mlxsw_core); err_trap_register: -devlink_health_reporter_destroy (mlxsw_core->health.fw_fatal); +devl_health_reporter_destroy (mlxsw_core->health.fw_fatal);return err; }
@@ -2085,7 +2085,7 @@ static void mlxsw_core_health_fini(struct mlxsw_core *mlxsw_core)mlxsw_core_trap_unregister (mlxsw_core, &mlxsw_core_health_listener, mlxsw_core);/* Make sure there is no more event work scheduled */ mlxsw_core_flush_owq (); -devlink_health_reporter_destroy (mlxsw_core->health.fw_fatal); +devl_health_reporter_destroy (mlxsw_core->health.fw_fatal); }static void mlxsw_core_irq_event_handler_init (struct mlxsw_core *mlxsw_core)
drivers/net/netdevsim/health.c +10 -10
@@ -233,16 +233,16 @@ int nsim_dev_health_init(struct nsim_dev *nsim_dev, struct devlink *devlink)int err; health->empty_reporter = -devlink_health_reporter_create (devlink, - &nsim_dev_empty_reporter_ops, -0 , health); +devl_health_reporter_create (devlink, + &nsim_dev_empty_reporter_ops, +0 , health);if (IS_ERR (health->empty_reporter))return PTR_ERR (health->empty_reporter); health->dummy_reporter = -devlink_health_reporter_create (devlink, - &nsim_dev_dummy_reporter_ops, -0 , health); +devl_health_reporter_create (devlink, + &nsim_dev_dummy_reporter_ops, +0 , health);if (IS_ERR (health->dummy_reporter)) { err =PTR_ERR (health->dummy_reporter); goto err_empty_reporter_destroy;
@@ -266,9 +266,9 @@ int nsim_dev_health_init(struct nsim_dev *nsim_dev, struct devlink *devlink)return 0 ; err_dummy_reporter_destroy: -devlink_health_reporter_destroy (health->dummy_reporter); +devl_health_reporter_destroy (health->dummy_reporter); err_empty_reporter_destroy: -devlink_health_reporter_destroy (health->empty_reporter); +devl_health_reporter_destroy (health->empty_reporter);return err; }
@@ -278,6 +278,6 @@ void nsim_dev_health_exit(struct nsim_dev *nsim_dev)debugfs_remove_recursive (health->ddir);kfree (health->recovered_break_msg); -devlink_health_reporter_destroy (health->dummy_reporter); -devlink_health_reporter_destroy (health->empty_reporter); +devl_health_reporter_destroy (health->dummy_reporter); +devl_health_reporter_destroy (health->empty_reporter); }
include/net/devlink.h +13 -5
@@ -1864,21 +1864,29 @@ int devlink_fmsg_string_pair_put(struct devlink_fmsg *fmsg, const char *name,int devlink_fmsg_binary_pair_put (struct devlink_fmsg *fmsg,const char *name,const void *value,u32 value_len); +struct devlink_health_reporter * +devl_port_health_reporter_create (struct devlink_port *port, +const struct devlink_health_reporter_ops *ops, +u64 graceful_period,void *priv); + +struct devlink_health_reporter * +devl_health_reporter_create (struct devlink *devlink, +const struct devlink_health_reporter_ops *ops, +u64 graceful_period,void *priv); +struct devlink_health_reporter *devlink_health_reporter_create (struct devlink *devlink,const struct devlink_health_reporter_ops *ops,u64 graceful_period,void *priv); -struct devlink_health_reporter * -devlink_port_health_reporter_create (struct devlink_port *port, -const struct devlink_health_reporter_ops *ops, -u64 graceful_period,void *priv); +void +devl_health_reporter_destroy (struct devlink_health_reporter *reporter);void devlink_health_reporter_destroy (struct devlink_health_reporter *reporter);void -devlink_port_health_reporter_destroy (struct devlink_health_reporter *reporter); +devl_port_health_reporter_destroy (struct devlink_health_reporter *reporter);void *devlink_health_reporter_priv (struct devlink_health_reporter *reporter);
net/devlink/leftover.c +52 -24
164 lines not on this page · raw message
Signature · 1 line
2.39.0
Re: [patch net-next v3 04/11] devlink: protect health reporter operation with instance lock
Quoted 8 lines · Jiri Pirko
From: Jiri Pirko <[email protected]>
Similar to other devlink objects, protect the reporters list by devlink instance lock. Alongside add unlocked versions of health reporter create/destroy functions and use them in drivers on call paths where the instance lock is held.
Signed-off-by Jiri Pirko <[email protected]>
The changes in devlink, mlxsw and netdevsim look fine to me, so:
Jiri Pirko
maintainerPATCH v3 5/11 devlink: remove reporters_lock
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Similar to other devlink objects, rely on devlink instance lock and remove object specific reporters_lock.
---v2->v3:
- split from v2 patch #4 - "devlink: remove reporters_lock", no change
--- include/net/devlink.h | 1 - net/devlink/core.c | 2 -- net/devlink/devl_internal.h | 1 - net/devlink/leftover.c | 53 +++++++------------------------------ 4 files changed, 9 insertions(+), 48 deletions(-)
include/net/devlink.h +0 -1
@@ -146,7 +146,6 @@ struct devlink_port { initialized:1 ;struct delayed_work type_warn_dw;struct list_head reporter_list; -struct mutex reporters_lock;/* Protects reporter_list */ struct devlink_rate *devlink_rate;struct devlink_linecard *linecard;
net/devlink/core.c +0 -2
@@ -217,7 +217,6 @@ struct devlink *devlink_alloc_ns(const struct devlink_ops *ops,lockdep_register_key (&devlink->lock_key);mutex_init (&devlink->lock);lockdep_set_class (&devlink->lock, &devlink->lock_key); -mutex_init (&devlink->reporters_lock);refcount_set (&devlink->refcount,1 );return devlink;
@@ -239,7 +238,6 @@ void devlink_free(struct devlink *devlink) {ASSERT_DEVLINK_NOT_REGISTERED (devlink); -mutex_destroy (&devlink->reporters_lock);mutex_destroy (&devlink->lock);lockdep_unregister_key (&devlink->lock_key);WARN_ON (!list_empty (&devlink->trap_policer_list));
net/devlink/devl_internal.h +0 -1
@@ -31,7 +31,6 @@ struct devlink {struct list_head param_list;struct list_head region_list;struct list_head reporter_list; -struct mutex reporters_lock;/* protects reporter_list */ struct devlink_dpipe_headers *dpipe_headers;struct list_head trap_list;struct list_head trap_group_list;
net/devlink/leftover.c +9 -44
178 lines not on this page · raw message
Signature · 1 line
2.39.0
Jiri Pirko
maintainerPATCH v3 6/11 devlink: remove devl_port_health_reporter_destroy()
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Remove port-specific health reporter destroy function as it is currently the same as the instance one so no longer needed. Inline __devlink_health_reporter_destroy() as it is no longer called from multiple places.
---v2->v3:
- split from v2 patch #4 - "devlink: remove reporters_lock", no change
--- .../mellanox/mlx5/core/en/reporter_rx.c | 2 +- .../mellanox/mlx5/core/en/reporter_tx.c | 2 +- include/net/devlink.h | 3 --- net/devlink/leftover.c | 24 ++----------------- 4 files changed, 4 insertions(+), 27 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c +1 -1
@@ -754,6 +754,6 @@ void mlx5e_reporter_rx_destroy(struct mlx5e_priv *priv)if (!priv->rx_reporter)return ; -devl_port_health_reporter_destroy (priv->rx_reporter); +devl_health_reporter_destroy (priv->rx_reporter); priv->rx_reporter =NULL ; }
drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c +1 -1
@@ -609,6 +609,6 @@ void mlx5e_reporter_tx_destroy(struct mlx5e_priv *priv)if (!priv->tx_reporter)return ; -devl_port_health_reporter_destroy (priv->tx_reporter); +devl_health_reporter_destroy (priv->tx_reporter); priv->tx_reporter =NULL ; }
include/net/devlink.h +0 -3
@@ -1884,9 +1884,6 @@ devl_health_reporter_destroy(struct devlink_health_reporter *reporter);void devlink_health_reporter_destroy (struct devlink_health_reporter *reporter); -void -devl_port_health_reporter_destroy (struct devlink_health_reporter *reporter); -void *devlink_health_reporter_priv (struct devlink_health_reporter *reporter); int devlink_health_report(struct devlink_health_reporter *reporter,
net/devlink/leftover.c +2 -22
@@ -7423,13 +7423,6 @@ devlink_health_reporter_put(struct devlink_health_reporter *reporter)devlink_health_reporter_free (reporter); } -static void -__devlink_health_reporter_destroy (struct devlink_health_reporter *reporter) -{ -list_del (&reporter->list); -devlink_health_reporter_put (reporter); -} -/** * devl_health_reporter_destroy - destroy devlink health reporter *
@@ -7440,7 +7433,8 @@ devl_health_reporter_destroy(struct devlink_health_reporter *reporter) {devl_assert_locked (reporter->devlink); -__devlink_health_reporter_destroy (reporter); +list_del (&reporter->list); +devlink_health_reporter_put (reporter); }EXPORT_SYMBOL_GPL (devl_health_reporter_destroy);
@@ -7455,20 +7449,6 @@ devlink_health_reporter_destroy(struct devlink_health_reporter *reporter) }EXPORT_SYMBOL_GPL (devlink_health_reporter_destroy); -/** -* devl_port_health_reporter_destroy - destroy devlink port health reporter -* -* @reporter: devlink health reporter to destroy -*/ -void -devl_port_health_reporter_destroy (struct devlink_health_reporter *reporter) -{ -devl_assert_locked (reporter->devlink); - -__devlink_health_reporter_destroy (reporter); -} -EXPORT_SYMBOL_GPL (devl_port_health_reporter_destroy); - static int devlink_nl_health_reporter_fill(struct sk_buff *msg, struct devlink_health_reporter *reporter,
Signature · 1 line
2.39.0
Jiri Pirko
maintainerPATCH v3 7/11 devlink: remove reporter reference counting
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
As long as the reporter life time is protected by devlink instance lock, the reference counting is no longer needed. Remove it.
---v2->v3
- fixed typo in patch description
--- net/devlink/leftover.c | 113 +++++++++++------------------------------ 1 file changed, 30 insertions(+), 83 deletions(-)
net/devlink/leftover.c +30 -83
@@ -7266,7 +7266,6 @@ struct devlink_health_reporter {u64 error_count;u64 recovery_count;u64 last_recovery_ts; -refcount_t refcount; }; void *
@@ -7325,7 +7324,6 @@ __devlink_health_reporter_create(struct devlink *devlink, reporter->auto_recover = !!ops->recover; reporter->auto_dump = !!ops->dump;mutex_init (&reporter->dump_lock); -refcount_set (&reporter->refcount,1 );return reporter; }
@@ -7416,13 +7414,6 @@ devlink_health_reporter_free(struct devlink_health_reporter *reporter)kfree (reporter); } -static void -devlink_health_reporter_put (struct devlink_health_reporter *reporter) -{ -if (refcount_dec_and_test (&reporter->refcount)) -devlink_health_reporter_free (reporter); -} -/** * devl_health_reporter_destroy - destroy devlink health reporter *
@@ -7434,7 +7425,7 @@ devl_health_reporter_destroy(struct devlink_health_reporter *reporter)devl_assert_locked (reporter->devlink);list_del (&reporter->list); -devlink_health_reporter_put (reporter); +devlink_health_reporter_free (reporter); }EXPORT_SYMBOL_GPL (devl_health_reporter_destroy);
@@ -7678,7 +7669,6 @@ static struct devlink_health_reporter * devlink_health_reporter_get_from_attrs(struct devlink *devlink, struct nlattr **attrs) { - struct devlink_health_reporter *reporter; struct devlink_port *devlink_port;char *reporter_name;
@@ -7687,17 +7677,12 @@ devlink_health_reporter_get_from_attrs(struct devlink *devlink, reporter_name =nla_data (attrs[DEVLINK_ATTR_HEALTH_REPORTER_NAME ]); devlink_port =devlink_port_get_from_attrs (devlink, attrs); -if (IS_ERR (devlink_port)) { - reporter =devlink_health_reporter_find_by_name (devlink, reporter_name); -if (reporter) -refcount_inc (&reporter->refcount); - }else { - reporter =devlink_port_health_reporter_find_by_name (devlink_port, reporter_name); -if (reporter) -refcount_inc (&reporter->refcount); - } - -return reporter; +if (IS_ERR (devlink_port)) +return devlink_health_reporter_find_by_name (devlink, + reporter_name); +else +return devlink_port_health_reporter_find_by_name (devlink_port, + reporter_name); } static struct devlink_health_reporter *
@@ -7756,10 +7741,8 @@ static int devlink_nl_cmd_health_reporter_get_doit(struct sk_buff *skb,return -EINVAL ; msg =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_KERNEL ); -if (!msg) { - err = -ENOMEM ; - goto out; - } +if (!msg) +return -ENOMEM ; err = devlink_nl_health_reporter_fill(msg, reporter, DEVLINK_CMD_HEALTH_REPORTER_GET,
@@ -7767,13 +7750,10 @@ static int devlink_nl_cmd_health_reporter_get_doit(struct sk_buff *skb, 0);if (err) {nlmsg_free (msg); - goto out; +return err; } - err =genlmsg_reply (msg, info); -out: -devlink_health_reporter_put (reporter); -return err; +return genlmsg_reply (msg, info); } static int
@@ -7847,7 +7827,6 @@ devlink_nl_cmd_health_reporter_set_doit(struct sk_buff *skb, {struct devlink *devlink = info->user_ptr[0 ];struct devlink_health_reporter *reporter; -int err; reporter =devlink_health_reporter_get_from_info (devlink, info);if (!reporter)
@@ -7855,15 +7834,12 @@ devlink_nl_cmd_health_reporter_set_doit(struct sk_buff *skb,if (!reporter->ops->recover && (info->attrs[DEVLINK_ATTR_HEALTH_REPORTER_GRACEFUL_PERIOD ] || - info->attrs[DEVLINK_ATTR_HEALTH_REPORTER_AUTO_RECOVER ])) { - err = -EOPNOTSUPP ; - goto out; - } + info->attrs[DEVLINK_ATTR_HEALTH_REPORTER_AUTO_RECOVER ])) +return -EOPNOTSUPP ; +if (!reporter->ops->dump && - info->attrs[DEVLINK_ATTR_HEALTH_REPORTER_AUTO_DUMP ]) { - err = -EOPNOTSUPP ; - goto out; - } + info->attrs[DEVLINK_ATTR_HEALTH_REPORTER_AUTO_DUMP ]) +return -EOPNOTSUPP ;if (info->attrs[DEVLINK_ATTR_HEALTH_REPORTER_GRACEFUL_PERIOD ]) reporter->graceful_period =
@@ -7877,11 +7853,7 @@ devlink_nl_cmd_health_reporter_set_doit(struct sk_buff *skb, reporter->auto_dump =nla_get_u8 (info->attrs[DEVLINK_ATTR_HEALTH_REPORTER_AUTO_DUMP ]); -devlink_health_reporter_put (reporter);return 0 ; -out: -devlink_health_reporter_put (reporter); -return err; } static int devlink_nl_cmd_health_reporter_recover_doit(struct sk_buff *skb,
@@ -7889,16 +7861,12 @@ static int devlink_nl_cmd_health_reporter_recover_doit(struct sk_buff *skb, {struct devlink *devlink = info->user_ptr[0 ];struct devlink_health_reporter *reporter; -int err; reporter =devlink_health_reporter_get_from_info (devlink, info);if (!reporter)return -EINVAL ; - err =devlink_health_reporter_recover (reporter,NULL , info->extack); - -devlink_health_reporter_put (reporter); -return err; +return devlink_health_reporter_recover (reporter,NULL , info->extack); } static int devlink_nl_cmd_health_reporter_diagnose_doit(struct sk_buff *skb,
@@ -7913,36 +7881,27 @@ static int devlink_nl_cmd_health_reporter_diagnose_doit(struct sk_buff *skb,if (!reporter)return -EINVAL ; -if (!reporter->ops->diagnose) { -devlink_health_reporter_put (reporter); +if (!reporter->ops->diagnose)return -EOPNOTSUPP ; - } fmsg =devlink_fmsg_alloc (); -if (!fmsg) { -devlink_health_reporter_put (reporter); +if (!fmsg)return -ENOMEM ; - } err =devlink_fmsg_obj_nest_start (fmsg);if (err) - goto out; +return err; err = reporter->ops->diagnose (reporter, fmsg, info->extack);if (err) - goto out; +return err; err =devlink_fmsg_obj_nest_end (fmsg);if (err) - goto out; - - err =devlink_fmsg_snd (fmsg, info, -DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE ,0 ); +return err; -out: -devlink_fmsg_free (fmsg); -devlink_health_reporter_put (reporter); -return err; +return devlink_fmsg_snd (fmsg, info, +DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE ,0 ); } static int
@@ -7957,10 +7916,9 @@ devlink_nl_cmd_health_reporter_dump_get_dumpit(struct sk_buff *skb,if (!reporter)return -EINVAL ; -if (!reporter->ops->dump) { - err = -EOPNOTSUPP ; - goto out; - } +if (!reporter->ops->dump) +return -EOPNOTSUPP ; +mutex_lock (&reporter->dump_lock);if (!state->idx) { err =devlink_health_do_dump (reporter,NULL , cb->extack);
@@ -7978,8 +7936,6 @@ devlink_nl_cmd_health_reporter_dump_get_dumpit(struct sk_buff *skb, DEVLINK_CMD_HEALTH_REPORTER_DUMP_GET); unlock:mutex_unlock (&reporter->dump_lock); -out: -devlink_health_reporter_put (reporter);return err; }
@@ -7994,15 +7950,12 @@ devlink_nl_cmd_health_reporter_dump_clear_doit(struct sk_buff *skb,if (!reporter)return -EINVAL ; -if (!reporter->ops->dump) { -devlink_health_reporter_put (reporter); +if (!reporter->ops->dump)return -EOPNOTSUPP ; - }mutex_lock (&reporter->dump_lock);devlink_health_dump_clear (reporter);mutex_unlock (&reporter->dump_lock); -devlink_health_reporter_put (reporter);return 0 ; }
@@ -8011,21 +7964,15 @@ static int devlink_nl_cmd_health_reporter_test_doit(struct sk_buff *skb, {struct devlink *devlink = info->user_ptr[0 ];struct devlink_health_reporter *reporter; -int err; reporter =devlink_health_reporter_get_from_info (devlink, info);if (!reporter)return -EINVAL ; -if (!reporter->ops->test) { -devlink_health_reporter_put (reporter); +if (!reporter->ops->test)return -EOPNOTSUPP ; - } - - err = reporter->ops->test (reporter, info->extack); -devlink_health_reporter_put (reporter); -return err; +return reporter->ops->test (reporter, info->extack); }struct devlink_stats {
Signature · 1 line
2.39.0
Jiri Pirko
maintainerPATCH v3 8/11 devlink: convert linecards dump to devlink_nl_instance_iter_dump()
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Benefit from recently introduced instance iteration and convert linecards .dumpit generic netlink callback to use it.
--- net/devlink/devl_internal.h | 1 + net/devlink/leftover.c | 64 ++++++++++++++++--------------------- net/devlink/netlink.c | 1 + 3 files changed, 30 insertions(+), 36 deletions(-)
net/devlink/devl_internal.h +1 -0
@@ -165,6 +165,7 @@ extern const struct devlink_gen_cmd devl_gen_info;extern const struct devlink_gen_cmd devl_gen_trap;extern const struct devlink_gen_cmd devl_gen_trap_group;extern const struct devlink_gen_cmd devl_gen_trap_policer; +extern const struct devlink_gen_cmd devl_gen_linecard;/* Ports */ int devlink_port_netdevice_event(struct notifier_block *nb,
net/devlink/leftover.c +28 -36
85 lines not on this page · raw message
net/devlink/netlink.c +1 -0
@@ -191,6 +191,7 @@ static const struct devlink_gen_cmd *devl_gen_cmds[] = { [DEVLINK_CMD_TRAP_GET] = &devl_gen_trap, [DEVLINK_CMD_TRAP_GROUP_GET] = &devl_gen_trap_group, [DEVLINK_CMD_TRAP_POLICER_GET] = &devl_gen_trap_policer, + [DEVLINK_CMD_LINECARD_GET] = &devl_gen_linecard, [DEVLINK_CMD_SELFTESTS_GET] = &devl_gen_selftests, };
Signature · 1 line
2.39.0
Jiri Pirko
maintainerPATCH v3 9/11 devlink: convert reporters dump to devlink_nl_instance_iter_dump()
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Benefit from recently introduced instance iteration and convert reporters .dumpit generic netlink callback to use it.
---v1->v2:
- unsquashed the next patch (devlink: remove devlink_dump_for_each_instance_get() helper) from this one
--- net/devlink/devl_internal.h | 1 + net/devlink/leftover.c | 87 ++++++++++++++++--------------------- net/devlink/netlink.c | 1 + 3 files changed, 40 insertions(+), 49 deletions(-)
net/devlink/devl_internal.h +1 -0
@@ -162,6 +162,7 @@ extern const struct devlink_gen_cmd devl_gen_selftests;extern const struct devlink_gen_cmd devl_gen_param;extern const struct devlink_gen_cmd devl_gen_region;extern const struct devlink_gen_cmd devl_gen_info; +extern const struct devlink_gen_cmd devl_gen_health_reporter;extern const struct devlink_gen_cmd devl_gen_trap;extern const struct devlink_gen_cmd devl_gen_trap_group;extern const struct devlink_gen_cmd devl_gen_trap_policer;
net/devlink/leftover.c +38 -49
115 lines not on this page · raw message
net/devlink/netlink.c +1 -0
@@ -187,6 +187,7 @@ static const struct devlink_gen_cmd *devl_gen_cmds[] = { [DEVLINK_CMD_PARAM_GET] = &devl_gen_param, [DEVLINK_CMD_REGION_GET] = &devl_gen_region, [DEVLINK_CMD_INFO_GET] = &devl_gen_info, + [DEVLINK_CMD_HEALTH_REPORTER_GET] = &devl_gen_health_reporter, [DEVLINK_CMD_RATE_GET] = &devl_gen_rate_get, [DEVLINK_CMD_TRAP_GET] = &devl_gen_trap, [DEVLINK_CMD_TRAP_GROUP_GET] = &devl_gen_trap_group,
Signature · 1 line
2.39.0
Jiri Pirko
maintainerPATCH v3 10/11 devlink: remove devlink_dump_for_each_instance_get() helper
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
devlink_dump_for_each_instance_get() is currently called from a single place in netlink.c. As there is no need to use this helper anywhere else in the future, remove it and call devlinks_xa_find_get() directly from while loop in devlink_nl_instance_iter_dump(). Also remove redundant idx clear on loop end as it is already done
in devlink_nl_instance_iter_dump().
---v1->v2: new patch, unsquashed from the previous one
--- net/devlink/devl_internal.h | 11 ----------- net/devlink/netlink.c | 5 ++++- 2 files changed, 4 insertions(+), 12 deletions(-)
net/devlink/devl_internal.h +0 -11
@@ -121,17 +121,6 @@ struct devlink_gen_cmd { struct netlink_callback *cb); }; -/* Iterate over registered devlink instances for devlink dump. -* devlink_put() needs to be called for each iterated devlink pointer -* in loop body in order to release the reference. -* Note: this is NOT a generic iterator, it makes assumptions about the use -* of @state and can only be used once per dumpit implementation. -*/ -#define devlink_dump_for_each_instance_get (msg, state, devlink) \ - for (; (devlink = devlinks_xa_find_get(sock_net(msg->sk), \ - &state->instance)); \ - state->instance++, state->idx = 0) -extern const struct genl_small_ops devlink_nl_ops[56 ]; struct devlink *
net/devlink/netlink.c +4 -1
@@ -207,7 +207,8 @@ int devlink_nl_instance_iter_dump(struct sk_buff *msg, cmd = devl_gen_cmds[info->op.cmd]; -devlink_dump_for_each_instance_get (msg, state, devlink) { +while ((devlink =devlinks_xa_find_get (sock_net (msg->sk), + &state->instance))) {devl_lock (devlink);if (devl_is_registered (devlink))
@@ -221,6 +222,8 @@ int devlink_nl_instance_iter_dump(struct sk_buff *msg,if (err)break ; + state->instance++; +/* restart sub-object walk for the next instance */ state->idx =0 ; }
Signature · 1 line
2.39.0
Jiri Pirko
maintainerPATCH v3 11/11 devlink: add instance lock assertion in devl_is_registered()
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
After region and linecard lock removals, this helper is always supposed to be called with instance lock held. So put the assertion here and remove the comment which is no longer accurate.
--- net/devlink/devl_internal.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
net/devlink/devl_internal.h +1 -3
@@ -83,9 +83,7 @@ struct devlink *devlinks_xa_find_get(struct net *net, unsigned long *indexp);static inline bool devl_is_registered (struct devlink *devlink) { -/* To prevent races the caller must hold the instance lock -* or another lock taken during unregistration. -*/ +devl_assert_locked (devlink);return xa_get_mark (&devlinks, devlink->index,DEVLINK_REGISTERED ); }
Signature · 1 line
2.39.0
Jakub Kicinski
maintainerQuoted 8 lines · On Mon, 9 Jan 2023 19:31:09 +0100 Jiri Pirko wrote:
This patchset does not change functionality.
In the first patch, no longer needed devlink features are removed.
Patches 2-7 removes linecards and reporters locks and reference counting, converting them to be protected by devlink instance lock as the rest of the objects.
Quoted 7 lines
Patches 8 and 9 convert linecards and reporters dumpit callbacks to recently introduced
devlink_nl_instance_iter_dump()infra. Patch 10 removes no longer neededdevlink_dump_for_each_instance_get()helper.The last patch adds assertion to
devl_is_registered()as dependency on other locks is removed.
Other than the question patch 1, lgtm!
Ido Schimmel
maintainerQuoted 10 lines · Jiri Pirko
From: Jiri Pirko <[email protected]>
This patchset does not change functionality.
In the first patch, no longer needed devlink features are removed.
Patches 2-7 removes linecards and reporters locks and reference counting, converting them to be protected by devlink instance lock as the rest of the objects.
Quoted 7 lines
Patches 8 and 9 convert linecards and reporters dumpit callbacks to recently introduced
devlink_nl_instance_iter_dump()infra. Patch 10 removes no longer neededdevlink_dump_for_each_instance_get()helper.The last patch adds assertion to
devl_is_registered()as dependency on other locks is removed.
Asked Petr to queue this for testing, so we should be able to report results tomorrow.
Ido Schimmel
maintainerQuoted 16 lines · Ido Schimmel
Quoted 15 lines · Jiri Pirko
From: Jiri Pirko <[email protected]>
This patchset does not change functionality.
In the first patch, no longer needed devlink features are removed.
Patches 2-7 removes linecards and reporters locks and reference counting, converting them to be protected by devlink instance lock as the rest of the objects.
Patches 8 and 9 convert linecards and reporters dumpit callbacks to recently introduced
devlink_nl_instance_iter_dump()infra. Patch 10 removes no longer neededdevlink_dump_for_each_instance_get()helper.
Quoted 5 lines
Quoted 2 lines
The last patch adds assertion to
devl_is_registered()as dependency on other locks is removed.Asked Petr to queue this for testing, so we should be able to report results tomorrow.
Looks OK, no regressions.