From patchwork Wed Dec 10 04:15:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 42082 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C5D5C260BE for ; Wed, 10 Dec 2014 04:16:15 +0000 (UTC) Received: by mail-la0-f69.google.com with SMTP id gd6sf1423788lab.4 for ; Tue, 09 Dec 2014 20:16:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=wWk0ck2fjDE9LWhFO5zWtf2EFdDpXQa7dxghgQfEGeQ=; b=WkQyR8WUNl5KGiMALqBW5yXM3foYK615MECb/WrJEI210vnh1YNs6gsAwQhoek4jZP hkZNxSqn3cEYLXHnKe5dVpjEI+GrIduaoNkmgUiS+HMPC9GB5XDdQOHeWi08YB5YqbHt aRku2LYL9RAjhUuiKgA2IZxOQ3WOMPb1VvmnYd9Eefnx204bkF6h27L9DFHqStU3q0j8 6oMjsIQ9pTktOW9wgHRnZF06SP+uildhIdppp76Ze2gP9D6weZB/kFNud6eriGJlz7qL ZEJzqMRr7cccJmV9P8tU8k1shvRZxzpTuZU24frhisyqYlgbZ9FGGTsoRVuTM6Tbvy/k rmrg== X-Gm-Message-State: ALoCoQlOnrUEjxGsJgE+gTFHwnZ/KnHZJutdu//0RXOZf0V2c3xqJGkChSsDD/kCLzNNfd68tGR+ X-Received: by 10.180.189.116 with SMTP id gh20mr1138174wic.2.1418184974117; Tue, 09 Dec 2014 20:16:14 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.170.133 with SMTP id am5ls125649lac.54.gmail; Tue, 09 Dec 2014 20:16:13 -0800 (PST) X-Received: by 10.112.235.196 with SMTP id uo4mr1847934lbc.66.1418184973882; Tue, 09 Dec 2014 20:16:13 -0800 (PST) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id jo17si1346122lab.19.2014.12.09.20.16.13 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Dec 2014 20:16:13 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by mail-la0-f49.google.com with SMTP id hs14so1667707lab.8 for ; Tue, 09 Dec 2014 20:16:13 -0800 (PST) X-Received: by 10.152.87.100 with SMTP id w4mr1771184laz.71.1418184973616; Tue, 09 Dec 2014 20:16:13 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp834699lbc; Tue, 9 Dec 2014 20:16:12 -0800 (PST) X-Received: by 10.68.215.67 with SMTP id og3mr3043088pbc.117.1418184971839; Tue, 09 Dec 2014 20:16:11 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ez16si4853936pad.84.2014.12.09.20.16.11 for ; Tue, 09 Dec 2014 20:16:11 -0800 (PST) Received-SPF: none (google.com: linux-pm-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755324AbaLJEQK (ORCPT + 12 others); Tue, 9 Dec 2014 23:16:10 -0500 Received: from mail-pd0-f174.google.com ([209.85.192.174]:46031 "EHLO mail-pd0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755310AbaLJEQJ (ORCPT ); Tue, 9 Dec 2014 23:16:09 -0500 Received: by mail-pd0-f174.google.com with SMTP id fp1so1934863pdb.19 for ; Tue, 09 Dec 2014 20:16:09 -0800 (PST) X-Received: by 10.68.220.39 with SMTP id pt7mr3159782pbc.37.1418184968960; Tue, 09 Dec 2014 20:16:08 -0800 (PST) Received: from localhost ([122.166.92.172]) by mx.google.com with ESMTPSA id ds16sm2796605pdb.65.2014.12.09.20.16.07 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 09 Dec 2014 20:16:08 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, Viresh Kumar Subject: [PATCH 1/5] opp: replace kfree with kfree_rcu while freeing 'struct device_opp' Date: Wed, 10 Dec 2014 09:45:31 +0530 Message-Id: <0a31e317c90f601f77cc21b80455633928c70c96.1418184737.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.2.0 Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Somehow one of the instance of freeing resources failed to use kfree_rcu() and used kfree() instead. This might cause problems as the node might be referenced by readers under rcu locks and we must wait for the rcu grace period as well. While we are at it, also update comment over 'struct device_opp' to mention why we are waiting for both rcu and srcu grace periods. Fixes: 129eec55df6a ("PM / OPP Introduce APIs to remove OPPs") Signed-off-by: Viresh Kumar --- Hi Rafael, Few more updates for the opp layer. First one is a potential bug fix and rest are cleanups. drivers/base/power/opp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c index 1bbef8e838e7..e1807268cbf2 100644 --- a/drivers/base/power/opp.c +++ b/drivers/base/power/opp.c @@ -84,7 +84,11 @@ struct dev_pm_opp { * * This is an internal data structure maintaining the link to opps attached to * a device. This structure is not meant to be shared to users as it is - * meant for book keeping and private to OPP library + * meant for book keeping and private to OPP library. + * + * Because the opp structures can be used from both rcu and srcu readers, we + * need to wait for the grace period of both of them before freeing any + * resources. And so we have used kfree_rcu() from within call_srcu() handlers. */ struct device_opp { struct list_head node; @@ -511,7 +515,7 @@ static void kfree_device_rcu(struct rcu_head *head) { struct device_opp *device_opp = container_of(head, struct device_opp, rcu_head); - kfree(device_opp); + kfree_rcu(device_opp, rcu_head); } void __dev_pm_opp_remove(struct device_opp *dev_opp, struct dev_pm_opp *opp)