From patchwork Fri Dec 6 00:37:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 297499 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id ABAF52C009D for ; Fri, 6 Dec 2013 11:38:03 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756438Ab3LFAiA (ORCPT ); Thu, 5 Dec 2013 19:38:00 -0500 Received: from mail-ob0-f180.google.com ([209.85.214.180]:42690 "EHLO mail-ob0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756277Ab3LFAhz (ORCPT ); Thu, 5 Dec 2013 19:37:55 -0500 Received: by mail-ob0-f180.google.com with SMTP id wo20so846obc.11 for ; Thu, 05 Dec 2013 16:37:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:to:from:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; bh=Er+pI4+0W+gR6bhBFbvWuq34S/Ya8GpsdGUMJs8UgKY=; b=pBCXaBIK3anXjhpZ8Owb3E+FkTBovUNHgjL6SlNtjvLtm1puXWFpO90hRSorwfkBKu qMoSiCq6pFODWftobWPTgEAxhBG0z9n1Ejgrb/8XKgEZuA+kuyR8zzn6eWA1Bwh8prL0 CvqcXzw2e+tEFmCTuMT0xDl0tufLzfJPQPntKZus/u7IbzDIXxhUTZ8MjVuPp9HgB4EP nSGGx4rx8uWO4KolsFYgNZpligFihEU747+GcnFTqEX2+IuhCYOz6Bkl80Gf8y/4OQQ4 5aOqIEkaZHPe0D5fdnFuxz5jKqnPqRhbGu7/f61caTsaUy/uNS/sSsGJS4jqT48VV0gG XJeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:from:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-type :content-transfer-encoding; bh=Er+pI4+0W+gR6bhBFbvWuq34S/Ya8GpsdGUMJs8UgKY=; b=mJgSSRdJee/vWYVzpd3s1L5QlM8uwfuW4HX+PSKbJ8bStHcC9g3vlJrP5VAKlN//5/ cdd0GmS045ZThIwQL8W3Qfr6AcAaGfczJHf1+2p9FLHYtaLE0Ct8agvIKLoHk3Uklyms CWFi3cORQk2fhJgtAEM0y0UBvuGvO5u3ac8c6B6aPicZTGQIUI43/FzgXEh8lISF1WA1 3B5WrE0ldghLs8aR7cNMB9chPp3BN6Ll7qtm5/Ee82yTSXJhntcSe/Br6TqtfxRDxafp MCYucCVlr+zMHH/NhCXdl8jBI/EksD0gFNWUd6SoR0rWT0MT5d3b66Ohwj4EfG0zxZ/L Sh5A== X-Gm-Message-State: ALoCoQmmna3FJ7FylqHuU/g5whh8E1emrRitwVj6E9Ay08TQw+lBXePVNKQ0W0+weWASERLmUiM7ZND5xpF5a+CM7qUNfAJsrWmdhV2xCYsA7u+Dp8Vcvzy9K/UfDYt4kh36b/R3RFWM6VOOVzRw7VZIb2c6W9b4hSc2/AtMXOsNu1xSFXRBF1ULSplcPdx5rgnh/vu0J8UUORE/N4ajKpQUpc0FOA62LA== X-Received: by 10.182.142.229 with SMTP id rz5mr432593obb.12.1386290274866; Thu, 05 Dec 2013 16:37:54 -0800 (PST) Received: from localhost ([216.160.131.133]) by mx.google.com with ESMTPSA id nw5sm8790527obc.9.2013.12.05.16.37.53 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 05 Dec 2013 16:37:54 -0800 (PST) Subject: [PATCH v2 1/2] kobject: delay kobject release for random time To: Greg Kroah-Hartman From: Bjorn Helgaas Cc: Veaceslav Falico , Russell King , Neil Horman , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Zdenek Kabelac Date: Thu, 05 Dec 2013 17:37:51 -0700 Message-ID: <20131206003751.28684.32460.stgit@bhelgaas-glaptop.roam.corp.google.com> In-Reply-To: <20131206003508.28684.1337.stgit@bhelgaas-glaptop.roam.corp.google.com> References: <20131206003508.28684.1337.stgit@bhelgaas-glaptop.roam.corp.google.com> User-Agent: StGit/0.16 MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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 --- lib/kobject.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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 #include #include +#include /* * 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