]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
lib: objagg: add root count to stats
authorJiri Pirko <jiri@mellanox.com>
Thu, 7 Feb 2019 11:22:47 +0000 (11:22 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 8 Feb 2019 23:02:49 +0000 (15:02 -0800)
Count number of roots and add it to stats. It is handy for the library
user to have this stats available as it can act upon it without
counting roots itself.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/objagg.h
lib/objagg.c

index a675286df1af92ca83b733eea6f3871836b176a6..78021777df46264af5279d56bf9628d2448ce279 100644 (file)
@@ -42,6 +42,7 @@ struct objagg_obj_stats_info {
 };
 
 struct objagg_stats {
+       unsigned int root_count;
        unsigned int stats_info_count;
        struct objagg_obj_stats_info stats_info[];
 };
index befe8a47d0800d69e03cd49576e38dc2eded51f9..781f41c3c47ded6b284a536d1252710440170640 100644 (file)
@@ -621,6 +621,8 @@ const struct objagg_stats *objagg_stats_get(struct objagg *objagg)
                objagg_stats->stats_info[i].objagg_obj = objagg_obj;
                objagg_stats->stats_info[i].is_root =
                                        objagg_obj_is_root(objagg_obj);
+               if (objagg_stats->stats_info[i].is_root)
+                       objagg_stats->root_count++;
                i++;
        }
        objagg_stats->stats_info_count = i;
@@ -1031,6 +1033,8 @@ objagg_hints_stats_get(struct objagg_hints *objagg_hints)
        list_for_each_entry(hnode, &objagg_hints->node_list, list) {
                memcpy(&objagg_stats->stats_info[i], &hnode->stats_info,
                       sizeof(objagg_stats->stats_info[0]));
+               if (objagg_stats->stats_info[i].is_root)
+                       objagg_stats->root_count++;
                i++;
        }
        objagg_stats->stats_info_count = i;