From: Bjorn Helgaas <bhelgaas@google.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Veaceslav Falico <vfalico@redhat.com>,
Russell King <linux@arm.linux.org.uk>,
Neil Horman <nhorman@tuxdriver.com>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
Zdenek Kabelac <zkabelac@redhat.com>
Subject: [PATCH v2 1/2] kobject: delay kobject release for random time
Date: Thu, 05 Dec 2013 17:37:51 -0700 [thread overview]
Message-ID: <20131206003751.28684.32460.stgit@bhelgaas-glaptop.roam.corp.google.com> (raw)
In-Reply-To: <20131206003508.28684.1337.stgit@bhelgaas-glaptop.roam.corp.google.com>
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>
---
lib/kobject.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/lib/kobject.c b/lib/kobject.c
index 962175134702..bc73312ac797 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -17,6 +17,7 @@
#include <linux/export.h>
#include <linux/stat.h>
#include <linux/slab.h>
+#include <linux/random.h>
/*
* populate_dir - populate directory with attributes.
@@ -592,10 +593,13 @@ static void kobject_release(struct kref *kref)
{
struct kobject *kobj = container_of(kref, struct kobject, kref);
#ifdef CONFIG_DEBUG_KOBJECT_RELEASE
- pr_debug("kobject: '%s' (%p): %s, parent %p (delayed)\n",
- kobject_name(kobj), kobj, __func__, kobj->parent);
+ unsigned long delay = HZ + HZ * (get_random_int() & 0x3);
+
+ pr_debug("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);
- schedule_delayed_work(&kobj->release, HZ);
+
+ schedule_delayed_work(&kobj->release, delay);
#else
kobject_cleanup(kobj);
#endif
next prev parent reply other threads:[~2013-12-06 0:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-06 0:37 [PATCH v2 0/2] Remove ksets from sysfs eagerly Bjorn Helgaas
2013-12-06 0:37 ` Bjorn Helgaas [this message]
2013-12-06 0:38 ` [PATCH v2 2/2] kobject: remove kset from sysfs immediately in kset_unregister() Bjorn Helgaas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131206003751.28684.32460.stgit@bhelgaas-glaptop.roam.corp.google.com \
--to=bhelgaas@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=nhorman@tuxdriver.com \
--cc=vfalico@redhat.com \
--cc=zkabelac@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®