aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kobject.c
diff options
context:
space:
mode:
authorBjorn Helgaas <bhelgaas@google.com>2013-12-05 19:37:51 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-12-08 00:14:13 -0500
commit89c86a64cd056e283323710c9ddf6f7090a450c8 (patch)
tree44fc2cd43f9cffc0ecfd44295b2d16411b827b1c /lib/kobject.c
parent2322392b020badfe49730f1529b9c1a15248c387 (diff)
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: Bjorn Helgaas <bhelgaas@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'lib/kobject.c')
-rw-r--r--lib/kobject.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/kobject.c b/lib/kobject.c
index b8d848fb1377..1d110dc95db5 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -18,6 +18,7 @@
18#include <linux/export.h> 18#include <linux/export.h>
19#include <linux/stat.h> 19#include <linux/stat.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/random.h>
21 22
22/** 23/**
23 * kobject_namespace - return @kobj's namespace tag 24 * kobject_namespace - return @kobj's namespace tag
@@ -642,10 +643,12 @@ static void kobject_release(struct kref *kref)
642{ 643{
643 struct kobject *kobj = container_of(kref, struct kobject, kref); 644 struct kobject *kobj = container_of(kref, struct kobject, kref);
644#ifdef CONFIG_DEBUG_KOBJECT_RELEASE 645#ifdef CONFIG_DEBUG_KOBJECT_RELEASE
645 pr_info("kobject: '%s' (%p): %s, parent %p (delayed)\n", 646 unsigned long delay = HZ + HZ * (get_random_int() & 0x3);
646 kobject_name(kobj), kobj, __func__, kobj->parent); 647 pr_info("kobject: '%s' (%p): %s, parent %p (delayed %ld)\n",
648 kobject_name(kobj), kobj, __func__, kobj->parent, delay);
647 INIT_DELAYED_WORK(&kobj->release, kobject_delayed_cleanup); 649 INIT_DELAYED_WORK(&kobj->release, kobject_delayed_cleanup);
648 schedule_delayed_work(&kobj->release, HZ); 650
651 schedule_delayed_work(&kobj->release, delay);
649#else 652#else
650 kobject_cleanup(kobj); 653 kobject_cleanup(kobj);
651#endif 654#endif