linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: srivatsa@MIT.EDU (Srivatsa S. Bhat)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 1/2] cpufreq: Don't destroy/realloc policy/sysfs on hotplug/suspend
Date: Wed, 16 Jul 2014 23:34:41 +0530	[thread overview]
Message-ID: <53C6BEB9.6090503@mit.edu> (raw)
In-Reply-To: <CAKohpomKF_TvpPZzEwocOK33RKnLWLtE2cPK6hk7YuhTVaNg2g@mail.gmail.com>

On 07/16/2014 06:43 PM, Viresh Kumar wrote:
> On 16 July 2014 16:46, Srivatsa S. Bhat <srivatsa@mit.edu> wrote:
>> Short answer: If the sysfs directory has already been created by cpufreq,
>> then yes, it will remain as it is. However, if the online operation failed
>> before that, then cpufreq won't know about that CPU at all, and no file will
>> be created.
>>
>> Long answer:
>> The existing cpufreq code does all its work (including creating the sysfs
>> directories etc) at the CPU_ONLINE stage. This stage is not expected to fail
>> (in fact even the core CPU hotplug code in kernel/cpu.c doesn't care for
>> error returns at this point). So if a CPU fails to come up in earlier stages
>> itself (such as CPU_UP_PREPARE), then cpufreq won't even hear about that CPU,
>> and hence no sysfs files will be created/linked. However, if the CPU bringup
>> operation fails during the CPU_ONLINE stage after the cpufreq's notifier has
>> been invoked, then we do nothing about it and the cpufreq sysfs files will
>> remain.
> 
> In short, the problem I mentioned before this para is genuine. And setting
> policy->cpu to the first cpu of a mask is indeed a bad idea.
> 
>>> Also, how does suspend/resume work without CONFIG_HOTPLUG_CPU ?
>>> What's the sequence of events?
>>>
>>
>> Well, CONFIG_SUSPEND doesn't have an explicit dependency on HOTPLUG_CPU, but
>> SMP systems usually use CONFIG_PM_SLEEP_SMP, which sets CONFIG_HOTPLUG_CPU.
> 
> I read usually as *optional*
> 
>> (I guess the reason why CONFIG_SUSPEND doesn't depend on HOTPLUG_CPU is
>> because suspend is possible even on uniprocessor systems and hence the
>> Kconfig dependency wasn't really justified).
> 
> Again the same question, how do we suspend when HOTPLUG is disabled?
> 

>From what I understand, if you disable HOTPLUG_CPU and enable CONFIG_SUSPEND
and try suspend/resume on an SMP system, the disable_nonboot_cpus() call will
return silently without doing anything. Thus, suspend will fail silently and
the system might have trouble resuming.

But surprisingly we have never had such bug reports so far! Most probably this
is because PM_SLEEP_SMP has a default of y (which in turn selects HOTPLUG_CPU):

config PM_SLEEP_SMP
        def_bool y
        depends on SMP
        depends on ARCH_SUSPEND_POSSIBLE || ARCH_HIBERNATION_POSSIBLE
        depends on PM_SLEEP
        select HOTPLUG_CPU

So I guess nobody really tried turning this off on SMP systems and then trying
suspend. Then I started looking at the git history and wondered where this
Kconfig dependency between SUSPEND and SMP<->HOTPLUG_CPU got messed up. But
instead I found that the initial commit itself didn't get the dependency right.

Commit 296699de6bdc (Introduce CONFIG_SUSPEND for suspend-to-Ram and standby)
introduced all the Kconfig options, and it indeed mentions this in the
changelog: "Make HOTPLUG_CPU be selected automatically if SUSPEND or
HIBERNATION has been chosen and the kernel is intended for SMP systems". But
unfortunately, the code didn't get it right because it made CONFIG_SUSPEND
depend on SUSPEND_SMP_POSSIBLE instead of SUSPEND_SMP.

In other words, we have had this incorrect dependency all the time!

Regards,
Srivatsa S. Bhat

  reply	other threads:[~2014-07-16 18:04 UTC|newest]

Thread overview: 76+ 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-11  4:18 ` [PATCH v2] " Saravana Kannan
2014-07-11  6:19   ` Viresh Kumar
2014-07-11  9:59     ` skannan at codeaurora.org
2014-07-11 10:07       ` skannan at codeaurora.org
2014-07-11 10:52       ` Viresh Kumar
2014-07-12  2:44         ` Saravana Kannan
2014-07-14  6:09           ` Viresh Kumar
2014-07-14 19:08             ` Saravana Kannan
2014-07-15  4:35               ` Viresh Kumar
2014-07-15  5:36                 ` Saravana Kannan
2014-07-15  5:52                   ` Viresh Kumar
2014-07-15  6:58                   ` Srivatsa S. Bhat
2014-07-15 17:35                     ` skannan at codeaurora.org
2014-07-16  7:44                       ` Srivatsa S. Bhat
2014-07-16  5:44                     ` Viresh Kumar
2014-07-16  7:49                       ` Srivatsa S. Bhat
2014-07-12  3:06     ` Saravana Kannan
2014-07-14  6:13       ` Viresh Kumar
2014-07-14 19:10         ` Saravana Kannan
2014-07-11  7:43   ` Srivatsa S. Bhat
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     ` [PATCH v3 1/2] cpufreq: Don't destroy/realloc policy/sysfs on hotplug/suspend Saravana Kannan
2014-07-16  0:28       ` Saravana Kannan
2014-07-16  8:30         ` Viresh Kumar
2014-07-16 19:19           ` Saravana Kannan
2014-07-16  8:24       ` Viresh Kumar
2014-07-16 11:16         ` Srivatsa S. Bhat
2014-07-16 13:13           ` Viresh Kumar
2014-07-16 18:04             ` Srivatsa S. Bhat [this message]
2014-07-16 19:56             ` Saravana Kannan
2014-07-17  5:51               ` Viresh Kumar
2014-07-16 19:56           ` Saravana Kannan
2014-07-17  5:35             ` Viresh Kumar
2014-07-18  3:25               ` Saravana Kannan
2014-07-18  4:19                 ` Viresh Kumar
2014-07-16 20:25         ` Saravana Kannan
2014-07-16 21:45           ` Saravana Kannan
2014-07-17  6:24           ` Viresh Kumar
2014-07-16 14:29       ` Dirk Brandewie
2014-07-16 15:28         ` Viresh Kumar
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-16  8:48       ` Viresh Kumar
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       ` [PATCH v4 1/5] cpufreq: Don't wait for CPU to going offline to restart governor 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-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-31 21:56         ` Rafael J. Wysocki
2014-07-31 22:15           ` Saravana Kannan
2014-07-31 23:48           ` Saravana Kannan
2014-08-07 10:51           ` Viresh Kumar
2014-08-12  9:17             ` Viresh Kumar
2014-08-07 10:48         ` Viresh Kumar
2014-08-11 22:13           ` Saravana Kannan
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-08-07 11:02         ` Viresh Kumar
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-08-07 11:06         ` Viresh Kumar
2014-07-29  5:52       ` [PATCH v4 0/5] Simplify hotplug/suspend handling skannan at codeaurora.org
2014-07-30  0:29       ` Rafael J. Wysocki
2014-07-31 20:25         ` Saravana Kannan
2014-08-07  6:04         ` skannan at codeaurora.org
2014-10-16  8:53       ` Viresh Kumar
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:35   ` Saravana Kannan
2014-07-24  3:02   ` Saravana Kannan
2014-07-24  5:04     ` Viresh Kumar
2014-07-24  9:12       ` skannan at codeaurora.org

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=53C6BEB9.6090503@mit.edu \
    --to=srivatsa@mit.edu \
    --cc=linux-arm-kernel@lists.infradead.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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).