Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1477708

[PATCH 3/3] kobject: Add calls to kobject trace points

From Shuah Khan <shuahkh@osg.samsung.com>
Newsgroups linux.kernel
Subject [PATCH 3/3] kobject: Add calls to kobject trace points
Date 2016-09-06 20:00 +0200
Message-ID <sesPd-55p-5@gated-at.bofh.it> (permalink)
References <sesFr-52m-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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 <shuahkh@osg.samsung.com>
---
 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 <linux/stat.h>
 #include <linux/slab.h>
 #include <linux/random.h>
+#include <trace/events/kobject.h>
 
 /**
  * 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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/3] kobject tracepoints Shuah Khan <shuahkh@osg.samsung.com> - 2016-09-06 20:00 +0200
  [PATCH 3/3] kobject: Add calls to kobject trace points Shuah Khan <shuahkh@osg.samsung.com> - 2016-09-06 20:00 +0200
  Re: [PATCH 0/3] kobject tracepoints Greg KH <gregkh@linuxfoundation.org> - 2016-09-06 21:40 +0200
    Re: [PATCH 0/3] kobject tracepoints Shuah Khan <shuahkh@osg.samsung.com> - 2016-09-06 22:20 +0200
      Re: [PATCH 0/3] kobject tracepoints Greg KH <gregkh@linuxfoundation.org> - 2016-09-07 07:50 +0200

csiph-web