From: Saravana Kannan <skannan@codeaurora.org> To: Saravana Kannan <skannan@codeaurora.org> Cc: "Rafael J . Wysocki" <rjw@rjwysocki.net>, Viresh Kumar <viresh.kumar@linaro.org>, Todd Poynor <toddpoynor@google.com>, "Srivatsa S . Bhat" <srivatsa@mit.edu>, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Stephen Boyd <sboyd@codeaurora.org> Subject: Re: [PATCH v3 1/2] cpufreq: Don't destroy/realloc policy/sysfs on hotplug/suspend Date: Tue, 15 Jul 2014 17:28:40 -0700 [thread overview] Message-ID: <53C5C738.5040705@codeaurora.org> (raw) In-Reply-To: <1405464473-3916-2-git-send-email-skannan@codeaurora.org> One preemptive comment. On 07/15/2014 03:47 PM, Saravana Kannan wrote: > The CPUfreq core moves the cpufreq policy ownership between CPUs when CPUs > within a cluster (CPUs sharing same policy) go ONLINE/OFFLINE. When moving > policy ownership between CPUs, it also moves the cpufreq sysfs directory > between CPUs and also fixes up the symlinks of the other CPUs in the > cluster. > > Also, when all the CPUs in a cluster go OFFLINE, all the sysfs nodes and > directories are deleted, the kobject is released and the policy is freed. > And when the first CPU in a cluster comes up, the policy is reallocated and > initialized, kobject is acquired, the sysfs nodes are created or symlinked, > etc. > > All these steps end up creating unnecessarily complicated code and locking. > There's no real benefit to adding/removing/moving the sysfs nodes and the > policy between CPUs. Other per CPU sysfs directories like power and cpuidle > are left alone during hotplug. So there's some precedence to what this > patch is trying to do. > > This patch simplifies a lot of the code and locking by removing the > adding/removing/moving of policy/sysfs/kobj and just leaves the cpufreq > directory and policy in place irrespective of whether the CPUs are > ONLINE/OFFLINE. > > Leaving the policy, sysfs and kobject in place also brings these additional > benefits: > * Faster suspend/resume > * Faster hotplug > * Sysfs file permissions maintained across hotplug > * Policy settings and governor tunables maintained across hotplug > * Cpufreq stats would be maintained across hotplug for all CPUs and can be > queried even after CPU goes OFFLINE > > Tested-by: Stephen Boyd <sboyd@codeaurora.org> > Signed-off-by: Saravana Kannan <skannan@codeaurora.org> > --- > drivers/cpufreq/cpufreq.c | 388 +++++++++++++--------------------------------- > 1 file changed, 107 insertions(+), 281 deletions(-) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index 62259d2..a0a2ec2 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c <SNIP> > @@ -961,60 +967,58 @@ static void cpufreq_init_policy(struct cpufreq_policy *policy) > } > > #ifdef CONFIG_HOTPLUG_CPU > -static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, > - unsigned int cpu, struct device *dev) > +static int cpufreq_change_policy_cpus(struct cpufreq_policy *policy, > + unsigned int cpu, bool add) > { > int ret = 0; > - unsigned long flags; > + unsigned int cpus, pcpu; > > - if (has_target()) { > + down_write(&policy->rwsem); > + > + cpus = !cpumask_empty(policy->cpus); > + if (has_target() && cpus) { > ret = __cpufreq_governor(policy, CPUFREQ_GOV_STOP); > if (ret) { > pr_err("%s: Failed to stop governor\n", __func__); > - return ret; > + goto unlock; > } > } > <SNIP> > + if (add) > + cpumask_set_cpu(cpu, policy->cpus); > + else > + cpumask_clear_cpu(cpu, policy->cpus); > > - up_write(&policy->rwsem); > + pcpu = cpumask_first(policy->cpus); > + if (pcpu < nr_cpu_ids && policy->cpu != pcpu) { > + policy->last_cpu = policy->cpu; > + policy->cpu = pcpu; > + blocking_notifier_call_chain(&cpufreq_policy_notifier_list, > + CPUFREQ_UPDATE_POLICY_CPU, policy); > + } > > - if (has_target()) { > + cpus = !cpumask_empty(policy->cpus); > + if (has_target() && cpus) { > ret = __cpufreq_governor(policy, CPUFREQ_GOV_START); > if (!ret) > ret = __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS); > > if (ret) { > pr_err("%s: Failed to start governor\n", __func__); > - return ret; > + goto unlock; > } > } > <SNIP> > + if (!cpus && cpufreq_driver->stop_cpu && cpufreq_driver->setpolicy) { > + cpufreq_driver->stop_cpu(policy); > + } > Viresh, I tried your suggestion (and my initial thought too) to combine this as an if/else with the previous if. But the indentation got nasty and made it hard to read. I'm sure the compiler will optimize it. So, I would prefer to leave it this way. > - policy->governor = NULL; > +unlock: > + up_write(&policy->rwsem); > > - return policy; > + return ret; > } > +#endif > -Saravana -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation
WARNING: multiple messages have this Message-ID (diff)
From: skannan@codeaurora.org (Saravana Kannan) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 1/2] cpufreq: Don't destroy/realloc policy/sysfs on hotplug/suspend Date: Tue, 15 Jul 2014 17:28:40 -0700 [thread overview] Message-ID: <53C5C738.5040705@codeaurora.org> (raw) In-Reply-To: <1405464473-3916-2-git-send-email-skannan@codeaurora.org> One preemptive comment. On 07/15/2014 03:47 PM, Saravana Kannan wrote: > The CPUfreq core moves the cpufreq policy ownership between CPUs when CPUs > within a cluster (CPUs sharing same policy) go ONLINE/OFFLINE. When moving > policy ownership between CPUs, it also moves the cpufreq sysfs directory > between CPUs and also fixes up the symlinks of the other CPUs in the > cluster. > > Also, when all the CPUs in a cluster go OFFLINE, all the sysfs nodes and > directories are deleted, the kobject is released and the policy is freed. > And when the first CPU in a cluster comes up, the policy is reallocated and > initialized, kobject is acquired, the sysfs nodes are created or symlinked, > etc. > > All these steps end up creating unnecessarily complicated code and locking. > There's no real benefit to adding/removing/moving the sysfs nodes and the > policy between CPUs. Other per CPU sysfs directories like power and cpuidle > are left alone during hotplug. So there's some precedence to what this > patch is trying to do. > > This patch simplifies a lot of the code and locking by removing the > adding/removing/moving of policy/sysfs/kobj and just leaves the cpufreq > directory and policy in place irrespective of whether the CPUs are > ONLINE/OFFLINE. > > Leaving the policy, sysfs and kobject in place also brings these additional > benefits: > * Faster suspend/resume > * Faster hotplug > * Sysfs file permissions maintained across hotplug > * Policy settings and governor tunables maintained across hotplug > * Cpufreq stats would be maintained across hotplug for all CPUs and can be > queried even after CPU goes OFFLINE > > Tested-by: Stephen Boyd <sboyd@codeaurora.org> > Signed-off-by: Saravana Kannan <skannan@codeaurora.org> > --- > drivers/cpufreq/cpufreq.c | 388 +++++++++++++--------------------------------- > 1 file changed, 107 insertions(+), 281 deletions(-) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index 62259d2..a0a2ec2 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c <SNIP> > @@ -961,60 +967,58 @@ static void cpufreq_init_policy(struct cpufreq_policy *policy) > } > > #ifdef CONFIG_HOTPLUG_CPU > -static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, > - unsigned int cpu, struct device *dev) > +static int cpufreq_change_policy_cpus(struct cpufreq_policy *policy, > + unsigned int cpu, bool add) > { > int ret = 0; > - unsigned long flags; > + unsigned int cpus, pcpu; > > - if (has_target()) { > + down_write(&policy->rwsem); > + > + cpus = !cpumask_empty(policy->cpus); > + if (has_target() && cpus) { > ret = __cpufreq_governor(policy, CPUFREQ_GOV_STOP); > if (ret) { > pr_err("%s: Failed to stop governor\n", __func__); > - return ret; > + goto unlock; > } > } > <SNIP> > + if (add) > + cpumask_set_cpu(cpu, policy->cpus); > + else > + cpumask_clear_cpu(cpu, policy->cpus); > > - up_write(&policy->rwsem); > + pcpu = cpumask_first(policy->cpus); > + if (pcpu < nr_cpu_ids && policy->cpu != pcpu) { > + policy->last_cpu = policy->cpu; > + policy->cpu = pcpu; > + blocking_notifier_call_chain(&cpufreq_policy_notifier_list, > + CPUFREQ_UPDATE_POLICY_CPU, policy); > + } > > - if (has_target()) { > + cpus = !cpumask_empty(policy->cpus); > + if (has_target() && cpus) { > ret = __cpufreq_governor(policy, CPUFREQ_GOV_START); > if (!ret) > ret = __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS); > > if (ret) { > pr_err("%s: Failed to start governor\n", __func__); > - return ret; > + goto unlock; > } > } > <SNIP> > + if (!cpus && cpufreq_driver->stop_cpu && cpufreq_driver->setpolicy) { > + cpufreq_driver->stop_cpu(policy); > + } > Viresh, I tried your suggestion (and my initial thought too) to combine this as an if/else with the previous if. But the indentation got nasty and made it hard to read. I'm sure the compiler will optimize it. So, I would prefer to leave it this way. > - policy->governor = NULL; > +unlock: > + up_write(&policy->rwsem); > > - return policy; > + return ret; > } > +#endif > -Saravana -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation
next prev parent reply other threads:[~2014-07-16 0:28 UTC|newest] Thread overview: 205+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-07-10 2:37 [PATCH] cpufreq: Don't destroy/realloc policy/sysfs on hotplug/suspend Saravana Kannan 2014-07-10 2:37 ` Saravana Kannan 2014-07-11 4:18 ` [PATCH v2] " Saravana Kannan 2014-07-11 4:18 ` Saravana Kannan 2014-07-11 6:19 ` Viresh Kumar 2014-07-11 6:19 ` Viresh Kumar 2014-07-11 6:19 ` Viresh Kumar 2014-07-11 9:59 ` skannan 2014-07-11 9:59 ` skannan at codeaurora.org 2014-07-11 9:59 ` skannan 2014-07-11 10:07 ` skannan 2014-07-11 10:07 ` skannan at codeaurora.org 2014-07-11 10:07 ` skannan 2014-07-11 10:52 ` Viresh Kumar 2014-07-11 10:52 ` Viresh Kumar 2014-07-11 10:52 ` Viresh Kumar 2014-07-12 2:44 ` Saravana Kannan 2014-07-12 2:44 ` Saravana Kannan 2014-07-12 2:44 ` Saravana Kannan 2014-07-14 6:09 ` Viresh Kumar 2014-07-14 6:09 ` Viresh Kumar 2014-07-14 6:09 ` Viresh Kumar 2014-07-14 19:08 ` Saravana Kannan 2014-07-14 19:08 ` Saravana Kannan 2014-07-14 19:08 ` Saravana Kannan 2014-07-15 4:35 ` Viresh Kumar 2014-07-15 4:35 ` Viresh Kumar 2014-07-15 4:35 ` Viresh Kumar 2014-07-15 5:36 ` Saravana Kannan 2014-07-15 5:36 ` Saravana Kannan 2014-07-15 5:36 ` Saravana Kannan 2014-07-15 5:52 ` Viresh Kumar 2014-07-15 5:52 ` Viresh Kumar 2014-07-15 5:52 ` Viresh Kumar 2014-07-15 6:58 ` Srivatsa S. Bhat 2014-07-15 6:58 ` Srivatsa S. Bhat 2014-07-15 6:58 ` Srivatsa S. Bhat 2014-07-15 17:35 ` skannan 2014-07-15 17:35 ` skannan at codeaurora.org 2014-07-15 17:35 ` skannan 2014-07-16 7:44 ` Srivatsa S. Bhat 2014-07-16 7:44 ` Srivatsa S. Bhat 2014-07-16 7:44 ` Srivatsa S. Bhat 2014-07-16 5:44 ` Viresh Kumar 2014-07-16 5:44 ` Viresh Kumar 2014-07-16 5:44 ` Viresh Kumar 2014-07-16 7:49 ` Srivatsa S. Bhat 2014-07-16 7:49 ` Srivatsa S. Bhat 2014-07-16 7:49 ` Srivatsa S. Bhat 2014-07-12 3:06 ` Saravana Kannan 2014-07-12 3:06 ` Saravana Kannan 2014-07-12 3:06 ` Saravana Kannan 2014-07-14 6:13 ` Viresh Kumar 2014-07-14 6:13 ` Viresh Kumar 2014-07-14 6:13 ` Viresh Kumar 2014-07-14 19:10 ` Saravana Kannan 2014-07-14 19:10 ` Saravana Kannan 2014-07-14 19:10 ` Saravana Kannan 2014-07-11 7:43 ` Srivatsa S. Bhat 2014-07-11 7:43 ` Srivatsa S. Bhat 2014-07-11 10:02 ` skannan 2014-07-11 10:02 ` skannan at codeaurora.org 2014-07-15 22:47 ` [PATCH v3 0/2] Simplify hotplug/suspend handling Saravana Kannan 2014-07-15 22:47 ` Saravana Kannan 2014-07-15 22:47 ` [PATCH v3 1/2] cpufreq: Don't destroy/realloc policy/sysfs on hotplug/suspend Saravana Kannan 2014-07-15 22:47 ` Saravana Kannan 2014-07-16 0:28 ` Saravana Kannan [this message] 2014-07-16 0:28 ` Saravana Kannan 2014-07-16 8:30 ` Viresh Kumar 2014-07-16 8:30 ` Viresh Kumar 2014-07-16 8:30 ` Viresh Kumar 2014-07-16 19:19 ` Saravana Kannan 2014-07-16 19:19 ` Saravana Kannan 2014-07-16 19:19 ` Saravana Kannan 2014-07-16 8:24 ` Viresh Kumar 2014-07-16 8:24 ` Viresh Kumar 2014-07-16 8:24 ` Viresh Kumar 2014-07-16 11:16 ` Srivatsa S. Bhat 2014-07-16 11:16 ` Srivatsa S. Bhat 2014-07-16 11:16 ` Srivatsa S. Bhat 2014-07-16 13:13 ` Viresh Kumar 2014-07-16 13:13 ` Viresh Kumar 2014-07-16 13:13 ` Viresh Kumar 2014-07-16 18:04 ` Srivatsa S. Bhat 2014-07-16 18:04 ` Srivatsa S. Bhat 2014-07-16 18:04 ` Srivatsa S. Bhat 2014-07-16 19:56 ` Saravana Kannan 2014-07-16 19:56 ` Saravana Kannan 2014-07-16 19:56 ` Saravana Kannan 2014-07-17 5:51 ` Viresh Kumar 2014-07-17 5:51 ` Viresh Kumar 2014-07-17 5:51 ` Viresh Kumar 2014-07-16 19:56 ` Saravana Kannan 2014-07-16 19:56 ` Saravana Kannan 2014-07-16 19:56 ` Saravana Kannan 2014-07-17 5:35 ` Viresh Kumar 2014-07-17 5:35 ` Viresh Kumar 2014-07-17 5:35 ` Viresh Kumar 2014-07-18 3:25 ` Saravana Kannan 2014-07-18 3:25 ` Saravana Kannan 2014-07-18 3:25 ` Saravana Kannan 2014-07-18 4:19 ` Viresh Kumar 2014-07-18 4:19 ` Viresh Kumar 2014-07-18 4:19 ` Viresh Kumar 2014-07-16 20:25 ` Saravana Kannan 2014-07-16 20:25 ` Saravana Kannan 2014-07-16 20:25 ` Saravana Kannan 2014-07-16 21:45 ` Saravana Kannan 2014-07-16 21:45 ` Saravana Kannan 2014-07-16 21:45 ` Saravana Kannan 2014-07-17 6:24 ` Viresh Kumar 2014-07-17 6:24 ` Viresh Kumar 2014-07-17 6:24 ` Viresh Kumar 2014-07-16 14:29 ` Dirk Brandewie 2014-07-16 14:29 ` Dirk Brandewie 2014-07-16 15:28 ` Viresh Kumar 2014-07-16 15:28 ` Viresh Kumar 2014-07-16 15:28 ` Viresh Kumar 2014-07-16 19:42 ` Saravana Kannan 2014-07-16 19:42 ` Saravana Kannan 2014-07-16 19:42 ` Saravana Kannan 2014-07-15 22:47 ` [PATCH v3 2/2] cpufreq: Simplify and fix mutual exclusion with hotplug Saravana Kannan 2014-07-15 22:47 ` Saravana Kannan 2014-07-16 8:48 ` Viresh Kumar 2014-07-16 8:48 ` Viresh Kumar 2014-07-16 8:48 ` Viresh Kumar 2014-07-16 19:34 ` Saravana Kannan 2014-07-16 19:34 ` Saravana Kannan 2014-07-16 19:34 ` Saravana Kannan 2014-07-25 1:07 ` [PATCH v4 0/5] Simplify hotplug/suspend handling Saravana Kannan 2014-07-25 1:07 ` Saravana Kannan 2014-07-25 1:07 ` [PATCH v4 1/5] cpufreq: Don't wait for CPU to going offline to restart governor Saravana Kannan 2014-07-25 1:07 ` Saravana Kannan 2014-07-31 20:47 ` Saravana Kannan 2014-07-31 20:47 ` Saravana Kannan 2014-07-25 1:07 ` [PATCH v4 2/5] cpufreq: Keep track of which CPU owns the kobj/sysfs nodes separately Saravana Kannan 2014-07-25 1:07 ` Saravana Kannan 2014-08-07 9:02 ` Viresh Kumar 2014-08-07 9:02 ` Viresh Kumar 2014-08-07 9:02 ` Viresh Kumar 2014-07-25 1:07 ` [PATCH v4 3/5] cpufreq: Don't destroy/realloc policy/sysfs on hotplug/suspend Saravana Kannan 2014-07-25 1:07 ` Saravana Kannan 2014-07-31 21:56 ` Rafael J. Wysocki 2014-07-31 21:56 ` Rafael J. Wysocki 2014-07-31 22:15 ` Saravana Kannan 2014-07-31 22:15 ` Saravana Kannan 2014-07-31 23:48 ` Saravana Kannan 2014-07-31 23:48 ` Saravana Kannan 2014-07-31 23:48 ` Saravana Kannan 2014-08-07 10:51 ` Viresh Kumar 2014-08-07 10:51 ` Viresh Kumar 2014-08-07 10:51 ` Viresh Kumar 2014-08-12 9:17 ` Viresh Kumar 2014-08-12 9:17 ` Viresh Kumar 2014-08-12 9:17 ` Viresh Kumar 2014-08-07 10:48 ` Viresh Kumar 2014-08-07 10:48 ` Viresh Kumar 2014-08-07 10:48 ` Viresh Kumar 2014-08-11 22:13 ` Saravana Kannan 2014-08-11 22:13 ` Saravana Kannan 2014-08-11 22:13 ` Saravana Kannan 2014-08-12 8:51 ` Viresh Kumar 2014-08-12 8:51 ` Viresh Kumar 2014-08-12 8:51 ` Viresh Kumar 2014-07-25 1:07 ` [PATCH v4 4/5] cpufreq: Properly handle physical CPU hot-add/hot-remove Saravana Kannan 2014-07-25 1:07 ` Saravana Kannan 2014-07-25 1:07 ` Saravana Kannan 2014-08-07 11:02 ` Viresh Kumar 2014-08-07 11:02 ` Viresh Kumar 2014-08-07 11:02 ` Viresh Kumar 2014-08-11 22:15 ` Saravana Kannan 2014-08-11 22:15 ` Saravana Kannan 2014-08-11 22:15 ` Saravana Kannan 2014-07-25 1:07 ` [PATCH v4 5/5] cpufreq: Delete dead code related to policy save/restore Saravana Kannan 2014-07-25 1:07 ` Saravana Kannan 2014-08-07 11:06 ` Viresh Kumar 2014-08-07 11:06 ` Viresh Kumar 2014-08-07 11:06 ` Viresh Kumar 2014-07-29 5:52 ` [PATCH v4 0/5] Simplify hotplug/suspend handling skannan 2014-07-29 5:52 ` skannan at codeaurora.org 2014-07-29 5:52 ` skannan 2014-07-30 0:29 ` Rafael J. Wysocki 2014-07-30 0:29 ` Rafael J. Wysocki 2014-07-31 20:25 ` Saravana Kannan 2014-07-31 20:25 ` Saravana Kannan 2014-08-07 6:04 ` skannan 2014-08-07 6:04 ` skannan at codeaurora.org 2014-10-16 8:53 ` Viresh Kumar 2014-10-16 8:53 ` Viresh Kumar 2014-10-16 8:53 ` Viresh Kumar 2014-10-23 21:41 ` Saravana Kannan 2014-10-23 21:41 ` Saravana Kannan 2014-10-23 21:41 ` Saravana Kannan 2014-07-16 22:02 ` [PATCH] cpufreq: Don't destroy/realloc policy/sysfs on hotplug/suspend Rafael J. Wysocki 2014-07-16 22:02 ` Rafael J. Wysocki 2014-07-16 22:35 ` Saravana Kannan 2014-07-16 22:35 ` Saravana Kannan 2014-07-24 3:02 ` Saravana Kannan 2014-07-24 3:02 ` Saravana Kannan 2014-07-24 5:04 ` Viresh Kumar 2014-07-24 5:04 ` Viresh Kumar 2014-07-24 5:04 ` Viresh Kumar 2014-07-24 9:12 ` skannan 2014-07-24 9:12 ` skannan at codeaurora.org 2014-07-24 9:12 ` skannan
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=53C5C738.5040705@codeaurora.org \ --to=skannan@codeaurora.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-arm-msm@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-pm@vger.kernel.org \ --cc=rjw@rjwysocki.net \ --cc=sboyd@codeaurora.org \ --cc=srivatsa@mit.edu \ --cc=toddpoynor@google.com \ --cc=viresh.kumar@linaro.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.