From patchwork Thu Feb 22 05:59:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 129146 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp242250lja; Wed, 21 Feb 2018 22:00:00 -0800 (PST) X-Google-Smtp-Source: AH8x227GrBA7BriaibXBcXrc4LsQRV3BG0ZRjfFQUTR18D/SNpT4DZxzbu/9TEDt2i5kxWsKCEkT X-Received: by 10.167.128.6 with SMTP id j6mr5771770pfi.56.1519279199879; Wed, 21 Feb 2018 21:59:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519279199; cv=none; d=google.com; s=arc-20160816; b=RDGzt1H+P3nUrnLvqPHntt1CVKWjTdxWs7WfpFM7nyHwi9LgeFP5eD1rWxGciTxCm3 0pijJpqhb30xoIfwAKIoxAisuTfnRjczck3gKLD3h+JP2QCx1n1xe6a1GlQG8nyoJyas Y6iE7cE0yi+WurvF5isQblJaxEwRVH3JycTBwwcRmSQee+XMClaNR1oZln61S52cM0sl oHsXIyBIuANHoNzAJzU/oUHh7tncyyTdS7CcxVXLkNLK1/7YkGWy/IZzCtFd7w+5mk1Y YnRSmPuU5ObvyUZXptXLqMLH1lQQjOLIB3Ojecwufck0cZt5LLdZ3itFqg2C95jNP8F0 RwBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=rSwdzXW36Q03qonYbDL8pFKw6KyBTgsxYvRUgrpCvnU=; b=aqw2ZR6ECPHM5WrlkNYq4IffQNtrvOqyyI3MVXNKnOdPpHYTa5fIet8hST12BZYFdS x4fbIdgtr/SfoQ1wuRCuIEjvP3Lvr7pDz+zvqM3GDATLKvgv8fXUdlJUsmeXofUTQ6eO wc5BctV2CfqNzoVuwakkmbCocsadr6XOCea3gj/s4gk/BZ7ac9xtrPjRy8Asq3+Vtq5I eHWL0O1dhRiqgx6cbQw2VMrEjsntoWKNfqZI/qr7tJe/hs/Q/mcUO0uDA1GBTI7R4e/Y 8FcQpSvEsIIfPX1rwmqFe3/R8n7W9mYpOm6I8MtamDID8j8+BPmgGQGYtZGLRRjBVRNL bvSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=geQn5hjL; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v7si907028pfi.302.2018.02.21.21.59.59; Wed, 21 Feb 2018 21:59:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=geQn5hjL; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752324AbeBVF76 (ORCPT + 11 others); Thu, 22 Feb 2018 00:59:58 -0500 Received: from mail-pl0-f66.google.com ([209.85.160.66]:34604 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750725AbeBVF75 (ORCPT ); Thu, 22 Feb 2018 00:59:57 -0500 Received: by mail-pl0-f66.google.com with SMTP id u13so2366579plq.1 for ; Wed, 21 Feb 2018 21:59:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=rSwdzXW36Q03qonYbDL8pFKw6KyBTgsxYvRUgrpCvnU=; b=geQn5hjLeVZLD9KEzZBjAzh/qDWnJyXa67aIYO3uwAzFx0D6erMmMcUrMqDZHaPK7s D+bCYYRg4LUkVfGKk2m9JaYhwc8x3AFeojUaTMjbEFtn0UCLQKLmxS4qI0iAQHYviDeU sxXSRKokYpUC594cj8uqJ5vz5JcpQOcAW1vrQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=rSwdzXW36Q03qonYbDL8pFKw6KyBTgsxYvRUgrpCvnU=; b=FKDm0rDRjbWGB7W8lI5Bo12On/ip5w08q+SQQkdUc2wlfF8QqHs6aySX1qoZlKyNm2 BveBGXCTzanQiI/cfix3fwKPeUCsz+FcQkNVkIeZn2tNts6676TSPBzLgGLQfuk6QS4a MNfoBoKuyMUpBrePRWIDvycgUfFNqzKuBfx+FrRF9TbqcQ1EGdPLnjSg6qjt5NX/7gZE agv1A8BskmOSRqrWNZhUufPQjy7kFhHVdRfQg/FcyUnbXiNeN5DJ8At/CKrkYfXuDeu6 EMwVO+Af1Nal0/10TOdk7ZzfDxorUrSlvtJEFhTmq6avLmXsgTW2aN16lKkk0Hr/xV6A 8R4Q== X-Gm-Message-State: APf1xPAJRtvSqhiRsmmKBA9DyIQvF7ueloeWWS61TtYL63a8UdcEfqxe 17cAy6huB8Awa+9K0j09Eg7JRw== X-Received: by 2002:a17:902:b598:: with SMTP id a24-v6mr898689pls.9.1519279197266; Wed, 21 Feb 2018 21:59:57 -0800 (PST) Received: from localhost ([122.167.232.138]) by smtp.gmail.com with ESMTPSA id x9sm1828103pgc.81.2018.02.21.21.59.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Feb 2018 21:59:56 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Michael Ellerman , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] cpufreq: Reorder cpufreq_online() a bit Date: Thu, 22 Feb 2018 11:29:43 +0530 Message-Id: X-Mailer: git-send-email 2.15.0.194.g9af6a3dea062 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Ideally the de-allocation of resources should happen in the exact opposite order in which they were allocated. It helps maintain the code in long term, even if nothing really breaks with incorrect ordering. The same wasn't followed in cpufreq_online() and it has some inconsistencies. For example, the symlinks were created from within the locked region while they are removed only after putting the locks. Also ->exit() should have been called only after the symlinks are removed and the lock is dropped, as that was the case when ->init() was first called. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.15.0.194.g9af6a3dea062 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index de33ebf008ad..8814c572e263 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1327,14 +1327,14 @@ static int cpufreq_online(unsigned int cpu) return 0; out_exit_policy: + for_each_cpu(j, policy->real_cpus) + remove_cpu_dev_symlink(policy, get_cpu_device(j)); + up_write(&policy->rwsem); if (cpufreq_driver->exit) cpufreq_driver->exit(policy); - for_each_cpu(j, policy->real_cpus) - remove_cpu_dev_symlink(policy, get_cpu_device(j)); - out_free_policy: cpufreq_policy_free(policy); return ret;