Skip to content

Commit 92e56b2

Browse files
almusildceara
authored andcommitted
objdep: Simplify the passing of UUIDs to update.
The objdep was adding "struct object_to_resources_list_node" to list that would be passed around and only used part would be the uuid. Create uuidset directly instead to avoid extra allocations of the intermediate struct. Signed-off-by: Ales Musil <amusil@redhat.com> Signed-off-by: Dumitru Ceara <dceara@redhat.com>
1 parent 6e2e489 commit 92e56b2

File tree

5 files changed

+18
-32
lines changed

5 files changed

+18
-32
lines changed

controller/lflow.c

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -748,30 +748,21 @@ lflow_handle_addr_set_update(const char *as_name,
748748

749749
bool
750750
lflow_handle_changed_ref(enum objdep_type type, const char *res_name,
751-
struct ovs_list *objs_todo,
751+
struct uuidset *objs_todo,
752752
const void *in_arg, void *out_arg)
753753
{
754754
struct lflow_ctx_in *l_ctx_in = CONST_CAST(struct lflow_ctx_in *, in_arg);
755755
struct lflow_ctx_out *l_ctx_out = out_arg;
756756

757757
/* Re-parse the related lflows. */
758758
/* Firstly, flood remove the flows from desired flow table. */
759-
struct object_to_resources_list_node *resource_list_node_uuid;
760-
struct uuidset flood_remove_nodes =
761-
UUIDSET_INITIALIZER(&flood_remove_nodes);
762-
LIST_FOR_EACH_SAFE (resource_list_node_uuid, list_node, objs_todo) {
763-
const struct uuid *obj_uuid = &resource_list_node_uuid->obj_uuid;
764-
VLOG_DBG("Reprocess lflow "UUID_FMT" for resource type: %s,"
765-
" name: %s.",
766-
UUID_ARGS(obj_uuid), objdep_type_name(type), res_name);
767-
uuidset_insert(&flood_remove_nodes, obj_uuid);
768-
free(resource_list_node_uuid);
769-
}
770-
ofctrl_flood_remove_flows(l_ctx_out->flow_table, &flood_remove_nodes);
759+
ofctrl_flood_remove_flows(l_ctx_out->flow_table, objs_todo);
771760

772761
/* Secondly, for each lflow that is actually removed, reprocessing it. */
773762
struct uuidset_node *ofrn;
774-
UUIDSET_FOR_EACH (ofrn, &flood_remove_nodes) {
763+
UUIDSET_FOR_EACH (ofrn, objs_todo) {
764+
VLOG_DBG("Reprocess lflow "UUID_FMT" for resource type: %s, name: %s.",
765+
UUID_ARGS(&ofrn->uuid), objdep_type_name(type), res_name);
775766
objdep_mgr_remove_obj(l_ctx_out->lflow_deps_mgr, &ofrn->uuid);
776767
lflow_conj_ids_free(l_ctx_out->conj_ids, &ofrn->uuid);
777768

@@ -798,7 +789,8 @@ lflow_handle_changed_ref(enum objdep_type type, const char *res_name,
798789

799790
consider_logical_flow(lflow, false, l_ctx_in, l_ctx_out);
800791
}
801-
uuidset_destroy(&flood_remove_nodes);
792+
793+
uuidset_destroy(objs_todo);
802794
return true;
803795
}
804796

controller/lflow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ bool lflow_handle_addr_set_update(const char *as_name, struct addr_set_diff *,
169169
struct lflow_ctx_out *,
170170
bool *changed);
171171
bool lflow_handle_changed_ref(enum objdep_type, const char *res_name,
172-
struct ovs_list *objs_todo,
172+
struct uuidset *objs_todo,
173173
const void *in_arg, void *out_arg);
174174

175175
void lflow_handle_changed_mac_bindings(

controller/ovn-controller.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2770,23 +2770,22 @@ lb_data_local_lb_remove(struct ed_type_lb_data *lb_data,
27702770

27712771
static bool
27722772
lb_data_handle_changed_ref(enum objdep_type type, const char *res_name,
2773-
struct ovs_list *objs_todo, const void *in_arg,
2773+
struct uuidset *objs_todo, const void *in_arg,
27742774
void *out_arg)
27752775
{
27762776
const struct lb_data_ctx_in *ctx_in = in_arg;
27772777
struct ed_type_lb_data *lb_data = out_arg;
27782778

2779-
struct object_to_resources_list_node *resource_lb_uuid;
2780-
LIST_FOR_EACH_POP (resource_lb_uuid, list_node, objs_todo) {
2781-
struct uuid *uuid = &resource_lb_uuid->obj_uuid;
2779+
struct uuidset_node *ofrn;
2780+
UUIDSET_FOR_EACH (ofrn, objs_todo) {
2781+
struct uuid *uuid = &ofrn->uuid;
27822782

27832783
VLOG_DBG("Reprocess LB "UUID_FMT" for resource type: %s, name: %s",
27842784
UUID_ARGS(uuid), objdep_type_name(type), res_name);
27852785

27862786
struct ovn_controller_lb *lb =
27872787
ovn_controller_lb_find(&lb_data->local_lbs, uuid);
27882788
if (!lb) {
2789-
free(resource_lb_uuid);
27902789
continue;
27912790
}
27922791

@@ -2795,14 +2794,13 @@ lb_data_handle_changed_ref(enum objdep_type type, const char *res_name,
27952794
const struct sbrec_load_balancer *sbrec_lb =
27962795
sbrec_load_balancer_table_get_for_uuid(ctx_in->lb_table, uuid);
27972796
if (!lb_is_local(sbrec_lb, ctx_in->local_datapaths)) {
2798-
free(resource_lb_uuid);
27992797
continue;
28002798
}
28012799

28022800
lb_data_local_lb_add(lb_data, sbrec_lb, ctx_in->template_vars, true);
2803-
2804-
free(resource_lb_uuid);
28052801
}
2802+
2803+
uuidset_destroy(objs_todo);
28062804
return true;
28072805
}
28082806

lib/objdep.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,21 +214,17 @@ objdep_mgr_handle_change(struct objdep_mgr *mgr,
214214
" name: %s.", objdep_type_name(type), res_name);
215215
*changed = false;
216216

217-
struct ovs_list objs_todo = OVS_LIST_INITIALIZER(&objs_todo);
218-
217+
struct uuidset objs_todo = UUIDSET_INITIALIZER(&objs_todo);
219218
struct object_to_resources_list_node *resource_list_node;
220219
HMAP_FOR_EACH (resource_list_node, hmap_node, &resource_node->objs) {
221220
if (uuidset_find(objs_processed, &resource_list_node->obj_uuid)) {
222221
continue;
223222
}
224223
/* Use object_to_resources_list_node as list node to store the uuid.
225224
* Other fields are not used here. */
226-
struct object_to_resources_list_node *resource_list_node_uuid =
227-
xmalloc(sizeof *resource_list_node_uuid);
228-
resource_list_node_uuid->obj_uuid = resource_list_node->obj_uuid;
229-
ovs_list_push_back(&objs_todo, &resource_list_node_uuid->list_node);
225+
uuidset_insert(&objs_todo, &resource_list_node->obj_uuid);
230226
}
231-
if (ovs_list_is_empty(&objs_todo)) {
227+
if (uuidset_is_empty(&objs_todo)) {
232228
return true;
233229
}
234230
*changed = true;

lib/objdep.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ enum objdep_type {
3535
* handled successfully. */
3636
typedef bool (*objdep_change_handler)(enum objdep_type,
3737
const char *res_name,
38-
struct ovs_list *ref_nodes,
38+
struct uuidset *ref_nodes,
3939
const void *in_arg, void *out_arg);
4040

4141
/* A node pointing to all objects that refer to a given resource. */

0 commit comments

Comments
 (0)