Lines Matching refs:objagg

10 #include <linux/objagg.h>
13 #include <trace/events/objagg.h>
43 struct objagg {
55 struct rhash_head ht_node; /* member of objagg->obj_ht */
56 struct list_head list; /* member of objagg->obj_list */
108 * @objagg_obj: objagg object instance
129 * @objagg_obj: objagg object instance
146 * @objagg_obj: objagg object instance
158 static struct objagg_obj *objagg_obj_lookup(struct objagg *objagg, void *obj)
160 return rhashtable_lookup_fast(&objagg->obj_ht, obj, objagg->ht_params);
163 static int objagg_obj_parent_assign(struct objagg *objagg,
170 delta_priv = objagg->ops->delta_create(objagg->priv, parent->obj,
182 trace_objagg_obj_parent_assign(objagg, objagg_obj,
188 static int objagg_obj_parent_lookup_assign(struct objagg *objagg,
194 list_for_each_entry(objagg_obj_cur, &objagg->obj_list, list) {
200 err = objagg_obj_parent_assign(objagg, objagg_obj,
208 static void __objagg_obj_put(struct objagg *objagg,
211 static void objagg_obj_parent_unassign(struct objagg *objagg,
214 trace_objagg_obj_parent_unassign(objagg, objagg_obj,
217 objagg->ops->delta_destroy(objagg->priv, objagg_obj->delta_priv);
218 __objagg_obj_put(objagg, objagg_obj->parent);
221 static int objagg_obj_root_id_alloc(struct objagg *objagg,
229 if (!objagg->hints) {
241 min = objagg->hints->root_count;
245 root_id = ida_alloc_range(&objagg->root_ida, min, max, GFP_KERNEL);
253 static void objagg_obj_root_id_free(struct objagg *objagg,
256 if (!objagg->hints)
258 ida_free(&objagg->root_ida, objagg_obj->root_id);
261 static int objagg_obj_root_create(struct objagg *objagg,
267 err = objagg_obj_root_id_alloc(objagg, objagg_obj, hnode);
270 objagg_obj->root_priv = objagg->ops->root_create(objagg->priv,
277 trace_objagg_obj_root_create(objagg, objagg_obj);
281 objagg_obj_root_id_free(objagg, objagg_obj);
285 static void objagg_obj_root_destroy(struct objagg *objagg,
288 trace_objagg_obj_root_destroy(objagg, objagg_obj);
289 objagg->ops->root_destroy(objagg->priv, objagg_obj->root_priv);
290 objagg_obj_root_id_free(objagg, objagg_obj);
293 static struct objagg_obj *__objagg_obj_get(struct objagg *objagg, void *obj);
295 static int objagg_obj_init_with_hints(struct objagg *objagg,
303 hnode = objagg_hints_lookup(objagg->hints, objagg_obj->obj);
311 return objagg_obj_root_create(objagg, objagg_obj, hnode);
313 parent = __objagg_obj_get(objagg, hnode->parent->obj);
317 err = objagg_obj_parent_assign(objagg, objagg_obj, parent, false);
327 objagg_obj_put(objagg, parent);
331 static int objagg_obj_init(struct objagg *objagg,
340 err = objagg_obj_init_with_hints(objagg, objagg_obj, &hint_found);
348 err = objagg_obj_parent_lookup_assign(objagg, objagg_obj);
352 return objagg_obj_root_create(objagg, objagg_obj, NULL);
355 static void objagg_obj_fini(struct objagg *objagg,
359 objagg_obj_parent_unassign(objagg, objagg_obj);
361 objagg_obj_root_destroy(objagg, objagg_obj);
364 static struct objagg_obj *objagg_obj_create(struct objagg *objagg, void *obj)
369 objagg_obj = kzalloc(sizeof(*objagg_obj) + objagg->ops->obj_size,
374 memcpy(objagg_obj->obj, obj, objagg->ops->obj_size);
376 err = objagg_obj_init(objagg, objagg_obj);
380 err = rhashtable_insert_fast(&objagg->obj_ht, &objagg_obj->ht_node,
381 objagg->ht_params);
384 list_add(&objagg_obj->list, &objagg->obj_list);
385 objagg->obj_count++;
386 trace_objagg_obj_create(objagg, objagg_obj);
391 objagg_obj_fini(objagg, objagg_obj);
397 static struct objagg_obj *__objagg_obj_get(struct objagg *objagg, void *obj)
404 objagg_obj = objagg_obj_lookup(objagg, obj);
410 return objagg_obj_create(objagg, obj);
414 * objagg_obj_get - gets an object within objagg instance
415 * @objagg: objagg instance
420 * Size of the "obj" memory is specified in "objagg->ops".
434 * Returns a pointer to objagg object instance in case of success,
437 struct objagg_obj *objagg_obj_get(struct objagg *objagg, void *obj)
441 objagg_obj = __objagg_obj_get(objagg, obj);
445 trace_objagg_obj_get(objagg, objagg_obj, objagg_obj->refcount);
450 static void objagg_obj_destroy(struct objagg *objagg,
453 trace_objagg_obj_destroy(objagg, objagg_obj);
454 --objagg->obj_count;
456 rhashtable_remove_fast(&objagg->obj_ht, &objagg_obj->ht_node,
457 objagg->ht_params);
458 objagg_obj_fini(objagg, objagg_obj);
462 static void __objagg_obj_put(struct objagg *objagg,
466 objagg_obj_destroy(objagg, objagg_obj);
470 * objagg_obj_put - puts an object within objagg instance
471 * @objagg: objagg instance
472 * @objagg_obj: objagg object instance
478 void objagg_obj_put(struct objagg *objagg, struct objagg_obj *objagg_obj)
480 trace_objagg_obj_put(objagg, objagg_obj, objagg_obj->refcount);
482 __objagg_obj_put(objagg, objagg_obj);
487 * objagg_create - creates a new objagg instance
504 * Each objagg instance contains multiple trees. Each tree node is
511 * Returns a pointer to newly created objagg instance in case of success,
514 struct objagg *objagg_create(const struct objagg_ops *ops,
517 struct objagg *objagg;
525 objagg = kzalloc(sizeof(*objagg), GFP_KERNEL);
526 if (!objagg)
528 objagg->ops = ops;
530 objagg->hints = objagg_hints;
533 objagg->priv = priv;
534 INIT_LIST_HEAD(&objagg->obj_list);
536 objagg->ht_params.key_len = ops->obj_size;
537 objagg->ht_params.key_offset = offsetof(struct objagg_obj, obj);
538 objagg->ht_params.head_offset = offsetof(struct objagg_obj, ht_node);
540 err = rhashtable_init(&objagg->obj_ht, &objagg->ht_params);
544 ida_init(&objagg->root_ida);
546 trace_objagg_create(objagg);
547 return objagg;
550 kfree(objagg);
556 * objagg_destroy - destroys a new objagg instance
557 * @objagg: objagg instance
561 void objagg_destroy(struct objagg *objagg)
563 trace_objagg_destroy(objagg);
564 ida_destroy(&objagg->root_ida);
565 WARN_ON(!list_empty(&objagg->obj_list));
566 rhashtable_destroy(&objagg->obj_ht);
567 if (objagg->hints)
568 objagg_hints_put(objagg->hints);
569 kfree(objagg);
588 * objagg_stats_get - obtains stats of the objagg instance
589 * @objagg: objagg instance
604 const struct objagg_stats *objagg_stats_get(struct objagg *objagg)
611 objagg->obj_count), GFP_KERNEL);
616 list_for_each_entry(objagg_obj, &objagg->obj_list, list) {
637 * objagg_stats_put - puts stats of the objagg instance
638 * @objagg_stats: objagg instance stats
777 static struct objagg_tmp_graph *objagg_tmp_graph_create(struct objagg *objagg)
779 unsigned int nodes_count = objagg->obj_count;
800 list_for_each_entry(objagg_obj, &objagg->obj_list, list) {
814 if (objagg->ops->delta_check(objagg->priv,
840 struct objagg *objagg)
849 graph = objagg_tmp_graph_create(objagg);
861 objagg->ops->obj_size,
877 objagg->ops->obj_size,
894 struct objagg *objagg);
922 * @objagg: objagg instance
927 * According to the algo type, the existing objects of objagg instance
930 * a new objagg instance. There, the future object creations are going
937 struct objagg_hints *objagg_hints_get(struct objagg *objagg,
948 objagg_hints->ops = objagg->ops;
953 objagg_hints->ht_params.key_len = objagg->ops->obj_size;
964 err = algo->fillup_hints(objagg_hints, objagg);
968 if (WARN_ON(objagg_hints->node_count != objagg->obj_count)) {
987 * @objagg_hints: objagg hints instance