team: remove sychronize_rcu() calls
Subsystems (3)
Jiri Pirko
maintainercover team: remove sychronize_rcu() calls
Jiri Pirko (3):
team: remove synchronize_rcu() called during queue override change
team: use kfree_rcu instead of synchronize_rcu in team_port_dev
team: remove synchronize_rcu() called during port disable
drivers/net/team/team.c | 84 ++++++++++++++++++++------------ drivers/net/team/team_mode_loadbalance.c | 3 +- drivers/net/team/team_mode_roundrobin.c | 3 +- include/linux/if_team.h | 11 +++++ 4 files changed, 66 insertions(+), 35 deletions(-)
Signature · 1 line
1.8.1.4
Jiri Pirko
maintainerPATCH 1/3 team: remove synchronize_rcu() called during queue override change
This patch removes synchronize_rcu() from function __team_queue_override_port_del(). That can be done because it is ok to do list_del_rcu() and list_add_tail_rcu() on the same list_head member without calling synchronize_rcu() in between. A bit of refactoring needed to be done because INIT_LIST_HEAD needed to be removed (to not kill the forward pointer) as well.
--- drivers/net/team/team.c | 63 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 16 deletions(-)
drivers/net/team/team.c +47 -16
@@ -725,9 +725,9 @@ static bool team_queue_override_transmit(struct team *team, struct sk_buff *skb)static void __team_queue_override_port_del (struct team *team,struct team_port *port) { +if (!port->queue_id) +return ;list_del_rcu (&port->qom_list); -synchronize_rcu (); -INIT_LIST_HEAD (&port->qom_list); } static bool team_queue_override_port_has_gt_prio_than(struct team_port *port,
@@ -749,9 +749,8 @@ static void __team_queue_override_port_add(struct team *team,struct list_head *qom_list;struct list_head *node; -if (!port->queue_id || !team_port_enabled (port)) +if (!port->queue_id)return ; - qom_list =__team_get_qom_list (team, port->queue_id); node = qom_list;list_for_each_entry (cur, qom_list, qom_list) {
@@ -768,7 +767,7 @@ static void __team_queue_override_enabled_check(struct team *team)bool enabled = false;list_for_each_entry (port, &team->port_list, list) { -if (!list_empty (&port->qom_list)) { +if (port->queue_id) { enabled = true;break ; }
@@ -780,14 +779,44 @@ static void __team_queue_override_enabled_check(struct team *team) team->queue_override_enabled = enabled; } -static void team_queue_override_port_refresh (struct team *team, -struct team_port *port) +static void team_queue_override_port_prio_changed (struct team *team, +struct team_port *port) { +if (!port->queue_id ||team_port_enabled (port)) +return ;__team_queue_override_port_del (team, port);__team_queue_override_port_add (team, port);__team_queue_override_enabled_check (team); } +static void team_queue_override_port_change_queue_id (struct team *team, +struct team_port *port, +u16 new_queue_id) +{ +if (team_port_enabled (port)) { +__team_queue_override_port_del (team, port); + port->queue_id = new_queue_id; +__team_queue_override_port_add (team, port); +__team_queue_override_enabled_check (team); + }else { + port->queue_id = new_queue_id; + } +} + +static void team_queue_override_port_add (struct team *team, +struct team_port *port) +{ +__team_queue_override_port_add (team, port); +__team_queue_override_enabled_check (team); +} + +static void team_queue_override_port_del (struct team *team, +struct team_port *port) +{ +__team_queue_override_port_del (team, port); +__team_queue_override_enabled_check (team); +} +/**************** * Port handling
@@ -819,7 +848,7 @@ static void team_port_enable(struct team *team,hlist_add_head_rcu (&port->hlist,team_port_index_hash (team, port->index));team_adjust_ops (team); -team_queue_override_port_refresh (team, port); +team_queue_override_port_add (team, port);if (team->ops.port_enabled) team->ops.port_enabled (team, port); }
@@ -848,7 +877,7 @@ static void team_port_disable(struct team *team,hlist_del_rcu (&port->hlist);__reconstruct_port_hlist (team, port->index); port->index =-1 ; -team_queue_override_port_refresh (team, port); +team_queue_override_port_del (team, port);__team_adjust_ops (team, team->en_port_count -1 );/* * Wait until readers see adjusted ops. This ensures that
@@ -1259,9 +1288,12 @@ static int team_priority_option_set(struct team *team, struct team_gsetter_ctx *ctx) {struct team_port *port = ctx->info->port; +s32 priority = ctx->data.s32_val; - port->priority = ctx->data.s32_val; -team_queue_override_port_refresh (team, port); +if (port->priority == priority) +return 0 ; + port->priority = priority; +team_queue_override_port_prio_changed (team, port);return 0 ; }
@@ -1278,17 +1310,16 @@ static int team_queue_id_option_set(struct team *team, struct team_gsetter_ctx *ctx) {struct team_port *port = ctx->info->port; +u16 new_queue_id = ctx->data.u32_val; -if (port->queue_id == ctx->data.u32_val) +if (port->queue_id == new_queue_id)return 0 ; -if (ctx->data.u32_val >= team->dev->real_num_tx_queues) +if (new_queue_id >= team->dev->real_num_tx_queues)return -EINVAL ; - port->queue_id = ctx->data.u32_val; -team_queue_override_port_refresh (team, port); +team_queue_override_port_change_queue_id (team, port, new_queue_id);return 0 ; } -static const struct team_option team_options[] = { { .name ="mode" ,
Signature · 1 line
1.8.1.4
Re: [patch net-next 1/3] team: remove synchronize_rcu() called during queue override change
Quoted 12 lines · Jiri Pirko
This patch removes
synchronize_rcu()from function__team_queue_override_port_del(). That can be done because it is ok to dolist_del_rcu()andlist_add_tail_rcu()on the samelist_headmember without callingsynchronize_rcu()in between. A bit of refactoring needed to be done becauseINIT_LIST_HEADneeded to be removed (to not kill the forward pointer) as well.Signed-off-by Jiri Pirko <[email protected]>--- drivers/net/team/team.c | 63 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 16 deletions(-)
[...]
drivers/net/team/team.c static int team_queue_id_option_set(struct team *team, · line 1315
Quoted 8 lines
drivers/net/team/team.c +2
-1@@ -1278,17 +1310,16 @@ static int team_queue_id_option_set(struct team *team, struct team_gsetter_ctx *ctx) {struct team_port *port = ctx->info->port; +u16 new_queue_id = ctx->data.u32_val; -if (port->queue_id == ctx->data.u32_val) +if (port->queue_id == new_queue_id)
Since you're passing new_queue_id to port->queue_id and in the other parts you test against !port->queue_id to see if it's enable or not, that means queue 0 can't be used.
Maybe I am missing something, but wouldn't be better to initialize with -1 and allow 0 to be used as well?
fbl
Quoted 10 lines
drivers/net/team/team.c +2
-3return 0 ; -if (ctx->data.u32_val >= team->dev->real_num_tx_queues) +if (new_queue_id >= team->dev->real_num_tx_queues)return -EINVAL ; - port->queue_id = ctx->data.u32_val; -team_queue_override_port_refresh (team, port); +team_queue_override_port_change_queue_id (team, port, new_queue_id);return 0 ; }
Jiri Pirko
maintainerRe: [patch net-next 1/3] team: remove synchronize_rcu() called during queue override change
Quoted 28 lines · Tue, Jun 11, 2013 at 02:48:45AM CEST, [email protected] wrote:
Quoted 12 lines · Jiri Pirko
This patch removes
synchronize_rcu()from function__team_queue_override_port_del(). That can be done because it is ok to dolist_del_rcu()andlist_add_tail_rcu()on the samelist_headmember without callingsynchronize_rcu()in between. A bit of refactoring needed to be done becauseINIT_LIST_HEADneeded to be removed (to not kill the forward pointer) as well.Signed-off-by Jiri Pirko <[email protected]>--- drivers/net/team/team.c | 63 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 16 deletions(-)[...]
drivers/net/team/team.c static int team_queue_id_option_set(struct team *team, · line 1315
Quoted 8 lines
drivers/net/team/team.c +2
-1@@ -1278,17 +1310,16 @@ static int team_queue_id_option_set(struct team *team, struct team_gsetter_ctx *ctx) {struct team_port *port = ctx->info->port; +u16 new_queue_id = ctx->data.u32_val; -if (port->queue_id == ctx->data.u32_val) +if (port->queue_id == new_queue_id)Since you're passing
new_queue_idtoport->queue_idand in the other parts you test against !port->queue_id to see if it's enable or not, that means queue 0 can't be used.
Quoted 2 lines
Maybe I am missing something, but wouldn't be better to initialize with -1 and allow 0 to be used as well?
0 means default queue. It's done the same was as in bonding code.
Quoted 14 lines
fbl
Quoted 10 lines
drivers/net/team/team.c +2
-3return 0 ; -if (ctx->data.u32_val >= team->dev->real_num_tx_queues) +if (new_queue_id >= team->dev->real_num_tx_queues)return -EINVAL ; - port->queue_id = ctx->data.u32_val; -team_queue_override_port_refresh (team, port); +team_queue_override_port_change_queue_id (team, port, new_queue_id);return 0 ; }
Jiri Pirko
maintainerRe: [patch net-next 1/3] team: remove synchronize_rcu() called during queue override change
Quoted 29 lines · Tue, Jun 11, 2013 at 07:40:46AM CEST, [email protected] wrote:
Quoted 28 lines · Tue, Jun 11, 2013 at 02:48:45AM CEST, [email protected] wrote:
Quoted 12 lines · Jiri Pirko
This patch removes
synchronize_rcu()from function__team_queue_override_port_del(). That can be done because it is ok to dolist_del_rcu()andlist_add_tail_rcu()on the samelist_headmember without callingsynchronize_rcu()in between. A bit of refactoring needed to be done becauseINIT_LIST_HEADneeded to be removed (to not kill the forward pointer) as well.Signed-off-by Jiri Pirko <[email protected]>--- drivers/net/team/team.c | 63 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 16 deletions(-)[...]
drivers/net/team/team.c static int team_queue_id_option_set(struct team *team, · line 1315
Quoted 8 lines
drivers/net/team/team.c +2
-1@@ -1278,17 +1310,16 @@ static int team_queue_id_option_set(struct team *team, struct team_gsetter_ctx *ctx) {struct team_port *port = ctx->info->port; +u16 new_queue_id = ctx->data.u32_val; -if (port->queue_id == ctx->data.u32_val) +if (port->queue_id == new_queue_id)Since you're passing
new_queue_idtoport->queue_idand in the other parts you test against !port->queue_id to see if it's enable or not, that means queue 0 can't be used.
Quoted 4 lines
Quoted 2 lines
Maybe I am missing something, but wouldn't be better to initialize with -1 and allow 0 to be used as well?
0 means default queue. It's done the same was as in bonding code.
+ this patch does not change original behaviour...
Quoted 15 lines
Quoted 15 lines
fbl
Quoted 10 lines
drivers/net/team/team.c +2
-3return 0 ; -if (ctx->data.u32_val >= team->dev->real_num_tx_queues) +if (new_queue_id >= team->dev->real_num_tx_queues)return -EINVAL ; - port->queue_id = ctx->data.u32_val; -team_queue_override_port_refresh (team, port); +team_queue_override_port_change_queue_id (team, port, new_queue_id);return 0 ; }
Flavio Leitner
Acked-byRe: [patch net-next 1/3] team: remove synchronize_rcu() called during queue override change
Quoted 30 lines · Jiri Pirko
Quoted 29 lines · Tue, Jun 11, 2013 at 07:40:46AM CEST, [email protected] wrote:
Quoted 28 lines · Tue, Jun 11, 2013 at 02:48:45AM CEST, [email protected] wrote:
Quoted 12 lines · Jiri Pirko
This patch removes
synchronize_rcu()from function__team_queue_override_port_del(). That can be done because it is ok to dolist_del_rcu()andlist_add_tail_rcu()on the samelist_headmember without callingsynchronize_rcu()in between. A bit of refactoring needed to be done becauseINIT_LIST_HEADneeded to be removed (to not kill the forward pointer) as well.Signed-off-by Jiri Pirko <[email protected]>--- drivers/net/team/team.c | 63 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 16 deletions(-)[...]
drivers/net/team/team.c static int team_queue_id_option_set(struct team *team, · line 1315
Quoted 8 lines
drivers/net/team/team.c +2
-1@@ -1278,17 +1310,16 @@ static int team_queue_id_option_set(struct team *team, struct team_gsetter_ctx *ctx) {struct team_port *port = ctx->info->port; +u16 new_queue_id = ctx->data.u32_val; -if (port->queue_id == ctx->data.u32_val) +if (port->queue_id == new_queue_id)Since you're passing
new_queue_idtoport->queue_idand in the other parts you test against !port->queue_id to see if it's enable or not, that means queue 0 can't be used.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Maybe I am missing something, but wouldn't be better to initialize with -1 and allow 0 to be used as well?
0 means default queue. It's done the same was as in bonding code.
+ this patch does not change original behaviour...
Jiri explained this bits off list to me, so
Thanks,
Signature · 1 line
fbl
Jiri Pirko
maintainerPATCH 2/3 team: use kfree_rcu instead of synchronize_rcu in team_port_dev
In reply to Jiri Pirko--- drivers/net/team/team.c | 3 +-- include/linux/if_team.h | 1 + 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/team/team.c +1 -2
@@ -1192,8 +1192,7 @@ static int team_port_del(struct team *team, struct net_device *port_dev)team_port_set_orig_dev_addr (port);dev_set_mtu (port_dev, port->orig.mtu); -synchronize_rcu (); -kfree (port); +kfree_rcu (port, rcu);netdev_info (dev,"Port device %s removed\n" , portname);__team_compute_features (team);
include/linux/if_team.h +1 -0
@@ -69,6 +69,7 @@ struct team_port {s32 priority;/* lower number ~ higher priority */ u16 queue_id;struct list_head qom_list;/* node in queue override mapping list */ +struct rcu_head rcu;long mode_priv[0 ]; };
Signature · 1 line
1.8.1.4
Jiri Pirko
maintainerPATCH 3/3 team: remove synchronize_rcu() called during port disable
In reply to Jiri PirkoCheck the unlikely case of team->en_port_count == 0 before modulo operation.
--- drivers/net/team/team.c | 20 +++++--------------- drivers/net/team/team_mode_loadbalance.c | 3 +-- drivers/net/team/team_mode_roundrobin.c | 3 ++- include/linux/if_team.h | 10 ++++++++++ 4 files changed, 18 insertions(+), 18 deletions(-)
drivers/net/team/team.c +5 -15
@@ -525,31 +525,26 @@ static void team_set_no_mode(struct team *team) team->mode = &__team_no_mode; } -static void __team_adjust_ops (struct team *team,int en_port_count) +static void team_adjust_ops (struct team *team) {/* * To avoid checks in rx/tx skb paths, ensure here that non-null and * correct ops are always set. */ -if (!en_port_count || !team_is_mode_set (team) || +if (!team->en_port_count || !team_is_mode_set (team) || !team->mode->ops->transmit) team->ops.transmit = team_dummy_transmit;else team->ops.transmit = team->mode->ops->transmit; -if (!en_port_count || !team_is_mode_set (team) || +if (!team->en_port_count || !team_is_mode_set (team) || !team->mode->ops->receive) team->ops.receive = team_dummy_receive;else team->ops.receive = team->mode->ops->receive; } -static void team_adjust_ops (struct team *team) -{ -__team_adjust_ops (team, team->en_port_count); -} -/* * We can benefit from the fact that it's ensured no port is present * at the time of mode change. Therefore no packets are in fly so there's no
@@ -877,14 +872,9 @@ static void team_port_disable(struct team *team,hlist_del_rcu (&port->hlist);__reconstruct_port_hlist (team, port->index); port->index =-1 ; -team_queue_override_port_del (team, port); -__team_adjust_ops (team, team->en_port_count -1 ); -/* -* Wait until readers see adjusted ops. This ensures that -* readers never see team->en_port_count == 0 -*/ -synchronize_rcu (); team->en_port_count--; +team_queue_override_port_del (team, port); +team_adjust_ops (team); }#define TEAM_VLAN_FEATURES (NETIF_F_ALL_CSUM | NETIF_F_SG | \
drivers/net/team/team_mode_loadbalance.c +1 -2
@@ -112,9 +112,8 @@ static struct team_port *lb_hash_select_tx_port(struct team *team,struct sk_buff *skb, unsigned char hash) { - int port_index; + int port_index = team_num_to_port_index(team, hash); - port_index = hash % team->en_port_count;return team_get_port_by_index_rcu (team, port_index); }
drivers/net/team/team_mode_roundrobin.c +2 -1
@@ -30,7 +30,8 @@ static bool rr_transmit(struct team *team, struct sk_buff *skb)struct team_port *port;int port_index; - port_index =rr_priv (team)->sent_packets++ % team->en_port_count; + port_index =team_num_to_port_index (team, +rr_priv (team)->sent_packets++); port =team_get_port_by_index_rcu (team, port_index);if (unlikely (!port)) goto drop;
include/linux/if_team.h +10 -0
@@ -229,6 +229,16 @@ static inline struct team_port *team_get_port_by_index(struct team *team,return port;return NULL ; } + +static inline int team_num_to_port_index (struct team *team,int num) +{ +int en_port_count =ACCESS_ONCE (team->en_port_count); + +if (unlikely (!en_port_count)) +return 0 ; +return num % en_port_count; +} +static inline struct team_port *team_get_port_by_index_rcu (struct team *team,int port_index) {
Signature · 1 line
1.8.1.4
From: Jiri Pirko <[email protected]>
Date: Mon, 10 Jun 2013 17:42:22 +0200
Quoted 4 lines
Jiri Pirko (3):
team: removesynchronize_rcu()called during queue override change
team: usekfree_rcuinstead ofsynchronize_rcuinteam_port_dev
team: removesynchronize_rcu()called during port disable
Applied, but I suspect this patch series was generated against the patch set you submitted for "net" because I had to hand apply patch #3 with some fuzz as git would not apply it directly.
Please don't do that, submit your patches in the future against what is actually in net-next.
Jiri Pirko
maintainerQuoted 8 lines · Wed, Jun 12, 2013 at 12:10:22PM CEST, [email protected] wrote:
From: Jiri Pirko <[email protected]>
Date: Mon, 10 Jun 2013 17:42:22 +0200Quoted 4 lines
Jiri Pirko (3):
team: removesynchronize_rcu()called during queue override change
team: usekfree_rcuinstead ofsynchronize_rcuinteam_port_dev
team: removesynchronize_rcu()called during port disable
Quoted 6 lines
Applied, but I suspect this patch series was generated against the patch set you submitted for "net" because I had to hand apply patch #3 with some fuzz as git would not apply it directly.
Please don't do that, submit your patches in the future against what is actually in net-next.
Sorry. I will be more careful next time.
Jiri