Commit 89c86a64 authored by Bjorn Helgaas's avatar Bjorn Helgaas Committed by Greg Kroah-Hartman

kobject: delay kobject release for random time

When CONFIG_DEBUG_KOBJECT_RELEASE=y, delay kobject release functions for a
random time between 1 and 8 seconds, which effectively changes the order in
which they're called.
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2322392b
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/export.h> #include <linux/export.h>
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/random.h>
/** /**
* kobject_namespace - return @kobj's namespace tag * kobject_namespace - return @kobj's namespace tag
...@@ -642,10 +643,12 @@ static void kobject_release(struct kref *kref) ...@@ -642,10 +643,12 @@ static void kobject_release(struct kref *kref)
{ {
struct kobject *kobj = container_of(kref, struct kobject, kref); struct kobject *kobj = container_of(kref, struct kobject, kref);
#ifdef CONFIG_DEBUG_KOBJECT_RELEASE #ifdef CONFIG_DEBUG_KOBJECT_RELEASE
pr_info("kobject: '%s' (%p): %s, parent %p (delayed)\n", unsigned long delay = HZ + HZ * (get_random_int() & 0x3);
kobject_name(kobj), kobj, __func__, kobj->parent); pr_info("kobject: '%s' (%p): %s, parent %p (delayed %ld)\n",
kobject_name(kobj), kobj, __func__, kobj->parent, delay);
INIT_DELAYED_WORK(&kobj->release, kobject_delayed_cleanup); INIT_DELAYED_WORK(&kobj->release, kobject_delayed_cleanup);
schedule_delayed_work(&kobj->release, HZ);
schedule_delayed_work(&kobj->release, delay);
#else #else
kobject_cleanup(kobj); kobject_cleanup(kobj);
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment