From patchwork Tue Sep 25 13:42:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 11719 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 9B2A023E53 for ; Tue, 25 Sep 2012 13:43: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 3A3AEA190AA for ; Tue, 25 Sep 2012 13:43:28 +0000 (UTC) Received: by ieje10 with SMTP id e10so12837660iej.11 for ; Tue, 25 Sep 2012 06:43: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=eIboSjC336PW4eTn8EZ1mDWiYYpLUork6rDBuQ1xZ50Q/VdzhhmmW8laU4Wfw7oVTK 9W3bIl7nklTeDUuei7Qxok+0/u7HPXGeytDPK0JsifYuLMtjuGGPPLY3BLe/RYqQY4HR H5o0DVMlCBWzBv4R6RFSHWq3X82D9HcD2tn/N1m2OkAkZeh5tEz/xStkAZMtlsSCoue7 VxctfEtfcfdldZETvw8yPRbl6PsyCjrxATmJEqYw8BnDy2RbGV+OhXOmgpnq4UHO0U8H ZJnpFSTQp6TKPxEEwNowmG8keuyIgTr/Qo7OPwLrvXDUYnW47JX7XNm9fu2IbeXo0l8S DZ/w== Received: by 10.50.217.227 with SMTP id pb3mr8279492igc.28.1348580607569; Tue, 25 Sep 2012 06:43: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 ex8csp294910igc; Tue, 25 Sep 2012 06:43:26 -0700 (PDT) Received: by 10.216.205.166 with SMTP id j38mr9626139weo.186.1348580605886; Tue, 25 Sep 2012 06:43:25 -0700 (PDT) Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) by mx.google.com with ESMTPS id l8si846392wie.36.2012.09.25.06.43.25 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 25 Sep 2012 06:43:25 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.178 is neither permitted nor denied by best guess record for domain of vincent.guittot@linaro.org) client-ip=209.85.212.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.178 is neither permitted nor denied by best guess record for domain of vincent.guittot@linaro.org) smtp.mail=vincent.guittot@linaro.org Received: by wibhr7 with SMTP id hr7so495727wib.13 for ; Tue, 25 Sep 2012 06:43:25 -0700 (PDT) Received: by 10.180.95.193 with SMTP id dm1mr21991481wib.10.1348580604882; Tue, 25 Sep 2012 06:43:24 -0700 (PDT) Received: from localhost.localdomain (LPuteaux-156-14-44-212.w82-127.abo.wanadoo.fr. [82.127.83.212]) by mx.google.com with ESMTPS id hv8sm26813883wib.0.2012.09.25.06.43.22 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 25 Sep 2012 06:43:23 -0700 (PDT) From: Vincent Guittot To: linux-pm@vger.kernel.org, linaro-dev@lists.linaro.org, rjw@sisk.pl Cc: nm@ti.com, Vincent Guittot Subject: [PATCH][RESEND] power: opp: rcu reclaim Date: Tue, 25 Sep 2012 15:42:53 +0200 Message-Id: <1348580573-21877-1-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQlTcx3WcpMPz/8aPQXTQoGKFF3ERMQp0M2xOffgNUuYXe/lhD82N34NUiD/OFyCEU+a0/k5 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; }