-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib: introduce initial implementation of object aggregation manager
This lib tracks objects which could be of two types: 1) root object 2) nested object - with a "delta" which differentiates it from the associated root object The objects are tracked by a hashtable and reference-counted. User is responsible of implementing callbacks to create/destroy root entity related to each root object and callback to create/destroy nested object delta. 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>
- Loading branch information
Jiri Pirko
authored and
David S. Miller
committed
Nov 15, 2018
1 parent
7dc5a0e
commit 0a020d4
Showing
8 changed files
with
1,633 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */ | ||
/* Copyright (c) 2018 Mellanox Technologies. All rights reserved */ | ||
|
||
#ifndef _OBJAGG_H | ||
#define _OBJAGG_H | ||
|
||
struct objagg_ops { | ||
size_t obj_size; | ||
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_destroy)(void *priv, void *root_priv); | ||
}; | ||
|
||
struct objagg; | ||
struct objagg_obj; | ||
|
||
const void *objagg_obj_root_priv(const struct objagg_obj *objagg_obj); | ||
const void *objagg_obj_delta_priv(const struct objagg_obj *objagg_obj); | ||
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); | ||
void objagg_destroy(struct objagg *objagg); | ||
|
||
struct objagg_obj_stats { | ||
unsigned int user_count; | ||
unsigned int delta_user_count; /* includes delta object users */ | ||
}; | ||
|
||
struct objagg_obj_stats_info { | ||
struct objagg_obj_stats stats; | ||
struct objagg_obj *objagg_obj; /* associated object */ | ||
bool is_root; | ||
}; | ||
|
||
struct objagg_stats { | ||
unsigned int stats_info_count; | ||
struct objagg_obj_stats_info stats_info[]; | ||
}; | ||
|
||
const struct objagg_stats *objagg_stats_get(struct objagg *objagg); | ||
void objagg_stats_put(const struct objagg_stats *objagg_stats); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,228 @@ | ||
/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */ | ||
/* Copyright (c) 2018 Mellanox Technologies. All rights reserved */ | ||
|
||
#undef TRACE_SYSTEM | ||
#define TRACE_SYSTEM objagg | ||
|
||
#if !defined(__TRACE_OBJAGG_H) || defined(TRACE_HEADER_MULTI_READ) | ||
#define __TRACE_OBJAGG_H | ||
|
||
#include <linux/tracepoint.h> | ||
|
||
struct objagg; | ||
struct objagg_obj; | ||
|
||
TRACE_EVENT(objagg_create, | ||
TP_PROTO(const struct objagg *objagg), | ||
|
||
TP_ARGS(objagg), | ||
|
||
TP_STRUCT__entry( | ||
__field(const void *, objagg) | ||
), | ||
|
||
TP_fast_assign( | ||
__entry->objagg = objagg; | ||
), | ||
|
||
TP_printk("objagg %p", __entry->objagg) | ||
); | ||
|
||
TRACE_EVENT(objagg_destroy, | ||
TP_PROTO(const struct objagg *objagg), | ||
|
||
TP_ARGS(objagg), | ||
|
||
TP_STRUCT__entry( | ||
__field(const void *, objagg) | ||
), | ||
|
||
TP_fast_assign( | ||
__entry->objagg = objagg; | ||
), | ||
|
||
TP_printk("objagg %p", __entry->objagg) | ||
); | ||
|
||
TRACE_EVENT(objagg_obj_create, | ||
TP_PROTO(const struct objagg *objagg, | ||
const struct objagg_obj *obj), | ||
|
||
TP_ARGS(objagg, obj), | ||
|
||
TP_STRUCT__entry( | ||
__field(const void *, objagg) | ||
__field(const void *, obj) | ||
), | ||
|
||
TP_fast_assign( | ||
__entry->objagg = objagg; | ||
__entry->obj = obj; | ||
), | ||
|
||
TP_printk("objagg %p, obj %p", __entry->objagg, __entry->obj) | ||
); | ||
|
||
TRACE_EVENT(objagg_obj_destroy, | ||
TP_PROTO(const struct objagg *objagg, | ||
const struct objagg_obj *obj), | ||
|
||
TP_ARGS(objagg, obj), | ||
|
||
TP_STRUCT__entry( | ||
__field(const void *, objagg) | ||
__field(const void *, obj) | ||
), | ||
|
||
TP_fast_assign( | ||
__entry->objagg = objagg; | ||
__entry->obj = obj; | ||
), | ||
|
||
TP_printk("objagg %p, obj %p", __entry->objagg, __entry->obj) | ||
); | ||
|
||
TRACE_EVENT(objagg_obj_get, | ||
TP_PROTO(const struct objagg *objagg, | ||
const struct objagg_obj *obj, | ||
unsigned int refcount), | ||
|
||
TP_ARGS(objagg, obj, refcount), | ||
|
||
TP_STRUCT__entry( | ||
__field(const void *, objagg) | ||
__field(const void *, obj) | ||
__field(unsigned int, refcount) | ||
), | ||
|
||
TP_fast_assign( | ||
__entry->objagg = objagg; | ||
__entry->obj = obj; | ||
__entry->refcount = refcount; | ||
), | ||
|
||
TP_printk("objagg %p, obj %p, refcount %u", | ||
__entry->objagg, __entry->obj, __entry->refcount) | ||
); | ||
|
||
TRACE_EVENT(objagg_obj_put, | ||
TP_PROTO(const struct objagg *objagg, | ||
const struct objagg_obj *obj, | ||
unsigned int refcount), | ||
|
||
TP_ARGS(objagg, obj, refcount), | ||
|
||
TP_STRUCT__entry( | ||
__field(const void *, objagg) | ||
__field(const void *, obj) | ||
__field(unsigned int, refcount) | ||
), | ||
|
||
TP_fast_assign( | ||
__entry->objagg = objagg; | ||
__entry->obj = obj; | ||
__entry->refcount = refcount; | ||
), | ||
|
||
TP_printk("objagg %p, obj %p, refcount %u", | ||
__entry->objagg, __entry->obj, __entry->refcount) | ||
); | ||
|
||
TRACE_EVENT(objagg_obj_parent_assign, | ||
TP_PROTO(const struct objagg *objagg, | ||
const struct objagg_obj *obj, | ||
const struct objagg_obj *parent, | ||
unsigned int parent_refcount), | ||
|
||
TP_ARGS(objagg, obj, parent, parent_refcount), | ||
|
||
TP_STRUCT__entry( | ||
__field(const void *, objagg) | ||
__field(const void *, obj) | ||
__field(const void *, parent) | ||
__field(unsigned int, parent_refcount) | ||
), | ||
|
||
TP_fast_assign( | ||
__entry->objagg = objagg; | ||
__entry->obj = obj; | ||
__entry->parent = parent; | ||
__entry->parent_refcount = parent_refcount; | ||
), | ||
|
||
TP_printk("objagg %p, obj %p, parent %p, parent_refcount %u", | ||
__entry->objagg, __entry->obj, | ||
__entry->parent, __entry->parent_refcount) | ||
); | ||
|
||
TRACE_EVENT(objagg_obj_parent_unassign, | ||
TP_PROTO(const struct objagg *objagg, | ||
const struct objagg_obj *obj, | ||
const struct objagg_obj *parent, | ||
unsigned int parent_refcount), | ||
|
||
TP_ARGS(objagg, obj, parent, parent_refcount), | ||
|
||
TP_STRUCT__entry( | ||
__field(const void *, objagg) | ||
__field(const void *, obj) | ||
__field(const void *, parent) | ||
__field(unsigned int, parent_refcount) | ||
), | ||
|
||
TP_fast_assign( | ||
__entry->objagg = objagg; | ||
__entry->obj = obj; | ||
__entry->parent = parent; | ||
__entry->parent_refcount = parent_refcount; | ||
), | ||
|
||
TP_printk("objagg %p, obj %p, parent %p, parent_refcount %u", | ||
__entry->objagg, __entry->obj, | ||
__entry->parent, __entry->parent_refcount) | ||
); | ||
|
||
TRACE_EVENT(objagg_obj_root_create, | ||
TP_PROTO(const struct objagg *objagg, | ||
const struct objagg_obj *obj), | ||
|
||
TP_ARGS(objagg, obj), | ||
|
||
TP_STRUCT__entry( | ||
__field(const void *, objagg) | ||
__field(const void *, obj) | ||
), | ||
|
||
TP_fast_assign( | ||
__entry->objagg = objagg; | ||
__entry->obj = obj; | ||
), | ||
|
||
TP_printk("objagg %p, obj %p", | ||
__entry->objagg, __entry->obj) | ||
); | ||
|
||
TRACE_EVENT(objagg_obj_root_destroy, | ||
TP_PROTO(const struct objagg *objagg, | ||
const struct objagg_obj *obj), | ||
|
||
TP_ARGS(objagg, obj), | ||
|
||
TP_STRUCT__entry( | ||
__field(const void *, objagg) | ||
__field(const void *, obj) | ||
), | ||
|
||
TP_fast_assign( | ||
__entry->objagg = objagg; | ||
__entry->obj = obj; | ||
), | ||
|
||
TP_printk("objagg %p, obj %p", | ||
__entry->objagg, __entry->obj) | ||
); | ||
|
||
#endif /* __TRACE_OBJAGG_H */ | ||
|
||
/* This part must be outside protection */ | ||
#include <trace/define_trace.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -624,3 +624,6 @@ config GENERIC_LIB_CMPDI2 | |
|
||
config GENERIC_LIB_UCMPDI2 | ||
bool | ||
|
||
config OBJAGG | ||
tristate "objagg" if COMPILE_TEST |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.