statistics: sets of statistics in single file
Subsystems (2)
RFC PATCH 3/4 statistics: sets of statistics in single file
This patch chips a structure describing a set of statistics from the structure used to manage the user interface (files) for a set of statistics. The benefit of this split and small API change is that users can have multiple sets of statistics per file.
For example, a user which reports statistics data for many entities of similar type can have them all represented in the same file now:
my_entity_1 some_statistic 0x1000 67my_entity_1 some_statistic 0x4000 52my_entity_1 some_statistic 0x5000 13my_entity_1 some_statistic other 4my_entity_1 another_statistic samples 83my_entity_1 another_statistic minimum 185my_entity_1 another_statistic average 2875.763my_entity_1 another_statistic maximum 2837585my_entity_1 another_statistic variance 298469.485my_entity_2 some_statistic other 0my_entity_2 another_statistic samples 0my_entity_2 another_statistic minimum 0my_entity_2 another_statistic average 0.000my_entity_2 another_statistic maximum 0my_entity_2 another_statistic variance 0.000
---
include/linux/statistic.h | 47 ++++ lib/statistic.c | 444 ++++++++++++++++++++++++++++------------------ 2 files changed, 315 insertions(+), 176 deletions(-)
include/linux/statistic.h +39 -8
@@ -108,13 +108,34 @@ struct statistic { };/** -* struct statistic_ui - collection of statistics for an entity +* struct statistic_coll - collection of statistics for an entity * @stat: a struct statistic array * @info: a struct statistic_info array describing the struct statistic array * @number: number of entries in both arrays -* @pull: an optional function called when user reads data from file +* @private: optional data pointer reserved for use by clients * @label: an optional function retrieving a label for each statistics entry +* +* Exploiters must setup a struct statistic_coll prior to calling +* statistic_attach(). +*/ +struct statistic_coll { +/* private: */ +struct list_head list; +/* public: */ +#define STATISTIC_COLL_NAME_SIZE 64 +char name[STATISTIC_COLL_NAME_SIZE ]; +struct statistic *stat; +struct statistic_info *info; +int number; +void *private; +void (*label)(struct statistic_coll *coll,int i, +void *key,char *buf,int size); +}; + +/** +* struct statistic_ui - user interface for statistics * @private: optional data pointer reserved for use by clients +* @pull: an optional function called when user reads data from file * * Exploiters must setup a struct statistic_ui prior to calling * statistic_create().
@@ -122,17 +143,13 @@ struct statistic {struct statistic_ui {/* private: */ struct list_head list; +struct list_head coll_list;void *dir;void *data;void *def;/* public: */ -struct statistic *stat; -struct statistic_info *info; -int number; -void (*pull)(struct statistic_ui *ui); -void (*label)(struct statistic_ui *ui, -int i,void *key,char *buf,int size);void *private; +void (*pull)(struct statistic_ui *ui); };#ifdef CONFIG_STATISTICS
@@ -140,6 +157,9 @@ struct statistic_ui {extern int statistic_create (struct statistic_ui *,const char *);extern int statistic_remove (struct statistic_ui *); +extern int statistic_attach (struct statistic_coll *,struct statistic_ui *); +extern int statistic_detach (struct statistic_coll *); +extern void statistic_set (struct statistic *,int ,s64 ,u64 );extern void statistic_set_key (struct statistic *,int ,void *,u64 );
@@ -323,6 +343,17 @@ static inline int statistic_remove(strucreturn 0 ; } +static inline int statistic_attach (struct statistic_coll *coll, +struct statistic_ui *ui) +{ +return 0 ; +} + +static inline int statistic_detach (struct statistic_coll *coll) +{ +return 0 ; +} +static inline void statistic_set (struct statistic *stat,int i,s64 value,u64 total) {
lib/statistic.c +276 -168
690 lines not on this page · raw message