aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/objagg.h
diff options
context:
space:
mode:
authorJiri Pirko <jiri@mellanox.com>2019-02-07 06:22:46 -0500
committerDavid S. Miller <davem@davemloft.net>2019-02-08 18:02:49 -0500
commit9069a3817d82b01b3a55da382c774e3575946130 (patch)
tree5b8aca6dbaf69345aec08b325761cdf9162ebc9b /include/linux/objagg.h
parentbb72e68bd1f2a86c37a990e9d905f34b712ae2b6 (diff)
lib: objagg: implement optimization hints assembly and use hints for object creation
Implement simple greedy algo to find more optimized root-delta tree for a given objagg instance. This "hints" can be used by a driver to: 1) check if the hints are better (driver's choice) than the original objagg tree. Driver does comparison of objagg stats and hints stats. 2) use the hints to create a new objagg instance which will construct the root-delta tree according to the passed hints. Currently, only a simple greedy algorithm is implemented. Basically it finds the roots according to the maximal possible user count including deltas. 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>
Diffstat (limited to 'include/linux/objagg.h')
-rw-r--r--include/linux/objagg.h20
1 files changed, 18 insertions, 2 deletions
diff --git a/include/linux/objagg.h b/include/linux/objagg.h
index 34f38c186ea0..a675286df1af 100644
--- a/include/linux/objagg.h
+++ b/include/linux/objagg.h
@@ -6,14 +6,19 @@
6 6
7struct objagg_ops { 7struct objagg_ops {
8 size_t obj_size; 8 size_t obj_size;
9 bool (*delta_check)(void *priv, const void *parent_obj,
10 const void *obj);
11 int (*hints_obj_cmp)(const void *obj1, const void *obj2);
9 void * (*delta_create)(void *priv, void *parent_obj, void *obj); 12 void * (*delta_create)(void *priv, void *parent_obj, void *obj);
10 void (*delta_destroy)(void *priv, void *delta_priv); 13 void (*delta_destroy)(void *priv, void *delta_priv);
11 void * (*root_create)(void *priv, void *obj); 14 void * (*root_create)(void *priv, void *obj, unsigned int root_id);
15#define OBJAGG_OBJ_ROOT_ID_INVALID UINT_MAX
12 void (*root_destroy)(void *priv, void *root_priv); 16 void (*root_destroy)(void *priv, void *root_priv);
13}; 17};
14 18
15struct objagg; 19struct objagg;
16struct objagg_obj; 20struct objagg_obj;
21struct objagg_hints;
17 22
18const void *objagg_obj_root_priv(const struct objagg_obj *objagg_obj); 23const void *objagg_obj_root_priv(const struct objagg_obj *objagg_obj);
19const void *objagg_obj_delta_priv(const struct objagg_obj *objagg_obj); 24const void *objagg_obj_delta_priv(const struct objagg_obj *objagg_obj);
@@ -21,7 +26,8 @@ const void *objagg_obj_raw(const struct objagg_obj *objagg_obj);
21 26
22struct objagg_obj *objagg_obj_get(struct objagg *objagg, void *obj); 27struct objagg_obj *objagg_obj_get(struct objagg *objagg, void *obj);
23void objagg_obj_put(struct objagg *objagg, struct objagg_obj *objagg_obj); 28void objagg_obj_put(struct objagg *objagg, struct objagg_obj *objagg_obj);
24struct objagg *objagg_create(const struct objagg_ops *ops, void *priv); 29struct objagg *objagg_create(const struct objagg_ops *ops,
30 struct objagg_hints *hints, void *priv);
25void objagg_destroy(struct objagg *objagg); 31void objagg_destroy(struct objagg *objagg);
26 32
27struct objagg_obj_stats { 33struct objagg_obj_stats {
@@ -43,4 +49,14 @@ struct objagg_stats {
43const struct objagg_stats *objagg_stats_get(struct objagg *objagg); 49const struct objagg_stats *objagg_stats_get(struct objagg *objagg);
44void objagg_stats_put(const struct objagg_stats *objagg_stats); 50void objagg_stats_put(const struct objagg_stats *objagg_stats);
45 51
52enum objagg_opt_algo_type {
53 OBJAGG_OPT_ALGO_SIMPLE_GREEDY,
54};
55
56struct objagg_hints *objagg_hints_get(struct objagg *objagg,
57 enum objagg_opt_algo_type opt_algo_type);
58void objagg_hints_put(struct objagg_hints *objagg_hints);
59const struct objagg_stats *
60objagg_hints_stats_get(struct objagg_hints *objagg_hints);
61
46#endif 62#endif