From patchwork Thu Sep 13 04:13:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 11384 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 7947823E41 for ; Thu, 13 Sep 2012 04:14:28 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id DF6A234B92B1 for ; Thu, 13 Sep 2012 04:14:27 +0000 (UTC) Received: by ieak11 with SMTP id k11so4089811iea.11 for ; Wed, 12 Sep 2012 21:14:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=GSxkvlR3siRJ3oOiw/lCHuxeNHN4GpLjPbxh6lV5bEU=; b=Ns3+OcKGqJ8NtNT1qYx9FyKJVkQOwGglm2Yd3xD0cfv5Xo0dv/BhU5EKsYYfooIEF1 6tt80EAS5S8GplhcTxUC2eA/kY4xTDAOMPbuWG/4PdQlwikD+Yanq2MCRUhvJ6LwykzO vVelvkbcC0LWwtURggJhn4vk6EIC3dMxhIMBQnplV05PrB5C1JWQlPs3THqwvHNbvHht ien/zR19Wv0vmx2RrJIEgkP60mJZE8gznZtCEVTpvx2M9RuVqOddu1Xviitpm/WK9AA0 Os69ZeOTfGSULjDR27e5kwUOe45z+rVO8Dqb745gAVs+hFkd0yIWSkOHoK8u4ahhjzL9 R/Mw== Received: by 10.50.195.134 with SMTP id ie6mr654696igc.28.1347509667225; Wed, 12 Sep 2012 21:14:27 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp111944igc; Wed, 12 Sep 2012 21:14:26 -0700 (PDT) Received: by 10.152.130.3 with SMTP id oa3mr534769lab.27.1347509666053; Wed, 12 Sep 2012 21:14:26 -0700 (PDT) Received: from mail-lpp01m010-f50.google.com (mail-lpp01m010-f50.google.com [209.85.215.50]) by mx.google.com with ESMTPS id ig6si36303574lab.30.2012.09.12.21.14.25 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 12 Sep 2012 21:14:25 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.215.50 is neither permitted nor denied by best guess record for domain of vincent.guittot@linaro.org) client-ip=209.85.215.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.215.50 is neither permitted nor denied by best guess record for domain of vincent.guittot@linaro.org) smtp.mail=vincent.guittot@linaro.org Received: by lago2 with SMTP id o2so1852772lag.37 for ; Wed, 12 Sep 2012 21:14:25 -0700 (PDT) Received: by 10.152.104.146 with SMTP id ge18mr569352lab.7.1347509665280; Wed, 12 Sep 2012 21:14:25 -0700 (PDT) Received: from lmenx30s.homerun.telia.com (host-78-65-129-30.homerun.telia.com. [78.65.129.30]) by mx.google.com with ESMTPS id ly17sm22072253lab.2.2012.09.12.21.14.23 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 12 Sep 2012 21:14:24 -0700 (PDT) From: Vincent Guittot To: linux-pm@vger.kernel.org, linaro-dev@lists.linaro.org Cc: rjw@sisk.pl, Vincent Guittot Subject: [RFC] power: opp: rcu reclaim Date: Thu, 13 Sep 2012 06:13:33 +0200 Message-Id: <1347509613-8813-1-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQlJJFsIPRPWuBTQe31DJPHLAmLEb1ew9mJUti6WB4/tg14XKN2GdK6UccAtf/MlvJ5+mpn/ synchronize_rcu blocks the caller of opp_enable/disbale for a complete grace period. This blocking duration prevents any intensive use of the functions. Replace synchronize_rcu by call_rcu which will call our function for freeing the old opp element. The duration of opp_enable and opp_disable will be no more dependant of the grace period. Signed-off-by: Vincent Guittot --- drivers/base/power/opp.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c index ac993ea..49e4626 100644 --- a/drivers/base/power/opp.c +++ b/drivers/base/power/opp.c @@ -64,6 +64,7 @@ struct opp { unsigned long u_volt; struct device_opp *dev_opp; + struct rcu_head head; }; /** @@ -441,6 +442,17 @@ int opp_add(struct device *dev, unsigned long freq, unsigned long u_volt) } /** + * opp_free_rcu() - helper to clear the struct opp when grace period has + * elapsed without blocking the the caller of opp_set_availability + */ +static void opp_free_rcu(struct rcu_head *head) +{ + struct opp *opp = container_of(head, struct opp, head); + + kfree(opp); +} + +/** * opp_set_availability() - helper to set the availability of an opp * @dev: device for which we do this operation * @freq: OPP frequency to modify availability @@ -511,7 +523,7 @@ static int opp_set_availability(struct device *dev, unsigned long freq, list_replace_rcu(&opp->node, &new_opp->node); mutex_unlock(&dev_opp_list_lock); - synchronize_rcu(); + call_rcu(&opp->head, opp_free_rcu); /* Notify the change of the OPP availability */ if (availability_req) @@ -521,13 +533,10 @@ static int opp_set_availability(struct device *dev, unsigned long freq, srcu_notifier_call_chain(&dev_opp->head, OPP_EVENT_DISABLE, new_opp); - /* clean up old opp */ - new_opp = opp; - goto out; + return 0; unlock: mutex_unlock(&dev_opp_list_lock); -out: kfree(new_opp); return r; }