diff mbox series

[net-next,v3,5/5] net/sched: cls_api: conditional notification of events

Message ID 20231206164416.543503-6-pctammela@mojatatu.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net/sched: conditional notification of events for cls and act | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1124 this patch: 1124
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 1143 this patch: 1143
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
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: 1151 this patch: 1151
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 36 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Pedro Tammela Dec. 6, 2023, 4:44 p.m. UTC
As of today tc-filter/chain events are unconditionally built and sent to
RTNLGRP_TC. As with the introduction of rtnl_notify_needed we can check
before-hand if they are really needed. This will help to alleviate
system pressure when filters are concurrently added without the rtnl
lock as in tc-flower.

Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
---
 net/sched/cls_api.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Simon Horman Dec. 7, 2023, 8:59 p.m. UTC | #1
On Wed, Dec 06, 2023 at 01:44:16PM -0300, Pedro Tammela wrote:
> As of today tc-filter/chain events are unconditionally built and sent to
> RTNLGRP_TC. As with the introduction of rtnl_notify_needed we can check
> before-hand if they are really needed. This will help to alleviate
> system pressure when filters are concurrently added without the rtnl
> lock as in tc-flower.
> 
> Reviewed-by: Jiri Pirko <jiri@nvidia.com>
> Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>

Thanks Pedro,

my comment below notwithstanding, this looks good to me.

Reviewed-by: Simon Horman <horms@kernel.org>

> ---
>  net/sched/cls_api.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
> index 1976bd163986..123185907ebd 100644
> --- a/net/sched/cls_api.c
> +++ b/net/sched/cls_api.c
> @@ -2053,6 +2053,9 @@ static int tfilter_notify(struct net *net, struct sk_buff *oskb,
>  	u32 portid = oskb ? NETLINK_CB(oskb).portid : 0;
>  	int err = 0;
>  
> +	if (!unicast && !rtnl_notify_needed(net, n->nlmsg_flags, RTNLGRP_TC))

I don't feel strongly about this, but
as the above condition appears 3 times in this patch,
perhaps it could be a helper?

> +		return 0;
> +
>  	skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
>  	if (!skb)
>  		return -ENOBUFS;
> @@ -2082,6 +2085,9 @@ static int tfilter_del_notify(struct net *net, struct sk_buff *oskb,
>  	u32 portid = oskb ? NETLINK_CB(oskb).portid : 0;
>  	int err;
>  
> +	if (!unicast && !rtnl_notify_needed(net, n->nlmsg_flags, RTNLGRP_TC))
> +		return tp->ops->delete(tp, fh, last, rtnl_held, extack);
> +
>  	skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
>  	if (!skb)
>  		return -ENOBUFS;
> @@ -2906,6 +2912,9 @@ static int tc_chain_notify(struct tcf_chain *chain, struct sk_buff *oskb,
>  	struct sk_buff *skb;
>  	int err = 0;
>  
> +	if (!unicast && !rtnl_notify_needed(net, flags, RTNLGRP_TC))
> +		return 0;
> +
>  	skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
>  	if (!skb)
>  		return -ENOBUFS;
> @@ -2935,6 +2944,9 @@ static int tc_chain_notify_delete(const struct tcf_proto_ops *tmplt_ops,
>  	struct net *net = block->net;
>  	struct sk_buff *skb;
>  
> +	if (!unicast && !rtnl_notify_needed(net, flags, RTNLGRP_TC))
> +		return 0;
> +
>  	skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
>  	if (!skb)
>  		return -ENOBUFS;
> -- 
> 2.40.1
>
Pedro Tammela Dec. 8, 2023, 5:48 p.m. UTC | #2
On 07/12/2023 17:59, Simon Horman wrote:
> On Wed, Dec 06, 2023 at 01:44:16PM -0300, Pedro Tammela wrote:
>> As of today tc-filter/chain events are unconditionally built and sent to
>> RTNLGRP_TC. As with the introduction of rtnl_notify_needed we can check
>> before-hand if they are really needed. This will help to alleviate
>> system pressure when filters are concurrently added without the rtnl
>> lock as in tc-flower.
>>
>> Reviewed-by: Jiri Pirko <jiri@nvidia.com>
>> Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
> 
> Thanks Pedro,
> 
> my comment below notwithstanding, this looks good to me.
> 
> Reviewed-by: Simon Horman <horms@kernel.org>
> 
>> ---
>>   net/sched/cls_api.c | 12 ++++++++++++
>>   1 file changed, 12 insertions(+)
>>
>> diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
>> index 1976bd163986..123185907ebd 100644
>> --- a/net/sched/cls_api.c
>> +++ b/net/sched/cls_api.c
>> @@ -2053,6 +2053,9 @@ static int tfilter_notify(struct net *net, struct sk_buff *oskb,
>>   	u32 portid = oskb ? NETLINK_CB(oskb).portid : 0;
>>   	int err = 0;
>>   
>> +	if (!unicast && !rtnl_notify_needed(net, n->nlmsg_flags, RTNLGRP_TC))
> 
> I don't feel strongly about this, but
> as the above condition appears 3 times in this patch,
> perhaps it could be a helper?

I noticed that some of these functions will never call with unicast set 
to true (delete routines). So I will append a patch that removes it.
So this pattern will hopefully bet not repeating enough for a macro :)

> 
>> +		return 0;
>> +
>>   	skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
>>   	if (!skb)
>>   		return -ENOBUFS;
>> @@ -2082,6 +2085,9 @@ static int tfilter_del_notify(struct net *net, struct sk_buff *oskb,
>>   	u32 portid = oskb ? NETLINK_CB(oskb).portid : 0;
>>   	int err;
>>   
>> +	if (!unicast && !rtnl_notify_needed(net, n->nlmsg_flags, RTNLGRP_TC))
>> +		return tp->ops->delete(tp, fh, last, rtnl_held, extack);
>> +
>>   	skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
>>   	if (!skb)
>>   		return -ENOBUFS;
>> @@ -2906,6 +2912,9 @@ static int tc_chain_notify(struct tcf_chain *chain, struct sk_buff *oskb,
>>   	struct sk_buff *skb;
>>   	int err = 0;
>>   
>> +	if (!unicast && !rtnl_notify_needed(net, flags, RTNLGRP_TC))
>> +		return 0;
>> +
>>   	skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
>>   	if (!skb)
>>   		return -ENOBUFS;
>> @@ -2935,6 +2944,9 @@ static int tc_chain_notify_delete(const struct tcf_proto_ops *tmplt_ops,
>>   	struct net *net = block->net;
>>   	struct sk_buff *skb;
>>   
>> +	if (!unicast && !rtnl_notify_needed(net, flags, RTNLGRP_TC))
>> +		return 0;
>> +
>>   	skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
>>   	if (!skb)
>>   		return -ENOBUFS;
>> -- 
>> 2.40.1
>>
diff mbox series

Patch

diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 1976bd163986..123185907ebd 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -2053,6 +2053,9 @@  static int tfilter_notify(struct net *net, struct sk_buff *oskb,
 	u32 portid = oskb ? NETLINK_CB(oskb).portid : 0;
 	int err = 0;
 
+	if (!unicast && !rtnl_notify_needed(net, n->nlmsg_flags, RTNLGRP_TC))
+		return 0;
+
 	skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
 	if (!skb)
 		return -ENOBUFS;
@@ -2082,6 +2085,9 @@  static int tfilter_del_notify(struct net *net, struct sk_buff *oskb,
 	u32 portid = oskb ? NETLINK_CB(oskb).portid : 0;
 	int err;
 
+	if (!unicast && !rtnl_notify_needed(net, n->nlmsg_flags, RTNLGRP_TC))
+		return tp->ops->delete(tp, fh, last, rtnl_held, extack);
+
 	skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
 	if (!skb)
 		return -ENOBUFS;
@@ -2906,6 +2912,9 @@  static int tc_chain_notify(struct tcf_chain *chain, struct sk_buff *oskb,
 	struct sk_buff *skb;
 	int err = 0;
 
+	if (!unicast && !rtnl_notify_needed(net, flags, RTNLGRP_TC))
+		return 0;
+
 	skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
 	if (!skb)
 		return -ENOBUFS;
@@ -2935,6 +2944,9 @@  static int tc_chain_notify_delete(const struct tcf_proto_ops *tmplt_ops,
 	struct net *net = block->net;
 	struct sk_buff *skb;
 
+	if (!unicast && !rtnl_notify_needed(net, flags, RTNLGRP_TC))
+		return 0;
+
 	skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
 	if (!skb)
 		return -ENOBUFS;