linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: Steve Muckle <smuckle.linux@gmail.com>
Cc: Rafael Wysocki <rjw@rjwysocki.net>,
	linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <Juri.Lelli@arm.com>,
	Robin Randhawa <robin.randhawa@arm.com>
Subject: Re: [PATCH V2 0/4] cpufreq: schedutil: move slow path from workqueue to SCHED_FIFO task
Date: Thu, 24 Nov 2016 09:34:04 +0530	[thread overview]
Message-ID: <20161124040404.GB9376@vireshk-i7> (raw)
In-Reply-To: <20161124030102.GA20047@graphite.smuckle.net>

On 23-11-16, 19:01, Steve Muckle wrote:
> I know this has already gone in, but can you expand on the unmet
> guarantees mentioned here just for my own (and perhaps others')
> understanding?

Sure. This is the simplified form of your original patch:

@@ -71,7 +73,7 @@ static bool sugov_should_update_freq(struct sugov_policy *sg_policy, u64 time)
 {
        s64 delta_ns;
 
-       if (sg_policy->work_in_progress)
+       if (sg_policy->thread_active)
                return false;
 
        if (unlikely(sg_policy->need_freq_update)) {
 
+static int sugov_thread(void *data)
 {
	...

+       do {

        ...

+               set_current_state(TASK_RUNNING);
+               /* Issue request. */
+               mutex_lock(&sg_policy->slow_lock);
+               __cpufreq_driver_target(sg_policy->policy,
+                                       sg_policy->next_freq,
+                                       CPUFREQ_RELATION_L);
+               mutex_unlock(&sg_policy->slow_lock);
+
+               sg_policy->thread_active = false;

        ...

+               schedule();
+
+       } while (!kthread_should_stop());
+       return 0;
 }
 
 static void sugov_irq_work(struct irq_work *irq_work)
@@ -349,7 +382,7 @@ static void sugov_irq_work(struct irq_work *irq_work)
        struct sugov_policy *sg_policy;
 
        sg_policy = container_of(irq_work, struct sugov_policy, irq_work);
-       schedule_work_on(smp_processor_id(), &sg_policy->work);
+       wake_up_process(sg_policy->thread);
 }

Consider that the thread has just got a chance to run and has set
'thread_active' to false from sugov_thread(), i.e. schedule() isn't called yet.

At this time if sugov_should_update_freq() gets called again, it will return
'true', and eventually we will land into sugov_irq_work() and that will call
wake_up_process(). But the process is already running and haven't slept yet.
I am not sure how it works but I don't expect the thread to go to sleep again at
this point of time.

And in this particular case we will end up not evaluating the load and doing
DVFS for period = 2 * rate_limit_us, whereas we wanted to do that every
rate_limit microseconds.

Of course a simple kthread would have been better instead of a kthread + work if
this wasn't the case.

Does that sound reasonable or Am I missing something ?

-- 
viresh

      reply	other threads:[~2016-11-24  4:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-15  8:23 [PATCH V2 0/4] cpufreq: schedutil: move slow path from workqueue to SCHED_FIFO task Viresh Kumar
2016-11-15  8:23 ` [PATCH V2 1/4] cpufreq: schedutil: Avoid indented labels Viresh Kumar
2016-11-15  8:23 ` [PATCH V2 2/4] cpufreq: schedutil: enable fast switch earlier Viresh Kumar
2016-11-15  8:23 ` [PATCH V2 3/4] cpufreq: schedutil: move slow path from workqueue to SCHED_FIFO task Viresh Kumar
2016-11-16 15:26   ` Peter Zijlstra
2016-11-24  1:19     ` Rafael J. Wysocki
2016-11-24  4:51   ` Ingo Molnar
2016-11-24  5:10     ` Viresh Kumar
2016-11-15  8:23 ` [PATCH V2 4/4] cpufreq: schedutil: irq-work and mutex are only used in slow path Viresh Kumar
2016-11-24  4:53   ` Ingo Molnar
2016-11-24  6:12     ` Viresh Kumar
2016-11-24  6:24       ` Ingo Molnar
2016-11-24  3:01 ` [PATCH V2 0/4] cpufreq: schedutil: move slow path from workqueue to SCHED_FIFO task Steve Muckle
2016-11-24  4:04   ` Viresh Kumar [this message]

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=20161124040404.GB9376@vireshk-i7 \
    --to=viresh.kumar@linaro.org \
    --cc=Juri.Lelli@arm.com \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rjw@rjwysocki.net \
    --cc=robin.randhawa@arm.com \
    --cc=smuckle.linux@gmail.com \
    --cc=vincent.guittot@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 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).