mirror of
https://github.com/lkl/linux.git
synced 2025-12-19 16:13:19 +09:00
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>
This commit is contained in:
committed by
David S. Miller
parent
bb72e68bd1
commit
9069a3817d
@@ -6,14 +6,19 @@
|
||||
|
||||
struct objagg_ops {
|
||||
size_t obj_size;
|
||||
bool (*delta_check)(void *priv, const void *parent_obj,
|
||||
const void *obj);
|
||||
int (*hints_obj_cmp)(const void *obj1, const void *obj2);
|
||||
void * (*delta_create)(void *priv, void *parent_obj, void *obj);
|
||||
void (*delta_destroy)(void *priv, void *delta_priv);
|
||||
void * (*root_create)(void *priv, void *obj);
|
||||
void * (*root_create)(void *priv, void *obj, unsigned int root_id);
|
||||
#define OBJAGG_OBJ_ROOT_ID_INVALID UINT_MAX
|
||||
void (*root_destroy)(void *priv, void *root_priv);
|
||||
};
|
||||
|
||||
struct objagg;
|
||||
struct objagg_obj;
|
||||
struct objagg_hints;
|
||||
|
||||
const void *objagg_obj_root_priv(const struct objagg_obj *objagg_obj);
|
||||
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);
|
||||
|
||||
struct objagg_obj *objagg_obj_get(struct objagg *objagg, void *obj);
|
||||
void objagg_obj_put(struct objagg *objagg, struct objagg_obj *objagg_obj);
|
||||
struct objagg *objagg_create(const struct objagg_ops *ops, void *priv);
|
||||
struct objagg *objagg_create(const struct objagg_ops *ops,
|
||||
struct objagg_hints *hints, void *priv);
|
||||
void objagg_destroy(struct objagg *objagg);
|
||||
|
||||
struct objagg_obj_stats {
|
||||
@@ -43,4 +49,14 @@ struct objagg_stats {
|
||||
const struct objagg_stats *objagg_stats_get(struct objagg *objagg);
|
||||
void objagg_stats_put(const struct objagg_stats *objagg_stats);
|
||||
|
||||
enum objagg_opt_algo_type {
|
||||
OBJAGG_OPT_ALGO_SIMPLE_GREEDY,
|
||||
};
|
||||
|
||||
struct objagg_hints *objagg_hints_get(struct objagg *objagg,
|
||||
enum objagg_opt_algo_type opt_algo_type);
|
||||
void objagg_hints_put(struct objagg_hints *objagg_hints);
|
||||
const struct objagg_stats *
|
||||
objagg_hints_stats_get(struct objagg_hints *objagg_hints);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user