From patchwork Mon Oct 21 13:28:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 177078 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3421983ill; Mon, 21 Oct 2019 06:29:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqyA1EPiCKeGTlsZXgnSETm7eN64tXMrX/rlnOuQ84usq9mXgHayGv6iUhlvpn7z+lz6DHTc X-Received: by 2002:a17:906:1505:: with SMTP id b5mr22435453ejd.195.1571664545467; Mon, 21 Oct 2019 06:29:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571664545; cv=none; d=google.com; s=arc-20160816; b=RZq/d05Lu0tnQl13DPHmWswCHlcVhLmoICZAE46/pZmd82/jmtM3J5D6wxZjZ7NIit KQoAqOlxSS17xTTM7gQ38ES4WPDopZLMJwfZLmsYeoEc/6K+PFXqQBHhHveLmQHgfAQs VXGdc119x2GeoWbIZZHrqFJcww2NgDK4N6dy56YQpIukCGtyrRB+ijTPkviYNBOqbq0g z6lR1mMtmvBTkWOA8saKyAFESpdVZkpU/JXZS65naYOsGL/oJKX0F9POEhjLrJaHbLm9 LYiIu8iNOtGudLV+smKaam1MQdSgPYLNSFBfGyk+pkA3C7qPEjurTs+VYmLRLXQjTc7x Boew== 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; bh=SYyiA9exc2sZP7+RGF/i9Z5NKlZjZbK0nFu02ioOBP8=; b=fUqfulNH6y4S0QRcWLFeE/S4OHTFb3sEo7VtklN+OCcyIDlhV+yD1Apzfh6dG+rOOC D+FAltAt7KIXAjUeGiEJniCfDFaWo/LN1IJxuwXYJL/enav0f1NbNNTouM/QHlIoBdSD Dm3qRmELh4aNzgDhwraSGQnNTfFPGVOo8awsviQhwnO9cG5gFNgtDrGkkbmBshLx+PbG htt2Jf/xbXHslu7mbGzlCBcdx9aqgaKIsLESTA/EXgqrhx4ml7zSFfRy1vScHszLYFzG W1s99ZsInnA7XvM48KAosDj4crXQzF/O5VA/4do6S5ULIGJI6SnwUlnzxMcIeWsBJI+U Ad7A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n5si8615722ejb.67.2019.10.21.06.29.05; Mon, 21 Oct 2019 06:29:05 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727322AbfJUN3B (ORCPT + 10 others); Mon, 21 Oct 2019 09:29:01 -0400 Received: from [217.140.110.172] ([217.140.110.172]:52642 "EHLO foss.arm.com" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1727152AbfJUN3B (ORCPT ); Mon, 21 Oct 2019 09:29:01 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A339C493; Mon, 21 Oct 2019 06:28:30 -0700 (PDT) Received: from usa.arm.com (e107155-lin.cambridge.arm.com [10.1.196.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D65B63F718; Mon, 21 Oct 2019 06:28:29 -0700 (PDT) From: Sudeep Holla To: viresh.kumar@linaro.org Cc: Sudeep Holla , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, rjw@rjwysocki.net Subject: [PATCH] cpufreq: Move cancelling of policy update work just after removing notifiers Date: Mon, 21 Oct 2019 14:28:18 +0100 Message-Id: <20191021132818.23787-1-sudeep.holla@arm.com> X-Mailer: git-send-email 2.17.1 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Commit 099967699ad9 ("cpufreq: Cancel policy update work scheduled before freeing") added cancel_work_sync(policy->update) after the frequency QoS were removed. We can cancel the work just after taking the last CPU in the policy offline and unregistering the notifiers as policy->update cannot be scheduled from anywhere at this point. However, due to other bugs, doing so still triggered the race between freeing of policy and scheduled policy update work. Now that all those issues are resolved, we can move this cancelling of any scheduled policy update work just after removing min/max notifiers. Signed-off-by: Sudeep Holla --- drivers/cpufreq/cpufreq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) Hi Rafael, Based on Viresh's suggestion, I am posting a patch to move this cancel_work_sync earlier though it's not a must have change. I will leave it up to your preference. Regards, Sudeep -- 2.17.1 Acked-by: Viresh Kumar diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 829a3764df1b..48a224a6b178 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1268,6 +1268,9 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy) freq_qos_remove_notifier(&policy->constraints, FREQ_QOS_MIN, &policy->nb_min); + /* Cancel any pending policy->update work before freeing the policy. */ + cancel_work_sync(&policy->update); + if (policy->max_freq_req) { /* * CPUFREQ_CREATE_POLICY notification is sent only after @@ -1279,8 +1282,6 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy) } freq_qos_remove_request(policy->min_freq_req); - /* Cancel any pending policy->update work before freeing the policy. */ - cancel_work_sync(&policy->update); kfree(policy->min_freq_req); cpufreq_policy_put_kobj(policy);