All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: rjw@rjwysocki.net, linux-kernel@vger.kernel.org,
	linux-pm@vger.kernel.org, Eduardo Valentin <edubezval@gmail.com>,
	Javi Merino <javi.merino@kernel.org>,
	Leo Yan <leo.yan@linaro.org>,
	Kevin Wangtao <kevin.wangtao@linaro.org>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Rui Zhang <rui.zhang@intel.com>,
	Daniel Thompson <daniel.thompson@linaro.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Andrea Parri <andrea.parri@amarulasolutions.com>
Subject: Re: [PATCH V7] powercap/drivers/idle_injection: Add an idle injection framework
Date: Mon, 18 Jun 2018 13:28:22 +0200	[thread overview]
Message-ID: <883320cc-5677-6612-1565-b5a05b8684e1@linaro.org> (raw)
In-Reply-To: <20180618103844.t2minxwc7tiu2qgd@vireshk-i7>

On 18/06/2018 12:38, Viresh Kumar wrote:
> On 18-06-18, 12:35, Daniel Lezcano wrote:
>> On 18/06/2018 12:22, Viresh Kumar wrote:
>>> On 15-06-18, 11:19, Daniel Lezcano wrote:
>>>> +/**
>>>> + * idle_injection_stop - stops the idle injections
>>>> + * @ii_dev: a pointer to an idle injection_device structure
>>>> + *
>>>> + * The function stops the idle injection and waits for the threads to
>>>> + * complete. If we are in the process of injecting an idle cycle, then
>>>> + * this will wait the end of the cycle.
>>>> + *
>>>> + * When the function returns there is no more idle injection
>>>> + * activity. The kthreads are scheduled out and the periodic timer is
>>>> + * off.
>>>> + */
>>>> +void idle_injection_stop(struct idle_injection_device *ii_dev)
>>>> +{
>>>> +	struct idle_injection_thread *iit;
>>>> +	unsigned int cpu;
>>>> +
>>>> +	pr_debug("Stopping injecting idle cycles on CPUs '%*pbl'\n",
>>>> +		 cpumask_pr_args(to_cpumask(ii_dev->cpumask)));
>>>> +
>>>> +	hrtimer_cancel(&ii_dev->timer);
>>>> +
>>>> +	/*
>>>> +	 * We want the guarantee we have a quescient point where
>>>> +	 * parked threads stay in there state while we are stopping
>>>> +	 * the idle injection. After exiting the loop, if any CPU is
>>>> +	 * plugged in, the 'should_run' boolean being false, the
>>>> +	 * smpboot main loop schedules the task out.
>>>> +	 */
>>>> +	cpu_hotplug_disable();
>>>> +
>>>> +	for_each_cpu_and(cpu, to_cpumask(ii_dev->cpumask), cpu_online_mask) {
>>>
>>> Maybe you should do below for all CPUs in the mask. Is the below usecase
>>> possible ?
>>>
>>> - CPU0-4 are part of the mask and are all online.
>>> - hrtimer fires and sets should_run for all of them to 1.
>>
>>     ^^
>> hrtimer_cancel gives you the guarantee, the timer is no longer active
>> and there is no execution in the timer handler. So the timer can no
>> longer fire after hrtimer_cancel() is called (which is a blocking call).
> 
> Right but that isn't called yet in my sequence.
> 
>>> - Right at this time CPU3 goes offline, so the thread gets parked with
>>>   should_run == 1. Is there a reason why this can't happen ?

for this specific case, we can use the park() callback to set should_run
to false, no ?

>>> - Now we unregister the stuff and CPU3 again comes online.
> 
> It gets called here from unregister/stop.
> 
>>> - Because it had should_run as true, we again run the thread and Crash.
>>>
>>> makes sense ?
> 
>>>> +out_rollback_per_cpu:
>>>> +	for_each_cpu(cpu, to_cpumask(ii_dev->cpumask))
>>>> +		per_cpu(idle_injection_device, cpu) = NULL;
>>>
>>> So if two parts of the kernel call this routine with the same cpumask, then the
>>> second call will also overwrite the masks with NULL and return error. That will
>>> screw up things a bit here.
>>
>> Apparently there is a misunderstanding :)
>>
>> https://lkml.org/lkml/2018/5/29/209 (at the end)
> 
> Right, your earlier version was doing the right thing :)
> 


-- 
 <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:[~2018-06-18 11:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-15  9:19 [PATCH V7] powercap/drivers/idle_injection: Add an idle injection framework Daniel Lezcano
2018-06-18 10:22 ` Viresh Kumar
2018-06-18 10:35   ` Daniel Lezcano
2018-06-18 10:38     ` Viresh Kumar
2018-06-18 11:28       ` Daniel Lezcano [this message]
2018-06-19  5:49         ` Viresh Kumar

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=883320cc-5677-6612-1565-b5a05b8684e1@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=andrea.parri@amarulasolutions.com \
    --cc=daniel.thompson@linaro.org \
    --cc=edubezval@gmail.com \
    --cc=javi.merino@kernel.org \
    --cc=kevin.wangtao@linaro.org \
    --cc=leo.yan@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=rjw@rjwysocki.net \
    --cc=rui.zhang@intel.com \
    --cc=vincent.guittot@linaro.org \
    --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: 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.