From: Peter Zijlstra <peterz@infradead.org>
To: Luca Abeni <luca.abeni@unitn.it>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
Juri Lelli <juri.lelli@arm.com>
Subject: Re: [RFC v2 3/7] Improve the tracking of active utilisation
Date: Tue, 5 Apr 2016 17:00:36 +0200 [thread overview]
Message-ID: <20160405150036.GA3430@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <1459523553-29089-4-git-send-email-luca.abeni@unitn.it>
On Fri, Apr 01, 2016 at 05:12:29PM +0200, Luca Abeni wrote:
> +static void task_go_inactive(struct task_struct *p)
> +{
> + struct sched_dl_entity *dl_se = &p->dl;
> + struct hrtimer *timer = &dl_se->inactive_timer;
> + struct dl_rq *dl_rq = dl_rq_of_se(dl_se);
> + struct rq *rq = rq_of_dl_rq(dl_rq);
> + ktime_t now, act;
> + s64 delta;
> + u64 zerolag_time;
> +
> + WARN_ON(dl_se->dl_runtime == 0);
> +
> + /* If the inactive timer is already armed, return immediately */
> + if (hrtimer_active(&dl_se->inactive_timer))
> + return;
So while we start the timer on the local cpu, we don't migrate the timer
when we migrate the task, so the callback can happen on a remote cpu,
right?
Therefore, the timer function might still be running, but just have done
task_rq_unlock(), which would have allowed our cpu to acquire the
rq->lock and get here.
Then the above check is true, we'll quit, but effectively the inactive
timer will not run 'again'.
> +
> +
> + /*
> + * We want the timer to fire at the "0 lag time", but considering
> + * that it is actually coming from rq->clock and not from
> + * hrtimer's time base reading.
> + */
> + zerolag_time = dl_se->deadline -
> + div64_long((dl_se->runtime * dl_se->dl_period),
> + dl_se->dl_runtime);
> +
> + act = ns_to_ktime(zerolag_time);
> + now = hrtimer_cb_get_time(timer);
> + delta = ktime_to_ns(now) - rq_clock(rq);
> + act = ktime_add_ns(act, delta);
> +
> + /*
> + * If the "0-lag time" already passed, decrease the active
> + * utilization now, instead of starting a timer
> + */
> + if (ktime_us_delta(act, now) < 0) {
> + sub_running_bw(dl_se, dl_rq);
> + if (!dl_task(p))
> + __dl_clear_params(p);
> +
> + return;
> + }
> +
> + get_task_struct(p);
> + hrtimer_start(timer, act, HRTIMER_MODE_ABS);
> +}
> @@ -1071,6 +1164,23 @@ select_task_rq_dl(struct task_struct *p, int cpu, int sd_flag, int flags)
> }
> rcu_read_unlock();
>
> + if (rq != cpu_rq(cpu)) {
I don't think this is right, you want:
if (task_cpu(p) != cpu) {
because @cpu does not need to be task_cpu().
> + int migrate_active;
> +
> + raw_spin_lock(&rq->lock);
Which then also means @rq is 'wrong', so you'll have to add:
rq = task_rq(p);
before this.
> + migrate_active = hrtimer_active(&p->dl.inactive_timer);
> + if (migrate_active)
> + sub_running_bw(&p->dl, &rq->dl);
> + raw_spin_unlock(&rq->lock);
At this point task_rq() is still the above rq, so if the inactive timer
hits here it will lock this rq and subtract the running bw here _again_,
right?
> + if (migrate_active) {
> + rq = cpu_rq(cpu);
> + raw_spin_lock(&rq->lock);
> + add_running_bw(&p->dl, &rq->dl);
> + raw_spin_unlock(&rq->lock);
> + }
> + }
next prev parent reply other threads:[~2016-04-05 15:00 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-01 15:12 [RFC v2 0/7] CPU reclaiming for SCHED_DEADLINE Luca Abeni
2016-04-01 15:12 ` [RFC v2 1/7] Track the active utilisation Luca Abeni
2016-04-05 12:23 ` Peter Zijlstra
2016-04-05 16:47 ` luca abeni
2016-04-01 15:12 ` [RFC v2 2/7] Correctly track the active utilisation for migrating tasks Luca Abeni
2016-04-05 12:24 ` Peter Zijlstra
2016-04-05 16:50 ` luca abeni
2016-04-01 15:12 ` [RFC v2 3/7] Improve the tracking of active utilisation Luca Abeni
2016-04-05 12:42 ` Peter Zijlstra
2016-04-05 17:00 ` luca abeni
2016-04-05 12:42 ` Peter Zijlstra
2016-04-05 17:05 ` luca abeni
2016-04-05 14:48 ` Peter Zijlstra
2016-04-05 17:17 ` luca abeni
2016-04-05 15:00 ` Peter Zijlstra [this message]
2016-04-05 17:56 ` luca abeni
2016-04-05 18:00 ` Peter Zijlstra
2016-04-05 19:35 ` luca abeni
2016-04-05 18:02 ` Peter Zijlstra
2016-04-05 19:24 ` luca abeni
2016-04-05 19:31 ` Peter Zijlstra
2016-04-05 19:32 ` luca abeni
2016-04-05 18:11 ` Peter Zijlstra
2016-04-01 15:12 ` [RFC v2 4/7] Fix the update of the total -deadline utilization Luca Abeni
2016-04-05 12:58 ` Peter Zijlstra
2016-04-05 17:16 ` luca abeni
2016-04-01 15:12 ` [RFC v2 5/7] GRUB accounting Luca Abeni
2016-04-01 15:12 ` [RFC v2 6/7] Make GRUB a task's flag Luca Abeni
2016-04-01 15:12 ` [RFC v2 7/7] Do not reclaim the whole CPU bandwidth Luca Abeni
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=20160405150036.GA3430@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=juri.lelli@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luca.abeni@unitn.it \
--cc=mingo@redhat.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.