From: Juergen Gross <jgross@suse.com>
To: Dario Faggioli <dario.faggioli@citrix.com>,
xen-devel@lists.xenproject.org
Cc: George Dunlap <george.dunlap@eu.citrix.com>
Subject: Re: [PATCH 4/9] xen: sched: add .init_pdata hook to the scheduler interface
Date: Thu, 1 Oct 2015 07:21:48 +0200 [thread overview]
Message-ID: <560CC2EC.6030801@suse.com> (raw)
In-Reply-To: <20150929165556.17589.62924.stgit@Solace.station>
On 09/29/2015 06:55 PM, Dario Faggioli wrote:
> with the purpose of decoupling the allocation phase and
> the initialization one, for per-pCPU data of the schedulers.
>
> This makes it possible to perform the initialization later
> in the pCPU bringup/assignement process, when more information
> (for instance, the host CPU topology) are available. This,
> for now, is important only for Credit2, but it can well be
> useful to other schedulers.
>
> This also fixes a latent bug. In fact, when moving a pCPU
> from a Credit2 cpupool to another, whose scheduler also
> remaps runqueue spin locks (e.g., RTDS), we experience the
> following Oops:
>
> (XEN) Initializing RTDS scheduler
> (XEN) WARNING: This is experimental software in development.
> (XEN) Use at your own risk.
> (XEN) Removing cpu 6 from runqueue 0
> (XEN) Assertion 'sd->schedule_lock == &rqd->lock' failed at sched_credit2.c:2102
> (XEN) ----[ Xen-4.7-unstable x86_64 debug=y Not tainted ]----
> ... ... ...
> (XEN) Xen call trace:
> (XEN) [<ffff82d0801256fa>] csched2_free_pdata+0x135/0x180
> (XEN) [<ffff82d08012ccad>] schedule_cpu_switch+0x1ee/0x217
> (XEN) [<ffff82d080101c34>] cpupool_assign_cpu_locked+0x4d/0x152
> (XEN) [<ffff82d0801024ad>] cpupool_do_sysctl+0x20b/0x69d
> (XEN) [<ffff82d08012f693>] do_sysctl+0x665/0x10f8
> (XEN) [<ffff82d08023cb86>] lstar_enter+0x106/0x160
>
> This happens because, right now, the scheduler of the
> target pool remaps the runqueue lock during (rt_)alloc_pdata,
> which is called at the very beginning of schedule_cpu_switch().
> Credit2's csched2_free_pdata(), however, wants to find the spin
> lock the same way it was put by csched2_alloc_pdata(), and
> explodes, it not being the case.
>
> This patch also fixes this as, now, spin lock remapping
> happens in the init_pdata hook of the target scheduler for
> the pCPU, which we can easily make sure it is ivoked *after*
> the free_pdata hook of the old scheduler (which is exactly
> what is done in this patch), without needing to restructure
> schedule_cpu_switch().
>
> Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
> ---
> Cc: George Dunlap <george.dunlap@eu.citrix.com>
> Cc: Juergen Gross <jgross@ssue.com>
> ---
> xen/common/schedule.c | 16 +++++++++++++---
> xen/include/xen/sched-if.h | 1 +
> 2 files changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/xen/common/schedule.c b/xen/common/schedule.c
> index 4a89222..83244d7 100644
> --- a/xen/common/schedule.c
> +++ b/xen/common/schedule.c
> @@ -1407,6 +1407,9 @@ static int cpu_schedule_callback(
>
> switch ( action )
> {
> + case CPU_STARTING:
> + SCHED_OP(&ops, init_pdata, cpu);
> + break;
> case CPU_UP_PREPARE:
> rc = cpu_schedule_up(cpu);
> break;
> @@ -1484,6 +1487,7 @@ void __init scheduler_init(void)
> if ( ops.alloc_pdata &&
> !(this_cpu(schedule_data).sched_priv = ops.alloc_pdata(&ops, 0)) )
> BUG();
> + SCHED_OP(&ops, init_pdata, 0);
You can't call this without having it set in all schedulers.
I guess using the init_pdata hook has to be introduced after or in
patch 5.
Juergen
> }
>
> int schedule_cpu_switch(unsigned int cpu, struct cpupool *c)
> @@ -1513,12 +1517,18 @@ int schedule_cpu_switch(unsigned int cpu, struct cpupool *c)
> per_cpu(scheduler, cpu) = new_ops;
> ppriv_old = per_cpu(schedule_data, cpu).sched_priv;
> per_cpu(schedule_data, cpu).sched_priv = ppriv;
> - SCHED_OP(new_ops, tick_resume, cpu);
> - SCHED_OP(new_ops, insert_vcpu, idle);
> -
> SCHED_OP(old_ops, free_vdata, vpriv_old);
> SCHED_OP(old_ops, free_pdata, ppriv_old, cpu);
>
> + /*
> + * Now that the new pcpu data have been allocated and all pointers
> + * correctly redirected to them, we can perform all the necessary
> + * initializations.
> + */
> + SCHED_OP(new_ops, init_pdata, cpu);
> + SCHED_OP(new_ops, tick_resume, cpu);
> + SCHED_OP(new_ops, insert_vcpu, idle);
> +
> return 0;
> }
>
> diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h
> index dbe7cab..14392f3 100644
> --- a/xen/include/xen/sched-if.h
> +++ b/xen/include/xen/sched-if.h
> @@ -133,6 +133,7 @@ struct scheduler {
> void *);
> void (*free_pdata) (const struct scheduler *, void *, int);
> void * (*alloc_pdata) (const struct scheduler *, int);
> + void (*init_pdata) (const struct scheduler *, int);
> void (*free_domdata) (const struct scheduler *, void *);
> void * (*alloc_domdata) (const struct scheduler *, struct domain *);
>
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
>
next prev parent reply other threads:[~2015-10-01 5:21 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-29 16:55 [PATCH 0/9] xen: sched: improve (a lot! :-D) Credit2 runqueue handling Dario Faggioli
2015-09-29 16:55 ` [PATCH 1/9] xen: sched: fix an 'off by one \t' in credit2 debug dump Dario Faggioli
2015-10-01 5:22 ` Juergen Gross
2015-10-08 14:09 ` George Dunlap
2015-09-29 16:55 ` [PATCH 2/9] xen: sched: improve scope and placement of credit2 boot parameters Dario Faggioli
2015-10-01 5:23 ` Juergen Gross
2015-10-01 7:51 ` Jan Beulich
2015-10-01 8:17 ` Dario Faggioli
2015-09-29 16:55 ` [PATCH 3/9] xen: sched: make locking for {insert, remove}_vcpu consistent Dario Faggioli
2015-09-29 17:31 ` Andrew Cooper
2015-09-29 21:40 ` Dario Faggioli
2015-09-29 21:56 ` Dario Faggioli
2015-09-30 9:00 ` Andrew Cooper
2015-10-08 14:58 ` George Dunlap
2015-10-08 15:20 ` Andrew Cooper
2015-10-08 16:46 ` George Dunlap
2015-10-08 17:23 ` Andrew Cooper
2015-10-08 20:44 ` Dario Faggioli
2015-10-12 9:44 ` George Dunlap
2015-10-08 20:39 ` Dario Faggioli
2015-10-09 13:05 ` Andrew Cooper
2015-10-09 16:56 ` Dario Faggioli
2015-10-01 8:03 ` Jan Beulich
2015-10-01 11:59 ` Dario Faggioli
2015-09-29 16:55 ` [PATCH 4/9] xen: sched: add .init_pdata hook to the scheduler interface Dario Faggioli
2015-10-01 5:21 ` Juergen Gross [this message]
2015-10-01 6:33 ` Dario Faggioli
2015-10-01 7:43 ` Juergen Gross
2015-10-01 9:32 ` Andrew Cooper
2015-10-01 9:40 ` Dario Faggioli
2015-10-01 8:17 ` Jan Beulich
2015-10-01 9:26 ` Dario Faggioli
2015-10-01 10:12 ` Jan Beulich
2015-10-01 10:35 ` Dario Faggioli
2015-10-01 10:47 ` Jan Beulich
2015-09-29 16:56 ` [PATCH 5/9] xen: sched: make implementing .alloc_pdata optional Dario Faggioli
2015-10-01 5:28 ` Juergen Gross
2015-10-01 6:35 ` Dario Faggioli
2015-10-01 7:49 ` Jan Beulich
2015-10-01 8:13 ` Dario Faggioli
2015-09-29 16:56 ` [PATCH 6/9] xen: sched: implement .init_pdata in all schedulers Dario Faggioli
2015-09-29 16:56 ` [PATCH 7/9] xen: sched: fix per-socket runqueue creation in credit2 Dario Faggioli
2015-09-29 16:56 ` [PATCH 8/9] xen: sched: allow for choosing credit2 runqueues configuration at boot Dario Faggioli
2015-10-01 5:48 ` Juergen Gross
2015-10-01 7:23 ` Dario Faggioli
2015-10-01 7:46 ` Juergen Gross
2015-09-29 16:56 ` [PATCH 9/9] xen: sched: per-core runqueues as default in credit2 Dario Faggioli
2015-10-01 5:48 ` Juergen Gross
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=560CC2EC.6030801@suse.com \
--to=jgross@suse.com \
--cc=dario.faggioli@citrix.com \
--cc=george.dunlap@eu.citrix.com \
--cc=xen-devel@lists.xenproject.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).