From: Peter Zijlstra <peterz@infradead.org>
To: Juri Lelli <juri.lelli@gmail.com>
Cc: Tejun Heo <tj@kernel.org>, Ingo Molnar <mingo@redhat.com>,
linux-kernel@vger.kernel.org,
Johannes Weiner <hannes@cmpxchg.org>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>
Subject: Re: [REGRESSION] funny sched_domain build failure during resume
Date: Thu, 15 May 2014 10:51:56 +0200 [thread overview]
Message-ID: <20140515085156.GG30445@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <20140515104055.e91844a5b75529edc560349a@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2626 bytes --]
On Thu, May 15, 2014 at 10:40:55AM +0200, Juri Lelli wrote:
> Hi,
>
> > @@ -37,10 +38,7 @@ static inline int dl_time_before(u64 a, u64 b)
> >
> > static void cpudl_exchange(struct cpudl *cp, int a, int b)
> > {
> > - int cpu_a = cp->elements[a].cpu, cpu_b = cp->elements[b].cpu;
> > -
> > swap(cp->elements[a], cp->elements[b]);
> > - swap(cp->cpu_to_idx[cpu_a], cp->cpu_to_idx[cpu_b]);
> > }
> >
>
> I think there is a problem here. Your patch "embeds" cpu_to_idx array
> in elements array, but here the swap operates differently on the two.
<snip>
> Sorry for this long reply, but I had to convince also myself...
Glad you explained it before I tried to untangle that code myself.
> So, I think that having just one dynamic array is nicer and better, but
> we still need to swap things separately. Something like (on top of
> yours):
>
> diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c
> index 60ad0af..10dc7ab 100644
> --- a/kernel/sched/cpudeadline.c
> +++ b/kernel/sched/cpudeadline.c
> @@ -36,9 +36,31 @@ static inline int dl_time_before(u64 a, u64 b)
> return (s64)(a - b) < 0;
> }
>
> +static inline void swap_element(struct cpudl *cp, int a, int b)
> +{
> + int cpu_tmp = cp->elements[a].cpu;
> + u64 dl_tmp = cp->elements[a].dl;
> +
> + cp->elements[a].cpu = cp->elements[b].cpu;
> + cp->elements[a].dl = cp->elements[b].dl;
> + cp->elements[b].cpu = cpu_tmp;
> + cp->elements[b].dl = dl_tmp;
You could've just written:
swap(cp->elements[a].cpu, cp->elements[b].cpu);
swap(cp->elements[a].dl , cp->elements[b].dl );
The swap macro does the tmp var for you.
> +}
> +
> +static inline void swap_idx(struct cpudl *cp, int a, int b)
> +{
> + int idx_tmp = cp->elements[a].idx;
> +
> + cp->elements[a].idx = cp->elements[b].idx;
> + cp->elements[b].idx = idx_tmp;
swap(cp->elements[a].idx, cp->elements[b].idx);
> +}
> +
> static void cpudl_exchange(struct cpudl *cp, int a, int b)
> {
> - swap(cp->elements[a], cp->elements[b]);
> + int cpu_a = cp->elements[a].cpu, cpu_b = cp->elements[b].cpu;
> +
> + swap_element(cp, a, b);
> + swap_idx(cp, cpu_a, cpu_b);
Or just skip the lot and put the 3 swap() stmts here.
> }
>
> static void cpudl_heapify(struct cpudl *cp, int idx)
> ---
>
> But, I don't know if this is too ugly and we better go with two arrays
> (or a better solution, as this is the fastest thing I could come up
> with :)).
Thanks for looking at it, and sorry for breaking it.
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2014-05-15 8:52 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-09 16:04 [REGRESSION] funny sched_domain build failure during resume Tejun Heo
2014-05-09 16:15 ` Peter Zijlstra
2014-05-14 14:00 ` Peter Zijlstra
2014-05-14 14:05 ` Peter Zijlstra
2014-05-14 17:02 ` Tejun Heo
2014-05-14 17:10 ` Peter Zijlstra
2014-05-14 22:36 ` Tejun Heo
2014-05-15 8:57 ` Peter Zijlstra
2014-05-15 14:41 ` Johannes Weiner
2014-05-15 15:12 ` Peter Zijlstra
2014-05-16 11:47 ` Srivatsa S. Bhat
2014-05-15 8:40 ` Juri Lelli
2014-05-15 8:51 ` Peter Zijlstra [this message]
2014-05-15 11:52 ` Juri Lelli
2014-05-16 10:43 ` Peter Zijlstra
2014-05-16 11:01 ` Juri Lelli
2014-05-16 11:04 ` Peter Zijlstra
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=20140515085156.GG30445@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=hannes@cmpxchg.org \
--cc=juri.lelli@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rjw@rjwysocki.net \
--cc=tj@kernel.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