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: 10234679 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9532260224 for ; Thu, 22 Feb 2018 06:00:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 887A52823D for ; Thu, 22 Feb 2018 06:00:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A90E288BD; Thu, 22 Feb 2018 06:00:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 959912823D for ; Thu, 22 Feb 2018 05:59:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752324AbeBVF76 (ORCPT ); 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-Google-Smtp-Source: AH8x226txm+ZklbH871icKinQLGeUjYRNlp9W2aD02VH/fyvrqKeglJ8wObxbMs8UuHyOPihJI3mDQ== 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 X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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;