All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: "Liu, Chuansheng" <chuansheng.liu@intel.com>,
	Peter Zijlstra <peterz@infradead.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"Liu, Changcheng" <changcheng.liu@intel.com>,
	"Wang, Xiaoming" <xiaoming.wang@intel.com>,
	"Chakravarty, Souvik K" <souvik.k.chakravarty@intel.com>
Subject: Re: [PATCH] cpuidle: Fix the CPU stuck at C0 for 2-3s after PM_QOS back to DEFAULT
Date: Thu, 14 Aug 2014 16:17:15 +0200	[thread overview]
Message-ID: <53ECC4EB.20407@linaro.org> (raw)
In-Reply-To: <27240C0AC20F114CBF8149A2696CBE4A01E5B73B@SHSMSX101.ccr.corp.intel.com>

On 08/14/2014 04:10 PM, Liu, Chuansheng wrote:
>
>
>> -----Original Message-----
>> From: Peter Zijlstra [mailto:peterz@infradead.org]
>> Sent: Thursday, August 14, 2014 9:13 PM
>> To: Liu, Chuansheng
>> Cc: Daniel Lezcano; Rafael J. Wysocki; linux-pm@vger.kernel.org; LKML; Liu,
>> Changcheng; Wang, Xiaoming; Chakravarty, Souvik K
>> Subject: Re: [PATCH] cpuidle: Fix the CPU stuck at C0 for 2-3s after PM_QOS
>> back to DEFAULT
>>
>> On Thu, Aug 14, 2014 at 11:24:06AM +0000, Liu, Chuansheng wrote:
>>> If inspecting the polling flag, we can not fix the race between poll_idle and
>> smp_callback,
>>> since in poll_idle(), before set polling flag, if the smp_callback come in, then
>> no resched bit set,
>>> after that, poll_idle() will do the polling action, without reselection
>> immediately, it will bring power
>>> regression here.
>>
>> -ENOPARSE. Is there a question there?
>
> Lezcano suggest to inspect the polling flag, then code is like below:
> smp_callback() {
> if (polling_flag)
>    set_resched_bit;
> }
>
> And the poll_idle code is like below:
> static int poll_idle(struct cpuidle_device *dev,
>                  struct cpuidle_driver *drv, int index)
> {
>          local_irq_enable();
>          if (!current_set_polling_and_test()) {
>                  while (!need_resched())

Or alternatively, something like:

	while (!need_resched() || kickme) {
		...
	}
			

smp_callback()
{
	kickme = 1;
}

kickme is a percpu variable and set to zero when exiting the 'enter' 
callback.

So we don't mess with the polling flag, which is already a bit tricky.

This patch is very straightforward to illustrate the idea.

>                          cpu_relax();
>          }
>          current_clr_polling();
>
>          return index;
> }
>
> The race is:
> Idle task:
> poll_idle
>    local_irq_enable()
> <== IPI interrupt coming, check the polling flag is not set yet, do nothing;
> Come back to poll_idle, it will stay in the poll loop for a while, instead break
> it immediately to let governor reselect the right C-state.
>
>
>
>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>


-- 
  <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

  reply	other threads:[~2014-08-14 14:17 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-14  2:11 [PATCH] cpuidle: Fix the CPU stuck at C0 for 2-3s after PM_QOS back to DEFAULT Chuansheng Liu
     [not found] ` <CAKnoXLw3DrBAxCUWEkXtvCTf+E1w0xTHJSiSUY6Qd6xHXeGaoQ@mail.gmail.com>
2014-08-14 10:53   ` Peter Zijlstra
2014-08-14 11:24     ` Liu, Chuansheng
2014-08-14 13:13       ` Peter Zijlstra
2014-08-14 14:10         ` Liu, Chuansheng
2014-08-14 14:17           ` Daniel Lezcano [this message]
2014-08-14 14:26             ` Liu, Chuansheng
2014-08-14 14:26               ` Liu, Chuansheng
2014-08-14 11:00   ` Peter Zijlstra
2014-08-14 11:14     ` Daniel Lezcano
2014-08-14 11:17       ` Liu, Chuansheng
2014-08-14 11:17         ` Liu, Chuansheng
2014-08-14 12:41       ` Peter Zijlstra
2014-08-14 13:29         ` Daniel Lezcano
2014-08-14 13:57           ` Liu, Chuansheng
2014-08-14 13:57             ` Liu, Chuansheng
2014-08-14 21:12       ` Andy Lutomirski
2014-08-14 21:16         ` Peter Zijlstra
2014-08-14 21:22           ` Andy Lutomirski
2014-08-15  1:21             ` Liu, Chuansheng
2014-08-15  1:21               ` Liu, Chuansheng
2014-08-15  1:27               ` Andy Lutomirski

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=53ECC4EB.20407@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=changcheng.liu@intel.com \
    --cc=chuansheng.liu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=rjw@rjwysocki.net \
    --cc=souvik.k.chakravarty@intel.com \
    --cc=xiaoming.wang@intel.com \
    /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 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.