xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: George Dunlap <george.dunlap@citrix.com>
To: Dario Faggioli <dario.faggioli@citrix.com>,
	xen-devel@lists.xenproject.org
Cc: George Dunlap <george.dunlap@eu.citrix.com>,
	Anshul Makkar <anshul.makkar@citrix.com>
Subject: Re: [PATCH v2 04/10] xen: credit2: only reset credit on reset condition
Date: Fri, 30 Sep 2016 12:28:41 +0100	[thread overview]
Message-ID: <764d297c-854e-a33c-4e7b-191ab0027469@citrix.com> (raw)
In-Reply-To: <147520402650.22544.2188671255927985759.stgit@Solace.fritz.box>

On 30/09/16 03:53, Dario Faggioli wrote:
> The condition for a Credit2 scheduling epoch coming to an
> end is that the vcpu at the front of the runqueue has negative
> credits. However, it is possible, that runq_candidate() does
> not actually return to the scheduler the first vcpu in the
> runqueue (e.g., because such vcpu can't run on the cpu that
> is going through the scheduler, because of hard-affinity).
> 
> If that happens, we should not trigger a credit reset, or we
> risk altering the lenght of a scheduler epoch, wrt what the
> original idea of the algorithm was.
> 
> Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>

Reviewed-by: George Dunlap <george.dunlap@citrix.com>

> ---
> Cc: George Dunlap <george.dunlap@eu.citrix.com>
> Cc: Anshul Makkar <anshul.makkar@citrix.com>
> ---
> Changes from v1:
>  * new patch, containing part of what was in patch 5;
>  * (wrt v1 patch 5) 'pos' parameter to runq_candidate renamed 'skipped', as
>    requested during review.
> ---
>  xen/common/sched_credit2.c |   33 ++++++++++++++++++++++++++++-----
>  1 file changed, 28 insertions(+), 5 deletions(-)
> 
> diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c
> index 3986441..72e31b5 100644
> --- a/xen/common/sched_credit2.c
> +++ b/xen/common/sched_credit2.c
> @@ -2244,12 +2244,15 @@ void __dump_execstate(void *unused);
>  static struct csched2_vcpu *
>  runq_candidate(struct csched2_runqueue_data *rqd,
>                 struct csched2_vcpu *scurr,
> -               int cpu, s_time_t now)
> +               int cpu, s_time_t now,
> +               unsigned int *skipped)
>  {
>      struct list_head *iter;
>      struct csched2_vcpu *snext = NULL;
>      struct csched2_private *prv = CSCHED2_PRIV(per_cpu(scheduler, cpu));
>  
> +    *skipped = 0;
> +
>      /* Default to current if runnable, idle otherwise */
>      if ( vcpu_runnable(scurr->vcpu) )
>          snext = scurr;
> @@ -2273,7 +2276,10 @@ runq_candidate(struct csched2_runqueue_data *rqd,
>  
>          /* Only consider vcpus that are allowed to run on this processor. */
>          if ( !cpumask_test_cpu(cpu, svc->vcpu->cpu_hard_affinity) )
> +        {
> +            (*skipped)++;
>              continue;
> +        }
>  
>          /*
>           * If a vcpu is meant to be picked up by another processor, and such
> @@ -2282,6 +2288,7 @@ runq_candidate(struct csched2_runqueue_data *rqd,
>          if ( svc->tickled_cpu != -1 && svc->tickled_cpu != cpu &&
>               cpumask_test_cpu(svc->tickled_cpu, &rqd->tickled) )
>          {
> +            (*skipped)++;
>              SCHED_STAT_CRANK(deferred_to_tickled_cpu);
>              continue;
>          }
> @@ -2291,6 +2298,7 @@ runq_candidate(struct csched2_runqueue_data *rqd,
>          if ( svc->vcpu->processor != cpu
>               && snext->credit + CSCHED2_MIGRATE_RESIST > svc->credit )
>          {
> +            (*skipped)++;
>              SCHED_STAT_CRANK(migrate_resisted);
>              continue;
>          }
> @@ -2308,11 +2316,12 @@ runq_candidate(struct csched2_runqueue_data *rqd,
>      {
>          struct {
>              unsigned vcpu:16, dom:16;
> -            unsigned tickled_cpu;
> +            unsigned tickled_cpu, skipped;
>          } d;
>          d.dom = snext->vcpu->domain->domain_id;
>          d.vcpu = snext->vcpu->vcpu_id;
>          d.tickled_cpu = snext->tickled_cpu;
> +        d.skipped = *skipped;
>          __trace_var(TRC_CSCHED2_RUNQ_CANDIDATE, 1,
>                      sizeof(d),
>                      (unsigned char *)&d);
> @@ -2336,6 +2345,7 @@ csched2_schedule(
>      struct csched2_runqueue_data *rqd;
>      struct csched2_vcpu * const scurr = CSCHED2_VCPU(current);
>      struct csched2_vcpu *snext = NULL;
> +    unsigned int skipped_vcpus = 0;
>      struct task_slice ret;
>  
>      SCHED_STAT_CRANK(schedule);
> @@ -2385,7 +2395,7 @@ csched2_schedule(
>          snext = CSCHED2_VCPU(idle_vcpu[cpu]);
>      }
>      else
> -        snext = runq_candidate(rqd, scurr, cpu, now);
> +        snext = runq_candidate(rqd, scurr, cpu, now, &skipped_vcpus);
>  
>      /* If switching from a non-idle runnable vcpu, put it
>       * back on the runqueue. */
> @@ -2409,8 +2419,21 @@ csched2_schedule(
>              __set_bit(__CSFLAG_scheduled, &snext->flags);
>          }
>  
> -        /* Check for the reset condition */
> -        if ( snext->credit <= CSCHED2_CREDIT_RESET )
> +        /*
> +         * The reset condition is "has a scheduler epoch come to an end?".
> +         * The way this is enforced is checking whether the vcpu at the top
> +         * of the runqueue has negative credits. This means the epochs have
> +         * variable lenght, as in one epoch expores when:
> +         *  1) the vcpu at the top of the runqueue has executed for
> +         *     around 10 ms (with default parameters);
> +         *  2) no other vcpu with higher credits wants to run.
> +         *
> +         * Here, where we want to check for reset, we need to make sure the
> +         * proper vcpu is being used. In fact, runqueue_candidate() may have
> +         * not returned the first vcpu in the runqueue, for various reasons
> +         * (e.g., affinity). Only trigger a reset when it does.
> +         */
> +        if ( skipped_vcpus == 0 && snext->credit <= CSCHED2_CREDIT_RESET )
>          {
>              reset_credit(ops, cpu, now, snext);
>              balance_load(ops, cpu, now);
> 


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2016-09-30 11:28 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-30  2:53 [PATCH v2 00/10] sched: Credit1 and Credit2 improvements... but *NO* soft-affinity for Credit2! Dario Faggioli
2016-09-30  2:53 ` [PATCH v2 01/10] xen: credit1: return the 'time remaining to the limit' as next timeslice Dario Faggioli
2016-09-30 11:16   ` George Dunlap
2016-09-30  2:53 ` [PATCH v2 02/10] xen: credit1: don't rate limit context switches in case of yields Dario Faggioli
2016-09-30 11:18   ` George Dunlap
2016-09-30  2:53 ` [PATCH v2 03/10] xen: credit2: make tickling more deterministic Dario Faggioli
2016-09-30 11:25   ` George Dunlap
2016-09-30  2:53 ` [PATCH v2 04/10] xen: credit2: only reset credit on reset condition Dario Faggioli
2016-09-30 11:28   ` George Dunlap [this message]
2016-09-30 12:25   ` anshul makkar
2016-09-30 12:57     ` Dario Faggioli
2016-09-30  2:53 ` [PATCH v2 05/10] xen: credit2: implement yield() Dario Faggioli
2016-09-30 12:52   ` George Dunlap
2016-09-30 14:01     ` Dario Faggioli
2016-09-30  2:54 ` [PATCH v2 06/10] xen: tracing: add trace records for schedule and rate-limiting Dario Faggioli
2016-09-30 13:16   ` George Dunlap
2016-10-01  0:18   ` Meng Xu
2016-09-30  2:54 ` [PATCH v2 07/10] tools: tracing: handle more scheduling related events Dario Faggioli
2016-09-30 10:22   ` Ian Jackson
2016-09-30  2:54 ` [PATCH v2 08/10] libxl: fix coding style of credit1 parameters related functions Dario Faggioli
2016-09-30 10:24   ` Ian Jackson
2016-09-30 12:04     ` Dario Faggioli
2016-09-30 13:25       ` George Dunlap
2016-09-30  2:54 ` [PATCH v2 09/10] libxl: allow to set the ratelimit value online for Credit2 Dario Faggioli
2016-09-30 10:30   ` Ian Jackson
2016-09-30 10:33     ` George Dunlap
2016-09-30 10:35       ` Ian Jackson
2016-09-30 12:37       ` Dario Faggioli
2016-09-30  2:54 ` [PATCH v2 10/10] xl: " Dario Faggioli
2016-09-30 10:34   ` Ian Jackson
2016-09-30 15:54     ` Dario Faggioli
2016-09-30 16:02       ` Ian Jackson
2016-10-13 22:19   ` Jim Fehlig
2016-10-14 11:31     ` George Dunlap
2016-09-30 13:51 ` [PATCH v2 00/10] sched: Credit1 and Credit2 improvements... but *NO* soft-affinity for Credit2! George Dunlap
2016-09-30 14:06   ` Dario Faggioli
2016-09-30 14:10     ` George Dunlap
2016-09-30 14:12       ` Dario Faggioli

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=764d297c-854e-a33c-4e7b-191ab0027469@citrix.com \
    --to=george.dunlap@citrix.com \
    --cc=anshul.makkar@citrix.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).