From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933266AbcBCG5u (ORCPT ); Wed, 3 Feb 2016 01:57:50 -0500 Received: from mail-pf0-f181.google.com ([209.85.192.181]:36028 "EHLO mail-pf0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755965AbcBCG5s (ORCPT ); Wed, 3 Feb 2016 01:57:48 -0500 Date: Wed, 3 Feb 2016 12:27:45 +0530 From: Viresh Kumar To: Saravana Kannan Cc: "Rafael J. Wysocki" , Juri Lelli , Rafael Wysocki , Lists linaro-kernel , "linux-pm@vger.kernel.org" , Peter Zijlstra , Michael Turquette , Steve Muckle , Vincent Guittot , Morten Rasmussen , dietmar.eggemann@arm.com, Linux Kernel Mailing List Subject: Re: [PATCH 2/5] cpufreq: governor: Create separate sysfs-ops Message-ID: <20160203065745.GW31828@vireshk> References: <20160202154717.GI3947@e106622-lin> <20160202170144.GL3947@e106622-lin> <56B12BEC.9070603@codeaurora.org> <56B158A0.6060604@codeaurora.org> <56B17BFC.4070403@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <56B17BFC.4070403@codeaurora.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02-02-16, 20:03, Saravana Kannan wrote: > This is the hotplug case I mentioned. The sysfs file removals will happen > only for the last CPU in that policy (we thankfully optimized that part last > year). We also know that multiple CPUs can't be hotplugged at the same time. > So, in the start of cpufreq_offline_prepare, we just need to check if this > is the last CPU in the policy and if that's the case, do the gov sysfs > remove and then grab the policy lock and do all our crap. If a read is going > on, that's going to finish before the sysfs attr remove can go ahead and it > can grab the policy lock if it needs to and that still won't cause a > deadlock because we haven't yet grabbed the policy lock in > cpufreq_offline_prepare(). If the read comes after the sysfs remove, then > the read is obviously going to fail (we can depend on the sysfs framework on > doing its job there). IMHO, these are all dirty hacks we should stay away from. Adding such hunks in code is considered a band-aid kind of solution and hurts readability badly. The new solution (new governor show/store) implement this in a very clean and proper way I feel.. Others are free to disagree though :) -- viresh