Re: [PATCH 1/3] kobject: add kobject trace points
From: Shuah Khan
Date: Wed Sep 07 2016 - 19:26:06 EST
On 09/06/2016 12:05 PM, Steven Rostedt wrote:
> On Tue, 6 Sep 2016 11:49:23 -0600
> Shuah Khan <shuahkh@xxxxxxxxxxxxxxx> 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
>
Nice. I should start thinking about efficient data structure packing
again. Used to do that a lot in the past when I worked on small embedded
systems.
I made the change and patch is ready, but holding off on sending the v2
of this patch until we conclude our tracepoint discussion at the kernel
summit and make some decisions.
thanks,
-- Shuah
Attachment:
signature.asc
Description: OpenPGP digital signature