Message ID | 20200526122907.1603776-1-numans@ovn.org |
---|---|
State | Superseded |
Headers | show |
Series | Incremental processing improvements. | expand |
On Tue, May 26, 2020 at 5:59 PM <numans@ovn.org> wrote: > From: Numan Siddique <numans@ovn.org> > > When ovn-controller updates the nb_cfg column of its chassis, > this results in full recomputation on all the nodes. This results > in wastage of CPU cycles. To address this, this patch handles > sbrec_chassis changes incrementally. > > We don't need to handle any sbrec_chassis changes during runtime_data > stage, because before engine_run() is called, encaps_run() is called > which will handle any chassis/encap changes. > > For new chassis addition and deletion, we need to add/delete flows for > the tunnel ports created/deleted. So physical_run() is called for this. > > For any chassis updates, we can ignore this for flow computation. > > This patch handles all these. > > Acked-by: Mark Michelson <mmichels@redhat.com> > Signed-off-by: Numan Siddique <numans@ovn.org> > --- > controller/ovn-controller.c | 53 ++++++++++++++++++++++++++++++------- > 1 file changed, 43 insertions(+), 10 deletions(-) > > diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c > index 5e9e0c62b..50c4f684c 100644 > --- a/controller/ovn-controller.c > +++ b/controller/ovn-controller.c > @@ -1443,7 +1443,8 @@ static void init_physical_ctx(struct engine_node > *node, > > struct sbrec_chassis_table *chassis_table = > (struct sbrec_chassis_table *)EN_OVSDB_GET( > - engine_get_input("SB_chassis", node)); > + engine_get_input("SB_chassis", > + engine_get_input("physical_flow_changes", node))); > > I should not have removed sb_chassis as input to flow_output engine. I'll fix it in the next version. > struct ed_type_mff_ovn_geneve *ed_mff_ovn_geneve = > engine_get_input_data("mff_ovn_geneve", node); > @@ -1459,7 +1460,8 @@ static void init_physical_ctx(struct engine_node > *node, > const struct sbrec_chassis *chassis = NULL; > struct ovsdb_idl_index *sbrec_chassis_by_name = > engine_ovsdb_node_get_index( > - engine_get_input("SB_chassis", node), > + engine_get_input("SB_chassis", > + engine_get_input("physical_flow_changes", node)), > "name"); > > if (chassis_id) { > chassis = chassis_lookup_by_name(sbrec_chassis_by_name, > chassis_id); > @@ -1536,7 +1538,8 @@ static void init_lflow_ctx(struct engine_node *node, > const struct sbrec_chassis *chassis = NULL; > struct ovsdb_idl_index *sbrec_chassis_by_name = > engine_ovsdb_node_get_index( > - engine_get_input("SB_chassis", node), > + engine_get_input("SB_chassis", > + engine_get_input("physical_flow_changes", node)), > "name"); > if (chassis_id) { > chassis = chassis_lookup_by_name(sbrec_chassis_by_name, > chassis_id); > @@ -1617,8 +1620,9 @@ en_flow_output_run(struct engine_node *node, void > *data) > > struct ovsdb_idl_index *sbrec_chassis_by_name = > engine_ovsdb_node_get_index( > - engine_get_input("SB_chassis", node), > - "name"); > + engine_get_input("SB_chassis", > + engine_get_input("physical_flow_changes", node)), > + "name"); > > const struct sbrec_chassis *chassis = NULL; > if (chassis_id) { > @@ -1783,8 +1787,9 @@ _flow_output_resource_ref_handler(struct engine_node > *node, void *data, > > struct ovsdb_idl_index *sbrec_chassis_by_name = > engine_ovsdb_node_get_index( > - engine_get_input("SB_chassis", node), > - "name"); > + engine_get_input("SB_chassis", > + engine_get_input("physical_flow_changes", node)), > + "name"); > const struct sbrec_chassis *chassis = NULL; > if (chassis_id) { > chassis = chassis_lookup_by_name(sbrec_chassis_by_name, > chassis_id); > @@ -1956,6 +1961,31 @@ physical_flow_changes_ovs_iface_handler(struct > engine_node *node, > return true; > } > > +/* Handles sbrec_chassis changes. > + * If a new chassis is added or removed return false, so that > + * physical flows are programmed. > + * For any updates, there is no need for any flow computation. > + * Encap changes will also result in sbrec_chassis changes, > + * but we handle encap changes separately. > + */ > +static bool > +physical_flow_changes_sb_chassis_handler(struct engine_node *node > OVS_UNUSED, > + void *data OVS_UNUSED) > +{ > + struct sbrec_chassis_table *chassis_table = > + (struct sbrec_chassis_table *)EN_OVSDB_GET( > + engine_get_input("SB_chassis", node)); > + > + const struct sbrec_chassis *ch; > + SBREC_CHASSIS_TABLE_FOR_EACH_TRACKED (ch, chassis_table) { > + if (sbrec_chassis_is_deleted(ch) || sbrec_chassis_is_new(ch)) { > + return false; > + } > + } > + > + return true; > +} > + > static bool > flow_output_physical_flow_changes_handler(struct engine_node *node, void > *data) > { > @@ -2205,6 +2235,10 @@ main(int argc, char *argv[]) > NULL); > engine_add_input(&en_physical_flow_changes, &en_ovs_interface, > physical_flow_changes_ovs_iface_handler); > + engine_add_input(&en_physical_flow_changes, &en_sb_chassis, > + physical_flow_changes_sb_chassis_handler); > + engine_add_input(&en_physical_flow_changes, &en_sb_encap, > + NULL); > > engine_add_input(&en_flow_output, &en_addr_sets, > flow_output_addr_sets_handler); > @@ -2224,8 +2258,6 @@ main(int argc, char *argv[]) > engine_add_input(&en_flow_output, &en_ovs_open_vswitch, NULL); > engine_add_input(&en_flow_output, &en_ovs_bridge, NULL); > > - engine_add_input(&en_flow_output, &en_sb_chassis, NULL); > I should not have removed sb_chassis as input here. I'll fix it. Thanks Numan - engine_add_input(&en_flow_output, &en_sb_encap, NULL); > engine_add_input(&en_flow_output, &en_sb_multicast_group, > flow_output_sb_multicast_group_handler); > engine_add_input(&en_flow_output, &en_sb_port_binding, > @@ -2252,7 +2284,8 @@ main(int argc, char *argv[]) > runtime_data_ovs_interface_handler); > engine_add_input(&en_runtime_data, &en_ovs_qos, NULL); > > - engine_add_input(&en_runtime_data, &en_sb_chassis, NULL); > + engine_add_input(&en_runtime_data, &en_sb_chassis, > + runtime_data_noop_handler); > engine_add_input(&en_runtime_data, &en_sb_datapath_binding, > runtime_data_sb_datapath_binding_handler); > engine_add_input(&en_runtime_data, &en_sb_port_binding, > -- > 2.26.2 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > https://mail.openvswitch.org/mailman/listinfo/ovs-dev > >
diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 5e9e0c62b..50c4f684c 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -1443,7 +1443,8 @@ static void init_physical_ctx(struct engine_node *node, struct sbrec_chassis_table *chassis_table = (struct sbrec_chassis_table *)EN_OVSDB_GET( - engine_get_input("SB_chassis", node)); + engine_get_input("SB_chassis", + engine_get_input("physical_flow_changes", node))); struct ed_type_mff_ovn_geneve *ed_mff_ovn_geneve = engine_get_input_data("mff_ovn_geneve", node); @@ -1459,7 +1460,8 @@ static void init_physical_ctx(struct engine_node *node, const struct sbrec_chassis *chassis = NULL; struct ovsdb_idl_index *sbrec_chassis_by_name = engine_ovsdb_node_get_index( - engine_get_input("SB_chassis", node), + engine_get_input("SB_chassis", + engine_get_input("physical_flow_changes", node)), "name"); if (chassis_id) { chassis = chassis_lookup_by_name(sbrec_chassis_by_name, chassis_id); @@ -1536,7 +1538,8 @@ static void init_lflow_ctx(struct engine_node *node, const struct sbrec_chassis *chassis = NULL; struct ovsdb_idl_index *sbrec_chassis_by_name = engine_ovsdb_node_get_index( - engine_get_input("SB_chassis", node), + engine_get_input("SB_chassis", + engine_get_input("physical_flow_changes", node)), "name"); if (chassis_id) { chassis = chassis_lookup_by_name(sbrec_chassis_by_name, chassis_id); @@ -1617,8 +1620,9 @@ en_flow_output_run(struct engine_node *node, void *data) struct ovsdb_idl_index *sbrec_chassis_by_name = engine_ovsdb_node_get_index( - engine_get_input("SB_chassis", node), - "name"); + engine_get_input("SB_chassis", + engine_get_input("physical_flow_changes", node)), + "name"); const struct sbrec_chassis *chassis = NULL; if (chassis_id) { @@ -1783,8 +1787,9 @@ _flow_output_resource_ref_handler(struct engine_node *node, void *data, struct ovsdb_idl_index *sbrec_chassis_by_name = engine_ovsdb_node_get_index( - engine_get_input("SB_chassis", node), - "name"); + engine_get_input("SB_chassis", + engine_get_input("physical_flow_changes", node)), + "name"); const struct sbrec_chassis *chassis = NULL; if (chassis_id) { chassis = chassis_lookup_by_name(sbrec_chassis_by_name, chassis_id); @@ -1956,6 +1961,31 @@ physical_flow_changes_ovs_iface_handler(struct engine_node *node, return true; } +/* Handles sbrec_chassis changes. + * If a new chassis is added or removed return false, so that + * physical flows are programmed. + * For any updates, there is no need for any flow computation. + * Encap changes will also result in sbrec_chassis changes, + * but we handle encap changes separately. + */ +static bool +physical_flow_changes_sb_chassis_handler(struct engine_node *node OVS_UNUSED, + void *data OVS_UNUSED) +{ + struct sbrec_chassis_table *chassis_table = + (struct sbrec_chassis_table *)EN_OVSDB_GET( + engine_get_input("SB_chassis", node)); + + const struct sbrec_chassis *ch; + SBREC_CHASSIS_TABLE_FOR_EACH_TRACKED (ch, chassis_table) { + if (sbrec_chassis_is_deleted(ch) || sbrec_chassis_is_new(ch)) { + return false; + } + } + + return true; +} + static bool flow_output_physical_flow_changes_handler(struct engine_node *node, void *data) { @@ -2205,6 +2235,10 @@ main(int argc, char *argv[]) NULL); engine_add_input(&en_physical_flow_changes, &en_ovs_interface, physical_flow_changes_ovs_iface_handler); + engine_add_input(&en_physical_flow_changes, &en_sb_chassis, + physical_flow_changes_sb_chassis_handler); + engine_add_input(&en_physical_flow_changes, &en_sb_encap, + NULL); engine_add_input(&en_flow_output, &en_addr_sets, flow_output_addr_sets_handler); @@ -2224,8 +2258,6 @@ main(int argc, char *argv[]) engine_add_input(&en_flow_output, &en_ovs_open_vswitch, NULL); engine_add_input(&en_flow_output, &en_ovs_bridge, NULL); - engine_add_input(&en_flow_output, &en_sb_chassis, NULL); - engine_add_input(&en_flow_output, &en_sb_encap, NULL); engine_add_input(&en_flow_output, &en_sb_multicast_group, flow_output_sb_multicast_group_handler); engine_add_input(&en_flow_output, &en_sb_port_binding, @@ -2252,7 +2284,8 @@ main(int argc, char *argv[]) runtime_data_ovs_interface_handler); engine_add_input(&en_runtime_data, &en_ovs_qos, NULL); - engine_add_input(&en_runtime_data, &en_sb_chassis, NULL); + engine_add_input(&en_runtime_data, &en_sb_chassis, + runtime_data_noop_handler); engine_add_input(&en_runtime_data, &en_sb_datapath_binding, runtime_data_sb_datapath_binding_handler); engine_add_input(&en_runtime_data, &en_sb_port_binding,