diff options
author | Prakash Surya <[email protected]> | 2013-09-12 16:14:51 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2013-10-16 14:48:35 -0700 |
commit | 56d40a686b0504042a088943154ba7b0dde36d51 (patch) | |
tree | 5d6d397d8e310874592909a7c17b453bb375b52c /include | |
parent | 4768c0d0a61497f2f3a52678154f2742a355618f (diff) |
Add callbacks for displaying KSTAT_TYPE_RAW kstats
The current implementation for displaying kstats of type KSTAT_TYPE_RAW
is rather crude. This patch attempts to enhance this handling by
allowing a kstat user to register formatting callbacks which can
optionally be used.
The callbacks allow the user to implement functions for interpreting
their data and transposing it into a character buffer. This buffer,
containing a string representation of the raw data, is then be displayed
through the current /proc textual interface.
Additionally the kstats are made writable because it's now possible
to provide a useful handler via the existing ks_update() interface.
Signed-off-by: Prakash Surya <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Issue #296
Diffstat (limited to 'include')
-rw-r--r-- | include/sys/kstat.h | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/include/sys/kstat.h b/include/sys/kstat.h index da3c5899d..75b384714 100644 --- a/include/sys/kstat.h +++ b/include/sys/kstat.h @@ -33,6 +33,7 @@ #include <sys/mutex.h> #define KSTAT_STRLEN 31 +#define KSTAT_RAW_MAX (128*1024) /* For reference valid classes are: * disk, tape, net, controller, vm, kvm, hat, streams, kstat, misc @@ -79,6 +80,7 @@ #define KSTAT_WRITE 1 struct kstat_s; +typedef struct kstat_s kstat_t; typedef int kid_t; /* unique kstat id */ typedef int kstat_update_t(struct kstat_s *, int); /* dynamic update cb */ @@ -90,7 +92,13 @@ typedef struct kstat_module { struct proc_dir_entry *ksm_proc; /* proc entry */ } kstat_module_t; -typedef struct kstat_s { +typedef struct kstat_raw_ops { + int (*headers)(char *buf, size_t size); + int (*data)(char *buf, size_t size, void *data); + void *(*addr)(kstat_t *ksp, loff_t index); +} kstat_raw_ops_t; + +struct kstat_s { int ks_magic; /* magic value */ kid_t ks_kid; /* unique kstat ID */ hrtime_t ks_crtime; /* creation time */ @@ -110,7 +118,10 @@ typedef struct kstat_s { kmutex_t ks_lock; /* kstat data lock */ struct list_head ks_list; /* kstat linkage */ kstat_module_t *ks_owner; /* kstat module linkage */ -} kstat_t; + kstat_raw_ops_t ks_raw_ops; /* ops table for raw type */ + char *ks_raw_buf; /* buf used for raw ops */ + size_t ks_raw_bufsize; /* size of raw ops buffer */ +}; typedef struct kstat_named_s { char name[KSTAT_STRLEN]; /* name of counter */ @@ -188,6 +199,10 @@ typedef struct kstat_txg { int spl_kstat_init(void); void spl_kstat_fini(void); +extern void __kstat_set_raw_ops(kstat_t *ksp, + int (*headers)(char *buf, size_t size), + int (*data)(char *buf, size_t size, void *data), + void* (*addr)(kstat_t *ksp, loff_t index)); extern kstat_t *__kstat_create(const char *ks_module, int ks_instance, const char *ks_name, const char *ks_class, uchar_t ks_type, uint_t ks_ndata, @@ -195,6 +210,7 @@ extern kstat_t *__kstat_create(const char *ks_module, int ks_instance, extern void __kstat_install(kstat_t *ksp); extern void __kstat_delete(kstat_t *ksp); +#define kstat_set_raw_ops(k,h,d,a) __kstat_set_raw_ops(k,h,d,a) #define kstat_create(m,i,n,c,t,s,f) __kstat_create(m,i,n,c,t,s,f) #define kstat_install(k) __kstat_install(k) #define kstat_delete(k) __kstat_delete(k) |