From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938978AbcIFRuD (ORCPT ); Tue, 6 Sep 2016 13:50:03 -0400 Received: from resqmta-po-07v.sys.comcast.net ([96.114.154.166]:37416 "EHLO resqmta-po-07v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755152AbcIFRtb (ORCPT ); Tue, 6 Sep 2016 13:49:31 -0400 From: Shuah Khan To: rostedt@goodmis.org, mingo@redhat.com, gregkh@linuxfoundation.org Cc: Shuah Khan , linux-kernel@vger.kernel.org Subject: [PATCH 3/3] kobject: Add calls to kobject trace points Date: Tue, 6 Sep 2016 11:49:25 -0600 Message-Id: <12a517d8f5de4d103f112bd80d6f22dab7c3ed53.1473174684.git.shuahkh@osg.samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: X-CMAE-Envelope: MS4wfDHjdtdVD6ue9RG+YIlYejyAmsKA8RSRZAXOD/2xmG/jT2By3EzC4fWWMQK3SFGarjXFWJXiEPQG6eQwdZ1mFED2rI1Gkr3o4uGVdqbBNYHtyhukgVz2 IgAy+bVLL61DE46ABXa6r6iBeWiVOvPIbiht+pA6TgXbB2oRCqhkgMoZ/NQBApjJ7+rw8hZHvpi+YHiUtplx5QVNTms7noNrcJnUDaLuf09p+pVC9eFNVn26 7tA85dgB0jhvnY+2doGpU69LsWRGyPedMLCCnJa7YnjfyCnsqKeCej4Z7ZRksYORwyfM2uI0HEMoIEtEcRDw+sG21E6gevigjEB/MNCh71g= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add calls to kobject trace points to kobject init, add, init_and_add, create_and_add, move, set_name, rename, get, put, cleanup, and del. Signed-off-by: Shuah Khan --- lib/kobject.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/kobject.c b/lib/kobject.c index 445dcae..97ab522 100644 --- a/lib/kobject.c +++ b/lib/kobject.c @@ -18,6 +18,7 @@ #include #include #include +#include /** * kobject_namespace - return @kobj's namespace tag @@ -306,6 +307,9 @@ int kobject_set_name(struct kobject *kobj, const char *fmt, ...) retval = kobject_set_name_vargs(kobj, fmt, vargs); va_end(vargs); + if (!retval) + trace_kobject_set_name(kobj); + return retval; } EXPORT_SYMBOL(kobject_set_name); @@ -343,6 +347,7 @@ void kobject_init(struct kobject *kobj, struct kobj_type *ktype) kobject_init_internal(kobj); kobj->ktype = ktype; + trace_kobject_init(kobj); return; error: @@ -411,6 +416,9 @@ int kobject_add(struct kobject *kobj, struct kobject *parent, retval = kobject_add_varg(kobj, parent, fmt, args); va_end(args); + if (!retval) + trace_kobject_add(kobj); + return retval; } EXPORT_SYMBOL(kobject_add); @@ -438,6 +446,9 @@ int kobject_init_and_add(struct kobject *kobj, struct kobj_type *ktype, retval = kobject_add_varg(kobj, parent, fmt, args); va_end(args); + if (!retval) + trace_kobject_init_and_add(kobj); + return retval; } EXPORT_SYMBOL_GPL(kobject_init_and_add); @@ -494,11 +505,14 @@ int kobject_rename(struct kobject *kobj, const char *new_name) dup_name = kobj->name; kobj->name = name; + trace_kobject_rename(kobj, devpath); + /* This function is mostly/only used for network interface. * Some hotplug package track interfaces by their name and * therefore want to know when the name is changed by the user. */ kobject_uevent_env(kobj, KOBJ_MOVE, envp); + out: kfree_const(dup_name); kfree(devpath_string); @@ -553,6 +567,7 @@ int kobject_move(struct kobject *kobj, struct kobject *new_parent) new_parent = NULL; kobject_put(old_parent); kobject_uevent_env(kobj, KOBJ_MOVE, envp); + trace_kobject_move(kobj, old_parent); out: kobject_put(new_parent); kobject_put(kobj); @@ -581,6 +596,7 @@ void kobject_del(struct kobject *kobj) kobj_kset_leave(kobj); kobject_put(kobj->parent); kobj->parent = NULL; + trace_kobject_del(kobj); } EXPORT_SYMBOL(kobject_del); @@ -596,6 +612,7 @@ struct kobject *kobject_get(struct kobject *kobj) "initialized, yet kobject_get() is being " "called.\n", kobject_name(kobj), kobj); kref_get(&kobj->kref); + trace_kobject_get(kobj); } return kobj; } @@ -620,6 +637,8 @@ static void kobject_cleanup(struct kobject *kobj) pr_debug("kobject: '%s' (%p): %s, parent %p\n", kobject_name(kobj), kobj, __func__, kobj->parent); + trace_kobject_cleanup(kobj); + if (t && !t->release) pr_debug("kobject: '%s' (%p): does not have a release() " "function, it is broken and must be fixed.\n", @@ -688,6 +707,8 @@ void kobject_put(struct kobject *kobj) WARN(1, KERN_WARNING "kobject: '%s' (%p): is not " "initialized, yet kobject_put() is being " "called.\n", kobject_name(kobj), kobj); + /* call it now - kobj could get released during kref_put() */ + trace_kobject_put(kobj); kref_put(&kobj->kref, kobject_release); } } @@ -756,6 +777,7 @@ struct kobject *kobject_create_and_add(const char *name, struct kobject *parent) kobject_put(kobj); kobj = NULL; } + trace_kobject_create_and_add(kobj); return kobj; } EXPORT_SYMBOL_GPL(kobject_create_and_add); -- 2.7.4