diff options
| author | Jiri Pirko <jiri@mellanox.com> | 2019-02-07 06:22:46 -0500 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2019-02-08 18:02:49 -0500 |
| commit | 9069a3817d82b01b3a55da382c774e3575946130 (patch) | |
| tree | 5b8aca6dbaf69345aec08b325761cdf9162ebc9b /include/linux/objagg.h | |
| parent | bb72e68bd1f2a86c37a990e9d905f34b712ae2b6 (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.h | 20 |
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 | ||
| 7 | struct objagg_ops { | 7 | struct 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 | ||
| 15 | struct objagg; | 19 | struct objagg; |
| 16 | struct objagg_obj; | 20 | struct objagg_obj; |
| 21 | struct objagg_hints; | ||
| 17 | 22 | ||
| 18 | const void *objagg_obj_root_priv(const struct objagg_obj *objagg_obj); | 23 | const void *objagg_obj_root_priv(const struct objagg_obj *objagg_obj); |
| 19 | const void *objagg_obj_delta_priv(const struct objagg_obj *objagg_obj); | 24 | const 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 | ||
| 22 | struct objagg_obj *objagg_obj_get(struct objagg *objagg, void *obj); | 27 | struct objagg_obj *objagg_obj_get(struct objagg *objagg, void *obj); |
| 23 | void objagg_obj_put(struct objagg *objagg, struct objagg_obj *objagg_obj); | 28 | void objagg_obj_put(struct objagg *objagg, struct objagg_obj *objagg_obj); |
| 24 | struct objagg *objagg_create(const struct objagg_ops *ops, void *priv); | 29 | struct objagg *objagg_create(const struct objagg_ops *ops, |
| 30 | struct objagg_hints *hints, void *priv); | ||
| 25 | void objagg_destroy(struct objagg *objagg); | 31 | void objagg_destroy(struct objagg *objagg); |
| 26 | 32 | ||
| 27 | struct objagg_obj_stats { | 33 | struct objagg_obj_stats { |
| @@ -43,4 +49,14 @@ struct objagg_stats { | |||
| 43 | const struct objagg_stats *objagg_stats_get(struct objagg *objagg); | 49 | const struct objagg_stats *objagg_stats_get(struct objagg *objagg); |
| 44 | void objagg_stats_put(const struct objagg_stats *objagg_stats); | 50 | void objagg_stats_put(const struct objagg_stats *objagg_stats); |
| 45 | 51 | ||
| 52 | enum objagg_opt_algo_type { | ||
| 53 | OBJAGG_OPT_ALGO_SIMPLE_GREEDY, | ||
| 54 | }; | ||
| 55 | |||
| 56 | struct objagg_hints *objagg_hints_get(struct objagg *objagg, | ||
| 57 | enum objagg_opt_algo_type opt_algo_type); | ||
| 58 | void objagg_hints_put(struct objagg_hints *objagg_hints); | ||
| 59 | const struct objagg_stats * | ||
| 60 | objagg_hints_stats_get(struct objagg_hints *objagg_hints); | ||
| 61 | |||
| 46 | #endif | 62 | #endif |
