Message ID | 20230118152115.1113149-3-jiri@resnulli.us (mailing list archive) |
---|---|
State | Accepted |
Commit | 3a10173f48aa1bae64baf0fea228c6045996b117 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | devlink: linecard and reporters locking cleanup | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Clearly marked for net-next |
netdev/fixes_present | success | Fixes tag not required for -next series |
netdev/subject_prefix | success | Link |
netdev/cover_letter | success | Series has a cover letter |
netdev/patch_count | success | Link |
netdev/header_inline | success | No static functions without inline keyword in header files |
netdev/build_32bit | success | Errors and warnings before: 2 this patch: 2 |
netdev/cc_maintainers | success | CCed 6 of 6 maintainers |
netdev/build_clang | success | Errors and warnings before: 1 this patch: 1 |
netdev/module_param | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/check_selftest | success | No net selftest shell script |
netdev/verify_fixes | success | No Fixes tag |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 2 this patch: 2 |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 65 lines checked |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | success | Was 0 now: 0 |
On 1/18/2023 7:21 AM, Jiri Pirko wrote: > From: Jiri Pirko <jiri@nvidia.com> > > As long as the linecard life time is protected by devlink instance > lock, the reference counting is no longer needed. Remove it. > Makes sense. Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> > Signed-off-by: Jiri Pirko <jiri@nvidia.com> > Reviewed-by: Ido Schimmel <idosch@nvidia.com> > --- > 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(-) > > diff --git a/net/devlink/devl_internal.h b/net/devlink/devl_internal.h > index 32f0adc40c18..dd4e2c37cf07 100644 > --- a/net/devlink/devl_internal.h > +++ b/net/devlink/devl_internal.h > @@ -193,7 +193,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; > diff --git a/net/devlink/leftover.c b/net/devlink/leftover.c > index 6ba1baab80d3..c92bc04bc25c 100644 > --- a/net/devlink/leftover.c > +++ b/net/devlink/leftover.c > @@ -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; > @@ -10266,7 +10256,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; > } > @@ -10282,7 +10271,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); > > diff --git a/net/devlink/netlink.c b/net/devlink/netlink.c > index b5b8ac6db2d1..3f2ab4360f11 100644 > --- a/net/devlink/netlink.c > +++ b/net/devlink/netlink.c > @@ -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); > }
diff --git a/net/devlink/devl_internal.h b/net/devlink/devl_internal.h index 32f0adc40c18..dd4e2c37cf07 100644 --- a/net/devlink/devl_internal.h +++ b/net/devlink/devl_internal.h @@ -193,7 +193,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; diff --git a/net/devlink/leftover.c b/net/devlink/leftover.c index 6ba1baab80d3..c92bc04bc25c 100644 --- a/net/devlink/leftover.c +++ b/net/devlink/leftover.c @@ -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; @@ -10266,7 +10256,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; } @@ -10282,7 +10271,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); diff --git a/net/devlink/netlink.c b/net/devlink/netlink.c index b5b8ac6db2d1..3f2ab4360f11 100644 --- a/net/devlink/netlink.c +++ b/net/devlink/netlink.c @@ -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); }