Messages in this thread | | | Date | Tue, 6 Sep 2016 14:05:44 -0400 | From | Steven Rostedt <> | Subject | Re: [PATCH 1/3] kobject: add kobject trace points |
| |
On Tue, 6 Sep 2016 11:49:23 -0600 Shuah Khan <shuahkh@osg.samsung.com> wrote:
> +#if !defined(_TRACE_KOBJECT_H) || defined(TRACE_HEADER_MULTI_READ) > +#define _TRACE_KOBJECT_H > + > +#include <linux/tracepoint.h> > +#include <linux/kobject.h> > + > +/* kobject_init_class */ > +DECLARE_EVENT_CLASS(kobject_init_class, > + > + TP_PROTO(struct kobject *kobj), > + > + TP_ARGS(kobj), > + > + TP_STRUCT__entry( > + __field(void *, kobj) > + __field(int, state_initialized) > + ), > + > + TP_fast_assign( > + __entry->kobj = kobj; > + __entry->state_initialized = kobj->state_initialized; > + ), > + > + TP_printk("KOBJECT: %p state=%d", > + __entry->kobj, > + __entry->state_initialized > + )); > + > +/** > + * kobject_init - called from kobject_init() when kobject is initialized > + * @kobj: - pointer to struct kobject > + */ > +DEFINE_EVENT(kobject_init_class, kobject_init, > + > + TP_PROTO(struct kobject *kobj), > + TP_ARGS(kobj)); > + > +/* kobject_class */ > +DECLARE_EVENT_CLASS(kobject_class, > + > + TP_PROTO(struct kobject *kobj), > + TP_ARGS(kobj), > + > + TP_STRUCT__entry( > + __field(void *, kobj) > + __string(name, kobject_name(kobj)) > + __field(int, state_initialized) > + __field(void *, parent) > + __string(pname, kobj->parent ? kobject_name(kobj->parent) : "") > + __field(int, count) > + ),
state_initialized looks to be a single bit. As you have two dynamic strings, it may be best to move this around and possibly save 3 bytes. Also, dynamic strings take 4 bytes, and pointers are 8 bytes on 64 bit machines, we want to move those too.
__field(void *, kobj) __field(void *, parent) __field(int, count) __string(name, ...) __string(pname, ...) __field(char, state_initialized)
This will compact the event a bit better.
-- Steve
> + > + TP_fast_assign( > + __entry->kobj = kobj; > + __assign_str(name, kobject_name(kobj)); > + __entry->state_initialized = kobj->state_initialized; > + __entry->parent = kobj->parent; > + __assign_str(pname, > + kobj->parent ? kobject_name(kobj->parent) : ""); > + __entry->count = atomic_read(&kobj->kref.refcount); > + ), > + > + TP_printk("KOBJECT: %s (%p) state=%d parent= %s (%p) counter= %d", > + __get_str(name), > + __entry->kobj, > + __entry->state_initialized, > + __get_str(pname), > + __entry->parent, > + __entry->count > + )); > +
| |