From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S940996AbcIFSFv (ORCPT ); Tue, 6 Sep 2016 14:05:51 -0400 Received: from smtprelay0073.hostedemail.com ([216.40.44.73]:33941 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934912AbcIFSFs (ORCPT ); Tue, 6 Sep 2016 14:05:48 -0400 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::::,RULES_HIT:41:355:379:541:599:960:973:981:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2194:2199:2393:2553:2559:2562:2693:3138:3139:3140:3141:3142:3354:3622:3865:3867:3868:3871:3872:3873:5007:6261:7875:9108:10004:10400:10848:10967:11026:11232:11473:11658:11914:12043:12438:12740:13439:14096:14097:14181:14659:14721:21080:21451:30029:30045:30054:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:3,LUA_SUMMARY:none X-HE-Tag: lamp76_1532d90374d48 X-Filterd-Recvd-Size: 3404 Date: Tue, 6 Sep 2016 14:05:44 -0400 From: Steven Rostedt To: Shuah Khan Cc: mingo@redhat.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] kobject: add kobject trace points Message-ID: <20160906140544.3a46f056@gandalf.local.home> In-Reply-To: References: X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 6 Sep 2016 11:49:23 -0600 Shuah Khan wrote: > +#if !defined(_TRACE_KOBJECT_H) || defined(TRACE_HEADER_MULTI_READ) > +#define _TRACE_KOBJECT_H > + > +#include > +#include > + > +/* 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 > + )); > +