From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125913; cv=none; d=zoho.com; s=zohoarc; b=CLoubL6f6JWYd0LP50jWwlAmOri9T1R48HdHTzgFFNBLPqz1ABCJwfF4TiMH5Nc6k51BmCxnVvaZsXKg+iDBHBDI/fo3fSM/lO7Oh+odBy5wshqt2cAZqWycECx/vGjto410Wk9yf696vrJn2TjVhmq8bybBJEyOtESKE5YQqzQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125913; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=BdRM63Er255TenQAobPUUdlylH9vKHGEaydAmZM41uY=; b=CQrXz1Irl6dJ1ObNmQXEgDJ8DA+f6t7tVcij3Wu8ZY8jrfipGAcCQxpt59y+sf9xWDWxjKmcNBATO9iU4kONC+RDjVGFoZ4q2crVWZrz71PJuxSLJiX/WYMW66iyjKnTRQQSBh0lkQorY8NxxVFzHQGuy4GPaHY7wLSkUx3C8os= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125913669626.0712756293841; Sun, 5 May 2019 23:58:33 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYU-0001sM-AO; Mon, 06 May 2019 06:56:54 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYT-0001s1-Fv for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:56:53 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 1ecbb955-6fcc-11e9-843c-bc764e045a96; Mon, 06 May 2019 06:56:50 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 8314DABC7; Mon, 6 May 2019 06:56:48 +0000 (UTC) X-Inumbo-ID: 1ecbb955-6fcc-11e9-843c-bc764e045a96 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:00 +0200 Message-Id: <20190506065644.7415-2-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 01/45] xen/sched: add inline wrappers for calling per-scheduler functions X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Tim Deegan , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Dario Faggioli , Julien Grall , Jan Beulich MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Instead of using the SCHED_OP() macro to call the different scheduler specific functions add inline wrappers for that purpose. Signed-off-by: Juergen Gross --- RFC V2: new patch (Andrew Cooper) --- xen/common/schedule.c | 104 ++++++++++++-------------- xen/include/xen/sched-if.h | 178 +++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 226 insertions(+), 56 deletions(-) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 66f1e2611b..35a40a40c8 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -73,10 +73,6 @@ extern const struct scheduler *__start_schedulers_array[= ], *__end_schedulers_arr =20 static struct scheduler __read_mostly ops; =20 -#define SCHED_OP(opsptr, fn, ...) = \ - (( (opsptr)->fn !=3D NULL ) ? (opsptr)->fn(opsptr, ##__VA_ARGS__ = ) \ - : (typeof((opsptr)->fn(opsptr, ##__VA_ARGS__)))0 ) - static inline struct scheduler *dom_scheduler(const struct domain *d) { if ( likely(d->cpupool !=3D NULL) ) @@ -267,8 +263,7 @@ int sched_init_vcpu(struct vcpu *v, unsigned int proces= sor) init_timer(&v->poll_timer, poll_timer_fn, v, v->processor); =20 - v->sched_priv =3D SCHED_OP(dom_scheduler(d), alloc_vdata, v, - d->sched_priv); + v->sched_priv =3D sched_alloc_vdata(dom_scheduler(d), v, d->sched_priv= ); if ( v->sched_priv =3D=3D NULL ) return 1; =20 @@ -289,7 +284,7 @@ int sched_init_vcpu(struct vcpu *v, unsigned int proces= sor) } else { - SCHED_OP(dom_scheduler(d), insert_vcpu, v); + sched_insert_vcpu(dom_scheduler(d), v); } =20 return 0; @@ -330,7 +325,7 @@ int sched_move_domain(struct domain *d, struct cpupool = *c) =20 for_each_vcpu ( d, v ) { - vcpu_priv[v->vcpu_id] =3D SCHED_OP(c->sched, alloc_vdata, v, domda= ta); + vcpu_priv[v->vcpu_id] =3D sched_alloc_vdata(c->sched, v, domdata); if ( vcpu_priv[v->vcpu_id] =3D=3D NULL ) { for_each_vcpu ( d, v ) @@ -348,7 +343,7 @@ int sched_move_domain(struct domain *d, struct cpupool = *c) =20 for_each_vcpu ( d, v ) { - SCHED_OP(old_ops, remove_vcpu, v); + sched_remove_vcpu(old_ops, v); } =20 d->cpupool =3D c; @@ -383,9 +378,9 @@ int sched_move_domain(struct domain *d, struct cpupool = *c) =20 new_p =3D cpumask_cycle(new_p, c->cpu_valid); =20 - SCHED_OP(c->sched, insert_vcpu, v); + sched_insert_vcpu(c->sched, v); =20 - SCHED_OP(old_ops, free_vdata, vcpudata); + sched_free_vdata(old_ops, vcpudata); } =20 domain_update_node_affinity(d); @@ -406,8 +401,8 @@ void sched_destroy_vcpu(struct vcpu *v) kill_timer(&v->poll_timer); if ( test_and_clear_bool(v->is_urgent) ) atomic_dec(&per_cpu(schedule_data, v->processor).urgent_count); - SCHED_OP(vcpu_scheduler(v), remove_vcpu, v); - SCHED_OP(vcpu_scheduler(v), free_vdata, v->sched_priv); + sched_remove_vcpu(vcpu_scheduler(v), v); + sched_free_vdata(vcpu_scheduler(v), v->sched_priv); } =20 int sched_init_domain(struct domain *d, int poolid) @@ -458,7 +453,7 @@ void vcpu_sleep_nosync_locked(struct vcpu *v) if ( v->runstate.state =3D=3D RUNSTATE_runnable ) vcpu_runstate_change(v, RUNSTATE_offline, NOW()); =20 - SCHED_OP(vcpu_scheduler(v), sleep, v); + sched_sleep(vcpu_scheduler(v), v); } } =20 @@ -499,7 +494,7 @@ void vcpu_wake(struct vcpu *v) { if ( v->runstate.state >=3D RUNSTATE_blocked ) vcpu_runstate_change(v, RUNSTATE_runnable, NOW()); - SCHED_OP(vcpu_scheduler(v), wake, v); + sched_wake(vcpu_scheduler(v), v); } else if ( !(v->pause_flags & VPF_blocked) ) { @@ -552,19 +547,16 @@ static void vcpu_move_locked(struct vcpu *v, unsigned= int new_cpu) =20 /* * Actual CPU switch to new CPU. This is safe because the lock - * pointer cant' change while the current lock is held. + * pointer can't change while the current lock is held. */ - if ( vcpu_scheduler(v)->migrate ) - SCHED_OP(vcpu_scheduler(v), migrate, v, new_cpu); - else - v->processor =3D new_cpu; + sched_migrate(vcpu_scheduler(v), v, new_cpu); } =20 /* * Initiating migration * * In order to migrate, we need the vcpu in question to have stopped - * running and had SCHED_OP(sleep) called (to take it off any + * running and had sched_sleep() called (to take it off any * runqueues, for instance); and if it is currently running, it needs * to be scheduled out. Finally, we need to hold the scheduling locks * for both the processor we're migrating from, and the processor @@ -635,7 +627,7 @@ static void vcpu_migrate_finish(struct vcpu *v) break; =20 /* Select a new CPU. */ - new_cpu =3D SCHED_OP(vcpu_scheduler(v), pick_cpu, v); + new_cpu =3D sched_pick_cpu(vcpu_scheduler(v), v); if ( (new_lock =3D=3D per_cpu(schedule_data, new_cpu).schedule= _lock) && cpumask_test_cpu(new_cpu, v->domain->cpupool->cpu_valid) ) break; @@ -740,7 +732,7 @@ void restore_vcpu_affinity(struct domain *d) v->processor =3D cpumask_any(cpumask_scratch_cpu(cpu)); =20 lock =3D vcpu_schedule_lock_irq(v); - v->processor =3D SCHED_OP(vcpu_scheduler(v), pick_cpu, v); + v->processor =3D sched_pick_cpu(vcpu_scheduler(v), v); spin_unlock_irq(lock); =20 if ( old_cpu !=3D v->processor ) @@ -852,7 +844,7 @@ static int cpu_disable_scheduler_check(unsigned int cpu) void sched_set_affinity( struct vcpu *v, const cpumask_t *hard, const cpumask_t *soft) { - SCHED_OP(dom_scheduler(v->domain), adjust_affinity, v, hard, soft); + sched_adjust_affinity(dom_scheduler(v->domain), v, hard, soft); =20 if ( hard ) cpumask_copy(v->cpu_hard_affinity, hard); @@ -1027,7 +1019,7 @@ long vcpu_yield(void) struct vcpu * v=3Dcurrent; spinlock_t *lock =3D vcpu_schedule_lock_irq(v); =20 - SCHED_OP(vcpu_scheduler(v), yield, v); + sched_yield(vcpu_scheduler(v), v); vcpu_schedule_unlock_irq(lock, v); =20 SCHED_STAT_CRANK(vcpu_yield); @@ -1352,7 +1344,7 @@ long sched_adjust(struct domain *d, struct xen_domctl= _scheduler_op *op) =20 /* NB: the pluggable scheduler code needs to take care * of locking by itself. */ - if ( (ret =3D SCHED_OP(dom_scheduler(d), adjust, d, op)) =3D=3D 0 ) + if ( (ret =3D sched_adjust_dom(dom_scheduler(d), d, op)) =3D=3D 0 ) TRACE_1D(TRC_SCHED_ADJDOM, d->domain_id); =20 return ret; @@ -1376,7 +1368,7 @@ long sched_adjust_global(struct xen_sysctl_scheduler_= op *op) return -ESRCH; =20 rc =3D ((op->sched_id =3D=3D pool->sched->sched_id) - ? SCHED_OP(pool->sched, adjust_global, op) : -EINVAL); + ? sched_adjust_cpupool(pool->sched, op) : -EINVAL); =20 cpupool_put(pool); =20 @@ -1530,7 +1522,7 @@ void context_saved(struct vcpu *prev) /* Check for migration request /after/ clearing running flag. */ smp_mb(); =20 - SCHED_OP(vcpu_scheduler(prev), context_saved, prev); + sched_context_saved(vcpu_scheduler(prev), prev); =20 vcpu_migrate_finish(prev); } @@ -1599,8 +1591,8 @@ static int cpu_schedule_up(unsigned int cpu) */ ASSERT(idle->sched_priv =3D=3D NULL); =20 - idle->sched_priv =3D SCHED_OP(&ops, alloc_vdata, idle, - idle->domain->sched_priv); + idle->sched_priv =3D sched_alloc_vdata(&ops, idle, + idle->domain->sched_priv); if ( idle->sched_priv =3D=3D NULL ) return -ENOMEM; } @@ -1612,7 +1604,7 @@ static int cpu_schedule_up(unsigned int cpu) * (e.g., inside free_pdata, from cpu_schedule_down() called * during CPU_UP_CANCELLED) that contains an IS_ERR value. */ - sched_priv =3D SCHED_OP(&ops, alloc_pdata, cpu); + sched_priv =3D sched_alloc_pdata(&ops, cpu); if ( IS_ERR(sched_priv) ) return PTR_ERR(sched_priv); =20 @@ -1626,8 +1618,8 @@ static void cpu_schedule_down(unsigned int cpu) struct schedule_data *sd =3D &per_cpu(schedule_data, cpu); struct scheduler *sched =3D per_cpu(scheduler, cpu); =20 - SCHED_OP(sched, free_pdata, sd->sched_priv, cpu); - SCHED_OP(sched, free_vdata, idle_vcpu[cpu]->sched_priv); + sched_free_pdata(sched, sd->sched_priv, cpu); + sched_free_vdata(sched, idle_vcpu[cpu]->sched_priv); =20 idle_vcpu[cpu]->sched_priv =3D NULL; sd->sched_priv =3D NULL; @@ -1679,7 +1671,7 @@ static int cpu_schedule_callback( { case CPU_STARTING: if ( system_state !=3D SYS_STATE_resume ) - SCHED_OP(sched, init_pdata, sd->sched_priv, cpu); + sched_init_pdata(sched, sd->sched_priv, cpu); break; case CPU_UP_PREPARE: if ( system_state !=3D SYS_STATE_resume ) @@ -1698,7 +1690,7 @@ static int cpu_schedule_callback( rc =3D cpu_disable_scheduler(cpu); BUG_ON(rc); rcu_read_unlock(&domlist_read_lock); - SCHED_OP(sched, deinit_pdata, sd->sched_priv, cpu); + sched_deinit_pdata(sched, sd->sched_priv, cpu); cpu_schedule_down(cpu); break; case CPU_UP_CANCELED: @@ -1751,7 +1743,7 @@ void __init scheduler_init(void) register_cpu_notifier(&cpu_schedule_nfb); =20 printk("Using scheduler: %s (%s)\n", ops.name, ops.opt_name); - if ( SCHED_OP(&ops, init) ) + if ( sched_init(&ops) ) panic("scheduler returned error on init\n"); =20 if ( sched_ratelimit_us && @@ -1773,9 +1765,9 @@ void __init scheduler_init(void) idle_domain->max_vcpus =3D nr_cpu_ids; if ( vcpu_create(idle_domain, 0, 0) =3D=3D NULL ) BUG(); - this_cpu(schedule_data).sched_priv =3D SCHED_OP(&ops, alloc_pdata, 0); + this_cpu(schedule_data).sched_priv =3D sched_alloc_pdata(&ops, 0); BUG_ON(IS_ERR(this_cpu(schedule_data).sched_priv)); - SCHED_OP(&ops, init_pdata, this_cpu(schedule_data).sched_priv, 0); + sched_init_pdata(&ops, this_cpu(schedule_data).sched_priv, 0); } =20 /* @@ -1818,26 +1810,26 @@ int schedule_cpu_switch(unsigned int cpu, struct cp= upool *c) /* * To setup the cpu for the new scheduler we need: * - a valid instance of per-CPU scheduler specific data, as it is - * allocated by SCHED_OP(alloc_pdata). Note that we do not want to - * initialize it yet (i.e., we are not calling SCHED_OP(init_pdata)= ). - * That will be done by the target scheduler, in SCHED_OP(switch_sc= hed), + * allocated by sched_alloc_pdata(). Note that we do not want to + * initialize it yet (i.e., we are not calling sched_init_pdata()). + * That will be done by the target scheduler, in sched_switch_sched= (), * in proper ordering and with locking. * - a valid instance of per-vCPU scheduler specific data, for the id= le * vCPU of cpu. That is what the target scheduler will use for the * sched_priv field of the per-vCPU info of the idle domain. */ idle =3D idle_vcpu[cpu]; - ppriv =3D SCHED_OP(new_ops, alloc_pdata, cpu); + ppriv =3D sched_alloc_pdata(new_ops, cpu); if ( IS_ERR(ppriv) ) return PTR_ERR(ppriv); - vpriv =3D SCHED_OP(new_ops, alloc_vdata, idle, idle->domain->sched_pri= v); + vpriv =3D sched_alloc_vdata(new_ops, idle, idle->domain->sched_priv); if ( vpriv =3D=3D NULL ) { - SCHED_OP(new_ops, free_pdata, ppriv, cpu); + sched_free_pdata(new_ops, ppriv, cpu); return -ENOMEM; } =20 - SCHED_OP(old_ops, tick_suspend, cpu); + sched_do_tick_suspend(old_ops, cpu); =20 /* * The actual switch, including (if necessary) the rerouting of the @@ -1855,17 +1847,17 @@ int schedule_cpu_switch(unsigned int cpu, struct cp= upool *c) =20 vpriv_old =3D idle->sched_priv; ppriv_old =3D per_cpu(schedule_data, cpu).sched_priv; - SCHED_OP(new_ops, switch_sched, cpu, ppriv, vpriv); + sched_switch_sched(new_ops, cpu, ppriv, vpriv); =20 /* _Not_ pcpu_schedule_unlock(): schedule_lock may have changed! */ spin_unlock_irq(old_lock); =20 - SCHED_OP(new_ops, tick_resume, cpu); + sched_do_tick_resume(new_ops, cpu); =20 - SCHED_OP(old_ops, deinit_pdata, ppriv_old, cpu); + sched_deinit_pdata(old_ops, ppriv_old, cpu); =20 - SCHED_OP(old_ops, free_vdata, vpriv_old); - SCHED_OP(old_ops, free_pdata, ppriv_old, cpu); + sched_free_vdata(old_ops, vpriv_old); + sched_free_pdata(old_ops, ppriv_old, cpu); =20 out: per_cpu(cpupool, cpu) =3D c; @@ -1897,7 +1889,7 @@ struct scheduler *scheduler_alloc(unsigned int sched_= id, int *perr) if ( (sched =3D xmalloc(struct scheduler)) =3D=3D NULL ) return NULL; memcpy(sched, schedulers[i], sizeof(*sched)); - if ( (*perr =3D SCHED_OP(sched, init)) !=3D 0 ) + if ( (*perr =3D sched_init(sched)) !=3D 0 ) { xfree(sched); sched =3D NULL; @@ -1909,7 +1901,7 @@ struct scheduler *scheduler_alloc(unsigned int sched_= id, int *perr) void scheduler_free(struct scheduler *sched) { BUG_ON(sched =3D=3D &ops); - SCHED_OP(sched, deinit); + sched_deinit(sched); xfree(sched); } =20 @@ -1926,7 +1918,7 @@ void schedule_dump(struct cpupool *c) sched =3D c->sched; cpus =3D c->cpu_valid; printk("Scheduler: %s (%s)\n", sched->name, sched->opt_name); - SCHED_OP(sched, dump_settings); + sched_dump_settings(sched); } else { @@ -1938,7 +1930,7 @@ void schedule_dump(struct cpupool *c) { printk("CPUs info:\n"); for_each_cpu (i, cpus) - SCHED_OP(sched, dump_cpu_state, i); + sched_dump_cpu_state(sched, i); } } =20 @@ -1948,7 +1940,7 @@ void sched_tick_suspend(void) unsigned int cpu =3D smp_processor_id(); =20 sched =3D per_cpu(scheduler, cpu); - SCHED_OP(sched, tick_suspend, cpu); + sched_do_tick_suspend(sched, cpu); rcu_idle_enter(cpu); rcu_idle_timer_start(); } @@ -1961,7 +1953,7 @@ void sched_tick_resume(void) rcu_idle_timer_stop(); rcu_idle_exit(cpu); sched =3D per_cpu(scheduler, cpu); - SCHED_OP(sched, tick_resume, cpu); + sched_do_tick_resume(sched, cpu); } =20 void wait(void) diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index 92bc7a0365..593cd79297 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -185,6 +185,49 @@ struct scheduler { void (*tick_resume) (const struct scheduler *, unsigned in= t); }; =20 +static inline int sched_init(struct scheduler *s) +{ + ASSERT(s->init); + return s->init(s); +} + +static inline void sched_deinit(struct scheduler *s) +{ + ASSERT(s->deinit); + s->deinit(s); +} + +static inline void sched_switch_sched(struct scheduler *s, unsigned int cp= u, + void *pdata, void *vdata) +{ + if ( s->switch_sched ) + s->switch_sched(s, cpu, pdata, vdata); +} + +static inline void sched_dump_settings(const struct scheduler *s) +{ + if ( s->dump_settings ) + s->dump_settings(s); +} + +static inline void sched_dump_cpu_state(const struct scheduler *s, int cpu) +{ + if ( s->dump_cpu_state ) + s->dump_cpu_state(s, cpu); +} + +static inline void sched_do_tick_suspend(const struct scheduler *s, int cp= u) +{ + if ( s->tick_suspend ) + s->tick_suspend(s, cpu); +} + +static inline void sched_do_tick_resume(const struct scheduler *s, int cpu) +{ + if ( s->tick_resume ) + s->tick_resume(s, cpu); +} + static inline void *sched_alloc_domdata(const struct scheduler *s, struct domain *d) { @@ -207,6 +250,141 @@ static inline void sched_free_domdata(const struct sc= heduler *s, ASSERT(!data); } =20 +static inline void *sched_alloc_pdata(const struct scheduler *s, int cpu) +{ + if ( s->alloc_pdata ) + return s->alloc_pdata(s, cpu); + else + return NULL; +} + +static inline void sched_free_pdata(const struct scheduler *s, void *data, + int cpu) +{ + if ( s->free_pdata ) + s->free_pdata(s, data, cpu); + else + /* + * Check that if there isn't a free_pdata hook, we haven't got any + * data we're expected to deal with. + */ + ASSERT(!data); +} + +static inline void sched_init_pdata(const struct scheduler *s, void *data, + int cpu) +{ + if ( s->init_pdata ) + s->init_pdata(s, data, cpu); +} + +static inline void sched_deinit_pdata(const struct scheduler *s, void *dat= a, + int cpu) +{ + if ( s->deinit_pdata ) + s->deinit_pdata(s, data, cpu); +} + +static inline void *sched_alloc_vdata(const struct scheduler *s, struct vc= pu *v, + void *dom_data) +{ + if ( s->alloc_vdata ) + return s->alloc_vdata(s, v, dom_data); + else + return NULL; +} + +static inline void sched_free_vdata(const struct scheduler *s, void *data) +{ + if ( s->free_vdata ) + s->free_vdata(s, data); + else + /* + * Check that if there isn't a free_vdata hook, we haven't got any + * data we're expected to deal with. + */ + ASSERT(!data); +} + +static inline void sched_insert_vcpu(const struct scheduler *s, struct vcp= u *v) +{ + if ( s->insert_vcpu ) + s->insert_vcpu(s, v); +} + +static inline void sched_remove_vcpu(const struct scheduler *s, struct vcp= u *v) +{ + if ( s->remove_vcpu ) + s->remove_vcpu(s, v); +} + +static inline void sched_sleep(const struct scheduler *s, struct vcpu *v) +{ + if ( s->sleep ) + s->sleep(s, v); +} + +static inline void sched_wake(const struct scheduler *s, struct vcpu *v) +{ + if ( s->wake ) + s->wake(s, v); +} + +static inline void sched_yield(const struct scheduler *s, struct vcpu *v) +{ + if ( s->yield ) + s->yield(s, v); +} + +static inline void sched_context_saved(const struct scheduler *s, + struct vcpu *v) +{ + if ( s->context_saved ) + s->context_saved(s, v); +} + +static inline void sched_migrate(const struct scheduler *s, struct vcpu *v, + unsigned int cpu) +{ + if ( s->migrate ) + s->migrate(s, v, cpu); + else + v->processor =3D cpu; +} + +static inline int sched_pick_cpu(const struct scheduler *s, struct vcpu *v) +{ + ASSERT(s->pick_cpu); + return s->pick_cpu(s, v); +} + +static inline void sched_adjust_affinity(const struct scheduler *s, + struct vcpu *v, + const cpumask_t *hard, + const cpumask_t *soft) +{ + if ( s->adjust_affinity ) + s->adjust_affinity(s, v, hard, soft); +} + +static inline int sched_adjust_dom(const struct scheduler *s, struct domai= n *d, + struct xen_domctl_scheduler_op *op) +{ + if ( s->adjust ) + return s->adjust(s, d, op); + else + return 0; +} + +static inline int sched_adjust_cpupool(const struct scheduler *s, + struct xen_sysctl_scheduler_op *op) +{ + if ( s->adjust_global ) + return s->adjust_global(s, op); + else + return 0; +} + #define REGISTER_SCHEDULER(x) static const struct scheduler *x##_entry \ __used_section(".data.schedulers") =3D &x; =20 --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125905; cv=none; d=zoho.com; s=zohoarc; b=TQAbi1VfQrOQyY0jJNA372jUdfmi5MYh7Hfa+3Apg9BA2ioaJzQnBaffzqnh0mEJBZfvVpbYeP7TzeH35kGOcoqFKtW3vtxICa9LO6BQmVe0B0FCiBFg5eOomxGRr+WqCIahieOFn5LFF2f4nBb9lWxnnOzUpm8Svlwy/nndlBw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125905; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=tsMO2aE8wO6N352lEkkPl/8zALKBkVlMdURYUHsiDDU=; b=SyJKDitG/KeEAPm00oyAKc77w0O9RflcL4ZXdyTtUM0p5t799jFhiDVUZ5xp72gj131DNHID3udVBmbYS4ivusUFJBzMg16h6IN5CHHIWhQJ0jkQfOnrilVeUYZOQGQj7+JC+PT+bEPgWUmQuFtS0lZWjCHpkysUN5qFbwvmm+I= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 155712590589820.5454714553116; Sun, 5 May 2019 23:58:25 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYW-0001sx-NK; Mon, 06 May 2019 06:56:56 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYV-0001sh-52 for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:56:55 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 1ecbb7a7-6fcc-11e9-843c-bc764e045a96; Mon, 06 May 2019 06:56:50 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id B4AC2AC8E; Mon, 6 May 2019 06:56:48 +0000 (UTC) X-Inumbo-ID: 1ecbb7a7-6fcc-11e9-843c-bc764e045a96 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:01 +0200 Message-Id: <20190506065644.7415-3-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 02/45] xen/sched: use new sched_item instead of vcpu in scheduler interfaces X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Tim Deegan , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Robert VanVossen , Dario Faggioli , Julien Grall , Josh Whitehead , Meng Xu , Jan Beulich MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" In order to prepare core- and socket-scheduling use a new struct sched_item instead of struct vcpu for interfaces of the different schedulers. Rename the per-scheduler functions insert_vcpu and remove_vcpu to insert_item and remove_item to reflect the change of the parameter. In the schedulers rename local functions switched to sched_item, too. For now this new struct will contain a vcpu pointer only and is allocated on the stack. This will be changed later. Signed-off-by: Juergen Gross --- RFC V2: - move definition of struct sched_item to sched.h (Andrew Cooper) --- xen/common/sched_arinc653.c | 30 +++++++++------ xen/common/sched_credit.c | 41 ++++++++++++-------- xen/common/sched_credit2.c | 57 ++++++++++++++++------------ xen/common/sched_null.c | 39 ++++++++++++------- xen/common/sched_rt.c | 33 +++++++++------- xen/common/schedule.c | 53 ++++++++++++++++++-------- xen/include/xen/sched-if.h | 92 ++++++++++++++++++++++++++---------------= ---- xen/include/xen/sched.h | 4 ++ 8 files changed, 218 insertions(+), 131 deletions(-) diff --git a/xen/common/sched_arinc653.c b/xen/common/sched_arinc653.c index a4c6d00b81..fffe23113e 100644 --- a/xen/common/sched_arinc653.c +++ b/xen/common/sched_arinc653.c @@ -376,13 +376,16 @@ a653sched_deinit(struct scheduler *ops) * This function allocates scheduler-specific data for a VCPU * * @param ops Pointer to this instance of the scheduler structure + * @param item Pointer to struct sched_item * * @return Pointer to the allocated data */ static void * -a653sched_alloc_vdata(const struct scheduler *ops, struct vcpu *vc, void *= dd) +a653sched_alloc_vdata(const struct scheduler *ops, struct sched_item *item, + void *dd) { a653sched_priv_t *sched_priv =3D SCHED_PRIV(ops); + struct vcpu *vc =3D item->vcpu; arinc653_vcpu_t *svc; unsigned int entry; unsigned long flags; @@ -458,11 +461,13 @@ a653sched_free_vdata(const struct scheduler *ops, voi= d *priv) * Xen scheduler callback function to sleep a VCPU * * @param ops Pointer to this instance of the scheduler structure - * @param vc Pointer to the VCPU structure for the current domain + * @param item Pointer to struct sched_item */ static void -a653sched_vcpu_sleep(const struct scheduler *ops, struct vcpu *vc) +a653sched_item_sleep(const struct scheduler *ops, struct sched_item *item) { + struct vcpu *vc =3D item->vcpu; + if ( AVCPU(vc) !=3D NULL ) AVCPU(vc)->awake =3D 0; =20 @@ -478,11 +483,13 @@ a653sched_vcpu_sleep(const struct scheduler *ops, str= uct vcpu *vc) * Xen scheduler callback function to wake up a VCPU * * @param ops Pointer to this instance of the scheduler structure - * @param vc Pointer to the VCPU structure for the current domain + * @param item Pointer to struct sched_item */ static void -a653sched_vcpu_wake(const struct scheduler *ops, struct vcpu *vc) +a653sched_item_wake(const struct scheduler *ops, struct sched_item *item) { + struct vcpu *vc =3D item->vcpu; + if ( AVCPU(vc) !=3D NULL ) AVCPU(vc)->awake =3D 1; =20 @@ -597,13 +604,14 @@ a653sched_do_schedule( * Xen scheduler callback function to select a CPU for the VCPU to run on * * @param ops Pointer to this instance of the scheduler structure - * @param v Pointer to the VCPU structure for the current domain + * @param item Pointer to struct sched_item * * @return Number of selected physical CPU */ static int -a653sched_pick_cpu(const struct scheduler *ops, struct vcpu *vc) +a653sched_pick_cpu(const struct scheduler *ops, struct sched_item *item) { + struct vcpu *vc =3D item->vcpu; cpumask_t *online; unsigned int cpu; =20 @@ -712,11 +720,11 @@ static const struct scheduler sched_arinc653_def =3D { .free_vdata =3D a653sched_free_vdata, .alloc_vdata =3D a653sched_alloc_vdata, =20 - .insert_vcpu =3D NULL, - .remove_vcpu =3D NULL, + .insert_item =3D NULL, + .remove_item =3D NULL, =20 - .sleep =3D a653sched_vcpu_sleep, - .wake =3D a653sched_vcpu_wake, + .sleep =3D a653sched_item_sleep, + .wake =3D a653sched_item_wake, .yield =3D NULL, .context_saved =3D NULL, =20 diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index 3abe20def8..3735486b4c 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -868,15 +868,16 @@ _csched_cpu_pick(const struct scheduler *ops, struct = vcpu *vc, bool_t commit) } =20 static int -csched_cpu_pick(const struct scheduler *ops, struct vcpu *vc) +csched_cpu_pick(const struct scheduler *ops, struct sched_item *item) { + struct vcpu *vc =3D item->vcpu; struct csched_vcpu *svc =3D CSCHED_VCPU(vc); =20 /* * We have been called by vcpu_migrate() (in schedule.c), as part * of the process of seeing if vc can be migrated to another pcpu. * We make a note about this in svc->flags so that later, in - * csched_vcpu_wake() (still called from vcpu_migrate()) we won't + * csched_item_wake() (still called from vcpu_migrate()) we won't * get boosted, which we don't deserve as we are "only" migrating. */ set_bit(CSCHED_FLAG_VCPU_MIGRATING, &svc->flags); @@ -1004,8 +1005,10 @@ csched_vcpu_acct(struct csched_private *prv, unsigne= d int cpu) } =20 static void * -csched_alloc_vdata(const struct scheduler *ops, struct vcpu *vc, void *dd) +csched_alloc_vdata(const struct scheduler *ops, struct sched_item *item, + void *dd) { + struct vcpu *vc =3D item->vcpu; struct csched_vcpu *svc; =20 /* Allocate per-VCPU info */ @@ -1025,8 +1028,9 @@ csched_alloc_vdata(const struct scheduler *ops, struc= t vcpu *vc, void *dd) } =20 static void -csched_vcpu_insert(const struct scheduler *ops, struct vcpu *vc) +csched_item_insert(const struct scheduler *ops, struct sched_item *item) { + struct vcpu *vc =3D item->vcpu; struct csched_vcpu *svc =3D vc->sched_priv; spinlock_t *lock; =20 @@ -1035,7 +1039,7 @@ csched_vcpu_insert(const struct scheduler *ops, struc= t vcpu *vc) /* csched_cpu_pick() looks in vc->processor's runq, so we need the loc= k. */ lock =3D vcpu_schedule_lock_irq(vc); =20 - vc->processor =3D csched_cpu_pick(ops, vc); + vc->processor =3D csched_cpu_pick(ops, item); =20 spin_unlock_irq(lock); =20 @@ -1060,9 +1064,10 @@ csched_free_vdata(const struct scheduler *ops, void = *priv) } =20 static void -csched_vcpu_remove(const struct scheduler *ops, struct vcpu *vc) +csched_item_remove(const struct scheduler *ops, struct sched_item *item) { struct csched_private *prv =3D CSCHED_PRIV(ops); + struct vcpu *vc =3D item->vcpu; struct csched_vcpu * const svc =3D CSCHED_VCPU(vc); struct csched_dom * const sdom =3D svc->sdom; =20 @@ -1087,8 +1092,9 @@ csched_vcpu_remove(const struct scheduler *ops, struc= t vcpu *vc) } =20 static void -csched_vcpu_sleep(const struct scheduler *ops, struct vcpu *vc) +csched_item_sleep(const struct scheduler *ops, struct sched_item *item) { + struct vcpu *vc =3D item->vcpu; struct csched_vcpu * const svc =3D CSCHED_VCPU(vc); unsigned int cpu =3D vc->processor; =20 @@ -1111,8 +1117,9 @@ csched_vcpu_sleep(const struct scheduler *ops, struct= vcpu *vc) } =20 static void -csched_vcpu_wake(const struct scheduler *ops, struct vcpu *vc) +csched_item_wake(const struct scheduler *ops, struct sched_item *item) { + struct vcpu *vc =3D item->vcpu; struct csched_vcpu * const svc =3D CSCHED_VCPU(vc); bool_t migrating; =20 @@ -1172,8 +1179,9 @@ csched_vcpu_wake(const struct scheduler *ops, struct = vcpu *vc) } =20 static void -csched_vcpu_yield(const struct scheduler *ops, struct vcpu *vc) +csched_item_yield(const struct scheduler *ops, struct sched_item *item) { + struct vcpu *vc =3D item->vcpu; struct csched_vcpu * const svc =3D CSCHED_VCPU(vc); =20 /* Let the scheduler know that this vcpu is trying to yield */ @@ -1226,9 +1234,10 @@ csched_dom_cntl( } =20 static void -csched_aff_cntl(const struct scheduler *ops, struct vcpu *v, +csched_aff_cntl(const struct scheduler *ops, struct sched_item *item, const cpumask_t *hard, const cpumask_t *soft) { + struct vcpu *v =3D item->vcpu; struct csched_vcpu *svc =3D CSCHED_VCPU(v); =20 if ( !hard ) @@ -1756,7 +1765,7 @@ csched_load_balance(struct csched_private *prv, int c= pu, * - if we race with inc_nr_runnable(), we skip a pCPU tha= t may * have runnable vCPUs in its runqueue, but that's not a * problem because: - * + if racing with csched_vcpu_insert() or csched_vcpu_= wake(), + * + if racing with csched_item_insert() or csched_item_= wake(), * __runq_tickle() will be called afterwords, so the v= CPU * won't get stuck in the runqueue for too long; * + if racing with csched_runq_steal(), it may be that a @@ -2268,12 +2277,12 @@ static const struct scheduler sched_credit_def =3D { =20 .global_init =3D csched_global_init, =20 - .insert_vcpu =3D csched_vcpu_insert, - .remove_vcpu =3D csched_vcpu_remove, + .insert_item =3D csched_item_insert, + .remove_item =3D csched_item_remove, =20 - .sleep =3D csched_vcpu_sleep, - .wake =3D csched_vcpu_wake, - .yield =3D csched_vcpu_yield, + .sleep =3D csched_item_sleep, + .wake =3D csched_item_wake, + .yield =3D csched_item_yield, =20 .adjust =3D csched_dom_cntl, .adjust_affinity=3D csched_aff_cntl, diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index 6958b265fc..f44286c2a5 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -273,7 +273,7 @@ * CSFLAG_delayed_runq_add: Do we need to add this to the runqueue once it= 'd done * being context switched out? * + Set when scheduling out in csched2_schedule() if prev is runnable - * + Set in csched2_vcpu_wake if it finds CSFLAG_scheduled set + * + Set in csched2_item_wake if it finds CSFLAG_scheduled set * + Read in csched2_context_saved(). If set, it adds prev to the runqueu= e and * clears the bit. */ @@ -623,14 +623,14 @@ static inline bool has_cap(const struct csched2_vcpu = *svc) * This logic is entirely implemented in runq_tickle(), and that is enough. * In fact, in this scheduler, placement of a vcpu on one of the pcpus of a * runq, _always_ happens by means of tickling: - * - when a vcpu wakes up, it calls csched2_vcpu_wake(), which calls + * - when a vcpu wakes up, it calls csched2_item_wake(), which calls * runq_tickle(); * - when a migration is initiated in schedule.c, we call csched2_cpu_pic= k(), - * csched2_vcpu_migrate() (which calls migrate()) and csched2_vcpu_wake= (). + * csched2_item_migrate() (which calls migrate()) and csched2_item_wake= (). * csched2_cpu_pick() looks for the least loaded runq and return just a= ny - * of its processors. Then, csched2_vcpu_migrate() just moves the vcpu = to + * of its processors. Then, csched2_item_migrate() just moves the vcpu = to * the chosen runq, and it is again runq_tickle(), called by - * csched2_vcpu_wake() that actually decides what pcpu to use within the + * csched2_item_wake() that actually decides what pcpu to use within the * chosen runq; * - when a migration is initiated in sched_credit2.c, by calling migrat= e() * directly, that again temporarily use a random pcpu from the new runq, @@ -2026,8 +2026,10 @@ csched2_vcpu_check(struct vcpu *vc) #endif =20 static void * -csched2_alloc_vdata(const struct scheduler *ops, struct vcpu *vc, void *dd) +csched2_alloc_vdata(const struct scheduler *ops, struct sched_item *item, + void *dd) { + struct vcpu *vc =3D item->vcpu; struct csched2_vcpu *svc; =20 /* Allocate per-VCPU info */ @@ -2069,8 +2071,9 @@ csched2_alloc_vdata(const struct scheduler *ops, stru= ct vcpu *vc, void *dd) } =20 static void -csched2_vcpu_sleep(const struct scheduler *ops, struct vcpu *vc) +csched2_item_sleep(const struct scheduler *ops, struct sched_item *item) { + struct vcpu *vc =3D item->vcpu; struct csched2_vcpu * const svc =3D csched2_vcpu(vc); =20 ASSERT(!is_idle_vcpu(vc)); @@ -2091,8 +2094,9 @@ csched2_vcpu_sleep(const struct scheduler *ops, struc= t vcpu *vc) } =20 static void -csched2_vcpu_wake(const struct scheduler *ops, struct vcpu *vc) +csched2_item_wake(const struct scheduler *ops, struct sched_item *item) { + struct vcpu *vc =3D item->vcpu; struct csched2_vcpu * const svc =3D csched2_vcpu(vc); unsigned int cpu =3D vc->processor; s_time_t now; @@ -2146,16 +2150,18 @@ out: } =20 static void -csched2_vcpu_yield(const struct scheduler *ops, struct vcpu *v) +csched2_item_yield(const struct scheduler *ops, struct sched_item *item) { + struct vcpu *v =3D item->vcpu; struct csched2_vcpu * const svc =3D csched2_vcpu(v); =20 __set_bit(__CSFLAG_vcpu_yield, &svc->flags); } =20 static void -csched2_context_saved(const struct scheduler *ops, struct vcpu *vc) +csched2_context_saved(const struct scheduler *ops, struct sched_item *item) { + struct vcpu *vc =3D item->vcpu; struct csched2_vcpu * const svc =3D csched2_vcpu(vc); spinlock_t *lock =3D vcpu_schedule_lock_irq(vc); s_time_t now =3D NOW(); @@ -2196,9 +2202,10 @@ csched2_context_saved(const struct scheduler *ops, s= truct vcpu *vc) =20 #define MAX_LOAD (STIME_MAX) static int -csched2_cpu_pick(const struct scheduler *ops, struct vcpu *vc) +csched2_cpu_pick(const struct scheduler *ops, struct sched_item *item) { struct csched2_private *prv =3D csched2_priv(ops); + struct vcpu *vc =3D item->vcpu; int i, min_rqi =3D -1, min_s_rqi =3D -1; unsigned int new_cpu, cpu =3D vc->processor; struct csched2_vcpu *svc =3D csched2_vcpu(vc); @@ -2733,9 +2740,10 @@ retry: } =20 static void -csched2_vcpu_migrate( - const struct scheduler *ops, struct vcpu *vc, unsigned int new_cpu) +csched2_item_migrate( + const struct scheduler *ops, struct sched_item *item, unsigned int new= _cpu) { + struct vcpu *vc =3D item->vcpu; struct domain *d =3D vc->domain; struct csched2_vcpu * const svc =3D csched2_vcpu(vc); struct csched2_runqueue_data *trqd; @@ -2996,9 +3004,10 @@ csched2_dom_cntl( } =20 static void -csched2_aff_cntl(const struct scheduler *ops, struct vcpu *v, +csched2_aff_cntl(const struct scheduler *ops, struct sched_item *item, const cpumask_t *hard, const cpumask_t *soft) { + struct vcpu *v =3D item->vcpu; struct csched2_vcpu *svc =3D csched2_vcpu(v); =20 if ( !hard ) @@ -3096,8 +3105,9 @@ csched2_free_domdata(const struct scheduler *ops, voi= d *data) } =20 static void -csched2_vcpu_insert(const struct scheduler *ops, struct vcpu *vc) +csched2_item_insert(const struct scheduler *ops, struct sched_item *item) { + struct vcpu *vc =3D item->vcpu; struct csched2_vcpu *svc =3D vc->sched_priv; struct csched2_dom * const sdom =3D svc->sdom; spinlock_t *lock; @@ -3108,7 +3118,7 @@ csched2_vcpu_insert(const struct scheduler *ops, stru= ct vcpu *vc) /* csched2_cpu_pick() expects the pcpu lock to be held */ lock =3D vcpu_schedule_lock_irq(vc); =20 - vc->processor =3D csched2_cpu_pick(ops, vc); + vc->processor =3D csched2_cpu_pick(ops, item); =20 spin_unlock_irq(lock); =20 @@ -3135,8 +3145,9 @@ csched2_free_vdata(const struct scheduler *ops, void = *priv) } =20 static void -csched2_vcpu_remove(const struct scheduler *ops, struct vcpu *vc) +csched2_item_remove(const struct scheduler *ops, struct sched_item *item) { + struct vcpu *vc =3D item->vcpu; struct csched2_vcpu * const svc =3D csched2_vcpu(vc); spinlock_t *lock; =20 @@ -4084,19 +4095,19 @@ static const struct scheduler sched_credit2_def =3D= { =20 .global_init =3D csched2_global_init, =20 - .insert_vcpu =3D csched2_vcpu_insert, - .remove_vcpu =3D csched2_vcpu_remove, + .insert_item =3D csched2_item_insert, + .remove_item =3D csched2_item_remove, =20 - .sleep =3D csched2_vcpu_sleep, - .wake =3D csched2_vcpu_wake, - .yield =3D csched2_vcpu_yield, + .sleep =3D csched2_item_sleep, + .wake =3D csched2_item_wake, + .yield =3D csched2_item_yield, =20 .adjust =3D csched2_dom_cntl, .adjust_affinity=3D csched2_aff_cntl, .adjust_global =3D csched2_sys_cntl, =20 .pick_cpu =3D csched2_cpu_pick, - .migrate =3D csched2_vcpu_migrate, + .migrate =3D csched2_item_migrate, .do_schedule =3D csched2_schedule, .context_saved =3D csched2_context_saved, =20 diff --git a/xen/common/sched_null.c b/xen/common/sched_null.c index a59dbb2692..7b508f35a4 100644 --- a/xen/common/sched_null.c +++ b/xen/common/sched_null.c @@ -194,8 +194,9 @@ static void null_deinit_pdata(const struct scheduler *o= ps, void *pcpu, int cpu) } =20 static void *null_alloc_vdata(const struct scheduler *ops, - struct vcpu *v, void *dd) + struct sched_item *item, void *dd) { + struct vcpu *v =3D item->vcpu; struct null_vcpu *nvc; =20 nvc =3D xzalloc(struct null_vcpu); @@ -413,8 +414,10 @@ static void null_switch_sched(struct scheduler *new_op= s, unsigned int cpu, sd->schedule_lock =3D &sd->_lock; } =20 -static void null_vcpu_insert(const struct scheduler *ops, struct vcpu *v) +static void null_item_insert(const struct scheduler *ops, + struct sched_item *item) { + struct vcpu *v =3D item->vcpu; struct null_private *prv =3D null_priv(ops); struct null_vcpu *nvc =3D null_vcpu(v); unsigned int cpu; @@ -505,8 +508,10 @@ static void _vcpu_remove(struct null_private *prv, str= uct vcpu *v) spin_unlock(&prv->waitq_lock); } =20 -static void null_vcpu_remove(const struct scheduler *ops, struct vcpu *v) +static void null_item_remove(const struct scheduler *ops, + struct sched_item *item) { + struct vcpu *v =3D item->vcpu; struct null_private *prv =3D null_priv(ops); struct null_vcpu *nvc =3D null_vcpu(v); spinlock_t *lock; @@ -536,8 +541,11 @@ static void null_vcpu_remove(const struct scheduler *o= ps, struct vcpu *v) SCHED_STAT_CRANK(vcpu_remove); } =20 -static void null_vcpu_wake(const struct scheduler *ops, struct vcpu *v) +static void null_item_wake(const struct scheduler *ops, + struct sched_item *item) { + struct vcpu *v =3D item->vcpu; + ASSERT(!is_idle_vcpu(v)); =20 if ( unlikely(curr_on_cpu(v->processor) =3D=3D v) ) @@ -562,8 +570,11 @@ static void null_vcpu_wake(const struct scheduler *ops= , struct vcpu *v) cpu_raise_softirq(v->processor, SCHEDULE_SOFTIRQ); } =20 -static void null_vcpu_sleep(const struct scheduler *ops, struct vcpu *v) +static void null_item_sleep(const struct scheduler *ops, + struct sched_item *item) { + struct vcpu *v =3D item->vcpu; + ASSERT(!is_idle_vcpu(v)); =20 /* If v is not assigned to a pCPU, or is not running, no need to bothe= r */ @@ -573,15 +584,17 @@ static void null_vcpu_sleep(const struct scheduler *o= ps, struct vcpu *v) SCHED_STAT_CRANK(vcpu_sleep); } =20 -static int null_cpu_pick(const struct scheduler *ops, struct vcpu *v) +static int null_cpu_pick(const struct scheduler *ops, struct sched_item *i= tem) { + struct vcpu *v =3D item->vcpu; ASSERT(!is_idle_vcpu(v)); return pick_cpu(null_priv(ops), v); } =20 -static void null_vcpu_migrate(const struct scheduler *ops, struct vcpu *v, - unsigned int new_cpu) +static void null_item_migrate(const struct scheduler *ops, + struct sched_item *item, unsigned int new_cp= u) { + struct vcpu *v =3D item->vcpu; struct null_private *prv =3D null_priv(ops); struct null_vcpu *nvc =3D null_vcpu(v); =20 @@ -888,13 +901,13 @@ const struct scheduler sched_null_def =3D { .alloc_domdata =3D null_alloc_domdata, .free_domdata =3D null_free_domdata, =20 - .insert_vcpu =3D null_vcpu_insert, - .remove_vcpu =3D null_vcpu_remove, + .insert_item =3D null_item_insert, + .remove_item =3D null_item_remove, =20 - .wake =3D null_vcpu_wake, - .sleep =3D null_vcpu_sleep, + .wake =3D null_item_wake, + .sleep =3D null_item_sleep, .pick_cpu =3D null_cpu_pick, - .migrate =3D null_vcpu_migrate, + .migrate =3D null_item_migrate, .do_schedule =3D null_schedule, =20 .dump_cpu_state =3D null_dump_pcpu, diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index f1b81f0373..ab8fa02306 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -136,7 +136,7 @@ * RTDS_delayed_runq_add: Do we need to add this to the RunQ/DepletedQ * once it's done being context switching out? * + Set when scheduling out in rt_schedule() if prev is runable - * + Set in rt_vcpu_wake if it finds RTDS_scheduled set + * + Set in rt_item_wake if it finds RTDS_scheduled set * + Read in rt_context_saved(). If set, it adds prev to the Runqueue/Depl= etedQ * and clears the bit. */ @@ -637,8 +637,9 @@ replq_reinsert(const struct scheduler *ops, struct rt_v= cpu *svc) * and available cpus */ static int -rt_cpu_pick(const struct scheduler *ops, struct vcpu *vc) +rt_cpu_pick(const struct scheduler *ops, struct sched_item *item) { + struct vcpu *vc =3D item->vcpu; cpumask_t cpus; cpumask_t *online; int cpu; @@ -846,8 +847,9 @@ rt_free_domdata(const struct scheduler *ops, void *data) } =20 static void * -rt_alloc_vdata(const struct scheduler *ops, struct vcpu *vc, void *dd) +rt_alloc_vdata(const struct scheduler *ops, struct sched_item *item, void = *dd) { + struct vcpu *vc =3D item->vcpu; struct rt_vcpu *svc; =20 /* Allocate per-VCPU info */ @@ -889,8 +891,9 @@ rt_free_vdata(const struct scheduler *ops, void *priv) * dest. cpupool. */ static void -rt_vcpu_insert(const struct scheduler *ops, struct vcpu *vc) +rt_item_insert(const struct scheduler *ops, struct sched_item *item) { + struct vcpu *vc =3D item->vcpu; struct rt_vcpu *svc =3D rt_vcpu(vc); s_time_t now; spinlock_t *lock; @@ -898,7 +901,7 @@ rt_vcpu_insert(const struct scheduler *ops, struct vcpu= *vc) BUG_ON( is_idle_vcpu(vc) ); =20 /* This is safe because vc isn't yet being scheduled */ - vc->processor =3D rt_cpu_pick(ops, vc); + vc->processor =3D rt_cpu_pick(ops, item); =20 lock =3D vcpu_schedule_lock_irq(vc); =20 @@ -922,8 +925,9 @@ rt_vcpu_insert(const struct scheduler *ops, struct vcpu= *vc) * Remove rt_vcpu svc from the old scheduler in source cpupool. */ static void -rt_vcpu_remove(const struct scheduler *ops, struct vcpu *vc) +rt_item_remove(const struct scheduler *ops, struct sched_item *item) { + struct vcpu *vc =3D item->vcpu; struct rt_vcpu * const svc =3D rt_vcpu(vc); struct rt_dom * const sdom =3D svc->sdom; spinlock_t *lock; @@ -1142,8 +1146,9 @@ rt_schedule(const struct scheduler *ops, s_time_t now= , bool_t tasklet_work_sched * The lock is already grabbed in schedule.c, no need to lock here */ static void -rt_vcpu_sleep(const struct scheduler *ops, struct vcpu *vc) +rt_item_sleep(const struct scheduler *ops, struct sched_item *item) { + struct vcpu *vc =3D item->vcpu; struct rt_vcpu * const svc =3D rt_vcpu(vc); =20 BUG_ON( is_idle_vcpu(vc) ); @@ -1257,8 +1262,9 @@ runq_tickle(const struct scheduler *ops, struct rt_vc= pu *new) * TODO: what if these two vcpus belongs to the same domain? */ static void -rt_vcpu_wake(const struct scheduler *ops, struct vcpu *vc) +rt_item_wake(const struct scheduler *ops, struct sched_item *item) { + struct vcpu *vc =3D item->vcpu; struct rt_vcpu * const svc =3D rt_vcpu(vc); s_time_t now; bool_t missed; @@ -1327,8 +1333,9 @@ rt_vcpu_wake(const struct scheduler *ops, struct vcpu= *vc) * and then pick the highest priority vcpu from runq to run */ static void -rt_context_saved(const struct scheduler *ops, struct vcpu *vc) +rt_context_saved(const struct scheduler *ops, struct sched_item *item) { + struct vcpu *vc =3D item->vcpu; struct rt_vcpu *svc =3D rt_vcpu(vc); spinlock_t *lock =3D vcpu_schedule_lock_irq(vc); =20 @@ -1557,15 +1564,15 @@ static const struct scheduler sched_rtds_def =3D { .free_domdata =3D rt_free_domdata, .alloc_vdata =3D rt_alloc_vdata, .free_vdata =3D rt_free_vdata, - .insert_vcpu =3D rt_vcpu_insert, - .remove_vcpu =3D rt_vcpu_remove, + .insert_item =3D rt_item_insert, + .remove_item =3D rt_item_remove, =20 .adjust =3D rt_dom_cntl, =20 .pick_cpu =3D rt_cpu_pick, .do_schedule =3D rt_schedule, - .sleep =3D rt_vcpu_sleep, - .wake =3D rt_vcpu_wake, + .sleep =3D rt_item_sleep, + .wake =3D rt_item_wake, .context_saved =3D rt_context_saved, }; =20 diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 35a40a40c8..27d8d36504 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -252,6 +252,7 @@ static void sched_spin_unlock_double(spinlock_t *lock1,= spinlock_t *lock2, int sched_init_vcpu(struct vcpu *v, unsigned int processor) { struct domain *d =3D v->domain; + struct sched_item item =3D { .vcpu =3D v }; =20 v->processor =3D processor; =20 @@ -263,7 +264,7 @@ int sched_init_vcpu(struct vcpu *v, unsigned int proces= sor) init_timer(&v->poll_timer, poll_timer_fn, v, v->processor); =20 - v->sched_priv =3D sched_alloc_vdata(dom_scheduler(d), v, d->sched_priv= ); + v->sched_priv =3D sched_alloc_vdata(dom_scheduler(d), &item, d->sched_= priv); if ( v->sched_priv =3D=3D NULL ) return 1; =20 @@ -284,7 +285,7 @@ int sched_init_vcpu(struct vcpu *v, unsigned int proces= sor) } else { - sched_insert_vcpu(dom_scheduler(d), v); + sched_insert_item(dom_scheduler(d), &item); } =20 return 0; @@ -305,6 +306,7 @@ int sched_move_domain(struct domain *d, struct cpupool = *c) void *vcpudata; struct scheduler *old_ops; void *old_domdata; + struct sched_item item; =20 for_each_vcpu ( d, v ) { @@ -325,7 +327,8 @@ int sched_move_domain(struct domain *d, struct cpupool = *c) =20 for_each_vcpu ( d, v ) { - vcpu_priv[v->vcpu_id] =3D sched_alloc_vdata(c->sched, v, domdata); + item.vcpu =3D v; + vcpu_priv[v->vcpu_id] =3D sched_alloc_vdata(c->sched, &item, domda= ta); if ( vcpu_priv[v->vcpu_id] =3D=3D NULL ) { for_each_vcpu ( d, v ) @@ -343,7 +346,8 @@ int sched_move_domain(struct domain *d, struct cpupool = *c) =20 for_each_vcpu ( d, v ) { - sched_remove_vcpu(old_ops, v); + item.vcpu =3D v; + sched_remove_item(old_ops, &item); } =20 d->cpupool =3D c; @@ -354,6 +358,7 @@ int sched_move_domain(struct domain *d, struct cpupool = *c) { spinlock_t *lock; =20 + item.vcpu =3D v; vcpudata =3D v->sched_priv; =20 migrate_timer(&v->periodic_timer, new_p); @@ -378,7 +383,7 @@ int sched_move_domain(struct domain *d, struct cpupool = *c) =20 new_p =3D cpumask_cycle(new_p, c->cpu_valid); =20 - sched_insert_vcpu(c->sched, v); + sched_insert_item(c->sched, &item); =20 sched_free_vdata(old_ops, vcpudata); } @@ -396,12 +401,14 @@ int sched_move_domain(struct domain *d, struct cpupoo= l *c) =20 void sched_destroy_vcpu(struct vcpu *v) { + struct sched_item item =3D { .vcpu =3D v }; + kill_timer(&v->periodic_timer); kill_timer(&v->singleshot_timer); kill_timer(&v->poll_timer); if ( test_and_clear_bool(v->is_urgent) ) atomic_dec(&per_cpu(schedule_data, v->processor).urgent_count); - sched_remove_vcpu(vcpu_scheduler(v), v); + sched_remove_item(vcpu_scheduler(v), &item); sched_free_vdata(vcpu_scheduler(v), v->sched_priv); } =20 @@ -446,6 +453,8 @@ void sched_destroy_domain(struct domain *d) =20 void vcpu_sleep_nosync_locked(struct vcpu *v) { + struct sched_item item =3D { .vcpu =3D v }; + ASSERT(spin_is_locked(per_cpu(schedule_data,v->processor).schedule_loc= k)); =20 if ( likely(!vcpu_runnable(v)) ) @@ -453,7 +462,7 @@ void vcpu_sleep_nosync_locked(struct vcpu *v) if ( v->runstate.state =3D=3D RUNSTATE_runnable ) vcpu_runstate_change(v, RUNSTATE_offline, NOW()); =20 - sched_sleep(vcpu_scheduler(v), v); + sched_sleep(vcpu_scheduler(v), &item); } } =20 @@ -485,6 +494,7 @@ void vcpu_wake(struct vcpu *v) { unsigned long flags; spinlock_t *lock; + struct sched_item item =3D { .vcpu =3D v }; =20 TRACE_2D(TRC_SCHED_WAKE, v->domain->domain_id, v->vcpu_id); =20 @@ -494,7 +504,7 @@ void vcpu_wake(struct vcpu *v) { if ( v->runstate.state >=3D RUNSTATE_blocked ) vcpu_runstate_change(v, RUNSTATE_runnable, NOW()); - sched_wake(vcpu_scheduler(v), v); + sched_wake(vcpu_scheduler(v), &item); } else if ( !(v->pause_flags & VPF_blocked) ) { @@ -533,6 +543,7 @@ void vcpu_unblock(struct vcpu *v) static void vcpu_move_locked(struct vcpu *v, unsigned int new_cpu) { unsigned int old_cpu =3D v->processor; + struct sched_item item =3D { .vcpu =3D v }; =20 /* * Transfer urgency status to new CPU before switching CPUs, as @@ -549,7 +560,7 @@ static void vcpu_move_locked(struct vcpu *v, unsigned i= nt new_cpu) * Actual CPU switch to new CPU. This is safe because the lock * pointer can't change while the current lock is held. */ - sched_migrate(vcpu_scheduler(v), v, new_cpu); + sched_migrate(vcpu_scheduler(v), &item, new_cpu); } =20 /* @@ -591,6 +602,7 @@ static void vcpu_migrate_finish(struct vcpu *v) unsigned int old_cpu, new_cpu; spinlock_t *old_lock, *new_lock; bool_t pick_called =3D 0; + struct sched_item item =3D { .vcpu =3D v }; =20 /* * If the vcpu is currently running, this will be handled by @@ -627,7 +639,7 @@ static void vcpu_migrate_finish(struct vcpu *v) break; =20 /* Select a new CPU. */ - new_cpu =3D sched_pick_cpu(vcpu_scheduler(v), v); + new_cpu =3D sched_pick_cpu(vcpu_scheduler(v), &item); if ( (new_lock =3D=3D per_cpu(schedule_data, new_cpu).schedule= _lock) && cpumask_test_cpu(new_cpu, v->domain->cpupool->cpu_valid) ) break; @@ -697,6 +709,7 @@ void restore_vcpu_affinity(struct domain *d) { spinlock_t *lock; unsigned int old_cpu =3D v->processor; + struct sched_item item =3D { .vcpu =3D v }; =20 ASSERT(!vcpu_runnable(v)); =20 @@ -732,7 +745,7 @@ void restore_vcpu_affinity(struct domain *d) v->processor =3D cpumask_any(cpumask_scratch_cpu(cpu)); =20 lock =3D vcpu_schedule_lock_irq(v); - v->processor =3D sched_pick_cpu(vcpu_scheduler(v), v); + v->processor =3D sched_pick_cpu(vcpu_scheduler(v), &item); spin_unlock_irq(lock); =20 if ( old_cpu !=3D v->processor ) @@ -844,7 +857,9 @@ static int cpu_disable_scheduler_check(unsigned int cpu) void sched_set_affinity( struct vcpu *v, const cpumask_t *hard, const cpumask_t *soft) { - sched_adjust_affinity(dom_scheduler(v->domain), v, hard, soft); + struct sched_item item =3D { .vcpu =3D v }; + + sched_adjust_affinity(dom_scheduler(v->domain), &item, hard, soft); =20 if ( hard ) cpumask_copy(v->cpu_hard_affinity, hard); @@ -1017,9 +1032,10 @@ static long do_poll(struct sched_poll *sched_poll) long vcpu_yield(void) { struct vcpu * v=3Dcurrent; + struct sched_item item =3D { .vcpu =3D v }; spinlock_t *lock =3D vcpu_schedule_lock_irq(v); =20 - sched_yield(vcpu_scheduler(v), v); + sched_yield(vcpu_scheduler(v), &item); vcpu_schedule_unlock_irq(lock, v); =20 SCHED_STAT_CRANK(vcpu_yield); @@ -1514,6 +1530,8 @@ static void schedule(void) =20 void context_saved(struct vcpu *prev) { + struct sched_item item =3D { .vcpu =3D prev }; + /* Clear running flag /after/ writing context to memory. */ smp_wmb(); =20 @@ -1522,7 +1540,7 @@ void context_saved(struct vcpu *prev) /* Check for migration request /after/ clearing running flag. */ smp_mb(); =20 - sched_context_saved(vcpu_scheduler(prev), prev); + sched_context_saved(vcpu_scheduler(prev), &item); =20 vcpu_migrate_finish(prev); } @@ -1578,6 +1596,7 @@ static int cpu_schedule_up(unsigned int cpu) else { struct vcpu *idle =3D idle_vcpu[cpu]; + struct sched_item item =3D { .vcpu =3D idle }; =20 /* * During (ACPI?) suspend the idle vCPU for this pCPU is not freed, @@ -1591,7 +1610,7 @@ static int cpu_schedule_up(unsigned int cpu) */ ASSERT(idle->sched_priv =3D=3D NULL); =20 - idle->sched_priv =3D sched_alloc_vdata(&ops, idle, + idle->sched_priv =3D sched_alloc_vdata(&ops, &item, idle->domain->sched_priv); if ( idle->sched_priv =3D=3D NULL ) return -ENOMEM; @@ -1784,6 +1803,7 @@ void __init scheduler_init(void) int schedule_cpu_switch(unsigned int cpu, struct cpupool *c) { struct vcpu *idle; + struct sched_item item; void *ppriv, *ppriv_old, *vpriv, *vpriv_old; struct scheduler *old_ops =3D per_cpu(scheduler, cpu); struct scheduler *new_ops =3D (c =3D=3D NULL) ? &ops : c->sched; @@ -1819,10 +1839,11 @@ int schedule_cpu_switch(unsigned int cpu, struct cp= upool *c) * sched_priv field of the per-vCPU info of the idle domain. */ idle =3D idle_vcpu[cpu]; + item.vcpu =3D idle; ppriv =3D sched_alloc_pdata(new_ops, cpu); if ( IS_ERR(ppriv) ) return PTR_ERR(ppriv); - vpriv =3D sched_alloc_vdata(new_ops, idle, idle->domain->sched_priv); + vpriv =3D sched_alloc_vdata(new_ops, &item, idle->domain->sched_priv); if ( vpriv =3D=3D NULL ) { sched_free_pdata(new_ops, ppriv, cpu); diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index 593cd79297..b4a93bb76b 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -141,8 +141,8 @@ struct scheduler { void (*deinit) (struct scheduler *); =20 void (*free_vdata) (const struct scheduler *, void *); - void * (*alloc_vdata) (const struct scheduler *, struct vcpu = *, - void *); + void * (*alloc_vdata) (const struct scheduler *, + struct sched_item *, void *); void (*free_pdata) (const struct scheduler *, void *, int); void * (*alloc_pdata) (const struct scheduler *, int); void (*init_pdata) (const struct scheduler *, void *, int); @@ -156,24 +156,32 @@ struct scheduler { void (*switch_sched) (struct scheduler *, unsigned int, void *, void *); =20 - /* Activate / deactivate vcpus in a cpu pool */ - void (*insert_vcpu) (const struct scheduler *, struct vcpu = *); - void (*remove_vcpu) (const struct scheduler *, struct vcpu = *); - - void (*sleep) (const struct scheduler *, struct vcpu = *); - void (*wake) (const struct scheduler *, struct vcpu = *); - void (*yield) (const struct scheduler *, struct vcpu = *); - void (*context_saved) (const struct scheduler *, struct vcpu = *); + /* Activate / deactivate items in a cpu pool */ + void (*insert_item) (const struct scheduler *, + struct sched_item *); + void (*remove_item) (const struct scheduler *, + struct sched_item *); + + void (*sleep) (const struct scheduler *, + struct sched_item *); + void (*wake) (const struct scheduler *, + struct sched_item *); + void (*yield) (const struct scheduler *, + struct sched_item *); + void (*context_saved) (const struct scheduler *, + struct sched_item *); =20 struct task_slice (*do_schedule) (const struct scheduler *, s_time_t, bool_t tasklet_work_scheduled); =20 - int (*pick_cpu) (const struct scheduler *, struct vcpu = *); - void (*migrate) (const struct scheduler *, struct vcpu = *, - unsigned int); + int (*pick_cpu) (const struct scheduler *, + struct sched_item *); + void (*migrate) (const struct scheduler *, + struct sched_item *, unsigned int); int (*adjust) (const struct scheduler *, struct domai= n *, struct xen_domctl_scheduler_op *); - void (*adjust_affinity)(const struct scheduler *, struct vcpu = *, + void (*adjust_affinity)(const struct scheduler *, + struct sched_item *, const struct cpumask *, const struct cpumask *); int (*adjust_global) (const struct scheduler *, @@ -285,11 +293,11 @@ static inline void sched_deinit_pdata(const struct sc= heduler *s, void *data, s->deinit_pdata(s, data, cpu); } =20 -static inline void *sched_alloc_vdata(const struct scheduler *s, struct vc= pu *v, - void *dom_data) +static inline void *sched_alloc_vdata(const struct scheduler *s, + struct sched_item *item, void *dom_d= ata) { if ( s->alloc_vdata ) - return s->alloc_vdata(s, v, dom_data); + return s->alloc_vdata(s, item, dom_data); else return NULL; } @@ -306,65 +314,71 @@ static inline void sched_free_vdata(const struct sche= duler *s, void *data) ASSERT(!data); } =20 -static inline void sched_insert_vcpu(const struct scheduler *s, struct vcp= u *v) +static inline void sched_insert_item(const struct scheduler *s, + struct sched_item *item) { - if ( s->insert_vcpu ) - s->insert_vcpu(s, v); + if ( s->insert_item ) + s->insert_item(s, item); } =20 -static inline void sched_remove_vcpu(const struct scheduler *s, struct vcp= u *v) +static inline void sched_remove_item(const struct scheduler *s, + struct sched_item *item) { - if ( s->remove_vcpu ) - s->remove_vcpu(s, v); + if ( s->remove_item ) + s->remove_item(s, item); } =20 -static inline void sched_sleep(const struct scheduler *s, struct vcpu *v) +static inline void sched_sleep(const struct scheduler *s, + struct sched_item *item) { if ( s->sleep ) - s->sleep(s, v); + s->sleep(s, item); } =20 -static inline void sched_wake(const struct scheduler *s, struct vcpu *v) +static inline void sched_wake(const struct scheduler *s, + struct sched_item *item) { if ( s->wake ) - s->wake(s, v); + s->wake(s, item); } =20 -static inline void sched_yield(const struct scheduler *s, struct vcpu *v) +static inline void sched_yield(const struct scheduler *s, + struct sched_item *item) { if ( s->yield ) - s->yield(s, v); + s->yield(s, item); } =20 static inline void sched_context_saved(const struct scheduler *s, - struct vcpu *v) + struct sched_item *item) { if ( s->context_saved ) - s->context_saved(s, v); + s->context_saved(s, item); } =20 -static inline void sched_migrate(const struct scheduler *s, struct vcpu *v, - unsigned int cpu) +static inline void sched_migrate(const struct scheduler *s, + struct sched_item *item, unsigned int cpu) { if ( s->migrate ) - s->migrate(s, v, cpu); + s->migrate(s, item, cpu); else - v->processor =3D cpu; + item->vcpu->processor =3D cpu; } =20 -static inline int sched_pick_cpu(const struct scheduler *s, struct vcpu *v) +static inline int sched_pick_cpu(const struct scheduler *s, + struct sched_item *item) { ASSERT(s->pick_cpu); - return s->pick_cpu(s, v); + return s->pick_cpu(s, item); } =20 static inline void sched_adjust_affinity(const struct scheduler *s, - struct vcpu *v, + struct sched_item *item, const cpumask_t *hard, const cpumask_t *soft) { if ( s->adjust_affinity ) - s->adjust_affinity(s, v, hard, soft); + s->adjust_affinity(s, item, hard, soft); } =20 static inline int sched_adjust_dom(const struct scheduler *s, struct domai= n *d, diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 748bb0f2f9..946a71ffdc 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -275,6 +275,10 @@ struct vcpu struct arch_vcpu arch; }; =20 +struct sched_item { + struct vcpu *vcpu; +}; + /* Per-domain lock can be recursively acquired in fault handlers. */ #define domain_lock(d) spin_lock_recursive(&(d)->domain_lock) #define domain_unlock(d) spin_unlock_recursive(&(d)->domain_lock) --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125918; cv=none; d=zoho.com; s=zohoarc; b=j/eB8P12BsIa4kT+LzR+71DPge1dbf1YKPkgexSQXqNdXxPNiz4+6hDkR6mPB/eieqG0vUywger6kKkWG4lsgnDCb07fQjxrDH/581XxH9dON25W3nhj7w2lAtC3HcztvNgJyAXWary3KJNCxRpVnoseFttWJbs9XIQkmyfjOBk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125918; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=rz1XEeEagk5fma1GVinkN8uJ1LwAfSRjnpG5+hwDeDM=; b=H1mXlJUV+zK7A9kxvwH+Yg/Zpul9/52bPYc4TldyuK2mX1FdjfR1RCBe45XClGNISnVop6TyEcdnhVN80UrCzLTb44Dg1afPmUOTJqkm/SUiQs8Dk4xljMCtuuSoVx+iH5Gc3TLoNZshkXU3c7jw1RFNDoMknkoBEyr5RzFD9+Q= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125918324696.1176975172816; Sun, 5 May 2019 23:58:38 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYT-0001sA-O1; Mon, 06 May 2019 06:56:53 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYS-0001rv-4d for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:56:52 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 1ee8480e-6fcc-11e9-843c-bc764e045a96; Mon, 06 May 2019 06:56:50 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 0AF0FACAA; Mon, 6 May 2019 06:56:49 +0000 (UTC) X-Inumbo-ID: 1ee8480e-6fcc-11e9-843c-bc764e045a96 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:02 +0200 Message-Id: <20190506065644.7415-4-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 03/45] xen/sched: alloc struct sched_item for each vcpu X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Tim Deegan , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Dario Faggioli , Julien Grall , Jan Beulich MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Allocate a struct sched_item for each vcpu. This removes the need to have it locally on the stack in schedule.c. Signed-off-by: Juergen Gross --- xen/common/schedule.c | 67 +++++++++++++++++++++++----------------------= ---- xen/include/xen/sched.h | 2 ++ 2 files changed, 33 insertions(+), 36 deletions(-) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 27d8d36504..071289b9c0 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -252,10 +252,15 @@ static void sched_spin_unlock_double(spinlock_t *lock= 1, spinlock_t *lock2, int sched_init_vcpu(struct vcpu *v, unsigned int processor) { struct domain *d =3D v->domain; - struct sched_item item =3D { .vcpu =3D v }; + struct sched_item *item; =20 v->processor =3D processor; =20 + if ( (item =3D xzalloc(struct sched_item)) =3D=3D NULL ) + return 1; + v->sched_item =3D item; + item->vcpu =3D v; + /* Initialise the per-vcpu timers. */ init_timer(&v->periodic_timer, vcpu_periodic_timer_fn, v, v->processor); @@ -264,9 +269,13 @@ int sched_init_vcpu(struct vcpu *v, unsigned int proce= ssor) init_timer(&v->poll_timer, poll_timer_fn, v, v->processor); =20 - v->sched_priv =3D sched_alloc_vdata(dom_scheduler(d), &item, d->sched_= priv); + v->sched_priv =3D sched_alloc_vdata(dom_scheduler(d), item, d->sched_p= riv); if ( v->sched_priv =3D=3D NULL ) + { + v->sched_item =3D NULL; + xfree(item); return 1; + } =20 /* * Initialize affinity settings. The idler, and potentially @@ -285,7 +294,7 @@ int sched_init_vcpu(struct vcpu *v, unsigned int proces= sor) } else { - sched_insert_item(dom_scheduler(d), &item); + sched_insert_item(dom_scheduler(d), item); } =20 return 0; @@ -306,7 +315,6 @@ int sched_move_domain(struct domain *d, struct cpupool = *c) void *vcpudata; struct scheduler *old_ops; void *old_domdata; - struct sched_item item; =20 for_each_vcpu ( d, v ) { @@ -327,8 +335,8 @@ int sched_move_domain(struct domain *d, struct cpupool = *c) =20 for_each_vcpu ( d, v ) { - item.vcpu =3D v; - vcpu_priv[v->vcpu_id] =3D sched_alloc_vdata(c->sched, &item, domda= ta); + vcpu_priv[v->vcpu_id] =3D sched_alloc_vdata(c->sched, v->sched_ite= m, + domdata); if ( vcpu_priv[v->vcpu_id] =3D=3D NULL ) { for_each_vcpu ( d, v ) @@ -346,8 +354,7 @@ int sched_move_domain(struct domain *d, struct cpupool = *c) =20 for_each_vcpu ( d, v ) { - item.vcpu =3D v; - sched_remove_item(old_ops, &item); + sched_remove_item(old_ops, v->sched_item); } =20 d->cpupool =3D c; @@ -358,7 +365,6 @@ int sched_move_domain(struct domain *d, struct cpupool = *c) { spinlock_t *lock; =20 - item.vcpu =3D v; vcpudata =3D v->sched_priv; =20 migrate_timer(&v->periodic_timer, new_p); @@ -383,7 +389,7 @@ int sched_move_domain(struct domain *d, struct cpupool = *c) =20 new_p =3D cpumask_cycle(new_p, c->cpu_valid); =20 - sched_insert_item(c->sched, &item); + sched_insert_item(c->sched, v->sched_item); =20 sched_free_vdata(old_ops, vcpudata); } @@ -401,15 +407,17 @@ int sched_move_domain(struct domain *d, struct cpupoo= l *c) =20 void sched_destroy_vcpu(struct vcpu *v) { - struct sched_item item =3D { .vcpu =3D v }; + struct sched_item *item =3D v->sched_item; =20 kill_timer(&v->periodic_timer); kill_timer(&v->singleshot_timer); kill_timer(&v->poll_timer); if ( test_and_clear_bool(v->is_urgent) ) atomic_dec(&per_cpu(schedule_data, v->processor).urgent_count); - sched_remove_item(vcpu_scheduler(v), &item); + sched_remove_item(vcpu_scheduler(v), item); sched_free_vdata(vcpu_scheduler(v), v->sched_priv); + xfree(item); + v->sched_item =3D NULL; } =20 int sched_init_domain(struct domain *d, int poolid) @@ -453,8 +461,6 @@ void sched_destroy_domain(struct domain *d) =20 void vcpu_sleep_nosync_locked(struct vcpu *v) { - struct sched_item item =3D { .vcpu =3D v }; - ASSERT(spin_is_locked(per_cpu(schedule_data,v->processor).schedule_loc= k)); =20 if ( likely(!vcpu_runnable(v)) ) @@ -462,7 +468,7 @@ void vcpu_sleep_nosync_locked(struct vcpu *v) if ( v->runstate.state =3D=3D RUNSTATE_runnable ) vcpu_runstate_change(v, RUNSTATE_offline, NOW()); =20 - sched_sleep(vcpu_scheduler(v), &item); + sched_sleep(vcpu_scheduler(v), v->sched_item); } } =20 @@ -494,7 +500,6 @@ void vcpu_wake(struct vcpu *v) { unsigned long flags; spinlock_t *lock; - struct sched_item item =3D { .vcpu =3D v }; =20 TRACE_2D(TRC_SCHED_WAKE, v->domain->domain_id, v->vcpu_id); =20 @@ -504,7 +509,7 @@ void vcpu_wake(struct vcpu *v) { if ( v->runstate.state >=3D RUNSTATE_blocked ) vcpu_runstate_change(v, RUNSTATE_runnable, NOW()); - sched_wake(vcpu_scheduler(v), &item); + sched_wake(vcpu_scheduler(v), v->sched_item); } else if ( !(v->pause_flags & VPF_blocked) ) { @@ -543,7 +548,6 @@ void vcpu_unblock(struct vcpu *v) static void vcpu_move_locked(struct vcpu *v, unsigned int new_cpu) { unsigned int old_cpu =3D v->processor; - struct sched_item item =3D { .vcpu =3D v }; =20 /* * Transfer urgency status to new CPU before switching CPUs, as @@ -560,7 +564,7 @@ static void vcpu_move_locked(struct vcpu *v, unsigned i= nt new_cpu) * Actual CPU switch to new CPU. This is safe because the lock * pointer can't change while the current lock is held. */ - sched_migrate(vcpu_scheduler(v), &item, new_cpu); + sched_migrate(vcpu_scheduler(v), v->sched_item, new_cpu); } =20 /* @@ -602,7 +606,6 @@ static void vcpu_migrate_finish(struct vcpu *v) unsigned int old_cpu, new_cpu; spinlock_t *old_lock, *new_lock; bool_t pick_called =3D 0; - struct sched_item item =3D { .vcpu =3D v }; =20 /* * If the vcpu is currently running, this will be handled by @@ -639,7 +642,7 @@ static void vcpu_migrate_finish(struct vcpu *v) break; =20 /* Select a new CPU. */ - new_cpu =3D sched_pick_cpu(vcpu_scheduler(v), &item); + new_cpu =3D sched_pick_cpu(vcpu_scheduler(v), v->sched_item); if ( (new_lock =3D=3D per_cpu(schedule_data, new_cpu).schedule= _lock) && cpumask_test_cpu(new_cpu, v->domain->cpupool->cpu_valid) ) break; @@ -709,7 +712,6 @@ void restore_vcpu_affinity(struct domain *d) { spinlock_t *lock; unsigned int old_cpu =3D v->processor; - struct sched_item item =3D { .vcpu =3D v }; =20 ASSERT(!vcpu_runnable(v)); =20 @@ -745,7 +747,7 @@ void restore_vcpu_affinity(struct domain *d) v->processor =3D cpumask_any(cpumask_scratch_cpu(cpu)); =20 lock =3D vcpu_schedule_lock_irq(v); - v->processor =3D sched_pick_cpu(vcpu_scheduler(v), &item); + v->processor =3D sched_pick_cpu(vcpu_scheduler(v), v->sched_item); spin_unlock_irq(lock); =20 if ( old_cpu !=3D v->processor ) @@ -857,9 +859,7 @@ static int cpu_disable_scheduler_check(unsigned int cpu) void sched_set_affinity( struct vcpu *v, const cpumask_t *hard, const cpumask_t *soft) { - struct sched_item item =3D { .vcpu =3D v }; - - sched_adjust_affinity(dom_scheduler(v->domain), &item, hard, soft); + sched_adjust_affinity(dom_scheduler(v->domain), v->sched_item, hard, s= oft); =20 if ( hard ) cpumask_copy(v->cpu_hard_affinity, hard); @@ -1032,10 +1032,9 @@ static long do_poll(struct sched_poll *sched_poll) long vcpu_yield(void) { struct vcpu * v=3Dcurrent; - struct sched_item item =3D { .vcpu =3D v }; spinlock_t *lock =3D vcpu_schedule_lock_irq(v); =20 - sched_yield(vcpu_scheduler(v), &item); + sched_yield(vcpu_scheduler(v), v->sched_item); vcpu_schedule_unlock_irq(lock, v); =20 SCHED_STAT_CRANK(vcpu_yield); @@ -1530,8 +1529,6 @@ static void schedule(void) =20 void context_saved(struct vcpu *prev) { - struct sched_item item =3D { .vcpu =3D prev }; - /* Clear running flag /after/ writing context to memory. */ smp_wmb(); =20 @@ -1540,7 +1537,7 @@ void context_saved(struct vcpu *prev) /* Check for migration request /after/ clearing running flag. */ smp_mb(); =20 - sched_context_saved(vcpu_scheduler(prev), &item); + sched_context_saved(vcpu_scheduler(prev), prev->sched_item); =20 vcpu_migrate_finish(prev); } @@ -1596,7 +1593,6 @@ static int cpu_schedule_up(unsigned int cpu) else { struct vcpu *idle =3D idle_vcpu[cpu]; - struct sched_item item =3D { .vcpu =3D idle }; =20 /* * During (ACPI?) suspend the idle vCPU for this pCPU is not freed, @@ -1610,7 +1606,7 @@ static int cpu_schedule_up(unsigned int cpu) */ ASSERT(idle->sched_priv =3D=3D NULL); =20 - idle->sched_priv =3D sched_alloc_vdata(&ops, &item, + idle->sched_priv =3D sched_alloc_vdata(&ops, idle->sched_item, idle->domain->sched_priv); if ( idle->sched_priv =3D=3D NULL ) return -ENOMEM; @@ -1803,7 +1799,6 @@ void __init scheduler_init(void) int schedule_cpu_switch(unsigned int cpu, struct cpupool *c) { struct vcpu *idle; - struct sched_item item; void *ppriv, *ppriv_old, *vpriv, *vpriv_old; struct scheduler *old_ops =3D per_cpu(scheduler, cpu); struct scheduler *new_ops =3D (c =3D=3D NULL) ? &ops : c->sched; @@ -1839,11 +1834,11 @@ int schedule_cpu_switch(unsigned int cpu, struct cp= upool *c) * sched_priv field of the per-vCPU info of the idle domain. */ idle =3D idle_vcpu[cpu]; - item.vcpu =3D idle; ppriv =3D sched_alloc_pdata(new_ops, cpu); if ( IS_ERR(ppriv) ) return PTR_ERR(ppriv); - vpriv =3D sched_alloc_vdata(new_ops, &item, idle->domain->sched_priv); + vpriv =3D sched_alloc_vdata(new_ops, idle->sched_item, + idle->domain->sched_priv); if ( vpriv =3D=3D NULL ) { sched_free_pdata(new_ops, ppriv, cpu); diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 946a71ffdc..85f9119d48 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -140,6 +140,7 @@ void evtchn_destroy(struct domain *d); /* from domain_k= ill */ void evtchn_destroy_final(struct domain *d); /* from complete_domain_destr= oy */ =20 struct waitqueue_vcpu; +struct sched_item; =20 struct vcpu { @@ -160,6 +161,7 @@ struct vcpu =20 struct timer poll_timer; /* timeout for SCHEDOP_poll */ =20 + struct sched_item *sched_item; void *sched_priv; /* scheduler-specific data */ =20 struct vcpu_runstate_info runstate; --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125918; cv=none; d=zoho.com; s=zohoarc; b=dvTKarhdBERSlYc64vph3AvbR5Inc7mseAjKOT5t5plgiEnW0wlCy+eOuOmWw7bypflV+B3IURx3mpX00z6mWrOWNRFaqKkFGU0/wUfNx8x4BRTgUYDg1NlBgNcdOPMANyZ7w+cjutBfLSFYzKDCaOLgpBnlkWGfo5/wB/gii0U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125918; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=NUrgIxP4CLip9n0tAWlg6ccFEj3wXWA1ZIcvZQS51TE=; b=nisJYRa72AEfn4W2UcVr0wJ3N5Rw/EC5n6VzFkmxJ/jOELLQgQbKfnkPvTzPJgW6GextjfM7msk5IG0k40pqU7wuWf82sCNbHPjOz74XdLLG5psu94olZERaPcXrbI11MERJ5w8vxkqdDi5V8PpNV9dEH4Ss1xvgiiUgNjFEoPU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125918188223.6906856787482; Sun, 5 May 2019 23:58:38 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYc-0001xi-Qc; Mon, 06 May 2019 06:57:02 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYb-0001wp-NH for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:01 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 1f18b870-6fcc-11e9-9193-ab607bdbffc7; Mon, 06 May 2019 06:56:50 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 6111BAD03; Mon, 6 May 2019 06:56:49 +0000 (UTC) X-Inumbo-ID: 1f18b870-6fcc-11e9-9193-ab607bdbffc7 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:03 +0200 Message-Id: <20190506065644.7415-5-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 04/45] xen/sched: move per-vcpu scheduler private data pointer to sched_item X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Tim Deegan , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Robert VanVossen , Dario Faggioli , Julien Grall , Josh Whitehead , Meng Xu , Jan Beulich MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" This prepares making the different schedulers vcpu agnostic. Signed-off-by: Juergen Gross --- xen/common/sched_arinc653.c | 4 ++-- xen/common/sched_credit.c | 6 +++--- xen/common/sched_credit2.c | 10 +++++----- xen/common/sched_null.c | 4 ++-- xen/common/sched_rt.c | 4 ++-- xen/common/schedule.c | 24 ++++++++++++------------ xen/include/xen/sched.h | 2 +- 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/xen/common/sched_arinc653.c b/xen/common/sched_arinc653.c index fffe23113e..f5af8b972d 100644 --- a/xen/common/sched_arinc653.c +++ b/xen/common/sched_arinc653.c @@ -53,7 +53,7 @@ * Return a pointer to the ARINC 653-specific scheduler data information * associated with the given VCPU (vc) */ -#define AVCPU(vc) ((arinc653_vcpu_t *)(vc)->sched_priv) +#define AVCPU(vc) ((arinc653_vcpu_t *)(vc)->sched_item->priv) =20 /** * Return the global scheduler private data given the scheduler ops pointer @@ -647,7 +647,7 @@ a653_switch_sched(struct scheduler *new_ops, unsigned i= nt cpu, =20 ASSERT(!pdata && svc && is_idle_vcpu(svc->vc)); =20 - idle_vcpu[cpu]->sched_priv =3D vdata; + idle_vcpu[cpu]->sched_item->priv =3D vdata; =20 per_cpu(scheduler, cpu) =3D new_ops; per_cpu(schedule_data, cpu).sched_priv =3D NULL; /* no pdata */ diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index 3735486b4c..cb8e167fc9 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -83,7 +83,7 @@ ((struct csched_private *)((_ops)->sched_data)) #define CSCHED_PCPU(_c) \ ((struct csched_pcpu *)per_cpu(schedule_data, _c).sched_priv) -#define CSCHED_VCPU(_vcpu) ((struct csched_vcpu *) (_vcpu)->sched_priv) +#define CSCHED_VCPU(_vcpu) ((struct csched_vcpu *) (_vcpu)->sched_item->p= riv) #define CSCHED_DOM(_dom) ((struct csched_dom *) (_dom)->sched_priv) #define RUNQ(_cpu) (&(CSCHED_PCPU(_cpu)->runq)) =20 @@ -641,7 +641,7 @@ csched_switch_sched(struct scheduler *new_ops, unsigned= int cpu, =20 ASSERT(svc && is_idle_vcpu(svc->vcpu)); =20 - idle_vcpu[cpu]->sched_priv =3D vdata; + idle_vcpu[cpu]->sched_item->priv =3D vdata; =20 /* * We are holding the runqueue lock already (it's been taken in @@ -1031,7 +1031,7 @@ static void csched_item_insert(const struct scheduler *ops, struct sched_item *item) { struct vcpu *vc =3D item->vcpu; - struct csched_vcpu *svc =3D vc->sched_priv; + struct csched_vcpu *svc =3D item->priv; spinlock_t *lock; =20 BUG_ON( is_idle_vcpu(vc) ); diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index f44286c2a5..9c052c24a7 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -572,7 +572,7 @@ static inline struct csched2_pcpu *csched2_pcpu(unsigne= d int cpu) =20 static inline struct csched2_vcpu *csched2_vcpu(const struct vcpu *v) { - return v->sched_priv; + return v->sched_item->priv; } =20 static inline struct csched2_dom *csched2_dom(const struct domain *d) @@ -970,7 +970,7 @@ _runq_assign(struct csched2_vcpu *svc, struct csched2_r= unqueue_data *rqd) static void runq_assign(const struct scheduler *ops, struct vcpu *vc) { - struct csched2_vcpu *svc =3D vc->sched_priv; + struct csched2_vcpu *svc =3D vc->sched_item->priv; =20 ASSERT(svc->rqd =3D=3D NULL); =20 @@ -997,7 +997,7 @@ _runq_deassign(struct csched2_vcpu *svc) static void runq_deassign(const struct scheduler *ops, struct vcpu *vc) { - struct csched2_vcpu *svc =3D vc->sched_priv; + struct csched2_vcpu *svc =3D vc->sched_item->priv; =20 ASSERT(svc->rqd =3D=3D c2rqd(ops, vc->processor)); =20 @@ -3108,7 +3108,7 @@ static void csched2_item_insert(const struct scheduler *ops, struct sched_item *item) { struct vcpu *vc =3D item->vcpu; - struct csched2_vcpu *svc =3D vc->sched_priv; + struct csched2_vcpu *svc =3D item->priv; struct csched2_dom * const sdom =3D svc->sdom; spinlock_t *lock; =20 @@ -3888,7 +3888,7 @@ csched2_switch_sched(struct scheduler *new_ops, unsig= ned int cpu, ASSERT(!local_irq_is_enabled()); write_lock(&prv->lock); =20 - idle_vcpu[cpu]->sched_priv =3D vdata; + idle_vcpu[cpu]->sched_item->priv =3D vdata; =20 rqi =3D init_pdata(prv, pdata, cpu); =20 diff --git a/xen/common/sched_null.c b/xen/common/sched_null.c index 7b508f35a4..eb51ddbccb 100644 --- a/xen/common/sched_null.c +++ b/xen/common/sched_null.c @@ -117,7 +117,7 @@ static inline struct null_private *null_priv(const stru= ct scheduler *ops) =20 static inline struct null_vcpu *null_vcpu(const struct vcpu *v) { - return v->sched_priv; + return v->sched_item->priv; } =20 static inline bool vcpu_check_affinity(struct vcpu *v, unsigned int cpu, @@ -391,7 +391,7 @@ static void null_switch_sched(struct scheduler *new_ops= , unsigned int cpu, =20 ASSERT(nvc && is_idle_vcpu(nvc->vcpu)); =20 - idle_vcpu[cpu]->sched_priv =3D vdata; + idle_vcpu[cpu]->sched_item->priv =3D vdata; =20 /* * We are holding the runqueue lock already (it's been taken in diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index ab8fa02306..c830aac92f 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -235,7 +235,7 @@ static inline struct rt_private *rt_priv(const struct s= cheduler *ops) =20 static inline struct rt_vcpu *rt_vcpu(const struct vcpu *vcpu) { - return vcpu->sched_priv; + return vcpu->sched_item->priv; } =20 static inline struct list_head *rt_runq(const struct scheduler *ops) @@ -761,7 +761,7 @@ rt_switch_sched(struct scheduler *new_ops, unsigned int= cpu, dprintk(XENLOG_DEBUG, "RTDS: timer initialized on cpu %u\n", cpu); } =20 - idle_vcpu[cpu]->sched_priv =3D vdata; + idle_vcpu[cpu]->sched_item->priv =3D vdata; per_cpu(scheduler, cpu) =3D new_ops; per_cpu(schedule_data, cpu).sched_priv =3D NULL; /* no pdata */ =20 diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 071289b9c0..795d56a793 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -269,8 +269,8 @@ int sched_init_vcpu(struct vcpu *v, unsigned int proces= sor) init_timer(&v->poll_timer, poll_timer_fn, v, v->processor); =20 - v->sched_priv =3D sched_alloc_vdata(dom_scheduler(d), item, d->sched_p= riv); - if ( v->sched_priv =3D=3D NULL ) + item->priv =3D sched_alloc_vdata(dom_scheduler(d), item, d->sched_priv= ); + if ( item->priv =3D=3D NULL ) { v->sched_item =3D NULL; xfree(item); @@ -365,7 +365,7 @@ int sched_move_domain(struct domain *d, struct cpupool = *c) { spinlock_t *lock; =20 - vcpudata =3D v->sched_priv; + vcpudata =3D v->sched_item->priv; =20 migrate_timer(&v->periodic_timer, new_p); migrate_timer(&v->singleshot_timer, new_p); @@ -383,7 +383,7 @@ int sched_move_domain(struct domain *d, struct cpupool = *c) */ spin_unlock_irq(lock); =20 - v->sched_priv =3D vcpu_priv[v->vcpu_id]; + v->sched_item->priv =3D vcpu_priv[v->vcpu_id]; if ( !d->is_dying ) sched_move_irqs(v); =20 @@ -415,7 +415,7 @@ void sched_destroy_vcpu(struct vcpu *v) if ( test_and_clear_bool(v->is_urgent) ) atomic_dec(&per_cpu(schedule_data, v->processor).urgent_count); sched_remove_item(vcpu_scheduler(v), item); - sched_free_vdata(vcpu_scheduler(v), v->sched_priv); + sched_free_vdata(vcpu_scheduler(v), item->priv); xfree(item); v->sched_item =3D NULL; } @@ -1593,6 +1593,7 @@ static int cpu_schedule_up(unsigned int cpu) else { struct vcpu *idle =3D idle_vcpu[cpu]; + struct sched_item *item =3D idle->sched_item; =20 /* * During (ACPI?) suspend the idle vCPU for this pCPU is not freed, @@ -1604,11 +1605,10 @@ static int cpu_schedule_up(unsigned int cpu) * with a different scheduler, it is schedule_cpu_switch(), invoked * later, that will set things up as appropriate. */ - ASSERT(idle->sched_priv =3D=3D NULL); + ASSERT(item->priv =3D=3D NULL); =20 - idle->sched_priv =3D sched_alloc_vdata(&ops, idle->sched_item, - idle->domain->sched_priv); - if ( idle->sched_priv =3D=3D NULL ) + item->priv =3D sched_alloc_vdata(&ops, item, idle->domain->sched_p= riv); + if ( item->priv =3D=3D NULL ) return -ENOMEM; } if ( idle_vcpu[cpu] =3D=3D NULL ) @@ -1634,9 +1634,9 @@ static void cpu_schedule_down(unsigned int cpu) struct scheduler *sched =3D per_cpu(scheduler, cpu); =20 sched_free_pdata(sched, sd->sched_priv, cpu); - sched_free_vdata(sched, idle_vcpu[cpu]->sched_priv); + sched_free_vdata(sched, idle_vcpu[cpu]->sched_item->priv); =20 - idle_vcpu[cpu]->sched_priv =3D NULL; + idle_vcpu[cpu]->sched_item->priv =3D NULL; sd->sched_priv =3D NULL; =20 kill_timer(&sd->s_timer); @@ -1861,7 +1861,7 @@ int schedule_cpu_switch(unsigned int cpu, struct cpup= ool *c) */ old_lock =3D pcpu_schedule_lock_irq(cpu); =20 - vpriv_old =3D idle->sched_priv; + vpriv_old =3D idle->sched_item->priv; ppriv_old =3D per_cpu(schedule_data, cpu).sched_priv; sched_switch_sched(new_ops, cpu, ppriv, vpriv); =20 diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 85f9119d48..45857b4d35 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -162,7 +162,6 @@ struct vcpu struct timer poll_timer; /* timeout for SCHEDOP_poll */ =20 struct sched_item *sched_item; - void *sched_priv; /* scheduler-specific data */ =20 struct vcpu_runstate_info runstate; #ifndef CONFIG_COMPAT @@ -279,6 +278,7 @@ struct vcpu =20 struct sched_item { struct vcpu *vcpu; + void *priv; /* scheduler private data */ }; =20 /* Per-domain lock can be recursively acquired in fault handlers. */ --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125920; cv=none; d=zoho.com; s=zohoarc; b=GDeBaC/VGjHjdizpu/pQuxnRvUufTvrsk05aGlWl9dQOu1bGQFzYcQQ+94rliKz5idPAFP2cOLr0CPWKuWlg3iStqGk3VFeynfdYRkqUnjRAg+UhjbNjvX/OD1BCS4cjl/uh5bdMAX7d/ihkQoqe+fNTQ1dACXEQxN2aVGDl5fs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125920; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=6joTyp+lyOPf4OvAi1VSKtGtikE3JaWc6+LjqFdMT98=; b=Icb0SQW16BnWwPp1CXQc8d6v6SUNw2fepwDowffhzWl8xNeM6MA0erZlVrcAfH4PhMmmia0bW6rUsXgX31CRaH/KVISPVbsKQx55Vn2YJCYLWz3e8M+Hb67I03wjO2vr+fwKt52H3zASuw4dhGzTsaTcmdRG8l6v0SMGaFBtPR8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125920871304.049832728797; Sun, 5 May 2019 23:58:40 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYd-0001ze-JY; Mon, 06 May 2019 06:57:03 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYb-0001wr-O1 for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:01 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 2044310c-6fcc-11e9-a0a7-1be20a8da492; Mon, 06 May 2019 06:56:52 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id AB92FAE3F; Mon, 6 May 2019 06:56:49 +0000 (UTC) X-Inumbo-ID: 2044310c-6fcc-11e9-a0a7-1be20a8da492 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:04 +0200 Message-Id: <20190506065644.7415-6-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 05/45] xen/sched: build a linked list of struct sched_item X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Tim Deegan , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Dario Faggioli , Julien Grall , Jan Beulich MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" In order to make it easy to iterate over sched_item elements of a domain build a single linked list and add an iterator for it. The new list is guarded by the same mechanisms as the vcpu linked list as it is modified only via vcpu_create() or vcpu_destroy(). For completeness add another iterator for_each_sched_item_vcpu() which will iterate over all vcpus if a sched_item (right now only one). This will be needed later for larger scheduling granularity (e.g. cores). Signed-off-by: Juergen Gross --- xen/common/schedule.c | 56 ++++++++++++++++++++++++++++++++++++++++++---= ---- xen/include/xen/sched.h | 9 ++++++++ 2 files changed, 58 insertions(+), 7 deletions(-) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 795d56a793..2d719a6acc 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -249,6 +249,52 @@ static void sched_spin_unlock_double(spinlock_t *lock1= , spinlock_t *lock2, spin_unlock_irqrestore(lock1, flags); } =20 +static void sched_free_item(struct sched_item *item) +{ + struct sched_item *prev_item; + struct domain *d =3D item->vcpu->domain; + + if ( d->sched_item_list =3D=3D item ) + d->sched_item_list =3D item->next_in_list; + else + { + for_each_sched_item(d, prev_item) + { + if ( prev_item->next_in_list =3D=3D item ) + { + prev_item->next_in_list =3D item->next_in_list; + break; + } + } + } + + item->vcpu->sched_item =3D NULL; + xfree(item); +} + +static struct sched_item *sched_alloc_item(struct vcpu *v) +{ + struct sched_item *item, **prev_item; + struct domain *d =3D v->domain; + + if ( (item =3D xzalloc(struct sched_item)) =3D=3D NULL ) + return NULL; + + v->sched_item =3D item; + item->vcpu =3D v; + + for ( prev_item =3D &d->sched_item_list; *prev_item; + prev_item =3D &(*prev_item)->next_in_list ) + if ( (*prev_item)->next_in_list && + (*prev_item)->next_in_list->vcpu->vcpu_id > v->vcpu_id ) + break; + + item->next_in_list =3D *prev_item; + *prev_item =3D item; + + return item; +} + int sched_init_vcpu(struct vcpu *v, unsigned int processor) { struct domain *d =3D v->domain; @@ -256,10 +302,8 @@ int sched_init_vcpu(struct vcpu *v, unsigned int proce= ssor) =20 v->processor =3D processor; =20 - if ( (item =3D xzalloc(struct sched_item)) =3D=3D NULL ) + if ( (item =3D sched_alloc_item(v)) =3D=3D NULL ) return 1; - v->sched_item =3D item; - item->vcpu =3D v; =20 /* Initialise the per-vcpu timers. */ init_timer(&v->periodic_timer, vcpu_periodic_timer_fn, @@ -272,8 +316,7 @@ int sched_init_vcpu(struct vcpu *v, unsigned int proces= sor) item->priv =3D sched_alloc_vdata(dom_scheduler(d), item, d->sched_priv= ); if ( item->priv =3D=3D NULL ) { - v->sched_item =3D NULL; - xfree(item); + sched_free_item(item); return 1; } =20 @@ -416,8 +459,7 @@ void sched_destroy_vcpu(struct vcpu *v) atomic_dec(&per_cpu(schedule_data, v->processor).urgent_count); sched_remove_item(vcpu_scheduler(v), item); sched_free_vdata(vcpu_scheduler(v), item->priv); - xfree(item); - v->sched_item =3D NULL; + sched_free_item(item); } =20 int sched_init_domain(struct domain *d, int poolid) diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 45857b4d35..bd6489a33d 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -279,8 +279,16 @@ struct vcpu struct sched_item { struct vcpu *vcpu; void *priv; /* scheduler private data */ + struct sched_item *next_in_list; }; =20 +#define for_each_sched_item(d, e) \ + for ( (e) =3D (d)->sched_item_list; (e) !=3D NULL; (e) =3D (e)->next_i= n_list ) + +#define for_each_sched_item_vcpu(i, v) \ + for ( (v) =3D (i)->vcpu; (v) !=3D NULL && (v)->sched_item =3D=3D (i); = \ + (v) =3D (v)->next_in_list ) + /* Per-domain lock can be recursively acquired in fault handlers. */ #define domain_lock(d) spin_lock_recursive(&(d)->domain_lock) #define domain_unlock(d) spin_unlock_recursive(&(d)->domain_lock) @@ -339,6 +347,7 @@ struct domain =20 /* Scheduling. */ void *sched_priv; /* scheduler-specific data */ + struct sched_item *sched_item_list; struct cpupool *cpupool; =20 struct domain *next_in_list; --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125913; cv=none; d=zoho.com; s=zohoarc; b=Nk8kYzRxUj2AD3pfn+w1mCyTdzMv/iQ6Hdmjq/x4j3ip8p/4XPD/aEycZS+WIan2SMDqhFOKDaN728LHDzwLKr53E1qXYgsiNQNKiA0d7gkVnIdKZ7jMfRfCWlqzlhNziTbFpksDMeeRxSnRnC2MbvdSSJCAXDh02q9C9MszVDM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125913; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=QMWuIfxHmcQaFzODmhAdp+/QAL//vhCsg/0T/gxaVGY=; b=l9/W+8Jr/tdI6XnLAZ6hsMNuKjGy5MIBJ/QWHj2tEynS4tfDNJtJOgD+U3e7swbD27acaiBerdlHii1o80sEE40WQTXdsR9d7AfumUhTu/rWdVPGIelyEzqv1pmnHJU97sKKNvDZ3er6DAA/5GQ7z5HcFnLt+O2XlYYikfe/UBQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125913653159.14867054079377; Sun, 5 May 2019 23:58:33 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYd-0001yI-5g; Mon, 06 May 2019 06:57:03 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYb-0001wq-Nd for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:01 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 20443224-6fcc-11e9-a7f1-eb0466932004; Mon, 06 May 2019 06:56:52 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 09644AEAE; Mon, 6 May 2019 06:56:50 +0000 (UTC) X-Inumbo-ID: 20443224-6fcc-11e9-a7f1-eb0466932004 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:05 +0200 Message-Id: <20190506065644.7415-7-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 06/45] xen/sched: introduce struct sched_resource X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Tim Deegan , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Dario Faggioli , Julien Grall , Meng Xu , Jan Beulich MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Add a scheduling abstraction layer between physical processors and the schedulers by introducing a struct sched_resource. Each scheduler item running is active on such a scheduler resource. For the time being there is one struct sched_resource per cpu, but in future there might be one for each core or socket only. Signed-off-by: Juergen Gross --- xen/common/sched_credit.c | 2 ++ xen/common/sched_credit2.c | 7 +++++++ xen/common/sched_null.c | 3 +++ xen/common/sched_rt.c | 2 ++ xen/common/schedule.c | 15 +++++++++++++++ xen/include/xen/sched-if.h | 8 ++++++++ xen/include/xen/sched.h | 3 +++ 7 files changed, 40 insertions(+) diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index cb8e167fc9..fc068a1c5f 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -1040,6 +1040,7 @@ csched_item_insert(const struct scheduler *ops, struc= t sched_item *item) lock =3D vcpu_schedule_lock_irq(vc); =20 vc->processor =3D csched_cpu_pick(ops, item); + item->res =3D per_cpu(sched_res, vc->processor); =20 spin_unlock_irq(lock); =20 @@ -1675,6 +1676,7 @@ csched_runq_steal(int peer_cpu, int cpu, int pri, int= balance_step) WARN_ON(vc->is_urgent); runq_remove(speer); vc->processor =3D cpu; + vc->sched_item->res =3D per_cpu(sched_res, cpu); /* * speer will start executing directly on cpu, without having = to * go through runq_insert(). So we must update the runnable co= unt diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index 9c052c24a7..614d71d948 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -2519,6 +2519,7 @@ static void migrate(const struct scheduler *ops, &trqd->active); svc->vcpu->processor =3D cpumask_cycle(trqd->pick_bias, cpumask_scratch_cpu(cpu)); + svc->vcpu->sched_item->res =3D per_cpu(sched_res, svc->vcpu->proce= ssor); trqd->pick_bias =3D svc->vcpu->processor; ASSERT(svc->vcpu->processor < nr_cpu_ids); =20 @@ -2774,6 +2775,7 @@ csched2_item_migrate( } _runq_deassign(svc); vc->processor =3D new_cpu; + item->res =3D per_cpu(sched_res, new_cpu); return; } =20 @@ -2794,7 +2796,10 @@ csched2_item_migrate( if ( trqd !=3D svc->rqd ) migrate(ops, svc, trqd, now); else + { vc->processor =3D new_cpu; + item->res =3D per_cpu(sched_res, new_cpu); + } } =20 static int @@ -3119,6 +3124,7 @@ csched2_item_insert(const struct scheduler *ops, stru= ct sched_item *item) lock =3D vcpu_schedule_lock_irq(vc); =20 vc->processor =3D csched2_cpu_pick(ops, item); + item->res =3D per_cpu(sched_res, vc->processor); =20 spin_unlock_irq(lock); =20 @@ -3596,6 +3602,7 @@ csched2_schedule( { snext->credit +=3D CSCHED2_MIGRATE_COMPENSATION; snext->vcpu->processor =3D cpu; + snext->vcpu->sched_item->res =3D per_cpu(sched_res, cpu); SCHED_STAT_CRANK(migrated); ret.migrated =3D 1; } diff --git a/xen/common/sched_null.c b/xen/common/sched_null.c index eb51ddbccb..114b32e2e1 100644 --- a/xen/common/sched_null.c +++ b/xen/common/sched_null.c @@ -343,6 +343,7 @@ static void vcpu_assign(struct null_private *prv, struc= t vcpu *v, { per_cpu(npc, cpu).vcpu =3D v; v->processor =3D cpu; + v->sched_item->res =3D per_cpu(sched_res, cpu); cpumask_clear_cpu(cpu, &prv->cpus_free); =20 dprintk(XENLOG_G_INFO, "%d <-- %pv\n", cpu, v); @@ -429,6 +430,7 @@ static void null_item_insert(const struct scheduler *op= s, retry: =20 cpu =3D v->processor =3D pick_cpu(prv, v); + item->res =3D per_cpu(sched_res, cpu); =20 spin_unlock(lock); =20 @@ -675,6 +677,7 @@ static void null_item_migrate(const struct scheduler *o= ps, * by this, will be fixed-up during resume. */ v->processor =3D new_cpu; + item->res =3D per_cpu(sched_res, new_cpu); } =20 #ifndef NDEBUG diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index c830aac92f..44b86fc08d 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -902,6 +902,7 @@ rt_item_insert(const struct scheduler *ops, struct sche= d_item *item) =20 /* This is safe because vc isn't yet being scheduled */ vc->processor =3D rt_cpu_pick(ops, item); + item->res =3D per_cpu(sched_res, vc->processor); =20 lock =3D vcpu_schedule_lock_irq(vc); =20 @@ -1132,6 +1133,7 @@ rt_schedule(const struct scheduler *ops, s_time_t now= , bool_t tasklet_work_sched if ( snext->vcpu->processor !=3D cpu ) { snext->vcpu->processor =3D cpu; + snext->vcpu->sched_item->res =3D per_cpu(sched_res, cpu); ret.migrated =3D 1; } ret.time =3D snext->cur_budget; /* invoke the scheduler next time = */ diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 2d719a6acc..e3d9ab5a3a 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -63,6 +63,7 @@ static void poll_timer_fn(void *data); /* This is global for now so that private implementations can reach it */ DEFINE_PER_CPU(struct schedule_data, schedule_data); DEFINE_PER_CPU(struct scheduler *, scheduler); +DEFINE_PER_CPU(struct sched_resource *, sched_res); =20 /* Scratch space for cpumasks. */ DEFINE_PER_CPU(cpumask_t, cpumask_scratch); @@ -305,6 +306,7 @@ int sched_init_vcpu(struct vcpu *v, unsigned int proces= sor) if ( (item =3D sched_alloc_item(v)) =3D=3D NULL ) return 1; =20 + item->res =3D per_cpu(sched_res, processor); /* Initialise the per-vcpu timers. */ init_timer(&v->periodic_timer, vcpu_periodic_timer_fn, v, v->processor); @@ -419,6 +421,7 @@ int sched_move_domain(struct domain *d, struct cpupool = *c) sched_set_affinity(v, &cpumask_all, &cpumask_all); =20 v->processor =3D new_p; + v->sched_item->res =3D per_cpu(sched_res, new_p); /* * With v->processor modified we must not * - make any further changes assuming we hold the scheduler lock, @@ -787,9 +790,11 @@ void restore_vcpu_affinity(struct domain *d) } =20 v->processor =3D cpumask_any(cpumask_scratch_cpu(cpu)); + v->sched_item->res =3D per_cpu(sched_res, v->processor); =20 lock =3D vcpu_schedule_lock_irq(v); v->processor =3D sched_pick_cpu(vcpu_scheduler(v), v->sched_item); + v->sched_item->res =3D per_cpu(sched_res, v->processor); spin_unlock_irq(lock); =20 if ( old_cpu !=3D v->processor ) @@ -1618,6 +1623,13 @@ static int cpu_schedule_up(unsigned int cpu) { struct schedule_data *sd =3D &per_cpu(schedule_data, cpu); void *sched_priv; + struct sched_resource *res; + + res =3D xzalloc(struct sched_resource); + if ( res =3D=3D NULL ) + return -ENOMEM; + res->processor =3D cpu; + per_cpu(sched_res, cpu) =3D res; =20 per_cpu(scheduler, cpu) =3D &ops; spin_lock_init(&sd->_lock); @@ -1682,6 +1694,9 @@ static void cpu_schedule_down(unsigned int cpu) sd->sched_priv =3D NULL; =20 kill_timer(&sd->s_timer); + + xfree(per_cpu(sched_res, cpu)); + per_cpu(sched_res, cpu) =3D NULL; } =20 static int cpu_schedule_callback( diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index b4a93bb76b..10570c9f6e 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -44,9 +44,14 @@ struct schedule_data { =20 #define curr_on_cpu(c) (per_cpu(schedule_data, c).curr) =20 +struct sched_resource { + unsigned processor; +}; + DECLARE_PER_CPU(struct schedule_data, schedule_data); DECLARE_PER_CPU(struct scheduler *, scheduler); DECLARE_PER_CPU(struct cpupool *, cpupool); +DECLARE_PER_CPU(struct sched_resource *, sched_res); =20 /* * Scratch space, for avoiding having too many cpumask_t on the stack. @@ -362,7 +367,10 @@ static inline void sched_migrate(const struct schedule= r *s, if ( s->migrate ) s->migrate(s, item, cpu); else + { item->vcpu->processor =3D cpu; + item->res =3D per_cpu(sched_res, cpu); + } } =20 static inline int sched_pick_cpu(const struct scheduler *s, diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index bd6489a33d..aa4ff25f76 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -276,10 +276,13 @@ struct vcpu struct arch_vcpu arch; }; =20 +struct sched_resource; + struct sched_item { struct vcpu *vcpu; void *priv; /* scheduler private data */ struct sched_item *next_in_list; + struct sched_resource *res; }; =20 #define for_each_sched_item(d, e) \ --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125926; cv=none; d=zoho.com; s=zohoarc; b=TI0NqFVvbOWgdz2IOeuatKfpfTkOflx7PwDduLYkKNGLGrCfHPWV4TGT1vSGWRAYvDZldDP3A5vABqbOFD93DCxD880p5S0fVAfIXMZsq+vkwAsvoWBahITXhbI4WGI8Xgj/PcnMoygzwLJW78D7qESPtdCy3pX1peI8vkYPKvk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125926; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=9Zmp1HmFKh3lP+QIVnK/4CDgllu5mjUh6wWJ5DvlWHM=; b=XU16H959kzixkNt4o5lfOjLvRH2WLyRSV/UDJE98osUi8IP3gHrKUSqQCkc3a9V/9vs7B6WbIguzR9quwRBTQ1IR2N2sQ5i7yvGc+4+c4xF00ofaNVAyJKdzrpoAVTPaWmywhUQ8nCUnlS4XuLszH6PRBcmlAFxZJhkcKOQ61oE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125926370404.45604234572863; Sun, 5 May 2019 23:58:46 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYX-0001tE-0F; Mon, 06 May 2019 06:56:57 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYV-0001sn-G4 for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:56:55 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 21232ad4-6fcc-11e9-843c-bc764e045a96; Mon, 06 May 2019 06:56:53 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 629ADAEC3; Mon, 6 May 2019 06:56:50 +0000 (UTC) X-Inumbo-ID: 21232ad4-6fcc-11e9-843c-bc764e045a96 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:06 +0200 Message-Id: <20190506065644.7415-8-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 07/45] xen/sched: let pick_cpu return a scheduler resource X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Tim Deegan , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Robert VanVossen , Dario Faggioli , Julien Grall , Josh Whitehead , Meng Xu , Jan Beulich MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Instead of returning a physical cpu number let pick_cpu() return a scheduler resource instead. Rename pick_cpu() to pick_resource() to reflect that change. Signed-off-by: Juergen Gross --- xen/common/sched_arinc653.c | 12 ++++++------ xen/common/sched_credit.c | 16 ++++++++-------- xen/common/sched_credit2.c | 22 +++++++++++----------- xen/common/sched_null.c | 20 +++++++++++--------- xen/common/sched_rt.c | 18 +++++++++--------- xen/common/schedule.c | 8 +++++--- xen/include/xen/perfc_defn.h | 2 +- xen/include/xen/sched-if.h | 12 ++++++------ 8 files changed, 57 insertions(+), 53 deletions(-) diff --git a/xen/common/sched_arinc653.c b/xen/common/sched_arinc653.c index f5af8b972d..a775be4cbc 100644 --- a/xen/common/sched_arinc653.c +++ b/xen/common/sched_arinc653.c @@ -601,15 +601,15 @@ a653sched_do_schedule( } =20 /** - * Xen scheduler callback function to select a CPU for the VCPU to run on + * Xen scheduler callback function to select a resource for the VCPU to ru= n on * * @param ops Pointer to this instance of the scheduler structure * @param item Pointer to struct sched_item * - * @return Number of selected physical CPU + * @return Scheduler resource to run on */ -static int -a653sched_pick_cpu(const struct scheduler *ops, struct sched_item *item) +static struct sched_resource * +a653sched_pick_resource(const struct scheduler *ops, struct sched_item *it= em) { struct vcpu *vc =3D item->vcpu; cpumask_t *online; @@ -627,7 +627,7 @@ a653sched_pick_cpu(const struct scheduler *ops, struct = sched_item *item) || (cpu >=3D nr_cpu_ids) ) cpu =3D vc->processor; =20 - return cpu; + return per_cpu(sched_res, cpu); } =20 /** @@ -730,7 +730,7 @@ static const struct scheduler sched_arinc653_def =3D { =20 .do_schedule =3D a653sched_do_schedule, =20 - .pick_cpu =3D a653sched_pick_cpu, + .pick_resource =3D a653sched_pick_resource, =20 .switch_sched =3D a653_switch_sched, =20 diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index fc068a1c5f..14b749dc1a 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -867,8 +867,8 @@ _csched_cpu_pick(const struct scheduler *ops, struct vc= pu *vc, bool_t commit) return cpu; } =20 -static int -csched_cpu_pick(const struct scheduler *ops, struct sched_item *item) +static struct sched_resource * +csched_res_pick(const struct scheduler *ops, struct sched_item *item) { struct vcpu *vc =3D item->vcpu; struct csched_vcpu *svc =3D CSCHED_VCPU(vc); @@ -881,7 +881,7 @@ csched_cpu_pick(const struct scheduler *ops, struct sch= ed_item *item) * get boosted, which we don't deserve as we are "only" migrating. */ set_bit(CSCHED_FLAG_VCPU_MIGRATING, &svc->flags); - return _csched_cpu_pick(ops, vc, 1); + return per_cpu(sched_res, _csched_cpu_pick(ops, vc, 1)); } =20 static inline void @@ -981,7 +981,7 @@ csched_vcpu_acct(struct csched_private *prv, unsigned i= nt cpu) /* * If it's been active a while, check if we'd be better off * migrating it to run elsewhere (see multi-core and multi-thread - * support in csched_cpu_pick()). + * support in csched_res_pick()). */ new_cpu =3D _csched_cpu_pick(ops, current, 0); =20 @@ -1036,11 +1036,11 @@ csched_item_insert(const struct scheduler *ops, str= uct sched_item *item) =20 BUG_ON( is_idle_vcpu(vc) ); =20 - /* csched_cpu_pick() looks in vc->processor's runq, so we need the loc= k. */ + /* csched_res_pick() looks in vc->processor's runq, so we need the loc= k. */ lock =3D vcpu_schedule_lock_irq(vc); =20 - vc->processor =3D csched_cpu_pick(ops, item); - item->res =3D per_cpu(sched_res, vc->processor); + item->res =3D csched_res_pick(ops, item); + vc->processor =3D item->res->processor; =20 spin_unlock_irq(lock); =20 @@ -2290,7 +2290,7 @@ static const struct scheduler sched_credit_def =3D { .adjust_affinity=3D csched_aff_cntl, .adjust_global =3D csched_sys_cntl, =20 - .pick_cpu =3D csched_cpu_pick, + .pick_resource =3D csched_res_pick, .do_schedule =3D csched_schedule, =20 .dump_cpu_state =3D csched_dump_pcpu, diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index 614d71d948..c8ae585272 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -625,9 +625,9 @@ static inline bool has_cap(const struct csched2_vcpu *s= vc) * runq, _always_ happens by means of tickling: * - when a vcpu wakes up, it calls csched2_item_wake(), which calls * runq_tickle(); - * - when a migration is initiated in schedule.c, we call csched2_cpu_pic= k(), + * - when a migration is initiated in schedule.c, we call csched2_res_pic= k(), * csched2_item_migrate() (which calls migrate()) and csched2_item_wake= (). - * csched2_cpu_pick() looks for the least loaded runq and return just a= ny + * csched2_res_pick() looks for the least loaded runq and return just a= ny * of its processors. Then, csched2_item_migrate() just moves the vcpu = to * the chosen runq, and it is again runq_tickle(), called by * csched2_item_wake() that actually decides what pcpu to use within the @@ -676,7 +676,7 @@ void smt_idle_mask_clear(unsigned int cpu, cpumask_t *m= ask) } =20 /* - * In csched2_cpu_pick(), it may not be possible to actually look at remote + * In csched2_res_pick(), it may not be possible to actually look at remote * runqueues (the trylock-s on their spinlocks can fail!). If that happens, * we pick, in order of decreasing preference: * 1) svc's current pcpu, if it is part of svc's soft affinity; @@ -2201,8 +2201,8 @@ csched2_context_saved(const struct scheduler *ops, st= ruct sched_item *item) } =20 #define MAX_LOAD (STIME_MAX) -static int -csched2_cpu_pick(const struct scheduler *ops, struct sched_item *item) +static struct sched_resource * +csched2_res_pick(const struct scheduler *ops, struct sched_item *item) { struct csched2_private *prv =3D csched2_priv(ops); struct vcpu *vc =3D item->vcpu; @@ -2214,7 +2214,7 @@ csched2_cpu_pick(const struct scheduler *ops, struct = sched_item *item) =20 ASSERT(!cpumask_empty(&prv->active_queues)); =20 - SCHED_STAT_CRANK(pick_cpu); + SCHED_STAT_CRANK(pick_resource); =20 /* Locking: * - Runqueue lock of vc->processor is already locked @@ -2423,7 +2423,7 @@ csched2_cpu_pick(const struct scheduler *ops, struct = sched_item *item) (unsigned char *)&d); } =20 - return new_cpu; + return per_cpu(sched_res, new_cpu); } =20 /* Working state of the load-balancing algorithm */ @@ -3120,11 +3120,11 @@ csched2_item_insert(const struct scheduler *ops, st= ruct sched_item *item) ASSERT(!is_idle_vcpu(vc)); ASSERT(list_empty(&svc->runq_elem)); =20 - /* csched2_cpu_pick() expects the pcpu lock to be held */ + /* csched2_res_pick() expects the pcpu lock to be held */ lock =3D vcpu_schedule_lock_irq(vc); =20 - vc->processor =3D csched2_cpu_pick(ops, item); - item->res =3D per_cpu(sched_res, vc->processor); + item->res =3D csched2_res_pick(ops, item); + vc->processor =3D item->res->processor; =20 spin_unlock_irq(lock); =20 @@ -4113,7 +4113,7 @@ static const struct scheduler sched_credit2_def =3D { .adjust_affinity=3D csched2_aff_cntl, .adjust_global =3D csched2_sys_cntl, =20 - .pick_cpu =3D csched2_cpu_pick, + .pick_resource =3D csched2_res_pick, .migrate =3D csched2_item_migrate, .do_schedule =3D csched2_schedule, .context_saved =3D csched2_context_saved, diff --git a/xen/common/sched_null.c b/xen/common/sched_null.c index 114b32e2e1..a08f23993c 100644 --- a/xen/common/sched_null.c +++ b/xen/common/sched_null.c @@ -269,9 +269,11 @@ static void null_free_domdata(const struct scheduler *= ops, void *data) * * So this is not part of any hot path. */ -static unsigned int pick_cpu(struct null_private *prv, struct vcpu *v) +static struct sched_resource * +pick_res(struct null_private *prv, struct sched_item *item) { unsigned int bs; + struct vcpu *v =3D item->vcpu; unsigned int cpu =3D v->processor, new_cpu; cpumask_t *cpus =3D cpupool_domain_cpumask(v->domain); =20 @@ -335,7 +337,7 @@ static unsigned int pick_cpu(struct null_private *prv, = struct vcpu *v) __trace_var(TRC_SNULL_PICKED_CPU, 1, sizeof(d), &d); } =20 - return new_cpu; + return per_cpu(sched_res, new_cpu); } =20 static void vcpu_assign(struct null_private *prv, struct vcpu *v, @@ -429,8 +431,8 @@ static void null_item_insert(const struct scheduler *op= s, lock =3D vcpu_schedule_lock_irq(v); retry: =20 - cpu =3D v->processor =3D pick_cpu(prv, v); - item->res =3D per_cpu(sched_res, cpu); + item->res =3D pick_res(prv, item); + cpu =3D v->processor =3D item->res->processor; =20 spin_unlock(lock); =20 @@ -586,11 +588,11 @@ static void null_item_sleep(const struct scheduler *o= ps, SCHED_STAT_CRANK(vcpu_sleep); } =20 -static int null_cpu_pick(const struct scheduler *ops, struct sched_item *i= tem) +static struct sched_resource * +null_res_pick(const struct scheduler *ops, struct sched_item *item) { - struct vcpu *v =3D item->vcpu; - ASSERT(!is_idle_vcpu(v)); - return pick_cpu(null_priv(ops), v); + ASSERT(!is_idle_vcpu(item->vcpu)); + return pick_res(null_priv(ops), item); } =20 static void null_item_migrate(const struct scheduler *ops, @@ -909,7 +911,7 @@ const struct scheduler sched_null_def =3D { =20 .wake =3D null_item_wake, .sleep =3D null_item_sleep, - .pick_cpu =3D null_cpu_pick, + .pick_resource =3D null_res_pick, .migrate =3D null_item_migrate, .do_schedule =3D null_schedule, =20 diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index 44b86fc08d..2bd4637592 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -632,12 +632,12 @@ replq_reinsert(const struct scheduler *ops, struct rt= _vcpu *svc) } =20 /* - * Pick a valid CPU for the vcpu vc - * Valid CPU of a vcpu is intesection of vcpu's affinity - * and available cpus + * Pick a valid resource for the vcpu vc + * Valid resource of a vcpu is intesection of vcpu's affinity + * and available resources */ -static int -rt_cpu_pick(const struct scheduler *ops, struct sched_item *item) +static struct sched_resource * +rt_res_pick(const struct scheduler *ops, struct sched_item *item) { struct vcpu *vc =3D item->vcpu; cpumask_t cpus; @@ -652,7 +652,7 @@ rt_cpu_pick(const struct scheduler *ops, struct sched_i= tem *item) : cpumask_cycle(vc->processor, &cpus); ASSERT( !cpumask_empty(&cpus) && cpumask_test_cpu(cpu, &cpus) ); =20 - return cpu; + return per_cpu(sched_res, cpu); } =20 /* @@ -901,8 +901,8 @@ rt_item_insert(const struct scheduler *ops, struct sche= d_item *item) BUG_ON( is_idle_vcpu(vc) ); =20 /* This is safe because vc isn't yet being scheduled */ - vc->processor =3D rt_cpu_pick(ops, item); - item->res =3D per_cpu(sched_res, vc->processor); + item->res =3D rt_res_pick(ops, item); + vc->processor =3D item->res->processor; =20 lock =3D vcpu_schedule_lock_irq(vc); =20 @@ -1571,7 +1571,7 @@ static const struct scheduler sched_rtds_def =3D { =20 .adjust =3D rt_dom_cntl, =20 - .pick_cpu =3D rt_cpu_pick, + .pick_resource =3D rt_res_pick, .do_schedule =3D rt_schedule, .sleep =3D rt_item_sleep, .wake =3D rt_item_wake, diff --git a/xen/common/schedule.c b/xen/common/schedule.c index e3d9ab5a3a..81eecaa689 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -687,7 +687,8 @@ static void vcpu_migrate_finish(struct vcpu *v) break; =20 /* Select a new CPU. */ - new_cpu =3D sched_pick_cpu(vcpu_scheduler(v), v->sched_item); + new_cpu =3D sched_pick_resource(vcpu_scheduler(v), + v->sched_item)->processor; if ( (new_lock =3D=3D per_cpu(schedule_data, new_cpu).schedule= _lock) && cpumask_test_cpu(new_cpu, v->domain->cpupool->cpu_valid) ) break; @@ -793,8 +794,9 @@ void restore_vcpu_affinity(struct domain *d) v->sched_item->res =3D per_cpu(sched_res, v->processor); =20 lock =3D vcpu_schedule_lock_irq(v); - v->processor =3D sched_pick_cpu(vcpu_scheduler(v), v->sched_item); - v->sched_item->res =3D per_cpu(sched_res, v->processor); + v->sched_item->res =3D sched_pick_resource(vcpu_scheduler(v), + v->sched_item); + v->processor =3D v->sched_item->res->processor; spin_unlock_irq(lock); =20 if ( old_cpu !=3D v->processor ) diff --git a/xen/include/xen/perfc_defn.h b/xen/include/xen/perfc_defn.h index ef6f86b91e..1ad4384080 100644 --- a/xen/include/xen/perfc_defn.h +++ b/xen/include/xen/perfc_defn.h @@ -69,7 +69,7 @@ PERFCOUNTER(migrate_on_runq, "csched2: migrate_on_= runq") PERFCOUNTER(migrate_no_runq, "csched2: migrate_no_runq") PERFCOUNTER(runtime_min_timer, "csched2: runtime_min_timer") PERFCOUNTER(runtime_max_timer, "csched2: runtime_max_timer") -PERFCOUNTER(pick_cpu, "csched2: pick_cpu") +PERFCOUNTER(pick_resource, "csched2: pick_resource") PERFCOUNTER(need_fallback_cpu, "csched2: need_fallback_cpu") PERFCOUNTER(migrated, "csched2: migrated") PERFCOUNTER(migrate_resisted, "csched2: migrate_resisted") diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index 10570c9f6e..c57cf58e03 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -179,8 +179,8 @@ struct scheduler { struct task_slice (*do_schedule) (const struct scheduler *, s_time_t, bool_t tasklet_work_scheduled); =20 - int (*pick_cpu) (const struct scheduler *, - struct sched_item *); + struct sched_resource * (*pick_resource) (const struct scheduler *, + struct sched_item *); void (*migrate) (const struct scheduler *, struct sched_item *, unsigned int); int (*adjust) (const struct scheduler *, struct domai= n *, @@ -373,11 +373,11 @@ static inline void sched_migrate(const struct schedul= er *s, } } =20 -static inline int sched_pick_cpu(const struct scheduler *s, - struct sched_item *item) +static inline struct sched_resource *sched_pick_resource( + const struct scheduler *s, struct sched_item *item) { - ASSERT(s->pick_cpu); - return s->pick_cpu(s, item); + ASSERT(s->pick_resource); + return s->pick_resource(s, item); } =20 static inline void sched_adjust_affinity(const struct scheduler *s, --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125914; cv=none; d=zoho.com; s=zohoarc; b=bhjXsFeqMej9PSHmEP+/b1zDB61/lFiEMMSW3IZw6ZMZByA43WoLdw+hp/ZD+QR11JP/zkJfTHdoCMs6tVv2qornn0uFKxlV/jRT55VfTM9rXckSBkVxEQRvd+/IPcEKLEPbdI67csZukaEjCHVaWq4JLucZFMJpG3XISBN4JHo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125914; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=MeBZJUaDDsE1Va2++IGqm0ovoUKvktDClPup3fbTkp8=; b=hc14SWrpcFC92HXiKhHzEFet6tq86JNyHT6LA/H2oizr2AJ3lhtC1wnEhNW0xfDwCfIqYEnJo+s1/ttFYS1L70j2D8PRB6Uhl1GtJzYrrQoInq7JhGT//AckDWr/FDSK2L6Im5Rz9rBigTyzqVsFY83MKsS8TL1fjY/r5bXHV5o= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125914368495.66592784927207; Sun, 5 May 2019 23:58:34 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYp-0002PZ-U4; Mon, 06 May 2019 06:57:15 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYi-00028z-AZ for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:08 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 211afd86-6fcc-11e9-8387-eb181d75d5a3; Mon, 06 May 2019 06:56:53 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id BA714AECB; Mon, 6 May 2019 06:56:50 +0000 (UTC) X-Inumbo-ID: 211afd86-6fcc-11e9-8387-eb181d75d5a3 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:07 +0200 Message-Id: <20190506065644.7415-9-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 08/45] xen/sched: switch schedule_data.curr to point at sched_item X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Tim Deegan , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Robert VanVossen , Dario Faggioli , Julien Grall , Josh Whitehead , Meng Xu , Jan Beulich MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" In preparation of core scheduling let the percpu pointer schedule_data.curr point to a strct sched_item instead of the related vcpu. At the same time rename the per-vcpu scheduler specific structs to per-item ones. Signed-off-by: Juergen Gross --- xen/common/sched_arinc653.c | 2 +- xen/common/sched_credit.c | 101 +++++++++++++------------- xen/common/sched_credit2.c | 168 ++++++++++++++++++++++------------------= ---- xen/common/sched_null.c | 44 ++++++------ xen/common/sched_rt.c | 118 +++++++++++++++---------------- xen/common/schedule.c | 8 ++- xen/include/xen/sched-if.h | 2 +- 7 files changed, 220 insertions(+), 223 deletions(-) diff --git a/xen/common/sched_arinc653.c b/xen/common/sched_arinc653.c index a775be4cbc..5701baf337 100644 --- a/xen/common/sched_arinc653.c +++ b/xen/common/sched_arinc653.c @@ -475,7 +475,7 @@ a653sched_item_sleep(const struct scheduler *ops, struc= t sched_item *item) * If the VCPU being put to sleep is the same one that is currently * running, raise a softirq to invoke the scheduler to switch domains. */ - if ( per_cpu(schedule_data, vc->processor).curr =3D=3D vc ) + if ( per_cpu(schedule_data, vc->processor).curr =3D=3D item ) cpu_raise_softirq(vc->processor, SCHEDULE_SOFTIRQ); } =20 diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index 14b749dc1a..6552d4c087 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -83,7 +83,7 @@ ((struct csched_private *)((_ops)->sched_data)) #define CSCHED_PCPU(_c) \ ((struct csched_pcpu *)per_cpu(schedule_data, _c).sched_priv) -#define CSCHED_VCPU(_vcpu) ((struct csched_vcpu *) (_vcpu)->sched_item->p= riv) +#define CSCHED_ITEM(item) ((struct csched_item *) (item)->priv) #define CSCHED_DOM(_dom) ((struct csched_dom *) (_dom)->sched_priv) #define RUNQ(_cpu) (&(CSCHED_PCPU(_cpu)->runq)) =20 @@ -160,7 +160,7 @@ struct csched_pcpu { /* * Virtual CPU */ -struct csched_vcpu { +struct csched_item { struct list_head runq_elem; struct list_head active_vcpu_elem; =20 @@ -231,15 +231,15 @@ static void csched_tick(void *_cpu); static void csched_acct(void *dummy); =20 static inline int -__vcpu_on_runq(struct csched_vcpu *svc) +__vcpu_on_runq(struct csched_item *svc) { return !list_empty(&svc->runq_elem); } =20 -static inline struct csched_vcpu * +static inline struct csched_item * __runq_elem(struct list_head *elem) { - return list_entry(elem, struct csched_vcpu, runq_elem); + return list_entry(elem, struct csched_item, runq_elem); } =20 /* Is the first element of cpu's runq (if any) cpu's idle vcpu? */ @@ -271,7 +271,7 @@ dec_nr_runnable(unsigned int cpu) } =20 static inline void -__runq_insert(struct csched_vcpu *svc) +__runq_insert(struct csched_item *svc) { unsigned int cpu =3D svc->vcpu->processor; const struct list_head * const runq =3D RUNQ(cpu); @@ -281,7 +281,7 @@ __runq_insert(struct csched_vcpu *svc) =20 list_for_each( iter, runq ) { - const struct csched_vcpu * const iter_svc =3D __runq_elem(iter); + const struct csched_item * const iter_svc =3D __runq_elem(iter); if ( svc->pri > iter_svc->pri ) break; } @@ -302,34 +302,34 @@ __runq_insert(struct csched_vcpu *svc) } =20 static inline void -runq_insert(struct csched_vcpu *svc) +runq_insert(struct csched_item *svc) { __runq_insert(svc); inc_nr_runnable(svc->vcpu->processor); } =20 static inline void -__runq_remove(struct csched_vcpu *svc) +__runq_remove(struct csched_item *svc) { BUG_ON( !__vcpu_on_runq(svc) ); list_del_init(&svc->runq_elem); } =20 static inline void -runq_remove(struct csched_vcpu *svc) +runq_remove(struct csched_item *svc) { dec_nr_runnable(svc->vcpu->processor); __runq_remove(svc); } =20 -static void burn_credits(struct csched_vcpu *svc, s_time_t now) +static void burn_credits(struct csched_item *svc, s_time_t now) { s_time_t delta; uint64_t val; unsigned int credits; =20 /* Assert svc is current */ - ASSERT( svc =3D=3D CSCHED_VCPU(curr_on_cpu(svc->vcpu->processor)) ); + ASSERT( svc =3D=3D CSCHED_ITEM(curr_on_cpu(svc->vcpu->processor)) ); =20 if ( (delta =3D now - svc->start_time) <=3D 0 ) return; @@ -347,10 +347,10 @@ boolean_param("tickle_one_idle_cpu", opt_tickle_one_i= dle); =20 DEFINE_PER_CPU(unsigned int, last_tickle_cpu); =20 -static inline void __runq_tickle(struct csched_vcpu *new) +static inline void __runq_tickle(struct csched_item *new) { unsigned int cpu =3D new->vcpu->processor; - struct csched_vcpu * const cur =3D CSCHED_VCPU(curr_on_cpu(cpu)); + struct csched_item * const cur =3D CSCHED_ITEM(curr_on_cpu(cpu)); struct csched_private *prv =3D CSCHED_PRIV(per_cpu(scheduler, cpu)); cpumask_t mask, idle_mask, *online; int balance_step, idlers_empty; @@ -605,7 +605,7 @@ init_pdata(struct csched_private *prv, struct csched_pc= pu *spc, int cpu) spc->idle_bias =3D nr_cpu_ids - 1; =20 /* Start off idling... */ - BUG_ON(!is_idle_vcpu(curr_on_cpu(cpu))); + BUG_ON(!is_idle_vcpu(curr_on_cpu(cpu)->vcpu)); cpumask_set_cpu(cpu, prv->idlers); spc->nr_runnable =3D 0; } @@ -637,7 +637,7 @@ csched_switch_sched(struct scheduler *new_ops, unsigned= int cpu, { struct schedule_data *sd =3D &per_cpu(schedule_data, cpu); struct csched_private *prv =3D CSCHED_PRIV(new_ops); - struct csched_vcpu *svc =3D vdata; + struct csched_item *svc =3D vdata; =20 ASSERT(svc && is_idle_vcpu(svc->vcpu)); =20 @@ -669,7 +669,7 @@ csched_switch_sched(struct scheduler *new_ops, unsigned= int cpu, static inline void __csched_vcpu_check(struct vcpu *vc) { - struct csched_vcpu * const svc =3D CSCHED_VCPU(vc); + struct csched_item * const svc =3D CSCHED_ITEM(vc->sched_item); struct csched_dom * const sdom =3D svc->sdom; =20 BUG_ON( svc->vcpu !=3D vc ); @@ -871,7 +871,7 @@ static struct sched_resource * csched_res_pick(const struct scheduler *ops, struct sched_item *item) { struct vcpu *vc =3D item->vcpu; - struct csched_vcpu *svc =3D CSCHED_VCPU(vc); + struct csched_item *svc =3D CSCHED_ITEM(item); =20 /* * We have been called by vcpu_migrate() (in schedule.c), as part @@ -885,7 +885,7 @@ csched_res_pick(const struct scheduler *ops, struct sch= ed_item *item) } =20 static inline void -__csched_vcpu_acct_start(struct csched_private *prv, struct csched_vcpu *s= vc) +__csched_vcpu_acct_start(struct csched_private *prv, struct csched_item *s= vc) { struct csched_dom * const sdom =3D svc->sdom; unsigned long flags; @@ -915,7 +915,7 @@ __csched_vcpu_acct_start(struct csched_private *prv, st= ruct csched_vcpu *svc) =20 static inline void __csched_vcpu_acct_stop_locked(struct csched_private *prv, - struct csched_vcpu *svc) + struct csched_item *svc) { struct csched_dom * const sdom =3D svc->sdom; =20 @@ -940,7 +940,7 @@ __csched_vcpu_acct_stop_locked(struct csched_private *p= rv, static void csched_vcpu_acct(struct csched_private *prv, unsigned int cpu) { - struct csched_vcpu * const svc =3D CSCHED_VCPU(current); + struct csched_item * const svc =3D CSCHED_ITEM(current->sched_item); const struct scheduler *ops =3D per_cpu(scheduler, cpu); =20 ASSERT( current->processor =3D=3D cpu ); @@ -1009,10 +1009,10 @@ csched_alloc_vdata(const struct scheduler *ops, str= uct sched_item *item, void *dd) { struct vcpu *vc =3D item->vcpu; - struct csched_vcpu *svc; + struct csched_item *svc; =20 /* Allocate per-VCPU info */ - svc =3D xzalloc(struct csched_vcpu); + svc =3D xzalloc(struct csched_item); if ( svc =3D=3D NULL ) return NULL; =20 @@ -1031,7 +1031,7 @@ static void csched_item_insert(const struct scheduler *ops, struct sched_item *item) { struct vcpu *vc =3D item->vcpu; - struct csched_vcpu *svc =3D item->priv; + struct csched_item *svc =3D item->priv; spinlock_t *lock; =20 BUG_ON( is_idle_vcpu(vc) ); @@ -1057,7 +1057,7 @@ csched_item_insert(const struct scheduler *ops, struc= t sched_item *item) static void csched_free_vdata(const struct scheduler *ops, void *priv) { - struct csched_vcpu *svc =3D priv; + struct csched_item *svc =3D priv; =20 BUG_ON( !list_empty(&svc->runq_elem) ); =20 @@ -1068,8 +1068,7 @@ static void csched_item_remove(const struct scheduler *ops, struct sched_item *item) { struct csched_private *prv =3D CSCHED_PRIV(ops); - struct vcpu *vc =3D item->vcpu; - struct csched_vcpu * const svc =3D CSCHED_VCPU(vc); + struct csched_item * const svc =3D CSCHED_ITEM(item); struct csched_dom * const sdom =3D svc->sdom; =20 SCHED_STAT_CRANK(vcpu_remove); @@ -1096,14 +1095,14 @@ static void csched_item_sleep(const struct scheduler *ops, struct sched_item *item) { struct vcpu *vc =3D item->vcpu; - struct csched_vcpu * const svc =3D CSCHED_VCPU(vc); + struct csched_item * const svc =3D CSCHED_ITEM(item); unsigned int cpu =3D vc->processor; =20 SCHED_STAT_CRANK(vcpu_sleep); =20 BUG_ON( is_idle_vcpu(vc) ); =20 - if ( curr_on_cpu(cpu) =3D=3D vc ) + if ( curr_on_cpu(cpu) =3D=3D item ) { /* * We are about to tickle cpu, so we should clear its bit in idler= s. @@ -1121,12 +1120,12 @@ static void csched_item_wake(const struct scheduler *ops, struct sched_item *item) { struct vcpu *vc =3D item->vcpu; - struct csched_vcpu * const svc =3D CSCHED_VCPU(vc); + struct csched_item * const svc =3D CSCHED_ITEM(item); bool_t migrating; =20 BUG_ON( is_idle_vcpu(vc) ); =20 - if ( unlikely(curr_on_cpu(vc->processor) =3D=3D vc) ) + if ( unlikely(curr_on_cpu(vc->processor) =3D=3D item) ) { SCHED_STAT_CRANK(vcpu_wake_running); return; @@ -1182,8 +1181,7 @@ csched_item_wake(const struct scheduler *ops, struct = sched_item *item) static void csched_item_yield(const struct scheduler *ops, struct sched_item *item) { - struct vcpu *vc =3D item->vcpu; - struct csched_vcpu * const svc =3D CSCHED_VCPU(vc); + struct csched_item * const svc =3D CSCHED_ITEM(item); =20 /* Let the scheduler know that this vcpu is trying to yield */ set_bit(CSCHED_FLAG_VCPU_YIELD, &svc->flags); @@ -1238,8 +1236,7 @@ static void csched_aff_cntl(const struct scheduler *ops, struct sched_item *item, const cpumask_t *hard, const cpumask_t *soft) { - struct vcpu *v =3D item->vcpu; - struct csched_vcpu *svc =3D CSCHED_VCPU(v); + struct csched_item *svc =3D CSCHED_ITEM(item); =20 if ( !hard ) return; @@ -1342,7 +1339,7 @@ csched_runq_sort(struct csched_private *prv, unsigned= int cpu) { struct csched_pcpu * const spc =3D CSCHED_PCPU(cpu); struct list_head *runq, *elem, *next, *last_under; - struct csched_vcpu *svc_elem; + struct csched_item *svc_elem; spinlock_t *lock; unsigned long flags; int sort_epoch; @@ -1388,7 +1385,7 @@ csched_acct(void* dummy) unsigned long flags; struct list_head *iter_vcpu, *next_vcpu; struct list_head *iter_sdom, *next_sdom; - struct csched_vcpu *svc; + struct csched_item *svc; struct csched_dom *sdom; uint32_t credit_total; uint32_t weight_total; @@ -1511,7 +1508,7 @@ csched_acct(void* dummy) =20 list_for_each_safe( iter_vcpu, next_vcpu, &sdom->active_vcpu ) { - svc =3D list_entry(iter_vcpu, struct csched_vcpu, active_vcpu_= elem); + svc =3D list_entry(iter_vcpu, struct csched_item, active_vcpu_= elem); BUG_ON( sdom !=3D svc->sdom ); =20 /* Increment credit */ @@ -1614,12 +1611,12 @@ csched_tick(void *_cpu) set_timer(&spc->ticker, NOW() + MICROSECS(prv->tick_period_us) ); } =20 -static struct csched_vcpu * +static struct csched_item * csched_runq_steal(int peer_cpu, int cpu, int pri, int balance_step) { const struct csched_private * const prv =3D CSCHED_PRIV(per_cpu(schedu= ler, cpu)); const struct csched_pcpu * const peer_pcpu =3D CSCHED_PCPU(peer_cpu); - struct csched_vcpu *speer; + struct csched_item *speer; struct list_head *iter; struct vcpu *vc; =20 @@ -1629,7 +1626,7 @@ csched_runq_steal(int peer_cpu, int cpu, int pri, int= balance_step) * Don't steal from an idle CPU's runq because it's about to * pick up work from it itself. */ - if ( unlikely(is_idle_vcpu(curr_on_cpu(peer_cpu))) ) + if ( unlikely(is_idle_vcpu(curr_on_cpu(peer_cpu)->vcpu)) ) goto out; =20 list_for_each( iter, &peer_pcpu->runq ) @@ -1691,12 +1688,12 @@ csched_runq_steal(int peer_cpu, int cpu, int pri, i= nt balance_step) return NULL; } =20 -static struct csched_vcpu * +static struct csched_item * csched_load_balance(struct csched_private *prv, int cpu, - struct csched_vcpu *snext, bool_t *stolen) + struct csched_item *snext, bool_t *stolen) { struct cpupool *c =3D per_cpu(cpupool, cpu); - struct csched_vcpu *speer; + struct csched_item *speer; cpumask_t workers; cpumask_t *online; int peer_cpu, first_cpu, peer_node, bstep; @@ -1845,9 +1842,9 @@ csched_schedule( { const int cpu =3D smp_processor_id(); struct list_head * const runq =3D RUNQ(cpu); - struct csched_vcpu * const scurr =3D CSCHED_VCPU(current); + struct csched_item * const scurr =3D CSCHED_ITEM(current->sched_item); struct csched_private *prv =3D CSCHED_PRIV(ops); - struct csched_vcpu *snext; + struct csched_item *snext; struct task_slice ret; s_time_t runtime, tslice; =20 @@ -1963,7 +1960,7 @@ csched_schedule( if ( tasklet_work_scheduled ) { TRACE_0D(TRC_CSCHED_SCHED_TASKLET); - snext =3D CSCHED_VCPU(idle_vcpu[cpu]); + snext =3D CSCHED_ITEM(idle_vcpu[cpu]->sched_item); snext->pri =3D CSCHED_PRI_TS_BOOST; } =20 @@ -2015,7 +2012,7 @@ out: } =20 static void -csched_dump_vcpu(struct csched_vcpu *svc) +csched_dump_vcpu(struct csched_item *svc) { struct csched_dom * const sdom =3D svc->sdom; =20 @@ -2051,7 +2048,7 @@ csched_dump_pcpu(const struct scheduler *ops, int cpu) struct list_head *runq, *iter; struct csched_private *prv =3D CSCHED_PRIV(ops); struct csched_pcpu *spc; - struct csched_vcpu *svc; + struct csched_item *svc; spinlock_t *lock; unsigned long flags; int loop; @@ -2075,7 +2072,7 @@ csched_dump_pcpu(const struct scheduler *ops, int cpu) nr_cpu_ids, cpumask_bits(per_cpu(cpu_core_mask, cpu))); =20 /* current VCPU (nothing to say if that's the idle vcpu). */ - svc =3D CSCHED_VCPU(curr_on_cpu(cpu)); + svc =3D CSCHED_ITEM(curr_on_cpu(cpu)); if ( svc && !is_idle_vcpu(svc->vcpu) ) { printk("\trun: "); @@ -2144,10 +2141,10 @@ csched_dump(const struct scheduler *ops) =20 list_for_each( iter_svc, &sdom->active_vcpu ) { - struct csched_vcpu *svc; + struct csched_item *svc; spinlock_t *lock; =20 - svc =3D list_entry(iter_svc, struct csched_vcpu, active_vcpu_e= lem); + svc =3D list_entry(iter_svc, struct csched_item, active_vcpu_e= lem); lock =3D vcpu_schedule_lock(svc->vcpu); =20 printk("\t%3d: ", ++loop); diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index c8ae585272..5a3a0babab 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -176,7 +176,7 @@ * load balancing; * + serializes runqueue operations (removing and inserting vcpus); * + protects runqueue-wide data in csched2_runqueue_data; - * + protects vcpu parameters in csched2_vcpu for the vcpu in the + * + protects vcpu parameters in csched2_item for the vcpu in the * runqueue. * * - Private scheduler lock @@ -511,7 +511,7 @@ struct csched2_pcpu { /* * Virtual CPU */ -struct csched2_vcpu { +struct csched2_item { struct csched2_dom *sdom; /* Up-pointer to domain = */ struct vcpu *vcpu; /* Up-pointer, to vcpu = */ struct csched2_runqueue_data *rqd; /* Up-pointer to the runqueue = */ @@ -570,9 +570,9 @@ static inline struct csched2_pcpu *csched2_pcpu(unsigne= d int cpu) return per_cpu(schedule_data, cpu).sched_priv; } =20 -static inline struct csched2_vcpu *csched2_vcpu(const struct vcpu *v) +static inline struct csched2_item *csched2_item(const struct sched_item *i= tem) { - return v->sched_item->priv; + return item->priv; } =20 static inline struct csched2_dom *csched2_dom(const struct domain *d) @@ -594,7 +594,7 @@ static inline struct csched2_runqueue_data *c2rqd(const= struct scheduler *ops, } =20 /* Does the domain of this vCPU have a cap? */ -static inline bool has_cap(const struct csched2_vcpu *svc) +static inline bool has_cap(const struct csched2_item *svc) { return svc->budget !=3D STIME_MAX; } @@ -688,7 +688,7 @@ void smt_idle_mask_clear(unsigned int cpu, cpumask_t *m= ask) * Of course, 1, 2 and 3 makes sense only if svc has a soft affinity. Also * note that at least 5 is guaranteed to _always_ return at least one pcpu. */ -static int get_fallback_cpu(struct csched2_vcpu *svc) +static int get_fallback_cpu(struct csched2_item *svc) { struct vcpu *v =3D svc->vcpu; unsigned int bs; @@ -773,7 +773,7 @@ static int get_fallback_cpu(struct csched2_vcpu *svc) * FIXME: Do pre-calculated division? */ static void t2c_update(struct csched2_runqueue_data *rqd, s_time_t time, - struct csched2_vcpu *svc) + struct csched2_item *svc) { uint64_t val =3D time * rqd->max_weight + svc->residual; =20 @@ -781,7 +781,7 @@ static void t2c_update(struct csched2_runqueue_data *rq= d, s_time_t time, svc->credit -=3D val; } =20 -static s_time_t c2t(struct csched2_runqueue_data *rqd, s_time_t credit, st= ruct csched2_vcpu *svc) +static s_time_t c2t(struct csched2_runqueue_data *rqd, s_time_t credit, st= ruct csched2_item *svc) { return credit * svc->weight / rqd->max_weight; } @@ -790,14 +790,14 @@ static s_time_t c2t(struct csched2_runqueue_data *rqd= , s_time_t credit, struct c * Runqueue related code. */ =20 -static inline int vcpu_on_runq(struct csched2_vcpu *svc) +static inline int vcpu_on_runq(struct csched2_item *svc) { return !list_empty(&svc->runq_elem); } =20 -static inline struct csched2_vcpu * runq_elem(struct list_head *elem) +static inline struct csched2_item * runq_elem(struct list_head *elem) { - return list_entry(elem, struct csched2_vcpu, runq_elem); + return list_entry(elem, struct csched2_item, runq_elem); } =20 static void activate_runqueue(struct csched2_private *prv, int rqi) @@ -915,7 +915,7 @@ static void update_max_weight(struct csched2_runqueue_d= ata *rqd, int new_weight, =20 list_for_each( iter, &rqd->svc ) { - struct csched2_vcpu * svc =3D list_entry(iter, struct csched2_= vcpu, rqd_elem); + struct csched2_item * svc =3D list_entry(iter, struct csched2_= item, rqd_elem); =20 if ( svc->weight > max_weight ) max_weight =3D svc->weight; @@ -940,7 +940,7 @@ static void update_max_weight(struct csched2_runqueue_d= ata *rqd, int new_weight, =20 /* Add and remove from runqueue assignment (not active run queue) */ static void -_runq_assign(struct csched2_vcpu *svc, struct csched2_runqueue_data *rqd) +_runq_assign(struct csched2_item *svc, struct csched2_runqueue_data *rqd) { =20 svc->rqd =3D rqd; @@ -970,7 +970,7 @@ _runq_assign(struct csched2_vcpu *svc, struct csched2_r= unqueue_data *rqd) static void runq_assign(const struct scheduler *ops, struct vcpu *vc) { - struct csched2_vcpu *svc =3D vc->sched_item->priv; + struct csched2_item *svc =3D vc->sched_item->priv; =20 ASSERT(svc->rqd =3D=3D NULL); =20 @@ -978,7 +978,7 @@ runq_assign(const struct scheduler *ops, struct vcpu *v= c) } =20 static void -_runq_deassign(struct csched2_vcpu *svc) +_runq_deassign(struct csched2_item *svc) { struct csched2_runqueue_data *rqd =3D svc->rqd; =20 @@ -997,7 +997,7 @@ _runq_deassign(struct csched2_vcpu *svc) static void runq_deassign(const struct scheduler *ops, struct vcpu *vc) { - struct csched2_vcpu *svc =3D vc->sched_item->priv; + struct csched2_item *svc =3D vc->sched_item->priv; =20 ASSERT(svc->rqd =3D=3D c2rqd(ops, vc->processor)); =20 @@ -1199,7 +1199,7 @@ update_runq_load(const struct scheduler *ops, =20 static void update_svc_load(const struct scheduler *ops, - struct csched2_vcpu *svc, int change, s_time_t now) + struct csched2_item *svc, int change, s_time_t now) { struct csched2_private *prv =3D csched2_priv(ops); s_time_t delta, vcpu_load; @@ -1259,7 +1259,7 @@ update_svc_load(const struct scheduler *ops, static void update_load(const struct scheduler *ops, struct csched2_runqueue_data *rqd, - struct csched2_vcpu *svc, int change, s_time_t now) + struct csched2_item *svc, int change, s_time_t now) { trace_var(TRC_CSCHED2_UPDATE_LOAD, 1, 0, NULL); =20 @@ -1269,7 +1269,7 @@ update_load(const struct scheduler *ops, } =20 static void -runq_insert(const struct scheduler *ops, struct csched2_vcpu *svc) +runq_insert(const struct scheduler *ops, struct csched2_item *svc) { struct list_head *iter; unsigned int cpu =3D svc->vcpu->processor; @@ -1288,7 +1288,7 @@ runq_insert(const struct scheduler *ops, struct csche= d2_vcpu *svc) =20 list_for_each( iter, runq ) { - struct csched2_vcpu * iter_svc =3D runq_elem(iter); + struct csched2_item * iter_svc =3D runq_elem(iter); =20 if ( svc->credit > iter_svc->credit ) break; @@ -1312,13 +1312,13 @@ runq_insert(const struct scheduler *ops, struct csc= hed2_vcpu *svc) } } =20 -static inline void runq_remove(struct csched2_vcpu *svc) +static inline void runq_remove(struct csched2_item *svc) { ASSERT(vcpu_on_runq(svc)); list_del_init(&svc->runq_elem); } =20 -void burn_credits(struct csched2_runqueue_data *rqd, struct csched2_vcpu *= , s_time_t); +void burn_credits(struct csched2_runqueue_data *rqd, struct csched2_item *= , s_time_t); =20 static inline void tickle_cpu(unsigned int cpu, struct csched2_runqueue_data *rqd) @@ -1334,7 +1334,7 @@ tickle_cpu(unsigned int cpu, struct csched2_runqueue_= data *rqd) * whether or not it already run for more than the ratelimit, to which we * apply some tolerance). */ -static inline bool is_preemptable(const struct csched2_vcpu *svc, +static inline bool is_preemptable(const struct csched2_item *svc, s_time_t now, s_time_t ratelimit) { if ( ratelimit <=3D CSCHED2_RATELIMIT_TICKLE_TOLERANCE ) @@ -1360,10 +1360,10 @@ static inline bool is_preemptable(const struct csch= ed2_vcpu *svc, * Within the same class, the highest difference of credit. */ static s_time_t tickle_score(const struct scheduler *ops, s_time_t now, - struct csched2_vcpu *new, unsigned int cpu) + struct csched2_item *new, unsigned int cpu) { struct csched2_runqueue_data *rqd =3D c2rqd(ops, cpu); - struct csched2_vcpu * cur =3D csched2_vcpu(curr_on_cpu(cpu)); + struct csched2_item * cur =3D csched2_item(curr_on_cpu(cpu)); struct csched2_private *prv =3D csched2_priv(ops); s_time_t score; =20 @@ -1432,7 +1432,7 @@ static s_time_t tickle_score(const struct scheduler *= ops, s_time_t now, * pick up some work, so it would be wrong to consider it idle. */ static void -runq_tickle(const struct scheduler *ops, struct csched2_vcpu *new, s_time_= t now) +runq_tickle(const struct scheduler *ops, struct csched2_item *new, s_time_= t now) { int i, ipid =3D -1; s_time_t max =3D 0; @@ -1587,7 +1587,7 @@ runq_tickle(const struct scheduler *ops, struct csche= d2_vcpu *new, s_time_t now) return; } =20 - ASSERT(!is_idle_vcpu(curr_on_cpu(ipid))); + ASSERT(!is_idle_vcpu(curr_on_cpu(ipid)->vcpu)); SCHED_STAT_CRANK(tickled_busy_cpu); tickle: BUG_ON(ipid =3D=3D -1); @@ -1614,7 +1614,7 @@ runq_tickle(const struct scheduler *ops, struct csche= d2_vcpu *new, s_time_t now) * Credit-related code */ static void reset_credit(const struct scheduler *ops, int cpu, s_time_t no= w, - struct csched2_vcpu *snext) + struct csched2_item *snext) { struct csched2_runqueue_data *rqd =3D c2rqd(ops, cpu); struct list_head *iter; @@ -1644,10 +1644,10 @@ static void reset_credit(const struct scheduler *op= s, int cpu, s_time_t now, list_for_each( iter, &rqd->svc ) { unsigned int svc_cpu; - struct csched2_vcpu * svc; + struct csched2_item * svc; int start_credit; =20 - svc =3D list_entry(iter, struct csched2_vcpu, rqd_elem); + svc =3D list_entry(iter, struct csched2_item, rqd_elem); svc_cpu =3D svc->vcpu->processor; =20 ASSERT(!is_idle_vcpu(svc->vcpu)); @@ -1657,7 +1657,7 @@ static void reset_credit(const struct scheduler *ops,= int cpu, s_time_t now, * If svc is running, it is our responsibility to make sure, here, * that the credit it has spent so far get accounted. */ - if ( svc->vcpu =3D=3D curr_on_cpu(svc_cpu) ) + if ( svc->vcpu =3D=3D curr_on_cpu(svc_cpu)->vcpu ) { burn_credits(rqd, svc, now); /* @@ -1709,11 +1709,11 @@ static void reset_credit(const struct scheduler *op= s, int cpu, s_time_t now, } =20 void burn_credits(struct csched2_runqueue_data *rqd, - struct csched2_vcpu *svc, s_time_t now) + struct csched2_item *svc, s_time_t now) { s_time_t delta; =20 - ASSERT(svc =3D=3D csched2_vcpu(curr_on_cpu(svc->vcpu->processor))); + ASSERT(svc =3D=3D csched2_item(curr_on_cpu(svc->vcpu->processor))); =20 if ( unlikely(is_idle_vcpu(svc->vcpu)) ) { @@ -1763,7 +1763,7 @@ void burn_credits(struct csched2_runqueue_data *rqd, * Budget-related code. */ =20 -static void park_vcpu(struct csched2_vcpu *svc) +static void park_vcpu(struct csched2_item *svc) { struct vcpu *v =3D svc->vcpu; =20 @@ -1792,7 +1792,7 @@ static void park_vcpu(struct csched2_vcpu *svc) list_add(&svc->parked_elem, &svc->sdom->parked_vcpus); } =20 -static bool vcpu_grab_budget(struct csched2_vcpu *svc) +static bool vcpu_grab_budget(struct csched2_item *svc) { struct csched2_dom *sdom =3D svc->sdom; unsigned int cpu =3D svc->vcpu->processor; @@ -1839,7 +1839,7 @@ static bool vcpu_grab_budget(struct csched2_vcpu *svc) } =20 static void -vcpu_return_budget(struct csched2_vcpu *svc, struct list_head *parked) +vcpu_return_budget(struct csched2_item *svc, struct list_head *parked) { struct csched2_dom *sdom =3D svc->sdom; unsigned int cpu =3D svc->vcpu->processor; @@ -1882,7 +1882,7 @@ vcpu_return_budget(struct csched2_vcpu *svc, struct l= ist_head *parked) static void unpark_parked_vcpus(const struct scheduler *ops, struct list_head *vcpus) { - struct csched2_vcpu *svc, *tmp; + struct csched2_item *svc, *tmp; spinlock_t *lock; =20 list_for_each_entry_safe(svc, tmp, vcpus, parked_elem) @@ -2004,7 +2004,7 @@ static void replenish_domain_budget(void* data) static inline void csched2_vcpu_check(struct vcpu *vc) { - struct csched2_vcpu * const svc =3D csched2_vcpu(vc); + struct csched2_item * const svc =3D csched2_item(vc->sched_item); struct csched2_dom * const sdom =3D svc->sdom; =20 BUG_ON( svc->vcpu !=3D vc ); @@ -2030,10 +2030,10 @@ csched2_alloc_vdata(const struct scheduler *ops, st= ruct sched_item *item, void *dd) { struct vcpu *vc =3D item->vcpu; - struct csched2_vcpu *svc; + struct csched2_item *svc; =20 /* Allocate per-VCPU info */ - svc =3D xzalloc(struct csched2_vcpu); + svc =3D xzalloc(struct csched2_item); if ( svc =3D=3D NULL ) return NULL; =20 @@ -2074,12 +2074,12 @@ static void csched2_item_sleep(const struct scheduler *ops, struct sched_item *item) { struct vcpu *vc =3D item->vcpu; - struct csched2_vcpu * const svc =3D csched2_vcpu(vc); + struct csched2_item * const svc =3D csched2_item(item); =20 ASSERT(!is_idle_vcpu(vc)); SCHED_STAT_CRANK(vcpu_sleep); =20 - if ( curr_on_cpu(vc->processor) =3D=3D vc ) + if ( curr_on_cpu(vc->processor) =3D=3D item ) { tickle_cpu(vc->processor, svc->rqd); } @@ -2097,7 +2097,7 @@ static void csched2_item_wake(const struct scheduler *ops, struct sched_item *item) { struct vcpu *vc =3D item->vcpu; - struct csched2_vcpu * const svc =3D csched2_vcpu(vc); + struct csched2_item * const svc =3D csched2_item(item); unsigned int cpu =3D vc->processor; s_time_t now; =20 @@ -2105,7 +2105,7 @@ csched2_item_wake(const struct scheduler *ops, struct= sched_item *item) =20 ASSERT(!is_idle_vcpu(vc)); =20 - if ( unlikely(curr_on_cpu(cpu) =3D=3D vc) ) + if ( unlikely(curr_on_cpu(cpu) =3D=3D item) ) { SCHED_STAT_CRANK(vcpu_wake_running); goto out; @@ -2152,8 +2152,7 @@ out: static void csched2_item_yield(const struct scheduler *ops, struct sched_item *item) { - struct vcpu *v =3D item->vcpu; - struct csched2_vcpu * const svc =3D csched2_vcpu(v); + struct csched2_item * const svc =3D csched2_item(item); =20 __set_bit(__CSFLAG_vcpu_yield, &svc->flags); } @@ -2162,7 +2161,7 @@ static void csched2_context_saved(const struct scheduler *ops, struct sched_item *item) { struct vcpu *vc =3D item->vcpu; - struct csched2_vcpu * const svc =3D csched2_vcpu(vc); + struct csched2_item * const svc =3D csched2_item(item); spinlock_t *lock =3D vcpu_schedule_lock_irq(vc); s_time_t now =3D NOW(); LIST_HEAD(were_parked); @@ -2208,7 +2207,7 @@ csched2_res_pick(const struct scheduler *ops, struct = sched_item *item) struct vcpu *vc =3D item->vcpu; int i, min_rqi =3D -1, min_s_rqi =3D -1; unsigned int new_cpu, cpu =3D vc->processor; - struct csched2_vcpu *svc =3D csched2_vcpu(vc); + struct csched2_item *svc =3D csched2_item(item); s_time_t min_avgload =3D MAX_LOAD, min_s_avgload =3D MAX_LOAD; bool has_soft; =20 @@ -2430,15 +2429,15 @@ csched2_res_pick(const struct scheduler *ops, struc= t sched_item *item) typedef struct { /* NB: Modified by consider() */ s_time_t load_delta; - struct csched2_vcpu * best_push_svc, *best_pull_svc; + struct csched2_item * best_push_svc, *best_pull_svc; /* NB: Read by consider() */ struct csched2_runqueue_data *lrqd; struct csched2_runqueue_data *orqd; =20 } balance_state_t; =20 static void consider(balance_state_t *st,=20 - struct csched2_vcpu *push_svc, - struct csched2_vcpu *pull_svc) + struct csched2_item *push_svc, + struct csched2_item *pull_svc) { s_time_t l_load, o_load, delta; =20 @@ -2471,8 +2470,8 @@ static void consider(balance_state_t *st, =20 =20 static void migrate(const struct scheduler *ops, - struct csched2_vcpu *svc,=20 - struct csched2_runqueue_data *trqd,=20 + struct csched2_item *svc, + struct csched2_runqueue_data *trqd, s_time_t now) { int cpu =3D svc->vcpu->processor; @@ -2541,7 +2540,7 @@ static void migrate(const struct scheduler *ops, * - svc is not already flagged to migrate, * - if svc is allowed to run on at least one of the pcpus of rqd. */ -static bool vcpu_is_migrateable(struct csched2_vcpu *svc, +static bool vcpu_is_migrateable(struct csched2_item *svc, struct csched2_runqueue_data *rqd) { struct vcpu *v =3D svc->vcpu; @@ -2691,7 +2690,7 @@ retry: /* Reuse load delta (as we're trying to minimize it) */ list_for_each( push_iter, &st.lrqd->svc ) { - struct csched2_vcpu * push_svc =3D list_entry(push_iter, struct cs= ched2_vcpu, rqd_elem); + struct csched2_item * push_svc =3D list_entry(push_iter, struct cs= ched2_item, rqd_elem); =20 update_svc_load(ops, push_svc, 0, now); =20 @@ -2700,7 +2699,7 @@ retry: =20 list_for_each( pull_iter, &st.orqd->svc ) { - struct csched2_vcpu * pull_svc =3D list_entry(pull_iter, struc= t csched2_vcpu, rqd_elem); + struct csched2_item * pull_svc =3D list_entry(pull_iter, struc= t csched2_item, rqd_elem); =20 if ( !inner_load_updated ) update_svc_load(ops, pull_svc, 0, now); @@ -2719,7 +2718,7 @@ retry: =20 list_for_each( pull_iter, &st.orqd->svc ) { - struct csched2_vcpu * pull_svc =3D list_entry(pull_iter, struct cs= ched2_vcpu, rqd_elem); + struct csched2_item * pull_svc =3D list_entry(pull_iter, struct cs= ched2_item, rqd_elem); =20 if ( !vcpu_is_migrateable(pull_svc, st.lrqd) ) continue; @@ -2746,7 +2745,7 @@ csched2_item_migrate( { struct vcpu *vc =3D item->vcpu; struct domain *d =3D vc->domain; - struct csched2_vcpu * const svc =3D csched2_vcpu(vc); + struct csched2_item * const svc =3D csched2_item(item); struct csched2_runqueue_data *trqd; s_time_t now =3D NOW(); =20 @@ -2847,7 +2846,7 @@ csched2_dom_cntl( /* Update weights for vcpus, and max_weight for runqueues on w= hich they reside */ for_each_vcpu ( d, v ) { - struct csched2_vcpu *svc =3D csched2_vcpu(v); + struct csched2_item *svc =3D csched2_item(v->sched_item); spinlock_t *lock =3D vcpu_schedule_lock(svc->vcpu); =20 ASSERT(svc->rqd =3D=3D c2rqd(ops, svc->vcpu->processor)); @@ -2861,7 +2860,7 @@ csched2_dom_cntl( /* Cap */ if ( op->u.credit2.cap !=3D 0 ) { - struct csched2_vcpu *svc; + struct csched2_item *svc; spinlock_t *lock; =20 /* Cap is only valid if it's below 100 * nr_of_vCPUS */ @@ -2885,7 +2884,7 @@ csched2_dom_cntl( */ for_each_vcpu ( d, v ) { - svc =3D csched2_vcpu(v); + svc =3D csched2_item(v->sched_item); lock =3D vcpu_schedule_lock(svc->vcpu); /* * Too small quotas would in theory cause a lot of overhea= d, @@ -2928,14 +2927,14 @@ csched2_dom_cntl( */ for_each_vcpu ( d, v ) { - svc =3D csched2_vcpu(v); + svc =3D csched2_item(v->sched_item); lock =3D vcpu_schedule_lock(svc->vcpu); if ( v->is_running ) { unsigned int cpu =3D v->processor; struct csched2_runqueue_data *rqd =3D c2rqd(ops, c= pu); =20 - ASSERT(curr_on_cpu(cpu) =3D=3D v); + ASSERT(curr_on_cpu(cpu)->vcpu =3D=3D v); =20 /* * We are triggering a reschedule on the vCPU's @@ -2975,7 +2974,7 @@ csched2_dom_cntl( /* Disable budget accounting for all the vCPUs. */ for_each_vcpu ( d, v ) { - struct csched2_vcpu *svc =3D csched2_vcpu(v); + struct csched2_item *svc =3D csched2_item(v->sched_item); spinlock_t *lock =3D vcpu_schedule_lock(svc->vcpu); =20 svc->budget =3D STIME_MAX; @@ -3012,8 +3011,7 @@ static void csched2_aff_cntl(const struct scheduler *ops, struct sched_item *item, const cpumask_t *hard, const cpumask_t *soft) { - struct vcpu *v =3D item->vcpu; - struct csched2_vcpu *svc =3D csched2_vcpu(v); + struct csched2_item *svc =3D csched2_item(item); =20 if ( !hard ) return; @@ -3113,7 +3111,7 @@ static void csched2_item_insert(const struct scheduler *ops, struct sched_item *item) { struct vcpu *vc =3D item->vcpu; - struct csched2_vcpu *svc =3D item->priv; + struct csched2_item *svc =3D item->priv; struct csched2_dom * const sdom =3D svc->sdom; spinlock_t *lock; =20 @@ -3145,7 +3143,7 @@ csched2_item_insert(const struct scheduler *ops, stru= ct sched_item *item) static void csched2_free_vdata(const struct scheduler *ops, void *priv) { - struct csched2_vcpu *svc =3D priv; + struct csched2_item *svc =3D priv; =20 xfree(svc); } @@ -3154,7 +3152,7 @@ static void csched2_item_remove(const struct scheduler *ops, struct sched_item *item) { struct vcpu *vc =3D item->vcpu; - struct csched2_vcpu * const svc =3D csched2_vcpu(vc); + struct csched2_item * const svc =3D csched2_item(item); spinlock_t *lock; =20 ASSERT(!is_idle_vcpu(vc)); @@ -3175,7 +3173,7 @@ csched2_item_remove(const struct scheduler *ops, stru= ct sched_item *item) /* How long should we let this vcpu run for? */ static s_time_t csched2_runtime(const struct scheduler *ops, int cpu, - struct csched2_vcpu *snext, s_time_t now) + struct csched2_item *snext, s_time_t now) { s_time_t time, min_time; int rt_credit; /* Proposed runtime measured in credits */ @@ -3220,7 +3218,7 @@ csched2_runtime(const struct scheduler *ops, int cpu, */ if ( ! list_empty(runq) ) { - struct csched2_vcpu *swait =3D runq_elem(runq->next); + struct csched2_item *swait =3D runq_elem(runq->next); =20 if ( ! is_idle_vcpu(swait->vcpu) && swait->credit > 0 ) @@ -3271,14 +3269,14 @@ csched2_runtime(const struct scheduler *ops, int cp= u, /* * Find a candidate. */ -static struct csched2_vcpu * +static struct csched2_item * runq_candidate(struct csched2_runqueue_data *rqd, - struct csched2_vcpu *scurr, + struct csched2_item *scurr, int cpu, s_time_t now, unsigned int *skipped) { struct list_head *iter, *temp; - struct csched2_vcpu *snext =3D NULL; + struct csched2_item *snext =3D NULL; struct csched2_private *prv =3D csched2_priv(per_cpu(scheduler, cpu)); bool yield =3D false, soft_aff_preempt =3D false; =20 @@ -3359,12 +3357,12 @@ runq_candidate(struct csched2_runqueue_data *rqd, if ( vcpu_runnable(scurr->vcpu) && !soft_aff_preempt ) snext =3D scurr; else - snext =3D csched2_vcpu(idle_vcpu[cpu]); + snext =3D csched2_item(idle_vcpu[cpu]->sched_item); =20 check_runq: list_for_each_safe( iter, temp, &rqd->runq ) { - struct csched2_vcpu * svc =3D list_entry(iter, struct csched2_vcpu= , runq_elem); + struct csched2_item * svc =3D list_entry(iter, struct csched2_item= , runq_elem); =20 if ( unlikely(tb_init_done) ) { @@ -3463,8 +3461,8 @@ csched2_schedule( { const int cpu =3D smp_processor_id(); struct csched2_runqueue_data *rqd; - struct csched2_vcpu * const scurr =3D csched2_vcpu(current); - struct csched2_vcpu *snext =3D NULL; + struct csched2_item * const scurr =3D csched2_item(current->sched_item= ); + struct csched2_item *snext =3D NULL; unsigned int skipped_vcpus =3D 0; struct task_slice ret; bool tickled; @@ -3540,7 +3538,7 @@ csched2_schedule( { __clear_bit(__CSFLAG_vcpu_yield, &scurr->flags); trace_var(TRC_CSCHED2_SCHED_TASKLET, 1, 0, NULL); - snext =3D csched2_vcpu(idle_vcpu[cpu]); + snext =3D csched2_item(idle_vcpu[cpu]->sched_item); } else snext =3D runq_candidate(rqd, scurr, cpu, now, &skipped_vcpus); @@ -3643,7 +3641,7 @@ csched2_schedule( } =20 static void -csched2_dump_vcpu(struct csched2_private *prv, struct csched2_vcpu *svc) +csched2_dump_vcpu(struct csched2_private *prv, struct csched2_item *svc) { printk("[%i.%i] flags=3D%x cpu=3D%i", svc->vcpu->domain->domain_id, @@ -3667,7 +3665,7 @@ static inline void dump_pcpu(const struct scheduler *ops, int cpu) { struct csched2_private *prv =3D csched2_priv(ops); - struct csched2_vcpu *svc; + struct csched2_item *svc; =20 printk("CPU[%02d] runq=3D%d, sibling=3D%*pb, core=3D%*pb\n", cpu, c2r(cpu), @@ -3675,7 +3673,7 @@ dump_pcpu(const struct scheduler *ops, int cpu) nr_cpu_ids, cpumask_bits(per_cpu(cpu_core_mask, cpu))); =20 /* current VCPU (nothing to say if that's the idle vcpu) */ - svc =3D csched2_vcpu(curr_on_cpu(cpu)); + svc =3D csched2_item(curr_on_cpu(cpu)); if ( svc && !is_idle_vcpu(svc->vcpu) ) { printk("\trun: "); @@ -3748,7 +3746,7 @@ csched2_dump(const struct scheduler *ops) =20 for_each_vcpu( sdom->dom, v ) { - struct csched2_vcpu * const svc =3D csched2_vcpu(v); + struct csched2_item * const svc =3D csched2_item(v->sched_item= ); spinlock_t *lock; =20 lock =3D vcpu_schedule_lock(svc->vcpu); @@ -3777,7 +3775,7 @@ csched2_dump(const struct scheduler *ops) printk("RUNQ:\n"); list_for_each( iter, runq ) { - struct csched2_vcpu *svc =3D runq_elem(iter); + struct csched2_item *svc =3D runq_elem(iter); =20 if ( svc ) { @@ -3879,7 +3877,7 @@ csched2_switch_sched(struct scheduler *new_ops, unsig= ned int cpu, void *pdata, void *vdata) { struct csched2_private *prv =3D csched2_priv(new_ops); - struct csched2_vcpu *svc =3D vdata; + struct csched2_item *svc =3D vdata; unsigned rqi; =20 ASSERT(pdata && svc && is_idle_vcpu(svc->vcpu)); diff --git a/xen/common/sched_null.c b/xen/common/sched_null.c index a08f23993c..f7a2650c48 100644 --- a/xen/common/sched_null.c +++ b/xen/common/sched_null.c @@ -94,7 +94,7 @@ DEFINE_PER_CPU(struct null_pcpu, npc); /* * Virtual CPU */ -struct null_vcpu { +struct null_item { struct list_head waitq_elem; struct vcpu *vcpu; }; @@ -115,9 +115,9 @@ static inline struct null_private *null_priv(const stru= ct scheduler *ops) return ops->sched_data; } =20 -static inline struct null_vcpu *null_vcpu(const struct vcpu *v) +static inline struct null_item *null_item(const struct sched_item *item) { - return v->sched_item->priv; + return item->priv; } =20 static inline bool vcpu_check_affinity(struct vcpu *v, unsigned int cpu, @@ -197,9 +197,9 @@ static void *null_alloc_vdata(const struct scheduler *o= ps, struct sched_item *item, void *dd) { struct vcpu *v =3D item->vcpu; - struct null_vcpu *nvc; + struct null_item *nvc; =20 - nvc =3D xzalloc(struct null_vcpu); + nvc =3D xzalloc(struct null_item); if ( nvc =3D=3D NULL ) return NULL; =20 @@ -213,7 +213,7 @@ static void *null_alloc_vdata(const struct scheduler *o= ps, =20 static void null_free_vdata(const struct scheduler *ops, void *priv) { - struct null_vcpu *nvc =3D priv; + struct null_item *nvc =3D priv; =20 xfree(nvc); } @@ -390,7 +390,7 @@ static void null_switch_sched(struct scheduler *new_ops= , unsigned int cpu, { struct schedule_data *sd =3D &per_cpu(schedule_data, cpu); struct null_private *prv =3D null_priv(new_ops); - struct null_vcpu *nvc =3D vdata; + struct null_item *nvc =3D vdata; =20 ASSERT(nvc && is_idle_vcpu(nvc->vcpu)); =20 @@ -422,7 +422,7 @@ static void null_item_insert(const struct scheduler *op= s, { struct vcpu *v =3D item->vcpu; struct null_private *prv =3D null_priv(ops); - struct null_vcpu *nvc =3D null_vcpu(v); + struct null_item *nvc =3D null_item(item); unsigned int cpu; spinlock_t *lock; =20 @@ -479,9 +479,9 @@ static void _vcpu_remove(struct null_private *prv, stru= ct vcpu *v) { unsigned int bs; unsigned int cpu =3D v->processor; - struct null_vcpu *wvc; + struct null_item *wvc; =20 - ASSERT(list_empty(&null_vcpu(v)->waitq_elem)); + ASSERT(list_empty(&null_item(v->sched_item)->waitq_elem)); =20 vcpu_deassign(prv, v, cpu); =20 @@ -517,7 +517,7 @@ static void null_item_remove(const struct scheduler *op= s, { struct vcpu *v =3D item->vcpu; struct null_private *prv =3D null_priv(ops); - struct null_vcpu *nvc =3D null_vcpu(v); + struct null_item *nvc =3D null_item(item); spinlock_t *lock; =20 ASSERT(!is_idle_vcpu(v)); @@ -552,13 +552,13 @@ static void null_item_wake(const struct scheduler *op= s, =20 ASSERT(!is_idle_vcpu(v)); =20 - if ( unlikely(curr_on_cpu(v->processor) =3D=3D v) ) + if ( unlikely(curr_on_cpu(v->processor) =3D=3D item) ) { SCHED_STAT_CRANK(vcpu_wake_running); return; } =20 - if ( unlikely(!list_empty(&null_vcpu(v)->waitq_elem)) ) + if ( unlikely(!list_empty(&null_item(item)->waitq_elem)) ) { /* Not exactly "on runq", but close enough for reusing the counter= */ SCHED_STAT_CRANK(vcpu_wake_onrunq); @@ -582,7 +582,7 @@ static void null_item_sleep(const struct scheduler *ops, ASSERT(!is_idle_vcpu(v)); =20 /* If v is not assigned to a pCPU, or is not running, no need to bothe= r */ - if ( curr_on_cpu(v->processor) =3D=3D v ) + if ( curr_on_cpu(v->processor) =3D=3D item ) cpu_raise_softirq(v->processor, SCHEDULE_SOFTIRQ); =20 SCHED_STAT_CRANK(vcpu_sleep); @@ -600,7 +600,7 @@ static void null_item_migrate(const struct scheduler *o= ps, { struct vcpu *v =3D item->vcpu; struct null_private *prv =3D null_priv(ops); - struct null_vcpu *nvc =3D null_vcpu(v); + struct null_item *nvc =3D null_item(item); =20 ASSERT(!is_idle_vcpu(v)); =20 @@ -685,7 +685,7 @@ static void null_item_migrate(const struct scheduler *o= ps, #ifndef NDEBUG static inline void null_vcpu_check(struct vcpu *v) { - struct null_vcpu * const nvc =3D null_vcpu(v); + struct null_item * const nvc =3D null_item(v->sched_item); struct null_dom * const ndom =3D v->domain->sched_priv; =20 BUG_ON(nvc->vcpu !=3D v); @@ -715,7 +715,7 @@ static struct task_slice null_schedule(const struct sch= eduler *ops, unsigned int bs; const unsigned int cpu =3D smp_processor_id(); struct null_private *prv =3D null_priv(ops); - struct null_vcpu *wvc; + struct null_item *wvc; struct task_slice ret; =20 SCHED_STAT_CRANK(schedule); @@ -798,7 +798,7 @@ static struct task_slice null_schedule(const struct sch= eduler *ops, return ret; } =20 -static inline void dump_vcpu(struct null_private *prv, struct null_vcpu *n= vc) +static inline void dump_vcpu(struct null_private *prv, struct null_item *n= vc) { printk("[%i.%i] pcpu=3D%d", nvc->vcpu->domain->domain_id, nvc->vcpu->vcpu_id, list_empty(&nvc->waitq_elem) ? @@ -808,7 +808,7 @@ static inline void dump_vcpu(struct null_private *prv, = struct null_vcpu *nvc) static void null_dump_pcpu(const struct scheduler *ops, int cpu) { struct null_private *prv =3D null_priv(ops); - struct null_vcpu *nvc; + struct null_item *nvc; spinlock_t *lock; unsigned long flags; =20 @@ -823,7 +823,7 @@ static void null_dump_pcpu(const struct scheduler *ops,= int cpu) printk("\n"); =20 /* current VCPU (nothing to say if that's the idle vcpu) */ - nvc =3D null_vcpu(curr_on_cpu(cpu)); + nvc =3D null_item(curr_on_cpu(cpu)); if ( nvc && !is_idle_vcpu(nvc->vcpu) ) { printk("\trun: "); @@ -857,7 +857,7 @@ static void null_dump(const struct scheduler *ops) printk("\tDomain: %d\n", ndom->dom->domain_id); for_each_vcpu( ndom->dom, v ) { - struct null_vcpu * const nvc =3D null_vcpu(v); + struct null_item * const nvc =3D null_item(v->sched_item); spinlock_t *lock; =20 lock =3D vcpu_schedule_lock(nvc->vcpu); @@ -875,7 +875,7 @@ static void null_dump(const struct scheduler *ops) spin_lock(&prv->waitq_lock); list_for_each( iter, &prv->waitq ) { - struct null_vcpu *nvc =3D list_entry(iter, struct null_vcpu, waitq= _elem); + struct null_item *nvc =3D list_entry(iter, struct null_item, waitq= _elem); =20 if ( loop++ !=3D 0 ) printk(", "); diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index 2bd4637592..a3cd00f765 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -195,7 +195,7 @@ struct rt_private { /* * Virtual CPU */ -struct rt_vcpu { +struct rt_item { struct list_head q_elem; /* on the runq/depletedq list */ struct list_head replq_elem; /* on the replenishment events list */ =20 @@ -233,9 +233,9 @@ static inline struct rt_private *rt_priv(const struct s= cheduler *ops) return ops->sched_data; } =20 -static inline struct rt_vcpu *rt_vcpu(const struct vcpu *vcpu) +static inline struct rt_item *rt_item(const struct sched_item *item) { - return vcpu->sched_item->priv; + return item->priv; } =20 static inline struct list_head *rt_runq(const struct scheduler *ops) @@ -253,7 +253,7 @@ static inline struct list_head *rt_replq(const struct s= cheduler *ops) return &rt_priv(ops)->replq; } =20 -static inline bool has_extratime(const struct rt_vcpu *svc) +static inline bool has_extratime(const struct rt_item *svc) { return svc->flags & RTDS_extratime; } @@ -263,25 +263,25 @@ static inline bool has_extratime(const struct rt_vcpu= *svc) * and the replenishment events queue. */ static int -vcpu_on_q(const struct rt_vcpu *svc) +vcpu_on_q(const struct rt_item *svc) { return !list_empty(&svc->q_elem); } =20 -static struct rt_vcpu * +static struct rt_item * q_elem(struct list_head *elem) { - return list_entry(elem, struct rt_vcpu, q_elem); + return list_entry(elem, struct rt_item, q_elem); } =20 -static struct rt_vcpu * +static struct rt_item * replq_elem(struct list_head *elem) { - return list_entry(elem, struct rt_vcpu, replq_elem); + return list_entry(elem, struct rt_item, replq_elem); } =20 static int -vcpu_on_replq(const struct rt_vcpu *svc) +vcpu_on_replq(const struct rt_item *svc) { return !list_empty(&svc->replq_elem); } @@ -291,7 +291,7 @@ vcpu_on_replq(const struct rt_vcpu *svc) * Otherwise, return value < 0 */ static s_time_t -compare_vcpu_priority(const struct rt_vcpu *v1, const struct rt_vcpu *v2) +compare_vcpu_priority(const struct rt_item *v1, const struct rt_item *v2) { int prio =3D v2->priority_level - v1->priority_level; =20 @@ -305,7 +305,7 @@ compare_vcpu_priority(const struct rt_vcpu *v1, const s= truct rt_vcpu *v2) * Debug related code, dump vcpu/cpu information */ static void -rt_dump_vcpu(const struct scheduler *ops, const struct rt_vcpu *svc) +rt_dump_vcpu(const struct scheduler *ops, const struct rt_item *svc) { cpumask_t *cpupool_mask, *mask; =20 @@ -352,13 +352,13 @@ static void rt_dump_pcpu(const struct scheduler *ops, int cpu) { struct rt_private *prv =3D rt_priv(ops); - struct rt_vcpu *svc; + struct rt_item *svc; unsigned long flags; =20 spin_lock_irqsave(&prv->lock, flags); printk("CPU[%02d]\n", cpu); /* current VCPU (nothing to say if that's the idle vcpu). */ - svc =3D rt_vcpu(curr_on_cpu(cpu)); + svc =3D rt_item(curr_on_cpu(cpu)); if ( svc && !is_idle_vcpu(svc->vcpu) ) { rt_dump_vcpu(ops, svc); @@ -371,7 +371,7 @@ rt_dump(const struct scheduler *ops) { struct list_head *runq, *depletedq, *replq, *iter; struct rt_private *prv =3D rt_priv(ops); - struct rt_vcpu *svc; + struct rt_item *svc; struct rt_dom *sdom; unsigned long flags; =20 @@ -415,7 +415,7 @@ rt_dump(const struct scheduler *ops) =20 for_each_vcpu ( sdom->dom, v ) { - svc =3D rt_vcpu(v); + svc =3D rt_item(v->sched_item); rt_dump_vcpu(ops, svc); } } @@ -429,7 +429,7 @@ rt_dump(const struct scheduler *ops) * it needs to be updated to the deadline of the current period */ static void -rt_update_deadline(s_time_t now, struct rt_vcpu *svc) +rt_update_deadline(s_time_t now, struct rt_item *svc) { ASSERT(now >=3D svc->cur_deadline); ASSERT(svc->period !=3D 0); @@ -500,8 +500,8 @@ deadline_queue_remove(struct list_head *queue, struct l= ist_head *elem) } =20 static inline bool -deadline_queue_insert(struct rt_vcpu * (*qelem)(struct list_head *), - struct rt_vcpu *svc, struct list_head *elem, +deadline_queue_insert(struct rt_item * (*qelem)(struct list_head *), + struct rt_item *svc, struct list_head *elem, struct list_head *queue) { struct list_head *iter; @@ -509,7 +509,7 @@ deadline_queue_insert(struct rt_vcpu * (*qelem)(struct = list_head *), =20 list_for_each ( iter, queue ) { - struct rt_vcpu * iter_svc =3D (*qelem)(iter); + struct rt_item * iter_svc =3D (*qelem)(iter); if ( compare_vcpu_priority(svc, iter_svc) > 0 ) break; pos++; @@ -523,14 +523,14 @@ deadline_queue_insert(struct rt_vcpu * (*qelem)(struc= t list_head *), deadline_queue_insert(&replq_elem, ##__VA_ARGS__) =20 static inline void -q_remove(struct rt_vcpu *svc) +q_remove(struct rt_item *svc) { ASSERT( vcpu_on_q(svc) ); list_del_init(&svc->q_elem); } =20 static inline void -replq_remove(const struct scheduler *ops, struct rt_vcpu *svc) +replq_remove(const struct scheduler *ops, struct rt_item *svc) { struct rt_private *prv =3D rt_priv(ops); struct list_head *replq =3D rt_replq(ops); @@ -547,7 +547,7 @@ replq_remove(const struct scheduler *ops, struct rt_vcp= u *svc) */ if ( !list_empty(replq) ) { - struct rt_vcpu *svc_next =3D replq_elem(replq->next); + struct rt_item *svc_next =3D replq_elem(replq->next); set_timer(&prv->repl_timer, svc_next->cur_deadline); } else @@ -561,7 +561,7 @@ replq_remove(const struct scheduler *ops, struct rt_vcp= u *svc) * Insert svc without budget in DepletedQ unsorted; */ static void -runq_insert(const struct scheduler *ops, struct rt_vcpu *svc) +runq_insert(const struct scheduler *ops, struct rt_item *svc) { struct rt_private *prv =3D rt_priv(ops); struct list_head *runq =3D rt_runq(ops); @@ -579,7 +579,7 @@ runq_insert(const struct scheduler *ops, struct rt_vcpu= *svc) } =20 static void -replq_insert(const struct scheduler *ops, struct rt_vcpu *svc) +replq_insert(const struct scheduler *ops, struct rt_item *svc) { struct list_head *replq =3D rt_replq(ops); struct rt_private *prv =3D rt_priv(ops); @@ -601,10 +601,10 @@ replq_insert(const struct scheduler *ops, struct rt_v= cpu *svc) * changed. */ static void -replq_reinsert(const struct scheduler *ops, struct rt_vcpu *svc) +replq_reinsert(const struct scheduler *ops, struct rt_item *svc) { struct list_head *replq =3D rt_replq(ops); - struct rt_vcpu *rearm_svc =3D svc; + struct rt_item *rearm_svc =3D svc; bool_t rearm =3D 0; =20 ASSERT( vcpu_on_replq(svc) ); @@ -735,7 +735,7 @@ rt_switch_sched(struct scheduler *new_ops, unsigned int= cpu, void *pdata, void *vdata) { struct rt_private *prv =3D rt_priv(new_ops); - struct rt_vcpu *svc =3D vdata; + struct rt_item *svc =3D vdata; =20 ASSERT(!pdata && svc && is_idle_vcpu(svc->vcpu)); =20 @@ -850,10 +850,10 @@ static void * rt_alloc_vdata(const struct scheduler *ops, struct sched_item *item, void = *dd) { struct vcpu *vc =3D item->vcpu; - struct rt_vcpu *svc; + struct rt_item *svc; =20 /* Allocate per-VCPU info */ - svc =3D xzalloc(struct rt_vcpu); + svc =3D xzalloc(struct rt_item); if ( svc =3D=3D NULL ) return NULL; =20 @@ -878,7 +878,7 @@ rt_alloc_vdata(const struct scheduler *ops, struct sche= d_item *item, void *dd) static void rt_free_vdata(const struct scheduler *ops, void *priv) { - struct rt_vcpu *svc =3D priv; + struct rt_item *svc =3D priv; =20 xfree(svc); } @@ -894,7 +894,7 @@ static void rt_item_insert(const struct scheduler *ops, struct sched_item *item) { struct vcpu *vc =3D item->vcpu; - struct rt_vcpu *svc =3D rt_vcpu(vc); + struct rt_item *svc =3D rt_item(item); s_time_t now; spinlock_t *lock; =20 @@ -923,13 +923,13 @@ rt_item_insert(const struct scheduler *ops, struct sc= hed_item *item) } =20 /* - * Remove rt_vcpu svc from the old scheduler in source cpupool. + * Remove rt_item svc from the old scheduler in source cpupool. */ static void rt_item_remove(const struct scheduler *ops, struct sched_item *item) { struct vcpu *vc =3D item->vcpu; - struct rt_vcpu * const svc =3D rt_vcpu(vc); + struct rt_item * const svc =3D rt_item(item); struct rt_dom * const sdom =3D svc->sdom; spinlock_t *lock; =20 @@ -951,7 +951,7 @@ rt_item_remove(const struct scheduler *ops, struct sche= d_item *item) * Burn budget in nanosecond granularity */ static void -burn_budget(const struct scheduler *ops, struct rt_vcpu *svc, s_time_t now) +burn_budget(const struct scheduler *ops, struct rt_item *svc, s_time_t now) { s_time_t delta; =20 @@ -1015,13 +1015,13 @@ burn_budget(const struct scheduler *ops, struct rt_= vcpu *svc, s_time_t now) * RunQ is sorted. Pick first one within cpumask. If no one, return NULL * lock is grabbed before calling this function */ -static struct rt_vcpu * +static struct rt_item * runq_pick(const struct scheduler *ops, const cpumask_t *mask) { struct list_head *runq =3D rt_runq(ops); struct list_head *iter; - struct rt_vcpu *svc =3D NULL; - struct rt_vcpu *iter_svc =3D NULL; + struct rt_item *svc =3D NULL; + struct rt_item *iter_svc =3D NULL; cpumask_t cpu_common; cpumask_t *online; =20 @@ -1072,8 +1072,8 @@ rt_schedule(const struct scheduler *ops, s_time_t now= , bool_t tasklet_work_sched { const int cpu =3D smp_processor_id(); struct rt_private *prv =3D rt_priv(ops); - struct rt_vcpu *const scurr =3D rt_vcpu(current); - struct rt_vcpu *snext =3D NULL; + struct rt_item *const scurr =3D rt_item(current->sched_item); + struct rt_item *snext =3D NULL; struct task_slice ret =3D { .migrated =3D 0 }; =20 /* TRACE */ @@ -1099,13 +1099,13 @@ rt_schedule(const struct scheduler *ops, s_time_t n= ow, bool_t tasklet_work_sched if ( tasklet_work_scheduled ) { trace_var(TRC_RTDS_SCHED_TASKLET, 1, 0, NULL); - snext =3D rt_vcpu(idle_vcpu[cpu]); + snext =3D rt_item(idle_vcpu[cpu]->sched_item); } else { snext =3D runq_pick(ops, cpumask_of(cpu)); if ( snext =3D=3D NULL ) - snext =3D rt_vcpu(idle_vcpu[cpu]); + snext =3D rt_item(idle_vcpu[cpu]->sched_item); =20 /* if scurr has higher priority and budget, still pick scurr */ if ( !is_idle_vcpu(current) && @@ -1151,12 +1151,12 @@ static void rt_item_sleep(const struct scheduler *ops, struct sched_item *item) { struct vcpu *vc =3D item->vcpu; - struct rt_vcpu * const svc =3D rt_vcpu(vc); + struct rt_item * const svc =3D rt_item(item); =20 BUG_ON( is_idle_vcpu(vc) ); SCHED_STAT_CRANK(vcpu_sleep); =20 - if ( curr_on_cpu(vc->processor) =3D=3D vc ) + if ( curr_on_cpu(vc->processor) =3D=3D item ) cpu_raise_softirq(vc->processor, SCHEDULE_SOFTIRQ); else if ( vcpu_on_q(svc) ) { @@ -1186,11 +1186,11 @@ rt_item_sleep(const struct scheduler *ops, struct s= ched_item *item) * lock is grabbed before calling this function */ static void -runq_tickle(const struct scheduler *ops, struct rt_vcpu *new) +runq_tickle(const struct scheduler *ops, struct rt_item *new) { struct rt_private *prv =3D rt_priv(ops); - struct rt_vcpu *latest_deadline_vcpu =3D NULL; /* lowest priority */ - struct rt_vcpu *iter_svc; + struct rt_item *latest_deadline_vcpu =3D NULL; /* lowest priority */ + struct rt_item *iter_svc; struct vcpu *iter_vc; int cpu =3D 0, cpu_to_tickle =3D 0; cpumask_t not_tickled; @@ -1211,14 +1211,14 @@ runq_tickle(const struct scheduler *ops, struct rt_= vcpu *new) cpu =3D cpumask_test_or_cycle(new->vcpu->processor, ¬_tickled); while ( cpu!=3D nr_cpu_ids ) { - iter_vc =3D curr_on_cpu(cpu); + iter_vc =3D curr_on_cpu(cpu)->vcpu; if ( is_idle_vcpu(iter_vc) ) { SCHED_STAT_CRANK(tickled_idle_cpu); cpu_to_tickle =3D cpu; goto out; } - iter_svc =3D rt_vcpu(iter_vc); + iter_svc =3D rt_item(iter_vc->sched_item); if ( latest_deadline_vcpu =3D=3D NULL || compare_vcpu_priority(iter_svc, latest_deadline_vcpu) < 0 ) latest_deadline_vcpu =3D iter_svc; @@ -1267,13 +1267,13 @@ static void rt_item_wake(const struct scheduler *ops, struct sched_item *item) { struct vcpu *vc =3D item->vcpu; - struct rt_vcpu * const svc =3D rt_vcpu(vc); + struct rt_item * const svc =3D rt_item(item); s_time_t now; bool_t missed; =20 BUG_ON( is_idle_vcpu(vc) ); =20 - if ( unlikely(curr_on_cpu(vc->processor) =3D=3D vc) ) + if ( unlikely(curr_on_cpu(vc->processor) =3D=3D item) ) { SCHED_STAT_CRANK(vcpu_wake_running); return; @@ -1338,7 +1338,7 @@ static void rt_context_saved(const struct scheduler *ops, struct sched_item *item) { struct vcpu *vc =3D item->vcpu; - struct rt_vcpu *svc =3D rt_vcpu(vc); + struct rt_item *svc =3D rt_item(item); spinlock_t *lock =3D vcpu_schedule_lock_irq(vc); =20 __clear_bit(__RTDS_scheduled, &svc->flags); @@ -1369,7 +1369,7 @@ rt_dom_cntl( struct xen_domctl_scheduler_op *op) { struct rt_private *prv =3D rt_priv(ops); - struct rt_vcpu *svc; + struct rt_item *svc; struct vcpu *v; unsigned long flags; int rc =3D 0; @@ -1393,7 +1393,7 @@ rt_dom_cntl( spin_lock_irqsave(&prv->lock, flags); for_each_vcpu ( d, v ) { - svc =3D rt_vcpu(v); + svc =3D rt_item(v->sched_item); svc->period =3D MICROSECS(op->u.rtds.period); /* transfer to n= anosec */ svc->budget =3D MICROSECS(op->u.rtds.budget); } @@ -1419,7 +1419,7 @@ rt_dom_cntl( if ( op->cmd =3D=3D XEN_DOMCTL_SCHEDOP_getvcpuinfo ) { spin_lock_irqsave(&prv->lock, flags); - svc =3D rt_vcpu(d->vcpu[local_sched.vcpuid]); + svc =3D rt_item(d->vcpu[local_sched.vcpuid]->sched_item); local_sched.u.rtds.budget =3D svc->budget / MICROSECS(1); local_sched.u.rtds.period =3D svc->period / MICROSECS(1); if ( has_extratime(svc) ) @@ -1447,7 +1447,7 @@ rt_dom_cntl( } =20 spin_lock_irqsave(&prv->lock, flags); - svc =3D rt_vcpu(d->vcpu[local_sched.vcpuid]); + svc =3D rt_item(d->vcpu[local_sched.vcpuid]->sched_item); svc->period =3D period; svc->budget =3D budget; if ( local_sched.u.rtds.flags & XEN_DOMCTL_SCHEDRT_extra ) @@ -1480,7 +1480,7 @@ static void repl_timer_handler(void *data){ struct list_head *replq =3D rt_replq(ops); struct list_head *runq =3D rt_runq(ops); struct list_head *iter, *tmp; - struct rt_vcpu *svc; + struct rt_item *svc; LIST_HEAD(tmp_replq); =20 spin_lock_irq(&prv->lock); @@ -1522,10 +1522,10 @@ static void repl_timer_handler(void *data){ { svc =3D replq_elem(iter); =20 - if ( curr_on_cpu(svc->vcpu->processor) =3D=3D svc->vcpu && + if ( curr_on_cpu(svc->vcpu->processor) =3D=3D svc->vcpu->sched_ite= m && !list_empty(runq) ) { - struct rt_vcpu *next_on_runq =3D q_elem(runq->next); + struct rt_item *next_on_runq =3D q_elem(runq->next); =20 if ( compare_vcpu_priority(svc, next_on_runq) < 0 ) runq_tickle(ops, next_on_runq); diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 81eecaa689..b1eb77290a 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -334,7 +334,7 @@ int sched_init_vcpu(struct vcpu *v, unsigned int proces= sor) /* Idle VCPUs are scheduled immediately, so don't put them in runqueue= . */ if ( is_idle_domain(d) ) { - per_cpu(schedule_data, v->processor).curr =3D v; + per_cpu(schedule_data, v->processor).curr =3D item; v->is_running =3D 1; } else @@ -1513,7 +1513,7 @@ static void schedule(void) =20 next =3D next_slice.task; =20 - sd->curr =3D next; + sd->curr =3D next->sched_item; =20 if ( next_slice.time >=3D 0 ) /* -ve means no limit */ set_timer(&sd->s_timer, now + next_slice.time); @@ -1636,7 +1636,6 @@ static int cpu_schedule_up(unsigned int cpu) per_cpu(scheduler, cpu) =3D &ops; spin_lock_init(&sd->_lock); sd->schedule_lock =3D &sd->_lock; - sd->curr =3D idle_vcpu[cpu]; init_timer(&sd->s_timer, s_timer_fn, NULL, cpu); atomic_set(&sd->urgent_count, 0); =20 @@ -1670,6 +1669,8 @@ static int cpu_schedule_up(unsigned int cpu) if ( idle_vcpu[cpu] =3D=3D NULL ) return -ENOMEM; =20 + sd->curr =3D idle_vcpu[cpu]->sched_item; + /* * We don't want to risk calling xfree() on an sd->sched_priv * (e.g., inside free_pdata, from cpu_schedule_down() called @@ -1839,6 +1840,7 @@ void __init scheduler_init(void) idle_domain->max_vcpus =3D nr_cpu_ids; if ( vcpu_create(idle_domain, 0, 0) =3D=3D NULL ) BUG(); + this_cpu(schedule_data).curr =3D idle_vcpu[0]->sched_item; this_cpu(schedule_data).sched_priv =3D sched_alloc_pdata(&ops, 0); BUG_ON(IS_ERR(this_cpu(schedule_data).sched_priv)); sched_init_pdata(&ops, this_cpu(schedule_data).sched_priv, 0); diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index c57cf58e03..9a0cd04af7 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -36,7 +36,7 @@ extern int sched_ratelimit_us; struct schedule_data { spinlock_t *schedule_lock, _lock; - struct vcpu *curr; /* current task = */ + struct sched_item *curr; /* current task = */ void *sched_priv; struct timer s_timer; /* scheduling timer = */ atomic_t urgent_count; /* how many urgent vcpus = */ --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557126005; cv=none; d=zoho.com; s=zohoarc; b=EMdkFd2JjYBmRbL0ofofjPRxWNMW/rJfakNaQ48FV6jMyVmfBCi3lVAsSZPkunEbh2a0p3BjEsMssIRouRh+KCLYlRhrxa/DVFgH13BDMlGrp2xIXm2jeObePaLD180RZd2H16yTEhGYLblHztNHOBICKEnamkuTZK32AIY0b98= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557126005; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=9LTsNTvS26HqB5t3sll2indf/EYCtUuOB1joUvUlF6k=; b=juuV6BghrJIXhuUHTFQrdDSIi+/mDHZaH9nUWglAblK3xbyaOq6LAIkbPTZZBuAUaSslSSpclbEQdt8BaKeA7aLO8mJsQOUJ07IAN0PRNG6CBxzxM7HSWS+9fZ80Iw5HgIMUhD+fFqZgvkbQlkA4bsv6KjEfmNWTulhqSYE5PPw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557126005434206.12230768324935; Mon, 6 May 2019 00:00:05 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXam-0005aM-3z; Mon, 06 May 2019 06:59:16 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXak-0005Yn-U2 for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:59:14 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 212aa696-6fcc-11e9-bf18-97dfa072d23c; Mon, 06 May 2019 06:56:53 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 27077AECD; Mon, 6 May 2019 06:56:51 +0000 (UTC) X-Inumbo-ID: 212aa696-6fcc-11e9-bf18-97dfa072d23c X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:08 +0200 Message-Id: <20190506065644.7415-10-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 09/45] xen/sched: move per cpu scheduler private data into struct sched_resource X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Tim Deegan , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Robert VanVossen , Dario Faggioli , Julien Grall , Josh Whitehead , Meng Xu , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" This prepares support of larger scheduling granularities, e.g. core scheduling. Signed-off-by: Juergen Gross --- xen/common/sched_arinc653.c | 6 ++--- xen/common/sched_credit.c | 14 +++++------ xen/common/sched_credit2.c | 24 +++++++++---------- xen/common/sched_null.c | 8 +++---- xen/common/sched_rt.c | 12 +++++----- xen/common/schedule.c | 56 +++++++++++++++++++++------------------= ---- xen/include/asm-x86/cpuidle.h | 2 +- xen/include/xen/sched-if.h | 20 +++++++--------- 8 files changed, 68 insertions(+), 74 deletions(-) diff --git a/xen/common/sched_arinc653.c b/xen/common/sched_arinc653.c index 5701baf337..9dc1ff6a73 100644 --- a/xen/common/sched_arinc653.c +++ b/xen/common/sched_arinc653.c @@ -475,7 +475,7 @@ a653sched_item_sleep(const struct scheduler *ops, struc= t sched_item *item) * If the VCPU being put to sleep is the same one that is currently * running, raise a softirq to invoke the scheduler to switch domains. */ - if ( per_cpu(schedule_data, vc->processor).curr =3D=3D item ) + if ( per_cpu(sched_res, vc->processor)->curr =3D=3D item ) cpu_raise_softirq(vc->processor, SCHEDULE_SOFTIRQ); } =20 @@ -642,7 +642,7 @@ static void a653_switch_sched(struct scheduler *new_ops, unsigned int cpu, void *pdata, void *vdata) { - struct schedule_data *sd =3D &per_cpu(schedule_data, cpu); + struct sched_resource *sd =3D per_cpu(sched_res, cpu); arinc653_vcpu_t *svc =3D vdata; =20 ASSERT(!pdata && svc && is_idle_vcpu(svc->vc)); @@ -650,7 +650,7 @@ a653_switch_sched(struct scheduler *new_ops, unsigned i= nt cpu, idle_vcpu[cpu]->sched_item->priv =3D vdata; =20 per_cpu(scheduler, cpu) =3D new_ops; - per_cpu(schedule_data, cpu).sched_priv =3D NULL; /* no pdata */ + per_cpu(sched_res, cpu)->sched_priv =3D NULL; /* no pdata */ =20 /* * (Re?)route the lock to its default location. We actually do not use diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index 6552d4c087..e8369b3648 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -82,7 +82,7 @@ #define CSCHED_PRIV(_ops) \ ((struct csched_private *)((_ops)->sched_data)) #define CSCHED_PCPU(_c) \ - ((struct csched_pcpu *)per_cpu(schedule_data, _c).sched_priv) + ((struct csched_pcpu *)per_cpu(sched_res, _c)->sched_priv) #define CSCHED_ITEM(item) ((struct csched_item *) (item)->priv) #define CSCHED_DOM(_dom) ((struct csched_dom *) (_dom)->sched_priv) #define RUNQ(_cpu) (&(CSCHED_PCPU(_cpu)->runq)) @@ -248,7 +248,7 @@ static inline bool_t is_runq_idle(unsigned int cpu) /* * We're peeking at cpu's runq, we must hold the proper lock. */ - ASSERT(spin_is_locked(per_cpu(schedule_data, cpu).schedule_lock)); + ASSERT(spin_is_locked(per_cpu(sched_res, cpu)->schedule_lock)); =20 return list_empty(RUNQ(cpu)) || is_idle_vcpu(__runq_elem(RUNQ(cpu)->next)->vcpu); @@ -257,7 +257,7 @@ static inline bool_t is_runq_idle(unsigned int cpu) static inline void inc_nr_runnable(unsigned int cpu) { - ASSERT(spin_is_locked(per_cpu(schedule_data, cpu).schedule_lock)); + ASSERT(spin_is_locked(per_cpu(sched_res, cpu)->schedule_lock)); CSCHED_PCPU(cpu)->nr_runnable++; =20 } @@ -265,7 +265,7 @@ inc_nr_runnable(unsigned int cpu) static inline void dec_nr_runnable(unsigned int cpu) { - ASSERT(spin_is_locked(per_cpu(schedule_data, cpu).schedule_lock)); + ASSERT(spin_is_locked(per_cpu(sched_res, cpu)->schedule_lock)); ASSERT(CSCHED_PCPU(cpu)->nr_runnable >=3D 1); CSCHED_PCPU(cpu)->nr_runnable--; } @@ -615,7 +615,7 @@ csched_init_pdata(const struct scheduler *ops, void *pd= ata, int cpu) { unsigned long flags; struct csched_private *prv =3D CSCHED_PRIV(ops); - struct schedule_data *sd =3D &per_cpu(schedule_data, cpu); + struct sched_resource *sd =3D per_cpu(sched_res, cpu); =20 /* * This is called either during during boot, resume or hotplug, in @@ -635,7 +635,7 @@ static void csched_switch_sched(struct scheduler *new_ops, unsigned int cpu, void *pdata, void *vdata) { - struct schedule_data *sd =3D &per_cpu(schedule_data, cpu); + struct sched_resource *sd =3D per_cpu(sched_res, cpu); struct csched_private *prv =3D CSCHED_PRIV(new_ops); struct csched_item *svc =3D vdata; =20 @@ -654,7 +654,7 @@ csched_switch_sched(struct scheduler *new_ops, unsigned= int cpu, spin_unlock(&prv->lock); =20 per_cpu(scheduler, cpu) =3D new_ops; - per_cpu(schedule_data, cpu).sched_priv =3D pdata; + per_cpu(sched_res, cpu)->sched_priv =3D pdata; =20 /* * (Re?)route the lock to the per pCPU lock as /last/ thing. In fact, diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index 5a3a0babab..df0e7282ce 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -567,7 +567,7 @@ static inline struct csched2_private *csched2_priv(cons= t struct scheduler *ops) =20 static inline struct csched2_pcpu *csched2_pcpu(unsigned int cpu) { - return per_cpu(schedule_data, cpu).sched_priv; + return per_cpu(sched_res, cpu)->sched_priv; } =20 static inline struct csched2_item *csched2_item(const struct sched_item *i= tem) @@ -1276,7 +1276,7 @@ runq_insert(const struct scheduler *ops, struct csche= d2_item *svc) struct list_head * runq =3D &c2rqd(ops, cpu)->runq; int pos =3D 0; =20 - ASSERT(spin_is_locked(per_cpu(schedule_data, cpu).schedule_lock)); + ASSERT(spin_is_locked(per_cpu(sched_res, cpu)->schedule_lock)); =20 ASSERT(!vcpu_on_runq(svc)); ASSERT(c2r(cpu) =3D=3D c2r(svc->vcpu->processor)); @@ -1797,7 +1797,7 @@ static bool vcpu_grab_budget(struct csched2_item *svc) struct csched2_dom *sdom =3D svc->sdom; unsigned int cpu =3D svc->vcpu->processor; =20 - ASSERT(spin_is_locked(per_cpu(schedule_data, cpu).schedule_lock)); + ASSERT(spin_is_locked(per_cpu(sched_res, cpu)->schedule_lock)); =20 if ( svc->budget > 0 ) return true; @@ -1844,7 +1844,7 @@ vcpu_return_budget(struct csched2_item *svc, struct l= ist_head *parked) struct csched2_dom *sdom =3D svc->sdom; unsigned int cpu =3D svc->vcpu->processor; =20 - ASSERT(spin_is_locked(per_cpu(schedule_data, cpu).schedule_lock)); + ASSERT(spin_is_locked(per_cpu(sched_res, cpu)->schedule_lock)); ASSERT(list_empty(parked)); =20 /* budget_lock nests inside runqueue lock. */ @@ -2101,7 +2101,7 @@ csched2_item_wake(const struct scheduler *ops, struct= sched_item *item) unsigned int cpu =3D vc->processor; s_time_t now; =20 - ASSERT(spin_is_locked(per_cpu(schedule_data, cpu).schedule_lock)); + ASSERT(spin_is_locked(per_cpu(sched_res, cpu)->schedule_lock)); =20 ASSERT(!is_idle_vcpu(vc)); =20 @@ -2229,7 +2229,7 @@ csched2_res_pick(const struct scheduler *ops, struct = sched_item *item) * just grab the prv lock. Instead, we'll have to trylock, and * do something else reasonable if we fail. */ - ASSERT(spin_is_locked(per_cpu(schedule_data, cpu).schedule_lock)); + ASSERT(spin_is_locked(per_cpu(sched_res, cpu)->schedule_lock)); =20 if ( !read_trylock(&prv->lock) ) { @@ -2569,7 +2569,7 @@ static void balance_load(const struct scheduler *ops,= int cpu, s_time_t now) * on either side may be empty). */ =20 - ASSERT(spin_is_locked(per_cpu(schedule_data, cpu).schedule_lock)); + ASSERT(spin_is_locked(per_cpu(sched_res, cpu)->schedule_lock)); st.lrqd =3D c2rqd(ops, cpu); =20 update_runq_load(ops, st.lrqd, 0, now); @@ -3475,7 +3475,7 @@ csched2_schedule( rqd =3D c2rqd(ops, cpu); BUG_ON(!cpumask_test_cpu(cpu, &rqd->active)); =20 - ASSERT(spin_is_locked(per_cpu(schedule_data, cpu).schedule_lock)); + ASSERT(spin_is_locked(per_cpu(sched_res, cpu)->schedule_lock)); =20 BUG_ON(!is_idle_vcpu(scurr->vcpu) && scurr->rqd !=3D rqd); =20 @@ -3864,7 +3864,7 @@ csched2_init_pdata(const struct scheduler *ops, void = *pdata, int cpu) =20 rqi =3D init_pdata(prv, pdata, cpu); /* Move the scheduler lock to the new runq lock. */ - per_cpu(schedule_data, cpu).schedule_lock =3D &prv->rqd[rqi].lock; + per_cpu(sched_res, cpu)->schedule_lock =3D &prv->rqd[rqi].lock; =20 /* _Not_ pcpu_schedule_unlock(): schedule_lock may have changed! */ spin_unlock(old_lock); @@ -3903,10 +3903,10 @@ csched2_switch_sched(struct scheduler *new_ops, uns= igned int cpu, * this scheduler, and so it's safe to have taken it /before/ our * private global lock. */ - ASSERT(per_cpu(schedule_data, cpu).schedule_lock !=3D &prv->rqd[rqi].l= ock); + ASSERT(per_cpu(sched_res, cpu)->schedule_lock !=3D &prv->rqd[rqi].lock= ); =20 per_cpu(scheduler, cpu) =3D new_ops; - per_cpu(schedule_data, cpu).sched_priv =3D pdata; + per_cpu(sched_res, cpu)->sched_priv =3D pdata; =20 /* * (Re?)route the lock to the per pCPU lock as /last/ thing. In fact, @@ -3914,7 +3914,7 @@ csched2_switch_sched(struct scheduler *new_ops, unsig= ned int cpu, * taking it, find all the initializations we've done above in place. */ smp_mb(); - per_cpu(schedule_data, cpu).schedule_lock =3D &prv->rqd[rqi].lock; + per_cpu(sched_res, cpu)->schedule_lock =3D &prv->rqd[rqi].lock; =20 write_unlock(&prv->lock); } diff --git a/xen/common/sched_null.c b/xen/common/sched_null.c index f7a2650c48..a9cfa163b9 100644 --- a/xen/common/sched_null.c +++ b/xen/common/sched_null.c @@ -168,7 +168,7 @@ static void init_pdata(struct null_private *prv, unsign= ed int cpu) static void null_init_pdata(const struct scheduler *ops, void *pdata, int = cpu) { struct null_private *prv =3D null_priv(ops); - struct schedule_data *sd =3D &per_cpu(schedule_data, cpu); + struct sched_resource *sd =3D per_cpu(sched_res, cpu); =20 /* alloc_pdata is not implemented, so we want this to be NULL. */ ASSERT(!pdata); @@ -277,7 +277,7 @@ pick_res(struct null_private *prv, struct sched_item *i= tem) unsigned int cpu =3D v->processor, new_cpu; cpumask_t *cpus =3D cpupool_domain_cpumask(v->domain); =20 - ASSERT(spin_is_locked(per_cpu(schedule_data, cpu).schedule_lock)); + ASSERT(spin_is_locked(per_cpu(sched_res, cpu)->schedule_lock)); =20 for_each_affinity_balance_step( bs ) { @@ -388,7 +388,7 @@ static void vcpu_deassign(struct null_private *prv, str= uct vcpu *v, static void null_switch_sched(struct scheduler *new_ops, unsigned int cpu, void *pdata, void *vdata) { - struct schedule_data *sd =3D &per_cpu(schedule_data, cpu); + struct sched_resource *sd =3D per_cpu(sched_res, cpu); struct null_private *prv =3D null_priv(new_ops); struct null_item *nvc =3D vdata; =20 @@ -406,7 +406,7 @@ static void null_switch_sched(struct scheduler *new_ops= , unsigned int cpu, init_pdata(prv, cpu); =20 per_cpu(scheduler, cpu) =3D new_ops; - per_cpu(schedule_data, cpu).sched_priv =3D pdata; + per_cpu(sched_res, cpu)->sched_priv =3D pdata; =20 /* * (Re?)route the lock to the per pCPU lock as /last/ thing. In fact, diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index a3cd00f765..0019646b52 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -75,7 +75,7 @@ /* * Locking: * A global system lock is used to protect the RunQ and DepletedQ. - * The global lock is referenced by schedule_data.schedule_lock + * The global lock is referenced by sched_res->schedule_lock * from all physical cpus. * * The lock is already grabbed when calling wake/sleep/schedule/ functions @@ -176,7 +176,7 @@ static void repl_timer_handler(void *data); =20 /* * System-wide private data, include global RunQueue/DepletedQ - * Global lock is referenced by schedule_data.schedule_lock from all + * Global lock is referenced by sched_res->schedule_lock from all * physical cpus. It can be grabbed via vcpu_schedule_lock_irq() */ struct rt_private { @@ -723,7 +723,7 @@ rt_init_pdata(const struct scheduler *ops, void *pdata,= int cpu) } =20 /* Move the scheduler lock to our global runqueue lock. */ - per_cpu(schedule_data, cpu).schedule_lock =3D &prv->lock; + per_cpu(sched_res, cpu)->schedule_lock =3D &prv->lock; =20 /* _Not_ pcpu_schedule_unlock(): per_cpu().schedule_lock changed! */ spin_unlock_irqrestore(old_lock, flags); @@ -745,7 +745,7 @@ rt_switch_sched(struct scheduler *new_ops, unsigned int= cpu, * another scheduler, but that is how things need to be, for * preventing races. */ - ASSERT(per_cpu(schedule_data, cpu).schedule_lock !=3D &prv->lock); + ASSERT(per_cpu(sched_res, cpu)->schedule_lock !=3D &prv->lock); =20 /* * If we are the absolute first cpu being switched toward this @@ -763,7 +763,7 @@ rt_switch_sched(struct scheduler *new_ops, unsigned int= cpu, =20 idle_vcpu[cpu]->sched_item->priv =3D vdata; per_cpu(scheduler, cpu) =3D new_ops; - per_cpu(schedule_data, cpu).sched_priv =3D NULL; /* no pdata */ + per_cpu(sched_res, cpu)->sched_priv =3D NULL; /* no pdata */ =20 /* * (Re?)route the lock to the per pCPU lock as /last/ thing. In fact, @@ -771,7 +771,7 @@ rt_switch_sched(struct scheduler *new_ops, unsigned int= cpu, * taking it, find all the initializations we've done above in place. */ smp_mb(); - per_cpu(schedule_data, cpu).schedule_lock =3D &prv->lock; + per_cpu(sched_res, cpu)->schedule_lock =3D &prv->lock; } =20 static void diff --git a/xen/common/schedule.c b/xen/common/schedule.c index b1eb77290a..51db98bcaa 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -61,7 +61,6 @@ static void vcpu_singleshot_timer_fn(void *data); static void poll_timer_fn(void *data); =20 /* This is global for now so that private implementations can reach it */ -DEFINE_PER_CPU(struct schedule_data, schedule_data); DEFINE_PER_CPU(struct scheduler *, scheduler); DEFINE_PER_CPU(struct sched_resource *, sched_res); =20 @@ -157,7 +156,7 @@ static inline void vcpu_urgent_count_update(struct vcpu= *v) !test_bit(v->vcpu_id, v->domain->poll_mask) ) { v->is_urgent =3D 0; - atomic_dec(&per_cpu(schedule_data,v->processor).urgent_count); + atomic_dec(&per_cpu(sched_res, v->processor)->urgent_count); } } else @@ -166,7 +165,7 @@ static inline void vcpu_urgent_count_update(struct vcpu= *v) unlikely(test_bit(v->vcpu_id, v->domain->poll_mask)) ) { v->is_urgent =3D 1; - atomic_inc(&per_cpu(schedule_data,v->processor).urgent_count); + atomic_inc(&per_cpu(sched_res, v->processor)->urgent_count); } } } @@ -177,7 +176,7 @@ static inline void vcpu_runstate_change( s_time_t delta; =20 ASSERT(v->runstate.state !=3D new_state); - ASSERT(spin_is_locked(per_cpu(schedule_data,v->processor).schedule_loc= k)); + ASSERT(spin_is_locked(per_cpu(sched_res, v->processor)->schedule_lock)= ); =20 vcpu_urgent_count_update(v); =20 @@ -334,7 +333,7 @@ int sched_init_vcpu(struct vcpu *v, unsigned int proces= sor) /* Idle VCPUs are scheduled immediately, so don't put them in runqueue= . */ if ( is_idle_domain(d) ) { - per_cpu(schedule_data, v->processor).curr =3D item; + per_cpu(sched_res, v->processor)->curr =3D item; v->is_running =3D 1; } else @@ -459,7 +458,7 @@ void sched_destroy_vcpu(struct vcpu *v) kill_timer(&v->singleshot_timer); kill_timer(&v->poll_timer); if ( test_and_clear_bool(v->is_urgent) ) - atomic_dec(&per_cpu(schedule_data, v->processor).urgent_count); + atomic_dec(&per_cpu(sched_res, v->processor)->urgent_count); sched_remove_item(vcpu_scheduler(v), item); sched_free_vdata(vcpu_scheduler(v), item->priv); sched_free_item(item); @@ -506,7 +505,7 @@ void sched_destroy_domain(struct domain *d) =20 void vcpu_sleep_nosync_locked(struct vcpu *v) { - ASSERT(spin_is_locked(per_cpu(schedule_data,v->processor).schedule_loc= k)); + ASSERT(spin_is_locked(per_cpu(sched_res, v->processor)->schedule_lock)= ); =20 if ( likely(!vcpu_runnable(v)) ) { @@ -601,8 +600,8 @@ static void vcpu_move_locked(struct vcpu *v, unsigned i= nt new_cpu) */ if ( unlikely(v->is_urgent) && (old_cpu !=3D new_cpu) ) { - atomic_inc(&per_cpu(schedule_data, new_cpu).urgent_count); - atomic_dec(&per_cpu(schedule_data, old_cpu).urgent_count); + atomic_inc(&per_cpu(sched_res, new_cpu)->urgent_count); + atomic_dec(&per_cpu(sched_res, old_cpu)->urgent_count); } =20 /* @@ -668,20 +667,20 @@ static void vcpu_migrate_finish(struct vcpu *v) * are not correct any longer after evaluating old and new cpu hol= ding * the locks. */ - old_lock =3D per_cpu(schedule_data, old_cpu).schedule_lock; - new_lock =3D per_cpu(schedule_data, new_cpu).schedule_lock; + old_lock =3D per_cpu(sched_res, old_cpu)->schedule_lock; + new_lock =3D per_cpu(sched_res, new_cpu)->schedule_lock; =20 sched_spin_lock_double(old_lock, new_lock, &flags); =20 old_cpu =3D v->processor; - if ( old_lock =3D=3D per_cpu(schedule_data, old_cpu).schedule_lock= ) + if ( old_lock =3D=3D per_cpu(sched_res, old_cpu)->schedule_lock ) { /* * If we selected a CPU on the previosu iteration, check if it * remains suitable for running this vCPU. */ if ( pick_called && - (new_lock =3D=3D per_cpu(schedule_data, new_cpu).schedule= _lock) && + (new_lock =3D=3D per_cpu(sched_res, new_cpu)->schedule_lo= ck) && cpumask_test_cpu(new_cpu, v->cpu_hard_affinity) && cpumask_test_cpu(new_cpu, v->domain->cpupool->cpu_valid) ) break; @@ -689,7 +688,7 @@ static void vcpu_migrate_finish(struct vcpu *v) /* Select a new CPU. */ new_cpu =3D sched_pick_resource(vcpu_scheduler(v), v->sched_item)->processor; - if ( (new_lock =3D=3D per_cpu(schedule_data, new_cpu).schedule= _lock) && + if ( (new_lock =3D=3D per_cpu(sched_res, new_cpu)->schedule_lo= ck) && cpumask_test_cpu(new_cpu, v->domain->cpupool->cpu_valid) ) break; pick_called =3D 1; @@ -1472,7 +1471,7 @@ static void schedule(void) struct scheduler *sched; unsigned long *tasklet_work =3D &this_cpu(tasklet_work_to_do); bool_t tasklet_work_scheduled =3D 0; - struct schedule_data *sd; + struct sched_resource *sd; spinlock_t *lock; struct task_slice next_slice; int cpu =3D smp_processor_id(); @@ -1481,7 +1480,7 @@ static void schedule(void) =20 SCHED_STAT_CRANK(sched_run); =20 - sd =3D &this_cpu(schedule_data); + sd =3D this_cpu(sched_res); =20 /* Update tasklet scheduling status. */ switch ( *tasklet_work ) @@ -1623,15 +1622,14 @@ static void poll_timer_fn(void *data) =20 static int cpu_schedule_up(unsigned int cpu) { - struct schedule_data *sd =3D &per_cpu(schedule_data, cpu); + struct sched_resource *sd; void *sched_priv; - struct sched_resource *res; =20 - res =3D xzalloc(struct sched_resource); - if ( res =3D=3D NULL ) + sd =3D xzalloc(struct sched_resource); + if ( sd =3D=3D NULL ) return -ENOMEM; - res->processor =3D cpu; - per_cpu(sched_res, cpu) =3D res; + sd->processor =3D cpu; + per_cpu(sched_res, cpu) =3D sd; =20 per_cpu(scheduler, cpu) =3D &ops; spin_lock_init(&sd->_lock); @@ -1687,7 +1685,7 @@ static int cpu_schedule_up(unsigned int cpu) =20 static void cpu_schedule_down(unsigned int cpu) { - struct schedule_data *sd =3D &per_cpu(schedule_data, cpu); + struct sched_resource *sd =3D per_cpu(sched_res, cpu); struct scheduler *sched =3D per_cpu(scheduler, cpu); =20 sched_free_pdata(sched, sd->sched_priv, cpu); @@ -1707,7 +1705,7 @@ static int cpu_schedule_callback( { unsigned int cpu =3D (unsigned long)hcpu; struct scheduler *sched =3D per_cpu(scheduler, cpu); - struct schedule_data *sd =3D &per_cpu(schedule_data, cpu); + struct sched_resource *sd =3D per_cpu(sched_res, cpu); int rc =3D 0; =20 /* @@ -1840,10 +1838,10 @@ void __init scheduler_init(void) idle_domain->max_vcpus =3D nr_cpu_ids; if ( vcpu_create(idle_domain, 0, 0) =3D=3D NULL ) BUG(); - this_cpu(schedule_data).curr =3D idle_vcpu[0]->sched_item; - this_cpu(schedule_data).sched_priv =3D sched_alloc_pdata(&ops, 0); - BUG_ON(IS_ERR(this_cpu(schedule_data).sched_priv)); - sched_init_pdata(&ops, this_cpu(schedule_data).sched_priv, 0); + this_cpu(sched_res)->curr =3D idle_vcpu[0]->sched_item; + this_cpu(sched_res)->sched_priv =3D sched_alloc_pdata(&ops, 0); + BUG_ON(IS_ERR(this_cpu(sched_res)->sched_priv)); + sched_init_pdata(&ops, this_cpu(sched_res)->sched_priv, 0); } =20 /* @@ -1923,7 +1921,7 @@ int schedule_cpu_switch(unsigned int cpu, struct cpup= ool *c) old_lock =3D pcpu_schedule_lock_irq(cpu); =20 vpriv_old =3D idle->sched_item->priv; - ppriv_old =3D per_cpu(schedule_data, cpu).sched_priv; + ppriv_old =3D per_cpu(sched_res, cpu)->sched_priv; sched_switch_sched(new_ops, cpu, ppriv, vpriv); =20 /* _Not_ pcpu_schedule_unlock(): schedule_lock may have changed! */ diff --git a/xen/include/asm-x86/cpuidle.h b/xen/include/asm-x86/cpuidle.h index 08da01803f..f520145752 100644 --- a/xen/include/asm-x86/cpuidle.h +++ b/xen/include/asm-x86/cpuidle.h @@ -33,7 +33,7 @@ void update_last_cx_stat(struct acpi_processor_power *, */ static inline int sched_has_urgent_vcpu(void) { - return atomic_read(&this_cpu(schedule_data).urgent_count); + return atomic_read(&this_cpu(sched_res)->urgent_count); } =20 #endif /* __X86_ASM_CPUIDLE_H__ */ diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index 9a0cd04af7..93617f0459 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -33,22 +33,18 @@ extern int sched_ratelimit_us; * For cache betterness, keep the actual lock in the same cache area * as the rest of the struct. Just have the scheduler point to the * one it wants (This may be the one right in front of it).*/ -struct schedule_data { +struct sched_resource { spinlock_t *schedule_lock, _lock; struct sched_item *curr; /* current task = */ void *sched_priv; struct timer s_timer; /* scheduling timer = */ atomic_t urgent_count; /* how many urgent vcpus = */ + unsigned processor; }; =20 -#define curr_on_cpu(c) (per_cpu(schedule_data, c).curr) - -struct sched_resource { - unsigned processor; -}; +#define curr_on_cpu(c) (per_cpu(sched_res, c)->curr) =20 -DECLARE_PER_CPU(struct schedule_data, schedule_data); DECLARE_PER_CPU(struct scheduler *, scheduler); DECLARE_PER_CPU(struct cpupool *, cpupool); DECLARE_PER_CPU(struct sched_resource *, sched_res); @@ -69,7 +65,7 @@ static inline spinlock_t *kind##_schedule_lock##irq(param= EXTRA_TYPE(arg)) \ { \ for ( ; ; ) \ { \ - spinlock_t *lock =3D per_cpu(schedule_data, cpu).schedule_lock; \ + spinlock_t *lock =3D per_cpu(sched_res, cpu)->schedule_lock; \ /* \ * v->processor may change when grabbing the lock; but \ * per_cpu(v->processor) may also change, if changing cpu pool \ @@ -79,7 +75,7 @@ static inline spinlock_t *kind##_schedule_lock##irq(param= EXTRA_TYPE(arg)) \ * lock may be the same; this will succeed in that case. \ */ \ spin_lock##irq(lock, ## arg); \ - if ( likely(lock =3D=3D per_cpu(schedule_data, cpu).schedule_lock)= ) \ + if ( likely(lock =3D=3D per_cpu(sched_res, cpu)->schedule_lock) ) \ return lock; \ spin_unlock##irq(lock, ## arg); \ } \ @@ -89,7 +85,7 @@ static inline spinlock_t *kind##_schedule_lock##irq(param= EXTRA_TYPE(arg)) \ static inline void kind##_schedule_unlock##irq(spinlock_t *lock \ EXTRA_TYPE(arg), param) \ { \ - ASSERT(lock =3D=3D per_cpu(schedule_data, cpu).schedule_lock); \ + ASSERT(lock =3D=3D per_cpu(sched_res, cpu)->schedule_lock); \ spin_unlock##irq(lock, ## arg); \ } =20 @@ -118,11 +114,11 @@ sched_unlock(vcpu, const struct vcpu *v, v->processor= , _irqrestore, flags) =20 static inline spinlock_t *pcpu_schedule_trylock(unsigned int cpu) { - spinlock_t *lock =3D per_cpu(schedule_data, cpu).schedule_lock; + spinlock_t *lock =3D per_cpu(sched_res, cpu)->schedule_lock; =20 if ( !spin_trylock(lock) ) return NULL; - if ( lock =3D=3D per_cpu(schedule_data, cpu).schedule_lock ) + if ( lock =3D=3D per_cpu(sched_res, cpu)->schedule_lock ) return lock; spin_unlock(lock); return NULL; --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125928; cv=none; d=zoho.com; s=zohoarc; b=jokGfvoGtdqxIeF9U0Xpd+lS2s/SmSrv25K/wcN/HEkbEHtSjVf9jy0fEbfREGi+4h8azHwtJsxRzVMRzVa5vepuNQYbDHHr+l4v+KExehpA3X4zSD/4ykLNTUv/6RKyw3LBKeVJyqi/bah6pzDnhgmurybjFys0vB96WOUz1k8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125928; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Au2nyjFf0KUtJfPE8GsuNQDlnaMijoMuhJ03KelzE4c=; b=nyZGrEfCIqJf/ccxNB5a+i9VaciqfZM6THBMTpzn5sTPxFQ9PCYWxEamwFHkd4hY9D5oq3il1GKm/B69+pcpk1qW3EkmNWejr9jgFnZ3ozWqbklmypz02Bw54u8zeG5WximHmmVOiEOFHYEKaEpM63uIduGjsW2IjQIBmDurKg4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125928088259.32026515757605; Sun, 5 May 2019 23:58:48 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYX-0001ti-Ff; Mon, 06 May 2019 06:56:57 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYV-0001ss-SB for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:56:55 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 21347ddc-6fcc-11e9-843c-bc764e045a96; Mon, 06 May 2019 06:56:53 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 74DD2AECE; Mon, 6 May 2019 06:56:51 +0000 (UTC) X-Inumbo-ID: 21347ddc-6fcc-11e9-843c-bc764e045a96 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:09 +0200 Message-Id: <20190506065644.7415-11-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 10/45] xen/sched: switch vcpu_schedule_lock to item_schedule_lock X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Tim Deegan , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Dario Faggioli , Julien Grall , Meng Xu , Jan Beulich MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Rename vcpu_schedule_[un]lock[_irq]() to item_schedule_[un]lock[_irq]() and let it take a sched_item pointer instead of a vcpu pointer as parameter. Signed-off-by: Juergen Gross --- xen/common/sched_credit.c | 17 +++++++++-------- xen/common/sched_credit2.c | 40 +++++++++++++++++++-------------------- xen/common/sched_null.c | 14 +++++++------- xen/common/sched_rt.c | 15 +++++++-------- xen/common/schedule.c | 47 +++++++++++++++++++++++-------------------= ---- xen/include/xen/sched-if.h | 12 ++++++------ 6 files changed, 73 insertions(+), 72 deletions(-) diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index e8369b3648..de4face2bc 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -940,7 +940,8 @@ __csched_vcpu_acct_stop_locked(struct csched_private *p= rv, static void csched_vcpu_acct(struct csched_private *prv, unsigned int cpu) { - struct csched_item * const svc =3D CSCHED_ITEM(current->sched_item); + struct sched_item *curritem =3D current->sched_item; + struct csched_item * const svc =3D CSCHED_ITEM(curritem); const struct scheduler *ops =3D per_cpu(scheduler, cpu); =20 ASSERT( current->processor =3D=3D cpu ); @@ -976,7 +977,7 @@ csched_vcpu_acct(struct csched_private *prv, unsigned i= nt cpu) { unsigned int new_cpu; unsigned long flags; - spinlock_t *lock =3D vcpu_schedule_lock_irqsave(current, &flags); + spinlock_t *lock =3D item_schedule_lock_irqsave(curritem, &flags); =20 /* * If it's been active a while, check if we'd be better off @@ -985,7 +986,7 @@ csched_vcpu_acct(struct csched_private *prv, unsigned i= nt cpu) */ new_cpu =3D _csched_cpu_pick(ops, current, 0); =20 - vcpu_schedule_unlock_irqrestore(lock, flags, current); + item_schedule_unlock_irqrestore(lock, flags, curritem); =20 if ( new_cpu !=3D cpu ) { @@ -1037,19 +1038,19 @@ csched_item_insert(const struct scheduler *ops, str= uct sched_item *item) BUG_ON( is_idle_vcpu(vc) ); =20 /* csched_res_pick() looks in vc->processor's runq, so we need the loc= k. */ - lock =3D vcpu_schedule_lock_irq(vc); + lock =3D item_schedule_lock_irq(item); =20 item->res =3D csched_res_pick(ops, item); vc->processor =3D item->res->processor; =20 spin_unlock_irq(lock); =20 - lock =3D vcpu_schedule_lock_irq(vc); + lock =3D item_schedule_lock_irq(item); =20 if ( !__vcpu_on_runq(svc) && vcpu_runnable(vc) && !vc->is_running ) runq_insert(svc); =20 - vcpu_schedule_unlock_irq(lock, vc); + item_schedule_unlock_irq(lock, item); =20 SCHED_STAT_CRANK(vcpu_insert); } @@ -2145,12 +2146,12 @@ csched_dump(const struct scheduler *ops) spinlock_t *lock; =20 svc =3D list_entry(iter_svc, struct csched_item, active_vcpu_e= lem); - lock =3D vcpu_schedule_lock(svc->vcpu); + lock =3D item_schedule_lock(svc->vcpu->sched_item); =20 printk("\t%3d: ", ++loop); csched_dump_vcpu(svc); =20 - vcpu_schedule_unlock(lock, svc->vcpu); + item_schedule_unlock(lock, svc->vcpu->sched_item); } } =20 diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index df0e7282ce..6106293b3f 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -171,7 +171,7 @@ * - runqueue lock * + it is per-runqueue, so: * * cpus in a runqueue take the runqueue lock, when using - * pcpu_schedule_lock() / vcpu_schedule_lock() (and friends), + * pcpu_schedule_lock() / item_schedule_lock() (and friends), * * a cpu may (try to) take a "remote" runqueue lock, e.g., for * load balancing; * + serializes runqueue operations (removing and inserting vcpus); @@ -1890,7 +1890,7 @@ unpark_parked_vcpus(const struct scheduler *ops, stru= ct list_head *vcpus) unsigned long flags; s_time_t now; =20 - lock =3D vcpu_schedule_lock_irqsave(svc->vcpu, &flags); + lock =3D item_schedule_lock_irqsave(svc->vcpu->sched_item, &flags); =20 __clear_bit(_VPF_parked, &svc->vcpu->pause_flags); if ( unlikely(svc->flags & CSFLAG_scheduled) ) @@ -1923,7 +1923,7 @@ unpark_parked_vcpus(const struct scheduler *ops, stru= ct list_head *vcpus) } list_del_init(&svc->parked_elem); =20 - vcpu_schedule_unlock_irqrestore(lock, flags, svc->vcpu); + item_schedule_unlock_irqrestore(lock, flags, svc->vcpu->sched_item= ); } } =20 @@ -2162,7 +2162,7 @@ csched2_context_saved(const struct scheduler *ops, st= ruct sched_item *item) { struct vcpu *vc =3D item->vcpu; struct csched2_item * const svc =3D csched2_item(item); - spinlock_t *lock =3D vcpu_schedule_lock_irq(vc); + spinlock_t *lock =3D item_schedule_lock_irq(item); s_time_t now =3D NOW(); LIST_HEAD(were_parked); =20 @@ -2194,7 +2194,7 @@ csched2_context_saved(const struct scheduler *ops, st= ruct sched_item *item) else if ( !is_idle_vcpu(vc) ) update_load(ops, svc->rqd, svc, -1, now); =20 - vcpu_schedule_unlock_irq(lock, vc); + item_schedule_unlock_irq(lock, item); =20 unpark_parked_vcpus(ops, &were_parked); } @@ -2847,14 +2847,14 @@ csched2_dom_cntl( for_each_vcpu ( d, v ) { struct csched2_item *svc =3D csched2_item(v->sched_item); - spinlock_t *lock =3D vcpu_schedule_lock(svc->vcpu); + spinlock_t *lock =3D item_schedule_lock(svc->vcpu->sched_i= tem); =20 ASSERT(svc->rqd =3D=3D c2rqd(ops, svc->vcpu->processor)); =20 svc->weight =3D sdom->weight; update_max_weight(svc->rqd, svc->weight, old_weight); =20 - vcpu_schedule_unlock(lock, svc->vcpu); + item_schedule_unlock(lock, svc->vcpu->sched_item); } } /* Cap */ @@ -2885,7 +2885,7 @@ csched2_dom_cntl( for_each_vcpu ( d, v ) { svc =3D csched2_item(v->sched_item); - lock =3D vcpu_schedule_lock(svc->vcpu); + lock =3D item_schedule_lock(svc->vcpu->sched_item); /* * Too small quotas would in theory cause a lot of overhea= d, * which then won't happen because, in csched2_runtime(), @@ -2893,7 +2893,7 @@ csched2_dom_cntl( */ svc->budget_quota =3D max(sdom->tot_budget / sdom->nr_vcpu= s, CSCHED2_MIN_TIMER); - vcpu_schedule_unlock(lock, svc->vcpu); + item_schedule_unlock(lock, svc->vcpu->sched_item); } =20 if ( sdom->cap =3D=3D 0 ) @@ -2928,7 +2928,7 @@ csched2_dom_cntl( for_each_vcpu ( d, v ) { svc =3D csched2_item(v->sched_item); - lock =3D vcpu_schedule_lock(svc->vcpu); + lock =3D item_schedule_lock(svc->vcpu->sched_item); if ( v->is_running ) { unsigned int cpu =3D v->processor; @@ -2959,7 +2959,7 @@ csched2_dom_cntl( cpu_raise_softirq(cpu, SCHEDULE_SOFTIRQ); } svc->budget =3D 0; - vcpu_schedule_unlock(lock, svc->vcpu); + item_schedule_unlock(lock, svc->vcpu->sched_item); } } =20 @@ -2975,12 +2975,12 @@ csched2_dom_cntl( for_each_vcpu ( d, v ) { struct csched2_item *svc =3D csched2_item(v->sched_item); - spinlock_t *lock =3D vcpu_schedule_lock(svc->vcpu); + spinlock_t *lock =3D item_schedule_lock(svc->vcpu->sched_i= tem); =20 svc->budget =3D STIME_MAX; svc->budget_quota =3D 0; =20 - vcpu_schedule_unlock(lock, svc->vcpu); + item_schedule_unlock(lock, svc->vcpu->sched_item); } sdom->cap =3D 0; /* @@ -3119,19 +3119,19 @@ csched2_item_insert(const struct scheduler *ops, st= ruct sched_item *item) ASSERT(list_empty(&svc->runq_elem)); =20 /* csched2_res_pick() expects the pcpu lock to be held */ - lock =3D vcpu_schedule_lock_irq(vc); + lock =3D item_schedule_lock_irq(item); =20 item->res =3D csched2_res_pick(ops, item); vc->processor =3D item->res->processor; =20 spin_unlock_irq(lock); =20 - lock =3D vcpu_schedule_lock_irq(vc); + lock =3D item_schedule_lock_irq(item); =20 /* Add vcpu to runqueue of initial processor */ runq_assign(ops, vc); =20 - vcpu_schedule_unlock_irq(lock, vc); + item_schedule_unlock_irq(lock, item); =20 sdom->nr_vcpus++; =20 @@ -3161,11 +3161,11 @@ csched2_item_remove(const struct scheduler *ops, st= ruct sched_item *item) SCHED_STAT_CRANK(vcpu_remove); =20 /* Remove from runqueue */ - lock =3D vcpu_schedule_lock_irq(vc); + lock =3D item_schedule_lock_irq(item); =20 runq_deassign(ops, vc); =20 - vcpu_schedule_unlock_irq(lock, vc); + item_schedule_unlock_irq(lock, item); =20 svc->sdom->nr_vcpus--; } @@ -3749,12 +3749,12 @@ csched2_dump(const struct scheduler *ops) struct csched2_item * const svc =3D csched2_item(v->sched_item= ); spinlock_t *lock; =20 - lock =3D vcpu_schedule_lock(svc->vcpu); + lock =3D item_schedule_lock(svc->vcpu->sched_item); =20 printk("\t%3d: ", ++loop); csched2_dump_vcpu(prv, svc); =20 - vcpu_schedule_unlock(lock, svc->vcpu); + item_schedule_unlock(lock, svc->vcpu->sched_item); } } =20 diff --git a/xen/common/sched_null.c b/xen/common/sched_null.c index a9cfa163b9..620925e8ce 100644 --- a/xen/common/sched_null.c +++ b/xen/common/sched_null.c @@ -317,7 +317,7 @@ pick_res(struct null_private *prv, struct sched_item *i= tem) * all the pCPUs are busy. * * In fact, there must always be something sane in v->processor, or - * vcpu_schedule_lock() and friends won't work. This is not a problem, + * item_schedule_lock() and friends won't work. This is not a problem, * as we will actually assign the vCPU to the pCPU we return from here, * only if the pCPU is free. */ @@ -428,7 +428,7 @@ static void null_item_insert(const struct scheduler *op= s, =20 ASSERT(!is_idle_vcpu(v)); =20 - lock =3D vcpu_schedule_lock_irq(v); + lock =3D item_schedule_lock_irq(item); retry: =20 item->res =3D pick_res(prv, item); @@ -436,7 +436,7 @@ static void null_item_insert(const struct scheduler *op= s, =20 spin_unlock(lock); =20 - lock =3D vcpu_schedule_lock(v); + lock =3D item_schedule_lock(item); =20 cpumask_and(cpumask_scratch_cpu(cpu), v->cpu_hard_affinity, cpupool_domain_cpumask(v->domain)); @@ -522,7 +522,7 @@ static void null_item_remove(const struct scheduler *op= s, =20 ASSERT(!is_idle_vcpu(v)); =20 - lock =3D vcpu_schedule_lock_irq(v); + lock =3D item_schedule_lock_irq(item); =20 /* If v is in waitqueue, just get it out of there and bail */ if ( unlikely(!list_empty(&nvc->waitq_elem)) ) @@ -540,7 +540,7 @@ static void null_item_remove(const struct scheduler *op= s, _vcpu_remove(prv, v); =20 out: - vcpu_schedule_unlock_irq(lock, v); + item_schedule_unlock_irq(lock, item); =20 SCHED_STAT_CRANK(vcpu_remove); } @@ -860,13 +860,13 @@ static void null_dump(const struct scheduler *ops) struct null_item * const nvc =3D null_item(v->sched_item); spinlock_t *lock; =20 - lock =3D vcpu_schedule_lock(nvc->vcpu); + lock =3D item_schedule_lock(nvc->vcpu->sched_item); =20 printk("\t%3d: ", ++loop); dump_vcpu(prv, nvc); printk("\n"); =20 - vcpu_schedule_unlock(lock, nvc->vcpu); + item_schedule_unlock(lock, nvc->vcpu->sched_item); } } =20 diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index 0019646b52..a604a0d5a6 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -177,7 +177,7 @@ static void repl_timer_handler(void *data); /* * System-wide private data, include global RunQueue/DepletedQ * Global lock is referenced by sched_res->schedule_lock from all - * physical cpus. It can be grabbed via vcpu_schedule_lock_irq() + * physical cpus. It can be grabbed via item_schedule_lock_irq() */ struct rt_private { spinlock_t lock; /* the global coarse-grained lock */ @@ -904,7 +904,7 @@ rt_item_insert(const struct scheduler *ops, struct sche= d_item *item) item->res =3D rt_res_pick(ops, item); vc->processor =3D item->res->processor; =20 - lock =3D vcpu_schedule_lock_irq(vc); + lock =3D item_schedule_lock_irq(item); =20 now =3D NOW(); if ( now >=3D svc->cur_deadline ) @@ -917,7 +917,7 @@ rt_item_insert(const struct scheduler *ops, struct sche= d_item *item) if ( !vc->is_running ) runq_insert(ops, svc); } - vcpu_schedule_unlock_irq(lock, vc); + item_schedule_unlock_irq(lock, item); =20 SCHED_STAT_CRANK(vcpu_insert); } @@ -928,7 +928,6 @@ rt_item_insert(const struct scheduler *ops, struct sche= d_item *item) static void rt_item_remove(const struct scheduler *ops, struct sched_item *item) { - struct vcpu *vc =3D item->vcpu; struct rt_item * const svc =3D rt_item(item); struct rt_dom * const sdom =3D svc->sdom; spinlock_t *lock; @@ -937,14 +936,14 @@ rt_item_remove(const struct scheduler *ops, struct sc= hed_item *item) =20 BUG_ON( sdom =3D=3D NULL ); =20 - lock =3D vcpu_schedule_lock_irq(vc); + lock =3D item_schedule_lock_irq(item); if ( vcpu_on_q(svc) ) q_remove(svc); =20 if ( vcpu_on_replq(svc) ) replq_remove(ops,svc); =20 - vcpu_schedule_unlock_irq(lock, vc); + item_schedule_unlock_irq(lock, item); } =20 /* @@ -1339,7 +1338,7 @@ rt_context_saved(const struct scheduler *ops, struct = sched_item *item) { struct vcpu *vc =3D item->vcpu; struct rt_item *svc =3D rt_item(item); - spinlock_t *lock =3D vcpu_schedule_lock_irq(vc); + spinlock_t *lock =3D item_schedule_lock_irq(item); =20 __clear_bit(__RTDS_scheduled, &svc->flags); /* not insert idle vcpu to runq */ @@ -1356,7 +1355,7 @@ rt_context_saved(const struct scheduler *ops, struct = sched_item *item) replq_remove(ops, svc); =20 out: - vcpu_schedule_unlock_irq(lock, vc); + item_schedule_unlock_irq(lock, item); } =20 /* diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 51db98bcaa..464e358f70 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -194,7 +194,8 @@ static inline void vcpu_runstate_change( =20 void vcpu_runstate_get(struct vcpu *v, struct vcpu_runstate_info *runstate) { - spinlock_t *lock =3D likely(v =3D=3D current) ? NULL : vcpu_schedule_l= ock_irq(v); + spinlock_t *lock =3D likely(v =3D=3D current) + ? NULL : item_schedule_lock_irq(v->sched_item); s_time_t delta; =20 memcpy(runstate, &v->runstate, sizeof(*runstate)); @@ -203,7 +204,7 @@ void vcpu_runstate_get(struct vcpu *v, struct vcpu_runs= tate_info *runstate) runstate->time[runstate->state] +=3D delta; =20 if ( unlikely(lock !=3D NULL) ) - vcpu_schedule_unlock_irq(lock, v); + item_schedule_unlock_irq(lock, v->sched_item); } =20 uint64_t get_cpu_idle_time(unsigned int cpu) @@ -415,7 +416,7 @@ int sched_move_domain(struct domain *d, struct cpupool = *c) migrate_timer(&v->singleshot_timer, new_p); migrate_timer(&v->poll_timer, new_p); =20 - lock =3D vcpu_schedule_lock_irq(v); + lock =3D item_schedule_lock_irq(v->sched_item); =20 sched_set_affinity(v, &cpumask_all, &cpumask_all); =20 @@ -424,7 +425,7 @@ int sched_move_domain(struct domain *d, struct cpupool = *c) /* * With v->processor modified we must not * - make any further changes assuming we hold the scheduler lock, - * - use vcpu_schedule_unlock_irq(). + * - use item_schedule_unlock_irq(). */ spin_unlock_irq(lock); =20 @@ -523,11 +524,11 @@ void vcpu_sleep_nosync(struct vcpu *v) =20 TRACE_2D(TRC_SCHED_SLEEP, v->domain->domain_id, v->vcpu_id); =20 - lock =3D vcpu_schedule_lock_irqsave(v, &flags); + lock =3D item_schedule_lock_irqsave(v->sched_item, &flags); =20 vcpu_sleep_nosync_locked(v); =20 - vcpu_schedule_unlock_irqrestore(lock, flags, v); + item_schedule_unlock_irqrestore(lock, flags, v->sched_item); } =20 void vcpu_sleep_sync(struct vcpu *v) @@ -547,7 +548,7 @@ void vcpu_wake(struct vcpu *v) =20 TRACE_2D(TRC_SCHED_WAKE, v->domain->domain_id, v->vcpu_id); =20 - lock =3D vcpu_schedule_lock_irqsave(v, &flags); + lock =3D item_schedule_lock_irqsave(v->sched_item, &flags); =20 if ( likely(vcpu_runnable(v)) ) { @@ -561,7 +562,7 @@ void vcpu_wake(struct vcpu *v) vcpu_runstate_change(v, RUNSTATE_offline, NOW()); } =20 - vcpu_schedule_unlock_irqrestore(lock, flags, v); + item_schedule_unlock_irqrestore(lock, flags, v->sched_item); } =20 void vcpu_unblock(struct vcpu *v) @@ -629,9 +630,9 @@ static void vcpu_move_locked(struct vcpu *v, unsigned i= nt new_cpu) * These steps are encapsulated in the following two functions; they * should be called like this: * - * lock =3D vcpu_schedule_lock_irq(v); + * lock =3D item_schedule_lock_irq(item); * vcpu_migrate_start(v); - * vcpu_schedule_unlock_irq(lock, v) + * item_schedule_unlock_irq(lock, item) * vcpu_migrate_finish(v); * * vcpu_migrate_finish() will do the work now if it can, or simply @@ -736,12 +737,12 @@ static void vcpu_migrate_finish(struct vcpu *v) */ void vcpu_force_reschedule(struct vcpu *v) { - spinlock_t *lock =3D vcpu_schedule_lock_irq(v); + spinlock_t *lock =3D item_schedule_lock_irq(v->sched_item); =20 if ( v->is_running ) vcpu_migrate_start(v); =20 - vcpu_schedule_unlock_irq(lock, v); + item_schedule_unlock_irq(lock, v->sched_item); =20 vcpu_migrate_finish(v); } @@ -792,7 +793,7 @@ void restore_vcpu_affinity(struct domain *d) v->processor =3D cpumask_any(cpumask_scratch_cpu(cpu)); v->sched_item->res =3D per_cpu(sched_res, v->processor); =20 - lock =3D vcpu_schedule_lock_irq(v); + lock =3D item_schedule_lock_irq(v->sched_item); v->sched_item->res =3D sched_pick_resource(vcpu_scheduler(v), v->sched_item); v->processor =3D v->sched_item->res->processor; @@ -827,7 +828,7 @@ int cpu_disable_scheduler(unsigned int cpu) for_each_vcpu ( d, v ) { unsigned long flags; - spinlock_t *lock =3D vcpu_schedule_lock_irqsave(v, &flags); + spinlock_t *lock =3D item_schedule_lock_irqsave(v->sched_item,= &flags); =20 cpumask_and(&online_affinity, v->cpu_hard_affinity, c->cpu_val= id); if ( cpumask_empty(&online_affinity) && @@ -836,7 +837,7 @@ int cpu_disable_scheduler(unsigned int cpu) if ( v->affinity_broken ) { /* The vcpu is temporarily pinned, can't move it. */ - vcpu_schedule_unlock_irqrestore(lock, flags, v); + item_schedule_unlock_irqrestore(lock, flags, v->sched_= item); ret =3D -EADDRINUSE; break; } @@ -849,7 +850,7 @@ int cpu_disable_scheduler(unsigned int cpu) if ( v->processor !=3D cpu ) { /* The vcpu is not on this cpu, so we can move on. */ - vcpu_schedule_unlock_irqrestore(lock, flags, v); + item_schedule_unlock_irqrestore(lock, flags, v->sched_item= ); continue; } =20 @@ -862,7 +863,7 @@ int cpu_disable_scheduler(unsigned int cpu) * things would have failed before getting in here. */ vcpu_migrate_start(v); - vcpu_schedule_unlock_irqrestore(lock, flags, v); + item_schedule_unlock_irqrestore(lock, flags, v->sched_item); =20 vcpu_migrate_finish(v); =20 @@ -926,7 +927,7 @@ static int vcpu_set_affinity( spinlock_t *lock; int ret =3D 0; =20 - lock =3D vcpu_schedule_lock_irq(v); + lock =3D item_schedule_lock_irq(v->sched_item); =20 if ( v->affinity_broken ) ret =3D -EBUSY; @@ -948,7 +949,7 @@ static int vcpu_set_affinity( vcpu_migrate_start(v); } =20 - vcpu_schedule_unlock_irq(lock, v); + item_schedule_unlock_irq(lock, v->sched_item); =20 domain_update_node_affinity(v->domain); =20 @@ -1080,10 +1081,10 @@ static long do_poll(struct sched_poll *sched_poll) long vcpu_yield(void) { struct vcpu * v=3Dcurrent; - spinlock_t *lock =3D vcpu_schedule_lock_irq(v); + spinlock_t *lock =3D item_schedule_lock_irq(v->sched_item); =20 sched_yield(vcpu_scheduler(v), v->sched_item); - vcpu_schedule_unlock_irq(lock, v); + item_schedule_unlock_irq(lock, v->sched_item); =20 SCHED_STAT_CRANK(vcpu_yield); =20 @@ -1169,7 +1170,7 @@ int vcpu_pin_override(struct vcpu *v, int cpu) spinlock_t *lock; int ret =3D -EINVAL; =20 - lock =3D vcpu_schedule_lock_irq(v); + lock =3D item_schedule_lock_irq(v->sched_item); =20 if ( cpu < 0 ) { @@ -1196,7 +1197,7 @@ int vcpu_pin_override(struct vcpu *v, int cpu) if ( ret =3D=3D 0 ) vcpu_migrate_start(v); =20 - vcpu_schedule_unlock_irq(lock, v); + item_schedule_unlock_irq(lock, v->sched_item); =20 domain_update_node_affinity(v->domain); =20 diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index 93617f0459..17f1ee8887 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -91,22 +91,22 @@ static inline void kind##_schedule_unlock##irq(spinlock= _t *lock \ =20 #define EXTRA_TYPE(arg) sched_lock(pcpu, unsigned int cpu, cpu, ) -sched_lock(vcpu, const struct vcpu *v, v->processor, ) +sched_lock(item, const struct sched_item *i, i->res->processor, ) sched_lock(pcpu, unsigned int cpu, cpu, _irq) -sched_lock(vcpu, const struct vcpu *v, v->processor, _irq) +sched_lock(item, const struct sched_item *i, i->res->processor, _irq) sched_unlock(pcpu, unsigned int cpu, cpu, ) -sched_unlock(vcpu, const struct vcpu *v, v->processor, ) +sched_unlock(item, const struct sched_item *i, i->res->processor, ) sched_unlock(pcpu, unsigned int cpu, cpu, _irq) -sched_unlock(vcpu, const struct vcpu *v, v->processor, _irq) +sched_unlock(item, const struct sched_item *i, i->res->processor, _irq) #undef EXTRA_TYPE =20 #define EXTRA_TYPE(arg) , unsigned long arg #define spin_unlock_irqsave spin_unlock_irqrestore sched_lock(pcpu, unsigned int cpu, cpu, _irqsave, *flags) -sched_lock(vcpu, const struct vcpu *v, v->processor, _irqsave, *flags) +sched_lock(item, const struct sched_item *i, i->res->processor, _irqsave, = *flags) #undef spin_unlock_irqsave sched_unlock(pcpu, unsigned int cpu, cpu, _irqrestore, flags) -sched_unlock(vcpu, const struct vcpu *v, v->processor, _irqrestore, flags) +sched_unlock(item, const struct sched_item *i, i->res->processor, _irqrest= ore, flags) #undef EXTRA_TYPE =20 #undef sched_unlock --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125909; cv=none; d=zoho.com; s=zohoarc; b=Drx9PDx64t6Xrj/MuEXsQt9/yNgSP97Z2uA02l99tsQD+dnf1JPZoBoSf0T331U1NPiUEQNqH7B+xfxkPu2KXzbPpEKjl7KRO8dZQ14QxiIadjNnnEg5n/0mYwNDlV8w0yso6KXEtIzd+sSveB7c6bDVByiIY9wb60ubyqzpADs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125909; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=nsDgCUetuDDxj4WagMdAryYgeb38ej1fR94tND/0TUY=; b=obDp48UuYntw2uDIa9ZapvRYxELEb18mO+3f2XYkakZEUDkMcyWrzHlYEtHWrAONtkTJZQ8g5S41zojgN1emZ1ucpcNffwsHsWV6iVfBlKjnp0mSLXWZU5/hSkwVI+OOfBf1h/wdvP865JfiLt6uKJKd7io1xfD+FPmdDU/RUG8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125909126718.7409441865052; Sun, 5 May 2019 23:58:29 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYh-000281-Mu; Mon, 06 May 2019 06:57:07 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYe-00020R-7P for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:04 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 22036e9a-6fcc-11e9-9b2a-97130b85c37c; Mon, 06 May 2019 06:56:55 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id CCF94AED6; Mon, 6 May 2019 06:56:51 +0000 (UTC) X-Inumbo-ID: 22036e9a-6fcc-11e9-9b2a-97130b85c37c X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:10 +0200 Message-Id: <20190506065644.7415-12-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 11/45] xen/sched: move some per-vcpu items to struct sched_item X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Meng Xu , Jan Beulich , Dario Faggioli , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Affinities are scheduler specific attributes, they should be per scheduling item. So move all affinity related fields in struct vcpu to struct sched_item. While at it switch affinity related functions in sched-if.h to use a pointer to sched_item instead to vcpu as parameter. vcpu->last_run_time is primarily used by sched_credit, so move it to struct sched_item, too. Signed-off-by: Juergen Gross --- xen/arch/x86/pv/emul-priv-op.c | 1 + xen/arch/x86/pv/traps.c | 5 +- xen/arch/x86/traps.c | 9 ++-- xen/common/domain.c | 19 ++----- xen/common/domctl.c | 13 +++-- xen/common/keyhandler.c | 4 +- xen/common/sched_credit.c | 20 ++++---- xen/common/sched_credit2.c | 42 ++++++++-------- xen/common/sched_null.c | 16 +++--- xen/common/sched_rt.c | 9 ++-- xen/common/schedule.c | 110 ++++++++++++++++++++++++-------------= ---- xen/common/wait.c | 4 +- xen/include/xen/sched-if.h | 17 ++++--- xen/include/xen/sched.h | 36 +++++++------- 14 files changed, 163 insertions(+), 142 deletions(-) diff --git a/xen/arch/x86/pv/emul-priv-op.c b/xen/arch/x86/pv/emul-priv-op.c index af74f50dc8..7030e8078a 100644 --- a/xen/arch/x86/pv/emul-priv-op.c +++ b/xen/arch/x86/pv/emul-priv-op.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include =20 diff --git a/xen/arch/x86/pv/traps.c b/xen/arch/x86/pv/traps.c index 1740784ff2..e2a387c7c5 100644 --- a/xen/arch/x86/pv/traps.c +++ b/xen/arch/x86/pv/traps.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include =20 @@ -155,8 +156,8 @@ static void nmi_mce_softirq(void) * Set the tmp value unconditionally, so that the check in the iret * hypercall works. */ - cpumask_copy(st->vcpu->cpu_hard_affinity_tmp, - st->vcpu->cpu_hard_affinity); + cpumask_copy(st->vcpu->sched_item->cpu_hard_affinity_tmp, + st->vcpu->sched_item->cpu_hard_affinity); =20 if ( (cpu !=3D st->processor) || (st->processor !=3D st->vcpu->processor) ) diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 05ddc39bfe..ff73cd0e29 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -1594,16 +1594,17 @@ static void pci_serr_softirq(void) void async_exception_cleanup(struct vcpu *curr) { int trap; + struct sched_item *item =3D curr->sched_item; =20 if ( !curr->async_exception_mask ) return; =20 /* Restore affinity. */ - if ( !cpumask_empty(curr->cpu_hard_affinity_tmp) && - !cpumask_equal(curr->cpu_hard_affinity_tmp, curr->cpu_hard_affini= ty) ) + if ( !cpumask_empty(item->cpu_hard_affinity_tmp) && + !cpumask_equal(item->cpu_hard_affinity_tmp, item->cpu_hard_affini= ty) ) { - vcpu_set_hard_affinity(curr, curr->cpu_hard_affinity_tmp); - cpumask_clear(curr->cpu_hard_affinity_tmp); + vcpu_set_hard_affinity(curr, item->cpu_hard_affinity_tmp); + cpumask_clear(item->cpu_hard_affinity_tmp); } =20 if ( !(curr->async_exception_mask & (curr->async_exception_mask - 1)) ) diff --git a/xen/common/domain.c b/xen/common/domain.c index 88bbe984bc..1c0abda66f 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -126,11 +126,6 @@ static void vcpu_info_reset(struct vcpu *v) =20 static void vcpu_destroy(struct vcpu *v) { - free_cpumask_var(v->cpu_hard_affinity); - free_cpumask_var(v->cpu_hard_affinity_tmp); - free_cpumask_var(v->cpu_hard_affinity_saved); - free_cpumask_var(v->cpu_soft_affinity); - free_vcpu_struct(v); } =20 @@ -154,12 +149,6 @@ struct vcpu *vcpu_create( =20 grant_table_init_vcpu(v); =20 - if ( !zalloc_cpumask_var(&v->cpu_hard_affinity) || - !zalloc_cpumask_var(&v->cpu_hard_affinity_tmp) || - !zalloc_cpumask_var(&v->cpu_hard_affinity_saved) || - !zalloc_cpumask_var(&v->cpu_soft_affinity) ) - goto fail; - if ( is_idle_domain(d) ) { v->runstate.state =3D RUNSTATE_running; @@ -199,7 +188,6 @@ struct vcpu *vcpu_create( sched_destroy_vcpu(v); fail_wq: destroy_waitqueue_vcpu(v); - fail: vcpu_destroy(v); =20 return NULL; @@ -558,9 +546,10 @@ void domain_update_node_affinity(struct domain *d) */ for_each_vcpu ( d, v ) { - cpumask_or(dom_cpumask, dom_cpumask, v->cpu_hard_affinity); + cpumask_or(dom_cpumask, dom_cpumask, + v->sched_item->cpu_hard_affinity); cpumask_or(dom_cpumask_soft, dom_cpumask_soft, - v->cpu_soft_affinity); + v->sched_item->cpu_soft_affinity); } /* Filter out non-online cpus */ cpumask_and(dom_cpumask, dom_cpumask, online); @@ -1229,7 +1218,7 @@ int vcpu_reset(struct vcpu *v) v->async_exception_mask =3D 0; memset(v->async_exception_state, 0, sizeof(v->async_exception_state)); #endif - cpumask_clear(v->cpu_hard_affinity_tmp); + cpumask_clear(v->sched_item->cpu_hard_affinity_tmp); clear_bit(_VPF_blocked, &v->pause_flags); clear_bit(_VPF_in_reset, &v->pause_flags); =20 diff --git a/xen/common/domctl.c b/xen/common/domctl.c index bade9a63b1..8464713d2b 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -614,6 +614,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_d= omctl) case XEN_DOMCTL_getvcpuaffinity: { struct vcpu *v; + struct sched_item *item; struct xen_domctl_vcpuaffinity *vcpuaff =3D &op->u.vcpuaffinity; =20 ret =3D -EINVAL; @@ -624,6 +625,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_d= omctl) if ( (v =3D d->vcpu[vcpuaff->vcpu]) =3D=3D NULL ) break; =20 + item =3D v->sched_item; ret =3D -EINVAL; if ( vcpuaffinity_params_invalid(vcpuaff) ) break; @@ -643,7 +645,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_d= omctl) ret =3D -ENOMEM; break; } - cpumask_copy(old_affinity, v->cpu_hard_affinity); + cpumask_copy(old_affinity, item->cpu_hard_affinity); =20 if ( !alloc_cpumask_var(&new_affinity) ) { @@ -676,7 +678,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_d= omctl) * For hard affinity, what we return is the intersection of * cpupool's online mask and the new hard affinity. */ - cpumask_and(new_affinity, online, v->cpu_hard_affinity); + cpumask_and(new_affinity, online, item->cpu_hard_affinity); ret =3D cpumask_to_xenctl_bitmap(&vcpuaff->cpumap_hard, new_affinity); } @@ -705,7 +707,8 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_d= omctl) * hard affinity. */ cpumask_and(new_affinity, new_affinity, online); - cpumask_and(new_affinity, new_affinity, v->cpu_hard_affini= ty); + cpumask_and(new_affinity, new_affinity, + item->cpu_hard_affinity); ret =3D cpumask_to_xenctl_bitmap(&vcpuaff->cpumap_soft, new_affinity); } @@ -718,10 +721,10 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u= _domctl) { if ( vcpuaff->flags & XEN_VCPUAFFINITY_HARD ) ret =3D cpumask_to_xenctl_bitmap(&vcpuaff->cpumap_hard, - v->cpu_hard_affinity); + item->cpu_hard_affinity); if ( vcpuaff->flags & XEN_VCPUAFFINITY_SOFT ) ret =3D cpumask_to_xenctl_bitmap(&vcpuaff->cpumap_soft, - v->cpu_soft_affinity); + item->cpu_soft_affinity); } break; } diff --git a/xen/common/keyhandler.c b/xen/common/keyhandler.c index 4f4a660b0c..d7607e39aa 100644 --- a/xen/common/keyhandler.c +++ b/xen/common/keyhandler.c @@ -312,8 +312,8 @@ static void dump_domains(unsigned char key) printk("dirty_cpu=3D%u", v->dirty_cpu); printk("\n"); printk(" cpu_hard_affinity=3D{%*pbl} cpu_soft_affinity=3D{%= *pbl}\n", - nr_cpu_ids, cpumask_bits(v->cpu_hard_affinity), - nr_cpu_ids, cpumask_bits(v->cpu_soft_affinity)); + nr_cpu_ids, cpumask_bits(v->sched_item->cpu_hard_affini= ty), + nr_cpu_ids, cpumask_bits(v->sched_item->cpu_soft_affini= ty)); printk(" pause_count=3D%d pause_flags=3D%lx\n", atomic_read(&v->pause_count), v->pause_flags); arch_dump_vcpu_info(v); diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index de4face2bc..9e7c849b94 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -350,6 +350,7 @@ DEFINE_PER_CPU(unsigned int, last_tickle_cpu); static inline void __runq_tickle(struct csched_item *new) { unsigned int cpu =3D new->vcpu->processor; + struct sched_item *item =3D new->vcpu->sched_item; struct csched_item * const cur =3D CSCHED_ITEM(curr_on_cpu(cpu)); struct csched_private *prv =3D CSCHED_PRIV(per_cpu(scheduler, cpu)); cpumask_t mask, idle_mask, *online; @@ -375,7 +376,7 @@ static inline void __runq_tickle(struct csched_item *ne= w) if ( unlikely(test_bit(CSCHED_FLAG_VCPU_PINNED, &new->flags) && cpumask_test_cpu(cpu, &idle_mask)) ) { - ASSERT(cpumask_cycle(cpu, new->vcpu->cpu_hard_affinity) =3D=3D cpu= ); + ASSERT(cpumask_cycle(cpu, item->cpu_hard_affinity) =3D=3D cpu); SCHED_STAT_CRANK(tickled_idle_cpu_excl); __cpumask_set_cpu(cpu, &mask); goto tickle; @@ -410,11 +411,11 @@ static inline void __runq_tickle(struct csched_item *= new) int new_idlers_empty; =20 if ( balance_step =3D=3D BALANCE_SOFT_AFFINITY - && !has_soft_affinity(new->vcpu) ) + && !has_soft_affinity(item) ) continue; =20 /* Are there idlers suitable for new (for this balance step)? = */ - affinity_balance_cpumask(new->vcpu, balance_step, + affinity_balance_cpumask(item, balance_step, cpumask_scratch_cpu(cpu)); cpumask_and(cpumask_scratch_cpu(cpu), cpumask_scratch_cpu(cpu), &idle_mask); @@ -443,8 +444,7 @@ static inline void __runq_tickle(struct csched_item *ne= w) */ if ( new_idlers_empty && new->pri > cur->pri ) { - if ( cpumask_intersects(cur->vcpu->cpu_hard_affinity, - &idle_mask) ) + if ( cpumask_intersects(item->cpu_hard_affinity, &idle_mas= k) ) { SCHED_VCPU_STAT_CRANK(cur, kicked_away); SCHED_VCPU_STAT_CRANK(cur, migrate_r); @@ -704,7 +704,7 @@ static inline bool __csched_vcpu_is_cache_hot(const struct csched_private *prv, struct vcpu *= v) { bool hot =3D prv->vcpu_migr_delay && - (NOW() - v->last_run_time) < prv->vcpu_migr_delay; + (NOW() - v->sched_item->last_run_time) < prv->vcpu_migr_del= ay; =20 if ( hot ) SCHED_STAT_CRANK(vcpu_hot); @@ -742,7 +742,7 @@ _csched_cpu_pick(const struct scheduler *ops, struct vc= pu *vc, bool_t commit) =20 for_each_affinity_balance_step( balance_step ) { - affinity_balance_cpumask(vc, balance_step, cpus); + affinity_balance_cpumask(vc->sched_item, balance_step, cpus); cpumask_and(cpus, online, cpus); /* * We want to pick up a pcpu among the ones that are online and @@ -761,7 +761,7 @@ _csched_cpu_pick(const struct scheduler *ops, struct vc= pu *vc, bool_t commit) * balancing step all together. */ if ( balance_step =3D=3D BALANCE_SOFT_AFFINITY && - (!has_soft_affinity(vc) || cpumask_empty(cpus)) ) + (!has_soft_affinity(vc->sched_item) || cpumask_empty(cpus)) ) continue; =20 /* If present, prefer vc's current processor */ @@ -1660,10 +1660,10 @@ csched_runq_steal(int peer_cpu, int cpu, int pri, i= nt balance_step) * or counter. */ if ( vc->is_running || (balance_step =3D=3D BALANCE_SOFT_AFFINITY = && - !has_soft_affinity(vc)) ) + !has_soft_affinity(vc->sched_item)) ) continue; =20 - affinity_balance_cpumask(vc, balance_step, cpumask_scratch); + affinity_balance_cpumask(vc->sched_item, balance_step, cpumask_scr= atch); if ( __csched_vcpu_is_migrateable(prv, vc, cpu, cpumask_scratch) ) { /* We got a candidate. Grab it! */ diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index 6106293b3f..5c1794db61 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -699,10 +699,10 @@ static int get_fallback_cpu(struct csched2_item *svc) { int cpu =3D v->processor; =20 - if ( bs =3D=3D BALANCE_SOFT_AFFINITY && !has_soft_affinity(v) ) + if ( bs =3D=3D BALANCE_SOFT_AFFINITY && !has_soft_affinity(v->sche= d_item) ) continue; =20 - affinity_balance_cpumask(v, bs, cpumask_scratch_cpu(cpu)); + affinity_balance_cpumask(v->sched_item, bs, cpumask_scratch_cpu(cp= u)); cpumask_and(cpumask_scratch_cpu(cpu), cpumask_scratch_cpu(cpu), cpupool_domain_cpumask(v->domain)); =20 @@ -1390,10 +1390,10 @@ static s_time_t tickle_score(const struct scheduler= *ops, s_time_t now, */ if ( score > 0 ) { - if ( cpumask_test_cpu(cpu, new->vcpu->cpu_soft_affinity) ) + if ( cpumask_test_cpu(cpu, new->vcpu->sched_item->cpu_soft_affinit= y) ) score +=3D CSCHED2_CREDIT_INIT; =20 - if ( !cpumask_test_cpu(cpu, cur->vcpu->cpu_soft_affinity) ) + if ( !cpumask_test_cpu(cpu, cur->vcpu->sched_item->cpu_soft_affini= ty) ) score +=3D CSCHED2_CREDIT_INIT; } =20 @@ -1436,6 +1436,7 @@ runq_tickle(const struct scheduler *ops, struct csche= d2_item *new, s_time_t now) { int i, ipid =3D -1; s_time_t max =3D 0; + struct sched_item *item =3D new->vcpu->sched_item; unsigned int bs, cpu =3D new->vcpu->processor; struct csched2_runqueue_data *rqd =3D c2rqd(ops, cpu); cpumask_t *online =3D cpupool_domain_cpumask(new->vcpu->domain); @@ -1473,7 +1474,7 @@ runq_tickle(const struct scheduler *ops, struct csche= d2_item *new, s_time_t now) cpumask_test_cpu(cpu, &rqd->idle) && !cpumask_test_cpu(cpu, &rqd->tickled)) ) { - ASSERT(cpumask_cycle(cpu, new->vcpu->cpu_hard_affinity) =3D=3D cpu= ); + ASSERT(cpumask_cycle(cpu, item->cpu_hard_affinity) =3D=3D cpu); SCHED_STAT_CRANK(tickled_idle_cpu_excl); ipid =3D cpu; goto tickle; @@ -1482,10 +1483,10 @@ runq_tickle(const struct scheduler *ops, struct csc= hed2_item *new, s_time_t now) for_each_affinity_balance_step( bs ) { /* Just skip first step, if we don't have a soft affinity */ - if ( bs =3D=3D BALANCE_SOFT_AFFINITY && !has_soft_affinity(new->vc= pu) ) + if ( bs =3D=3D BALANCE_SOFT_AFFINITY && !has_soft_affinity(item) ) continue; =20 - affinity_balance_cpumask(new->vcpu, bs, cpumask_scratch_cpu(cpu)); + affinity_balance_cpumask(item, bs, cpumask_scratch_cpu(cpu)); =20 /* * First of all, consider idle cpus, checking if we can just @@ -1557,7 +1558,7 @@ runq_tickle(const struct scheduler *ops, struct csche= d2_item *new, s_time_t now) ipid =3D cpu; =20 /* If this is in new's soft affinity, just take it */ - if ( cpumask_test_cpu(cpu, new->vcpu->cpu_soft_affinity) ) + if ( cpumask_test_cpu(cpu, item->cpu_soft_affinity) ) { SCHED_STAT_CRANK(tickled_busy_cpu); goto tickle; @@ -2243,7 +2244,7 @@ csched2_res_pick(const struct scheduler *ops, struct = sched_item *item) goto out; } =20 - cpumask_and(cpumask_scratch_cpu(cpu), vc->cpu_hard_affinity, + cpumask_and(cpumask_scratch_cpu(cpu), item->cpu_hard_affinity, cpupool_domain_cpumask(vc->domain)); =20 /* @@ -2288,7 +2289,7 @@ csched2_res_pick(const struct scheduler *ops, struct = sched_item *item) * * Find both runqueues in one pass. */ - has_soft =3D has_soft_affinity(vc); + has_soft =3D has_soft_affinity(item); for_each_cpu(i, &prv->active_queues) { struct csched2_runqueue_data *rqd; @@ -2335,7 +2336,7 @@ csched2_res_pick(const struct scheduler *ops, struct = sched_item *item) cpumask_t mask; =20 cpumask_and(&mask, cpumask_scratch_cpu(cpu), &rqd->active); - if ( cpumask_intersects(&mask, svc->vcpu->cpu_soft_affinity) ) + if ( cpumask_intersects(&mask, item->cpu_soft_affinity) ) { min_s_avgload =3D rqd_avgload; min_s_rqi =3D i; @@ -2357,9 +2358,9 @@ csched2_res_pick(const struct scheduler *ops, struct = sched_item *item) * Note that, to obtain the soft-affinity mask, we "just" put what= we * have in cpumask_scratch in && with vc->cpu_soft_affinity. This = is * ok because: - * - we know that vc->cpu_hard_affinity and vc->cpu_soft_affinity = have + * - we know that item->cpu_hard_affinity and ->cpu_soft_affinity = have * a non-empty intersection (because has_soft is true); - * - we have vc->cpu_hard_affinity & cpupool_domain_cpumask() alre= ady + * - we have item->cpu_hard_affinity & cpupool_domain_cpumask() al= ready * in cpumask_scratch, we do save a lot doing like this. * * It's kind of like open coding affinity_balance_cpumask() but, in @@ -2367,7 +2368,7 @@ csched2_res_pick(const struct scheduler *ops, struct = sched_item *item) * cpumask operations. */ cpumask_and(cpumask_scratch_cpu(cpu), cpumask_scratch_cpu(cpu), - vc->cpu_soft_affinity); + item->cpu_soft_affinity); cpumask_and(cpumask_scratch_cpu(cpu), cpumask_scratch_cpu(cpu), &prv->rqd[min_s_rqi].active); } @@ -2475,6 +2476,7 @@ static void migrate(const struct scheduler *ops, s_time_t now) { int cpu =3D svc->vcpu->processor; + struct sched_item *item =3D svc->vcpu->sched_item; =20 if ( unlikely(tb_init_done) ) { @@ -2512,7 +2514,7 @@ static void migrate(const struct scheduler *ops, } _runq_deassign(svc); =20 - cpumask_and(cpumask_scratch_cpu(cpu), svc->vcpu->cpu_hard_affinity, + cpumask_and(cpumask_scratch_cpu(cpu), item->cpu_hard_affinity, cpupool_domain_cpumask(svc->vcpu->domain)); cpumask_and(cpumask_scratch_cpu(cpu), cpumask_scratch_cpu(cpu), &trqd->active); @@ -2546,7 +2548,7 @@ static bool vcpu_is_migrateable(struct csched2_item *= svc, struct vcpu *v =3D svc->vcpu; int cpu =3D svc->vcpu->processor; =20 - cpumask_and(cpumask_scratch_cpu(cpu), v->cpu_hard_affinity, + cpumask_and(cpumask_scratch_cpu(cpu), v->sched_item->cpu_hard_affinity, cpupool_domain_cpumask(v->domain)); =20 return !(svc->flags & CSFLAG_runq_migrate_request) && @@ -2780,7 +2782,7 @@ csched2_item_migrate( =20 /* If here, new_cpu must be a valid Credit2 pCPU, and in our affinity.= */ ASSERT(cpumask_test_cpu(new_cpu, &csched2_priv(ops)->initialized)); - ASSERT(cpumask_test_cpu(new_cpu, vc->cpu_hard_affinity)); + ASSERT(cpumask_test_cpu(new_cpu, item->cpu_hard_affinity)); =20 trqd =3D c2rqd(ops, new_cpu); =20 @@ -3320,9 +3322,9 @@ runq_candidate(struct csched2_runqueue_data *rqd, } =20 /* If scurr has a soft-affinity, let's check whether cpu is part of it= */ - if ( has_soft_affinity(scurr->vcpu) ) + if ( has_soft_affinity(scurr->vcpu->sched_item) ) { - affinity_balance_cpumask(scurr->vcpu, BALANCE_SOFT_AFFINITY, + affinity_balance_cpumask(scurr->vcpu->sched_item, BALANCE_SOFT_AFF= INITY, cpumask_scratch); if ( unlikely(!cpumask_test_cpu(cpu, cpumask_scratch)) ) { @@ -3377,7 +3379,7 @@ runq_candidate(struct csched2_runqueue_data *rqd, } =20 /* Only consider vcpus that are allowed to run on this processor. = */ - if ( !cpumask_test_cpu(cpu, svc->vcpu->cpu_hard_affinity) ) + if ( !cpumask_test_cpu(cpu, svc->vcpu->sched_item->cpu_hard_affini= ty) ) { (*skipped)++; continue; diff --git a/xen/common/sched_null.c b/xen/common/sched_null.c index 620925e8ce..c45af9f8ee 100644 --- a/xen/common/sched_null.c +++ b/xen/common/sched_null.c @@ -123,7 +123,8 @@ static inline struct null_item *null_item(const struct = sched_item *item) static inline bool vcpu_check_affinity(struct vcpu *v, unsigned int cpu, unsigned int balance_step) { - affinity_balance_cpumask(v, balance_step, cpumask_scratch_cpu(cpu)); + affinity_balance_cpumask(v->sched_item, balance_step, + cpumask_scratch_cpu(cpu)); cpumask_and(cpumask_scratch_cpu(cpu), cpumask_scratch_cpu(cpu), cpupool_domain_cpumask(v->domain)); =20 @@ -281,10 +282,10 @@ pick_res(struct null_private *prv, struct sched_item = *item) =20 for_each_affinity_balance_step( bs ) { - if ( bs =3D=3D BALANCE_SOFT_AFFINITY && !has_soft_affinity(v) ) + if ( bs =3D=3D BALANCE_SOFT_AFFINITY && !has_soft_affinity(item) ) continue; =20 - affinity_balance_cpumask(v, bs, cpumask_scratch_cpu(cpu)); + affinity_balance_cpumask(item, bs, cpumask_scratch_cpu(cpu)); cpumask_and(cpumask_scratch_cpu(cpu), cpumask_scratch_cpu(cpu), cp= us); =20 /* @@ -321,7 +322,7 @@ pick_res(struct null_private *prv, struct sched_item *i= tem) * as we will actually assign the vCPU to the pCPU we return from here, * only if the pCPU is free. */ - cpumask_and(cpumask_scratch_cpu(cpu), cpus, v->cpu_hard_affinity); + cpumask_and(cpumask_scratch_cpu(cpu), cpus, item->cpu_hard_affinity); new_cpu =3D cpumask_any(cpumask_scratch_cpu(cpu)); =20 out: @@ -438,7 +439,7 @@ static void null_item_insert(const struct scheduler *op= s, =20 lock =3D item_schedule_lock(item); =20 - cpumask_and(cpumask_scratch_cpu(cpu), v->cpu_hard_affinity, + cpumask_and(cpumask_scratch_cpu(cpu), item->cpu_hard_affinity, cpupool_domain_cpumask(v->domain)); =20 /* If the pCPU is free, we assign v to it */ @@ -496,7 +497,8 @@ static void _vcpu_remove(struct null_private *prv, stru= ct vcpu *v) { list_for_each_entry( wvc, &prv->waitq, waitq_elem ) { - if ( bs =3D=3D BALANCE_SOFT_AFFINITY && !has_soft_affinity(wvc= ->vcpu) ) + if ( bs =3D=3D BALANCE_SOFT_AFFINITY && + !has_soft_affinity(wvc->vcpu->sched_item) ) continue; =20 if ( vcpu_check_affinity(wvc->vcpu, cpu, bs) ) @@ -775,7 +777,7 @@ static struct task_slice null_schedule(const struct sch= eduler *ops, list_for_each_entry( wvc, &prv->waitq, waitq_elem ) { if ( bs =3D=3D BALANCE_SOFT_AFFINITY && - !has_soft_affinity(wvc->vcpu) ) + !has_soft_affinity(wvc->vcpu->sched_item) ) continue; =20 if ( vcpu_check_affinity(wvc->vcpu, cpu, bs) ) diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index a604a0d5a6..58560d086b 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -327,7 +327,7 @@ rt_dump_vcpu(const struct scheduler *ops, const struct = rt_item *svc) mask =3D cpumask_scratch_cpu(svc->vcpu->processor); =20 cpupool_mask =3D cpupool_domain_cpumask(svc->vcpu->domain); - cpumask_and(mask, cpupool_mask, svc->vcpu->cpu_hard_affinity); + cpumask_and(mask, cpupool_mask, svc->vcpu->sched_item->cpu_hard_affini= ty); printk("[%5d.%-2u] cpu %u, (%"PRI_stime", %"PRI_stime")," " cur_b=3D%"PRI_stime" cur_d=3D%"PRI_stime" last_start=3D%"PRI_= stime"\n" " \t\t priority_level=3D%d has_extratime=3D%d\n" @@ -645,7 +645,7 @@ rt_res_pick(const struct scheduler *ops, struct sched_i= tem *item) int cpu; =20 online =3D cpupool_domain_cpumask(vc->domain); - cpumask_and(&cpus, online, vc->cpu_hard_affinity); + cpumask_and(&cpus, online, item->cpu_hard_affinity); =20 cpu =3D cpumask_test_cpu(vc->processor, &cpus) ? vc->processor @@ -1030,7 +1030,8 @@ runq_pick(const struct scheduler *ops, const cpumask_= t *mask) =20 /* mask cpu_hard_affinity & cpupool & mask */ online =3D cpupool_domain_cpumask(iter_svc->vcpu->domain); - cpumask_and(&cpu_common, online, iter_svc->vcpu->cpu_hard_affinity= ); + cpumask_and(&cpu_common, online, + iter_svc->vcpu->sched_item->cpu_hard_affinity); cpumask_and(&cpu_common, mask, &cpu_common); if ( cpumask_empty(&cpu_common) ) continue; @@ -1199,7 +1200,7 @@ runq_tickle(const struct scheduler *ops, struct rt_it= em *new) return; =20 online =3D cpupool_domain_cpumask(new->vcpu->domain); - cpumask_and(¬_tickled, online, new->vcpu->cpu_hard_affinity); + cpumask_and(¬_tickled, online, new->vcpu->sched_item->cpu_hard_affi= nity); cpumask_andnot(¬_tickled, ¬_tickled, &prv->tickled); =20 /* diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 464e358f70..f4850a57f6 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -270,6 +270,12 @@ static void sched_free_item(struct sched_item *item) } =20 item->vcpu->sched_item =3D NULL; + + free_cpumask_var(item->cpu_hard_affinity); + free_cpumask_var(item->cpu_hard_affinity_tmp); + free_cpumask_var(item->cpu_hard_affinity_saved); + free_cpumask_var(item->cpu_soft_affinity); + xfree(item); } =20 @@ -293,7 +299,17 @@ static struct sched_item *sched_alloc_item(struct vcpu= *v) item->next_in_list =3D *prev_item; *prev_item =3D item; =20 + if ( !zalloc_cpumask_var(&item->cpu_hard_affinity) || + !zalloc_cpumask_var(&item->cpu_hard_affinity_tmp) || + !zalloc_cpumask_var(&item->cpu_hard_affinity_saved) || + !zalloc_cpumask_var(&item->cpu_soft_affinity) ) + goto fail; + return item; + + fail: + sched_free_item(item); + return NULL; } =20 int sched_init_vcpu(struct vcpu *v, unsigned int processor) @@ -363,7 +379,7 @@ int sched_move_domain(struct domain *d, struct cpupool = *c) =20 for_each_vcpu ( d, v ) { - if ( v->affinity_broken ) + if ( v->sched_item->affinity_broken ) return -EBUSY; } =20 @@ -682,7 +698,7 @@ static void vcpu_migrate_finish(struct vcpu *v) */ if ( pick_called && (new_lock =3D=3D per_cpu(sched_res, new_cpu)->schedule_lo= ck) && - cpumask_test_cpu(new_cpu, v->cpu_hard_affinity) && + cpumask_test_cpu(new_cpu, v->sched_item->cpu_hard_affinit= y) && cpumask_test_cpu(new_cpu, v->domain->cpupool->cpu_valid) ) break; =20 @@ -758,6 +774,7 @@ void restore_vcpu_affinity(struct domain *d) { spinlock_t *lock; unsigned int old_cpu =3D v->processor; + struct sched_item *item =3D v->sched_item; =20 ASSERT(!vcpu_runnable(v)); =20 @@ -769,15 +786,15 @@ void restore_vcpu_affinity(struct domain *d) * set v->processor of each of their vCPUs to something that will * make sense for the scheduler of the cpupool in which they are i= n. */ - cpumask_and(cpumask_scratch_cpu(cpu), v->cpu_hard_affinity, + cpumask_and(cpumask_scratch_cpu(cpu), item->cpu_hard_affinity, cpupool_domain_cpumask(d)); if ( cpumask_empty(cpumask_scratch_cpu(cpu)) ) { - if ( v->affinity_broken ) + if ( item->affinity_broken ) { - sched_set_affinity(v, v->cpu_hard_affinity_saved, NULL); - v->affinity_broken =3D 0; - cpumask_and(cpumask_scratch_cpu(cpu), v->cpu_hard_affinity, + sched_set_affinity(v, item->cpu_hard_affinity_saved, NULL); + item->affinity_broken =3D 0; + cpumask_and(cpumask_scratch_cpu(cpu), item->cpu_hard_affin= ity, cpupool_domain_cpumask(d)); } =20 @@ -785,18 +802,17 @@ void restore_vcpu_affinity(struct domain *d) { printk(XENLOG_DEBUG "Breaking affinity for %pv\n", v); sched_set_affinity(v, &cpumask_all, NULL); - cpumask_and(cpumask_scratch_cpu(cpu), v->cpu_hard_affinity, + cpumask_and(cpumask_scratch_cpu(cpu), item->cpu_hard_affin= ity, cpupool_domain_cpumask(d)); } } =20 v->processor =3D cpumask_any(cpumask_scratch_cpu(cpu)); - v->sched_item->res =3D per_cpu(sched_res, v->processor); + item->res =3D per_cpu(sched_res, v->processor); =20 - lock =3D item_schedule_lock_irq(v->sched_item); - v->sched_item->res =3D sched_pick_resource(vcpu_scheduler(v), - v->sched_item); - v->processor =3D v->sched_item->res->processor; + lock =3D item_schedule_lock_irq(item); + item->res =3D sched_pick_resource(vcpu_scheduler(v), item); + v->processor =3D item->res->processor; spin_unlock_irq(lock); =20 if ( old_cpu !=3D v->processor ) @@ -828,16 +844,17 @@ int cpu_disable_scheduler(unsigned int cpu) for_each_vcpu ( d, v ) { unsigned long flags; - spinlock_t *lock =3D item_schedule_lock_irqsave(v->sched_item,= &flags); + struct sched_item *item =3D v->sched_item; + spinlock_t *lock =3D item_schedule_lock_irqsave(item, &flags); =20 - cpumask_and(&online_affinity, v->cpu_hard_affinity, c->cpu_val= id); + cpumask_and(&online_affinity, item->cpu_hard_affinity, c->cpu_= valid); if ( cpumask_empty(&online_affinity) && - cpumask_test_cpu(cpu, v->cpu_hard_affinity) ) + cpumask_test_cpu(cpu, item->cpu_hard_affinity) ) { - if ( v->affinity_broken ) + if ( item->affinity_broken ) { /* The vcpu is temporarily pinned, can't move it. */ - item_schedule_unlock_irqrestore(lock, flags, v->sched_= item); + item_schedule_unlock_irqrestore(lock, flags, item); ret =3D -EADDRINUSE; break; } @@ -850,7 +867,7 @@ int cpu_disable_scheduler(unsigned int cpu) if ( v->processor !=3D cpu ) { /* The vcpu is not on this cpu, so we can move on. */ - item_schedule_unlock_irqrestore(lock, flags, v->sched_item= ); + item_schedule_unlock_irqrestore(lock, flags, item); continue; } =20 @@ -863,7 +880,7 @@ int cpu_disable_scheduler(unsigned int cpu) * things would have failed before getting in here. */ vcpu_migrate_start(v); - item_schedule_unlock_irqrestore(lock, flags, v->sched_item); + item_schedule_unlock_irqrestore(lock, flags, item); =20 vcpu_migrate_finish(v); =20 @@ -892,7 +909,7 @@ static int cpu_disable_scheduler_check(unsigned int cpu) =20 for_each_domain_in_cpupool ( d, c ) for_each_vcpu ( d, v ) - if ( v->affinity_broken ) + if ( v->sched_item->affinity_broken ) return -EADDRINUSE; =20 return 0; @@ -908,28 +925,31 @@ static int cpu_disable_scheduler_check(unsigned int c= pu) void sched_set_affinity( struct vcpu *v, const cpumask_t *hard, const cpumask_t *soft) { - sched_adjust_affinity(dom_scheduler(v->domain), v->sched_item, hard, s= oft); + struct sched_item *item =3D v->sched_item; + + sched_adjust_affinity(dom_scheduler(v->domain), item, hard, soft); =20 if ( hard ) - cpumask_copy(v->cpu_hard_affinity, hard); + cpumask_copy(item->cpu_hard_affinity, hard); if ( soft ) - cpumask_copy(v->cpu_soft_affinity, soft); + cpumask_copy(item->cpu_soft_affinity, soft); =20 - v->soft_aff_effective =3D !cpumask_subset(v->cpu_hard_affinity, - v->cpu_soft_affinity) && - cpumask_intersects(v->cpu_soft_affinity, - v->cpu_hard_affinity); + item->soft_aff_effective =3D !cpumask_subset(item->cpu_hard_affinity, + item->cpu_soft_affinity) && + cpumask_intersects(item->cpu_soft_affinity, + item->cpu_hard_affinity); } =20 static int vcpu_set_affinity( struct vcpu *v, const cpumask_t *affinity, const cpumask_t *which) { + struct sched_item *item =3D v->sched_item; spinlock_t *lock; int ret =3D 0; =20 - lock =3D item_schedule_lock_irq(v->sched_item); + lock =3D item_schedule_lock_irq(item); =20 - if ( v->affinity_broken ) + if ( item->affinity_broken ) ret =3D -EBUSY; else { @@ -937,19 +957,19 @@ static int vcpu_set_affinity( * Tell the scheduler we changes something about affinity, * and ask to re-evaluate vcpu placement. */ - if ( which =3D=3D v->cpu_hard_affinity ) + if ( which =3D=3D item->cpu_hard_affinity ) { sched_set_affinity(v, affinity, NULL); } else { - ASSERT(which =3D=3D v->cpu_soft_affinity); + ASSERT(which =3D=3D item->cpu_soft_affinity); sched_set_affinity(v, NULL, affinity); } vcpu_migrate_start(v); } =20 - item_schedule_unlock_irq(lock, v->sched_item); + item_schedule_unlock_irq(lock, item); =20 domain_update_node_affinity(v->domain); =20 @@ -968,12 +988,12 @@ int vcpu_set_hard_affinity(struct vcpu *v, const cpum= ask_t *affinity) if ( cpumask_empty(&online_affinity) ) return -EINVAL; =20 - return vcpu_set_affinity(v, affinity, v->cpu_hard_affinity); + return vcpu_set_affinity(v, affinity, v->sched_item->cpu_hard_affinity= ); } =20 int vcpu_set_soft_affinity(struct vcpu *v, const cpumask_t *affinity) { - return vcpu_set_affinity(v, affinity, v->cpu_soft_affinity); + return vcpu_set_affinity(v, affinity, v->sched_item->cpu_soft_affinity= ); } =20 /* Block the currently-executing domain until a pertinent event occurs. */ @@ -1167,28 +1187,30 @@ void watchdog_domain_destroy(struct domain *d) =20 int vcpu_pin_override(struct vcpu *v, int cpu) { + struct sched_item *item =3D v->sched_item; spinlock_t *lock; int ret =3D -EINVAL; =20 - lock =3D item_schedule_lock_irq(v->sched_item); + lock =3D item_schedule_lock_irq(item); =20 if ( cpu < 0 ) { - if ( v->affinity_broken ) + if ( item->affinity_broken ) { - sched_set_affinity(v, v->cpu_hard_affinity_saved, NULL); - v->affinity_broken =3D 0; + sched_set_affinity(v, item->cpu_hard_affinity_saved, NULL); + item->affinity_broken =3D 0; ret =3D 0; } } else if ( cpu < nr_cpu_ids ) { - if ( v->affinity_broken ) + if ( item->affinity_broken ) ret =3D -EBUSY; else if ( cpumask_test_cpu(cpu, VCPU2ONLINE(v)) ) { - cpumask_copy(v->cpu_hard_affinity_saved, v->cpu_hard_affinity); - v->affinity_broken =3D 1; + cpumask_copy(item->cpu_hard_affinity_saved, + item->cpu_hard_affinity); + item->affinity_broken =3D 1; sched_set_affinity(v, cpumask_of(cpu), NULL); ret =3D 0; } @@ -1197,7 +1219,7 @@ int vcpu_pin_override(struct vcpu *v, int cpu) if ( ret =3D=3D 0 ) vcpu_migrate_start(v); =20 - item_schedule_unlock_irq(lock, v->sched_item); + item_schedule_unlock_irq(lock, item); =20 domain_update_node_affinity(v->domain); =20 @@ -1549,7 +1571,7 @@ static void schedule(void) ((prev->pause_flags & VPF_blocked) ? RUNSTATE_blocked : (vcpu_runnable(prev) ? RUNSTATE_runnable : RUNSTATE_offline)), now); - prev->last_run_time =3D now; + prev->sched_item->last_run_time =3D now; =20 ASSERT(next->runstate.state !=3D RUNSTATE_running); vcpu_runstate_change(next, RUNSTATE_running, now); diff --git a/xen/common/wait.c b/xen/common/wait.c index 4f830a14e8..47f17928c4 100644 --- a/xen/common/wait.c +++ b/xen/common/wait.c @@ -132,7 +132,7 @@ static void __prepare_to_wait(struct waitqueue_vcpu *wq= v) =20 /* Save current VCPU affinity; force wakeup on *this* CPU only. */ wqv->wakeup_cpu =3D smp_processor_id(); - cpumask_copy(&wqv->saved_affinity, curr->cpu_hard_affinity); + cpumask_copy(&wqv->saved_affinity, curr->sched_item->cpu_hard_affinity= ); if ( vcpu_set_hard_affinity(curr, cpumask_of(wqv->wakeup_cpu)) ) { gdprintk(XENLOG_ERR, "Unable to set vcpu affinity\n"); @@ -199,7 +199,7 @@ void check_wakeup_from_wait(void) { /* Re-set VCPU affinity and re-enter the scheduler. */ struct vcpu *curr =3D current; - cpumask_copy(&wqv->saved_affinity, curr->cpu_hard_affinity); + cpumask_copy(&wqv->saved_affinity, curr->sched_item->cpu_hard_affi= nity); if ( vcpu_set_hard_affinity(curr, cpumask_of(wqv->wakeup_cpu)) ) { gdprintk(XENLOG_ERR, "Unable to set vcpu affinity\n"); diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index 17f1ee8887..5e024dceb0 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -463,11 +463,11 @@ static inline cpumask_t* cpupool_domain_cpumask(struc= t domain *d) * * The hard affinity is not a subset of soft affinity * * There is an overlap between the soft and hard affinity masks */ -static inline int has_soft_affinity(const struct vcpu *v) +static inline int has_soft_affinity(const struct sched_item *item) { - return v->soft_aff_effective && - !cpumask_subset(cpupool_domain_cpumask(v->domain), - v->cpu_soft_affinity); + return item->soft_aff_effective && + !cpumask_subset(cpupool_domain_cpumask(item->vcpu->domain), + item->cpu_soft_affinity); } =20 /* @@ -477,17 +477,18 @@ static inline int has_soft_affinity(const struct vcpu= *v) * to avoid running a vcpu where it would like, but is not allowed to! */ static inline void -affinity_balance_cpumask(const struct vcpu *v, int step, cpumask_t *mask) +affinity_balance_cpumask(const struct sched_item *item, int step, + cpumask_t *mask) { if ( step =3D=3D BALANCE_SOFT_AFFINITY ) { - cpumask_and(mask, v->cpu_soft_affinity, v->cpu_hard_affinity); + cpumask_and(mask, item->cpu_soft_affinity, item->cpu_hard_affinity= ); =20 if ( unlikely(cpumask_empty(mask)) ) - cpumask_copy(mask, v->cpu_hard_affinity); + cpumask_copy(mask, item->cpu_hard_affinity); } else /* step =3D=3D BALANCE_HARD_AFFINITY */ - cpumask_copy(mask, v->cpu_hard_affinity); + cpumask_copy(mask, item->cpu_hard_affinity); } =20 #endif /* __XEN_SCHED_IF_H__ */ diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index aa4ff25f76..b43f5f3662 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -175,9 +175,6 @@ struct vcpu } runstate_guest; /* guest address */ #endif =20 - /* last time when vCPU is scheduled out */ - uint64_t last_run_time; - /* Has the FPU been initialised? */ bool fpu_initialised; /* Has the FPU been used since it was last saved? */ @@ -203,8 +200,6 @@ struct vcpu bool defer_shutdown; /* VCPU is paused following shutdown request (d->is_shutting_down)? */ bool paused_for_shutdown; - /* VCPU need affinity restored */ - bool affinity_broken; =20 /* A hypercall has been preempted. */ bool hcall_preempted; @@ -213,9 +208,6 @@ struct vcpu bool hcall_compat; #endif =20 - /* Does soft affinity actually play a role (given hard affinity)? */ - bool soft_aff_effective; - /* The CPU, if any, which is holding onto this VCPU's state. */ #define VCPU_CPU_CLEAN (~0u) unsigned int dirty_cpu; @@ -247,16 +239,6 @@ struct vcpu evtchn_port_t virq_to_evtchn[NR_VIRQS]; spinlock_t virq_lock; =20 - /* Bitmask of CPUs on which this VCPU may run. */ - cpumask_var_t cpu_hard_affinity; - /* Used to change affinity temporarily. */ - cpumask_var_t cpu_hard_affinity_tmp; - /* Used to restore affinity across S3. */ - cpumask_var_t cpu_hard_affinity_saved; - - /* Bitmask of CPUs on which this VCPU prefers to run. */ - cpumask_var_t cpu_soft_affinity; - /* Tasklet for continue_hypercall_on_cpu(). */ struct tasklet continue_hypercall_tasklet; =20 @@ -283,6 +265,22 @@ struct sched_item { void *priv; /* scheduler private data */ struct sched_item *next_in_list; struct sched_resource *res; + + /* Last time when item has been scheduled out. */ + uint64_t last_run_time; + + /* Item needs affinity restored. */ + bool affinity_broken; + /* Does soft affinity actually play a role (given hard affinity)? */ + bool soft_aff_effective; + /* Bitmask of CPUs on which this VCPU may run. */ + cpumask_var_t cpu_hard_affinity; + /* Used to change affinity temporarily. */ + cpumask_var_t cpu_hard_affinity_tmp; + /* Used to restore affinity across S3. */ + cpumask_var_t cpu_hard_affinity_saved; + /* Bitmask of CPUs on which this VCPU prefers to run. */ + cpumask_var_t cpu_soft_affinity; }; =20 #define for_each_sched_item(d, e) \ @@ -982,7 +980,7 @@ static inline bool is_hvm_vcpu(const struct vcpu *v) static inline bool is_hwdom_pinned_vcpu(const struct vcpu *v) { return (is_hardware_domain(v->domain) && - cpumask_weight(v->cpu_hard_affinity) =3D=3D 1); + cpumask_weight(v->sched_item->cpu_hard_affinity) =3D=3D 1); } =20 #ifdef CONFIG_HAS_PASSTHROUGH --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125920; cv=none; d=zoho.com; s=zohoarc; b=kDRSl6TdMYFnpx3DcGmeQievzE7AJ0oIdtWXtwMZiixtbOgOLnzN4rvzUlrknbowdDZrfKxc+G4aMszYTzvHfF0u/5srnC2jGAv27ObTi6fR0L3hwEbc164VT3QmD2NqI66ge7lfuI5b5ebo0dHZ3b5ZNdRCVLlJySDMMaDdNS0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125920; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=peGIkkJen5QtRlVTL8QSRxHjQtfJxe5wXhL6tgaEytw=; b=k5q5VmTperCor7NQvIORkVwzimewdJhA5QdExAP8zlkWdF7M04znktcOiMfffR+I89sfgyh2t9o5dT5RabEvmc8dEDJU+eSzdICTmiiN1UQClFZXAjOtMsLGMXodV9sQ9Gnp2iSf5tUDcwxN+detZXQDeKoufg0M+8v7UlV8v+k= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125920317332.61920337980916; Sun, 5 May 2019 23:58:40 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYZ-0001uY-7H; Mon, 06 May 2019 06:56:59 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYX-0001tL-9b for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:56:57 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 220b4e55-6fcc-11e9-843c-bc764e045a96; Mon, 06 May 2019 06:56:55 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 1DBB7AEF7; Mon, 6 May 2019 06:56:52 +0000 (UTC) X-Inumbo-ID: 220b4e55-6fcc-11e9-843c-bc764e045a96 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:11 +0200 Message-Id: <20190506065644.7415-13-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 12/45] xen/sched: add scheduler helpers hiding vcpu X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Tim Deegan , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Dario Faggioli , Julien Grall , Jan Beulich MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Add the following helpers using a sched_item as input instead of a vcpu: - is_idle_item() similar to is_idle_vcpu() - item_runnable() like vcpu_runnable() - sched_set_res() to set the current processor of an item - sched_item_cpu() to get the current processor of an item - sched_{set|clear}_pause_flags[_atomic]() to modify pause_flags of the associated vcpu(s) - sched_idle_item() to get the sched_item pointer of the idle vcpu of a specific physical cpu Signed-off-by: Juergen Gross --- xen/common/sched_credit.c | 3 +-- xen/common/schedule.c | 19 ++++++++-------- xen/include/xen/sched-if.h | 56 ++++++++++++++++++++++++++++++++++++++++++= ---- 3 files changed, 62 insertions(+), 16 deletions(-) diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index 9e7c849b94..8cfe54ec36 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -1673,8 +1673,7 @@ csched_runq_steal(int peer_cpu, int cpu, int pri, int= balance_step) SCHED_STAT_CRANK(migrate_queued); WARN_ON(vc->is_urgent); runq_remove(speer); - vc->processor =3D cpu; - vc->sched_item->res =3D per_cpu(sched_res, cpu); + sched_set_res(vc->sched_item, per_cpu(sched_res, cpu)); /* * speer will start executing directly on cpu, without having = to * go through runq_insert(). So we must update the runnable co= unt diff --git a/xen/common/schedule.c b/xen/common/schedule.c index f4850a57f6..d56dc567ac 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -317,12 +317,11 @@ int sched_init_vcpu(struct vcpu *v, unsigned int proc= essor) struct domain *d =3D v->domain; struct sched_item *item; =20 - v->processor =3D processor; - if ( (item =3D sched_alloc_item(v)) =3D=3D NULL ) return 1; =20 - item->res =3D per_cpu(sched_res, processor); + sched_set_res(item, per_cpu(sched_res, processor)); + /* Initialise the per-vcpu timers. */ init_timer(&v->periodic_timer, vcpu_periodic_timer_fn, v, v->processor); @@ -436,8 +435,7 @@ int sched_move_domain(struct domain *d, struct cpupool = *c) =20 sched_set_affinity(v, &cpumask_all, &cpumask_all); =20 - v->processor =3D new_p; - v->sched_item->res =3D per_cpu(sched_res, new_p); + sched_set_res(v->sched_item, per_cpu(sched_res, new_p)); /* * With v->processor modified we must not * - make any further changes assuming we hold the scheduler lock, @@ -775,8 +773,9 @@ void restore_vcpu_affinity(struct domain *d) spinlock_t *lock; unsigned int old_cpu =3D v->processor; struct sched_item *item =3D v->sched_item; + struct sched_resource *res; =20 - ASSERT(!vcpu_runnable(v)); + ASSERT(!item_runnable(item)); =20 /* * Re-assign the initial processor as after resume we have no @@ -807,12 +806,12 @@ void restore_vcpu_affinity(struct domain *d) } } =20 - v->processor =3D cpumask_any(cpumask_scratch_cpu(cpu)); - item->res =3D per_cpu(sched_res, v->processor); + res =3D per_cpu(sched_res, cpumask_any(cpumask_scratch_cpu(cpu))); + sched_set_res(item, res); =20 lock =3D item_schedule_lock_irq(item); - item->res =3D sched_pick_resource(vcpu_scheduler(v), item); - v->processor =3D item->res->processor; + res =3D sched_pick_resource(vcpu_scheduler(v), item); + sched_set_res(item, res); spin_unlock_irq(lock); =20 if ( old_cpu !=3D v->processor ) diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index 5e024dceb0..51c3477580 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -49,6 +49,57 @@ DECLARE_PER_CPU(struct scheduler *, scheduler); DECLARE_PER_CPU(struct cpupool *, cpupool); DECLARE_PER_CPU(struct sched_resource *, sched_res); =20 +static inline bool is_idle_item(const struct sched_item *item) +{ + return is_idle_vcpu(item->vcpu); +} + +static inline bool item_runnable(const struct sched_item *item) +{ + return vcpu_runnable(item->vcpu); +} + +static inline void sched_set_res(struct sched_item *item, + struct sched_resource *res) +{ + item->vcpu->processor =3D res->processor; + item->res =3D res; +} + +static inline unsigned int sched_item_cpu(struct sched_item *item) +{ + return item->res->processor; +} + +static inline void sched_set_pause_flags(struct sched_item *item, + unsigned int bit) +{ + __set_bit(bit, &item->vcpu->pause_flags); +} + +static inline void sched_clear_pause_flags(struct sched_item *item, + unsigned int bit) +{ + __clear_bit(bit, &item->vcpu->pause_flags); +} + +static inline void sched_set_pause_flags_atomic(struct sched_item *item, + unsigned int bit) +{ + set_bit(bit, &item->vcpu->pause_flags); +} + +static inline void sched_clear_pause_flags_atomic(struct sched_item *item, + unsigned int bit) +{ + clear_bit(bit, &item->vcpu->pause_flags); +} + +static inline struct sched_item *sched_idle_item(unsigned int cpu) +{ + return idle_vcpu[cpu]->sched_item; +} + /* * Scratch space, for avoiding having too many cpumask_t on the stack. * Within each scheduler, when using the scratch mask of one pCPU: @@ -363,10 +414,7 @@ static inline void sched_migrate(const struct schedule= r *s, if ( s->migrate ) s->migrate(s, item, cpu); else - { - item->vcpu->processor =3D cpu; - item->res =3D per_cpu(sched_res, cpu); - } + sched_set_res(item, per_cpu(sched_res, cpu)); } =20 static inline struct sched_resource *sched_pick_resource( --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125910; cv=none; d=zoho.com; s=zohoarc; b=bFBiOFrihd1Frj26mHbIqLgUijdVbmQM+BcP7ty1YKbv3G9QnBC0I1wFNFsbBmZZSFJbHwgSxk1qX80A1puh2lJ3R2A/190ZMPJutyhHrKYUVLQLWfX3iDqNy98nKcMc39J6gRqEOfeuuVVUrZOsvGRBSfhaW5NRpg3vDLslWcU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125910; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=MTx4BhORLe9bNQGCGBL0xc6PxuuO3qlL1GCPJvajxEs=; b=nwwOrxidFcgUwyU8krWk2zruKT4oHGIlBXtN38GlIpeN/cw+LMurB9/v/34DiT/6skdYEeQ59lBYnOeePbygLkR8Wcp8eWi05LNewjJUJZR7pslPRReQbuNizx5GGVH3j2/NXIUKZhD1fBM3barwGVTE+6FjZYBBUx/o0XdJ2v4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125910434281.1016254537873; Sun, 5 May 2019 23:58:30 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYY-0001uR-Ui; Mon, 06 May 2019 06:56:58 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYX-0001tK-7o for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:56:57 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 2278dfa2-6fcc-11e9-843c-bc764e045a96; Mon, 06 May 2019 06:56:56 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 6B42BAEFE; Mon, 6 May 2019 06:56:52 +0000 (UTC) X-Inumbo-ID: 2278dfa2-6fcc-11e9-843c-bc764e045a96 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:12 +0200 Message-Id: <20190506065644.7415-14-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 13/45] xen/sched: add domain pointer to struct sched_item X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Tim Deegan , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Dario Faggioli , Julien Grall , Jan Beulich MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Add a pointer to the domain to struct sched_item in order to avoid having to dereference the vcpu pointer of struct sched_item to find the related domain. Signed-off-by: Juergen Gross --- xen/common/schedule.c | 3 ++- xen/include/xen/sched.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index d56dc567ac..53aac107e1 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -253,7 +253,7 @@ static void sched_spin_unlock_double(spinlock_t *lock1,= spinlock_t *lock2, static void sched_free_item(struct sched_item *item) { struct sched_item *prev_item; - struct domain *d =3D item->vcpu->domain; + struct domain *d =3D item->domain; =20 if ( d->sched_item_list =3D=3D item ) d->sched_item_list =3D item->next_in_list; @@ -289,6 +289,7 @@ static struct sched_item *sched_alloc_item(struct vcpu = *v) =20 v->sched_item =3D item; item->vcpu =3D v; + item->domain =3D d; =20 for ( prev_item =3D &d->sched_item_list; *prev_item; prev_item =3D &(*prev_item)->next_in_list ) diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index b43f5f3662..83d7646088 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -261,6 +261,7 @@ struct vcpu struct sched_resource; =20 struct sched_item { + struct domain *domain; struct vcpu *vcpu; void *priv; /* scheduler private data */ struct sched_item *next_in_list; --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125914; cv=none; d=zoho.com; s=zohoarc; b=U8JovGJ7geVMPz5CKtJonBHkfTiwzP2ZRYOf7v5xDgp87JhJ23i3P7eYu+6kK3lMULw9WqnUwLgYZ0SmUkxSKU/b5RFYnKe8vXo/xiW1AG2EIrUXZRd2bdqM8KrYdVZelHwr5yUDCRNoVWdH8wiAPuHuC10CuOUQ6tux+FGk5o0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125914; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=YhCE3ynKhOill8+L6vzYSSWQD+ezdcz0bS4+yQqx+Yk=; b=IAjTWqMIGov3Y2Qt7E2F6EQZqOgv4HlB6SChkxMASFpsQCaMl4aPmgR5UrngmArp3f2JzajL0Uxg76Oq4PlAcAegEqAmYpGPcjdoUO+IzW+vf5DvU06v06CPyKWVIDwiJebjelB5SaHqijvp9yZTdxz0fIygPQ20tulTGj8vwwc= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125914074115.31133611157122; Sun, 5 May 2019 23:58:34 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYe-000225-SA; Mon, 06 May 2019 06:57:04 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYc-0001xo-VK for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:02 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 2270701c-6fcc-11e9-a899-c71b92f5a7ed; Mon, 06 May 2019 06:56:55 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id B459CAF03; Mon, 6 May 2019 06:56:52 +0000 (UTC) X-Inumbo-ID: 2270701c-6fcc-11e9-a899-c71b92f5a7ed X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:13 +0200 Message-Id: <20190506065644.7415-15-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 14/45] xen/sched: add id to struct sched_item X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Tim Deegan , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Dario Faggioli , Julien Grall , Jan Beulich MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Add an identifier to sched_item. For now it will be the same as the related vcpu_id. Signed-off-by: Juergen Gross --- xen/common/schedule.c | 3 ++- xen/include/xen/sched.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 53aac107e1..ffc0920e5f 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -289,12 +289,13 @@ static struct sched_item *sched_alloc_item(struct vcp= u *v) =20 v->sched_item =3D item; item->vcpu =3D v; + item->item_id =3D v->vcpu_id; item->domain =3D d; =20 for ( prev_item =3D &d->sched_item_list; *prev_item; prev_item =3D &(*prev_item)->next_in_list ) if ( (*prev_item)->next_in_list && - (*prev_item)->next_in_list->vcpu->vcpu_id > v->vcpu_id ) + (*prev_item)->next_in_list->item_id > item->item_id ) break; =20 item->next_in_list =3D *prev_item; diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 83d7646088..ce7ead9971 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -266,6 +266,7 @@ struct sched_item { void *priv; /* scheduler private data */ struct sched_item *next_in_list; struct sched_resource *res; + int item_id; =20 /* Last time when item has been scheduled out. */ uint64_t last_run_time; --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125912; cv=none; d=zoho.com; s=zohoarc; b=IUYKIC722WE+f1OvlSccUryn6rdZUAFagvOfRyC2e141jgX68SVBeIDEZs+lmRnEyeibfVgd5p+vbyBjhPf3GS3FuoS7c8omxIEsBrBnRfxqHyZx9NdC3QDxhHQsP0IXu/aZEiP7fuvOkJOND4x4xw140g9uLeTVQ87pMFToO/M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125912; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=giG+1hDwj91S7gW4vpTOnbco7qn4r2D01KZdMxk6/nY=; b=oH+Oqi+VS7KxYRZoDvT6nGdgoA3K9PvRst1YwDsEA3yQyEAf7Aakj99v/xFW6u167o50BbwQ49KTcVi2kfjsjkGC4K1pJxFgWFK3+GaZWFuVzBICYPu4NFFpgm6+UHPs/r6kDjE6cJFUsrC1R9W5qx/xLOK8XQjPRKD40Sn3Eac= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125912004319.13917252285796; Sun, 5 May 2019 23:58:32 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYZ-0001ur-GA; Mon, 06 May 2019 06:56:59 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYY-0001uJ-Le for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:56:58 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 22a5b0ca-6fcc-11e9-843c-bc764e045a96; Mon, 06 May 2019 06:56:56 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 118EBAF1A; Mon, 6 May 2019 06:56:53 +0000 (UTC) X-Inumbo-ID: 22a5b0ca-6fcc-11e9-843c-bc764e045a96 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:14 +0200 Message-Id: <20190506065644.7415-16-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 15/45] xen/sched: rename scheduler related perf counters X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Tim Deegan , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Dario Faggioli , Julien Grall , Meng Xu , Jan Beulich MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Rename the scheduler related perf counters from vcpu* to item* where appropriate. Signed-off-by: Juergen Gross --- xen/common/sched_credit.c | 32 ++++++++++++++++---------------- xen/common/sched_credit2.c | 18 +++++++++--------- xen/common/sched_null.c | 18 +++++++++--------- xen/common/sched_rt.c | 16 ++++++++-------- xen/include/xen/perfc_defn.h | 30 +++++++++++++++--------------- 5 files changed, 57 insertions(+), 57 deletions(-) diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index 8cfe54ec36..3ea0d40afb 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -684,7 +684,7 @@ __csched_vcpu_check(struct vcpu *vc) BUG_ON( !is_idle_vcpu(vc) ); } =20 - SCHED_STAT_CRANK(vcpu_check); + SCHED_STAT_CRANK(item_check); } #define CSCHED_VCPU_CHECK(_vc) (__csched_vcpu_check(_vc)) #else @@ -707,7 +707,7 @@ __csched_vcpu_is_cache_hot(const struct csched_private = *prv, struct vcpu *v) (NOW() - v->sched_item->last_run_time) < prv->vcpu_migr_del= ay; =20 if ( hot ) - SCHED_STAT_CRANK(vcpu_hot); + SCHED_STAT_CRANK(item_hot); =20 return hot; } @@ -895,7 +895,7 @@ __csched_vcpu_acct_start(struct csched_private *prv, st= ruct csched_item *svc) if ( list_empty(&svc->active_vcpu_elem) ) { SCHED_VCPU_STAT_CRANK(svc, state_active); - SCHED_STAT_CRANK(acct_vcpu_active); + SCHED_STAT_CRANK(acct_item_active); =20 sdom->active_vcpu_count++; list_add(&svc->active_vcpu_elem, &sdom->active_vcpu); @@ -922,7 +922,7 @@ __csched_vcpu_acct_stop_locked(struct csched_private *p= rv, BUG_ON( list_empty(&svc->active_vcpu_elem) ); =20 SCHED_VCPU_STAT_CRANK(svc, state_idle); - SCHED_STAT_CRANK(acct_vcpu_idle); + SCHED_STAT_CRANK(acct_item_idle); =20 BUG_ON( prv->weight < sdom->weight ); sdom->active_vcpu_count--; @@ -1024,7 +1024,7 @@ csched_alloc_vdata(const struct scheduler *ops, struc= t sched_item *item, svc->pri =3D is_idle_domain(vc->domain) ? CSCHED_PRI_IDLE : CSCHED_PRI_TS_UNDER; SCHED_VCPU_STATS_RESET(svc); - SCHED_STAT_CRANK(vcpu_alloc); + SCHED_STAT_CRANK(item_alloc); return svc; } =20 @@ -1052,7 +1052,7 @@ csched_item_insert(const struct scheduler *ops, struc= t sched_item *item) =20 item_schedule_unlock_irq(lock, item); =20 - SCHED_STAT_CRANK(vcpu_insert); + SCHED_STAT_CRANK(item_insert); } =20 static void @@ -1072,13 +1072,13 @@ csched_item_remove(const struct scheduler *ops, str= uct sched_item *item) struct csched_item * const svc =3D CSCHED_ITEM(item); struct csched_dom * const sdom =3D svc->sdom; =20 - SCHED_STAT_CRANK(vcpu_remove); + SCHED_STAT_CRANK(item_remove); =20 ASSERT(!__vcpu_on_runq(svc)); =20 if ( test_and_clear_bit(CSCHED_FLAG_VCPU_PARKED, &svc->flags) ) { - SCHED_STAT_CRANK(vcpu_unpark); + SCHED_STAT_CRANK(item_unpark); vcpu_unpause(svc->vcpu); } =20 @@ -1099,7 +1099,7 @@ csched_item_sleep(const struct scheduler *ops, struct= sched_item *item) struct csched_item * const svc =3D CSCHED_ITEM(item); unsigned int cpu =3D vc->processor; =20 - SCHED_STAT_CRANK(vcpu_sleep); + SCHED_STAT_CRANK(item_sleep); =20 BUG_ON( is_idle_vcpu(vc) ); =20 @@ -1128,19 +1128,19 @@ csched_item_wake(const struct scheduler *ops, struc= t sched_item *item) =20 if ( unlikely(curr_on_cpu(vc->processor) =3D=3D item) ) { - SCHED_STAT_CRANK(vcpu_wake_running); + SCHED_STAT_CRANK(item_wake_running); return; } if ( unlikely(__vcpu_on_runq(svc)) ) { - SCHED_STAT_CRANK(vcpu_wake_onrunq); + SCHED_STAT_CRANK(item_wake_onrunq); return; } =20 if ( likely(vcpu_runnable(vc)) ) - SCHED_STAT_CRANK(vcpu_wake_runnable); + SCHED_STAT_CRANK(item_wake_runnable); else - SCHED_STAT_CRANK(vcpu_wake_not_runnable); + SCHED_STAT_CRANK(item_wake_not_runnable); =20 /* * We temporarly boost the priority of awaking VCPUs! @@ -1170,7 +1170,7 @@ csched_item_wake(const struct scheduler *ops, struct = sched_item *item) !test_bit(CSCHED_FLAG_VCPU_PARKED, &svc->flags) ) { TRACE_2D(TRC_CSCHED_BOOST_START, vc->domain->domain_id, vc->vcpu_i= d); - SCHED_STAT_CRANK(vcpu_boost); + SCHED_STAT_CRANK(item_boost); svc->pri =3D CSCHED_PRI_TS_BOOST; } =20 @@ -1529,7 +1529,7 @@ csched_acct(void* dummy) credit < -credit_cap && !test_and_set_bit(CSCHED_FLAG_VCPU_PARKED, &svc->flag= s) ) { - SCHED_STAT_CRANK(vcpu_park); + SCHED_STAT_CRANK(item_park); vcpu_pause_nosync(svc->vcpu); } =20 @@ -1553,7 +1553,7 @@ csched_acct(void* dummy) * call to make sure the VCPU's priority is not boosted * if it is woken up here. */ - SCHED_STAT_CRANK(vcpu_unpark); + SCHED_STAT_CRANK(item_unpark); vcpu_unpause(svc->vcpu); } =20 diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index 5c1794db61..8bee7cb9a2 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -2019,7 +2019,7 @@ csched2_vcpu_check(struct vcpu *vc) { BUG_ON( !is_idle_vcpu(vc) ); } - SCHED_STAT_CRANK(vcpu_check); + SCHED_STAT_CRANK(item_check); } #define CSCHED2_VCPU_CHECK(_vc) (csched2_vcpu_check(_vc)) #else @@ -2066,7 +2066,7 @@ csched2_alloc_vdata(const struct scheduler *ops, stru= ct sched_item *item, svc->budget_quota =3D 0; INIT_LIST_HEAD(&svc->parked_elem); =20 - SCHED_STAT_CRANK(vcpu_alloc); + SCHED_STAT_CRANK(item_alloc); =20 return svc; } @@ -2078,7 +2078,7 @@ csched2_item_sleep(const struct scheduler *ops, struc= t sched_item *item) struct csched2_item * const svc =3D csched2_item(item); =20 ASSERT(!is_idle_vcpu(vc)); - SCHED_STAT_CRANK(vcpu_sleep); + SCHED_STAT_CRANK(item_sleep); =20 if ( curr_on_cpu(vc->processor) =3D=3D item ) { @@ -2108,20 +2108,20 @@ csched2_item_wake(const struct scheduler *ops, stru= ct sched_item *item) =20 if ( unlikely(curr_on_cpu(cpu) =3D=3D item) ) { - SCHED_STAT_CRANK(vcpu_wake_running); + SCHED_STAT_CRANK(item_wake_running); goto out; } =20 if ( unlikely(vcpu_on_runq(svc)) ) { - SCHED_STAT_CRANK(vcpu_wake_onrunq); + SCHED_STAT_CRANK(item_wake_onrunq); goto out; } =20 if ( likely(vcpu_runnable(vc)) ) - SCHED_STAT_CRANK(vcpu_wake_runnable); + SCHED_STAT_CRANK(item_wake_runnable); else - SCHED_STAT_CRANK(vcpu_wake_not_runnable); + SCHED_STAT_CRANK(item_wake_not_runnable); =20 /* If the context hasn't been saved for this vcpu yet, we can't put it= on * another runqueue. Instead, we set a flag so that it will be put on= the runqueue @@ -3137,7 +3137,7 @@ csched2_item_insert(const struct scheduler *ops, stru= ct sched_item *item) =20 sdom->nr_vcpus++; =20 - SCHED_STAT_CRANK(vcpu_insert); + SCHED_STAT_CRANK(item_insert); =20 CSCHED2_VCPU_CHECK(vc); } @@ -3160,7 +3160,7 @@ csched2_item_remove(const struct scheduler *ops, stru= ct sched_item *item) ASSERT(!is_idle_vcpu(vc)); ASSERT(list_empty(&svc->runq_elem)); =20 - SCHED_STAT_CRANK(vcpu_remove); + SCHED_STAT_CRANK(item_remove); =20 /* Remove from runqueue */ lock =3D item_schedule_lock_irq(item); diff --git a/xen/common/sched_null.c b/xen/common/sched_null.c index c45af9f8ee..5570cc1a8c 100644 --- a/xen/common/sched_null.c +++ b/xen/common/sched_null.c @@ -207,7 +207,7 @@ static void *null_alloc_vdata(const struct scheduler *o= ps, INIT_LIST_HEAD(&nvc->waitq_elem); nvc->vcpu =3D v; =20 - SCHED_STAT_CRANK(vcpu_alloc); + SCHED_STAT_CRANK(item_alloc); =20 return nvc; } @@ -473,7 +473,7 @@ static void null_item_insert(const struct scheduler *op= s, } spin_unlock_irq(lock); =20 - SCHED_STAT_CRANK(vcpu_insert); + SCHED_STAT_CRANK(item_insert); } =20 static void _vcpu_remove(struct null_private *prv, struct vcpu *v) @@ -544,7 +544,7 @@ static void null_item_remove(const struct scheduler *op= s, out: item_schedule_unlock_irq(lock, item); =20 - SCHED_STAT_CRANK(vcpu_remove); + SCHED_STAT_CRANK(item_remove); } =20 static void null_item_wake(const struct scheduler *ops, @@ -556,21 +556,21 @@ static void null_item_wake(const struct scheduler *op= s, =20 if ( unlikely(curr_on_cpu(v->processor) =3D=3D item) ) { - SCHED_STAT_CRANK(vcpu_wake_running); + SCHED_STAT_CRANK(item_wake_running); return; } =20 if ( unlikely(!list_empty(&null_item(item)->waitq_elem)) ) { /* Not exactly "on runq", but close enough for reusing the counter= */ - SCHED_STAT_CRANK(vcpu_wake_onrunq); + SCHED_STAT_CRANK(item_wake_onrunq); return; } =20 if ( likely(vcpu_runnable(v)) ) - SCHED_STAT_CRANK(vcpu_wake_runnable); + SCHED_STAT_CRANK(item_wake_runnable); else - SCHED_STAT_CRANK(vcpu_wake_not_runnable); + SCHED_STAT_CRANK(item_wake_not_runnable); =20 /* Note that we get here only for vCPUs assigned to a pCPU */ cpu_raise_softirq(v->processor, SCHEDULE_SOFTIRQ); @@ -587,7 +587,7 @@ static void null_item_sleep(const struct scheduler *ops, if ( curr_on_cpu(v->processor) =3D=3D item ) cpu_raise_softirq(v->processor, SCHEDULE_SOFTIRQ); =20 - SCHED_STAT_CRANK(vcpu_sleep); + SCHED_STAT_CRANK(item_sleep); } =20 static struct sched_resource * @@ -697,7 +697,7 @@ static inline void null_vcpu_check(struct vcpu *v) else BUG_ON(!is_idle_vcpu(v)); =20 - SCHED_STAT_CRANK(vcpu_check); + SCHED_STAT_CRANK(item_check); } #define NULL_VCPU_CHECK(v) (null_vcpu_check(v)) #else diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index 58560d086b..0639cdce0a 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -870,7 +870,7 @@ rt_alloc_vdata(const struct scheduler *ops, struct sche= d_item *item, void *dd) if ( !is_idle_vcpu(vc) ) svc->budget =3D RTDS_DEFAULT_BUDGET; =20 - SCHED_STAT_CRANK(vcpu_alloc); + SCHED_STAT_CRANK(item_alloc); =20 return svc; } @@ -919,7 +919,7 @@ rt_item_insert(const struct scheduler *ops, struct sche= d_item *item) } item_schedule_unlock_irq(lock, item); =20 - SCHED_STAT_CRANK(vcpu_insert); + SCHED_STAT_CRANK(item_insert); } =20 /* @@ -932,7 +932,7 @@ rt_item_remove(const struct scheduler *ops, struct sche= d_item *item) struct rt_dom * const sdom =3D svc->sdom; spinlock_t *lock; =20 - SCHED_STAT_CRANK(vcpu_remove); + SCHED_STAT_CRANK(item_remove); =20 BUG_ON( sdom =3D=3D NULL ); =20 @@ -1154,7 +1154,7 @@ rt_item_sleep(const struct scheduler *ops, struct sch= ed_item *item) struct rt_item * const svc =3D rt_item(item); =20 BUG_ON( is_idle_vcpu(vc) ); - SCHED_STAT_CRANK(vcpu_sleep); + SCHED_STAT_CRANK(item_sleep); =20 if ( curr_on_cpu(vc->processor) =3D=3D item ) cpu_raise_softirq(vc->processor, SCHEDULE_SOFTIRQ); @@ -1275,21 +1275,21 @@ rt_item_wake(const struct scheduler *ops, struct sc= hed_item *item) =20 if ( unlikely(curr_on_cpu(vc->processor) =3D=3D item) ) { - SCHED_STAT_CRANK(vcpu_wake_running); + SCHED_STAT_CRANK(item_wake_running); return; } =20 /* on RunQ/DepletedQ, just update info is ok */ if ( unlikely(vcpu_on_q(svc)) ) { - SCHED_STAT_CRANK(vcpu_wake_onrunq); + SCHED_STAT_CRANK(item_wake_onrunq); return; } =20 if ( likely(vcpu_runnable(vc)) ) - SCHED_STAT_CRANK(vcpu_wake_runnable); + SCHED_STAT_CRANK(item_wake_runnable); else - SCHED_STAT_CRANK(vcpu_wake_not_runnable); + SCHED_STAT_CRANK(item_wake_not_runnable); =20 /* * If a deadline passed while svc was asleep/blocked, we need new diff --git a/xen/include/xen/perfc_defn.h b/xen/include/xen/perfc_defn.h index 1ad4384080..25af4dbd12 100644 --- a/xen/include/xen/perfc_defn.h +++ b/xen/include/xen/perfc_defn.h @@ -21,20 +21,20 @@ PERFCOUNTER(sched_ctx, "sched: context swi= tches") PERFCOUNTER(schedule, "sched: specific scheduler") PERFCOUNTER(dom_init, "sched: dom_init") PERFCOUNTER(dom_destroy, "sched: dom_destroy") -PERFCOUNTER(vcpu_alloc, "sched: vcpu_alloc") -PERFCOUNTER(vcpu_insert, "sched: vcpu_insert") -PERFCOUNTER(vcpu_remove, "sched: vcpu_remove") -PERFCOUNTER(vcpu_sleep, "sched: vcpu_sleep") PERFCOUNTER(vcpu_yield, "sched: vcpu_yield") -PERFCOUNTER(vcpu_wake_running, "sched: vcpu_wake_running") -PERFCOUNTER(vcpu_wake_onrunq, "sched: vcpu_wake_onrunq") -PERFCOUNTER(vcpu_wake_runnable, "sched: vcpu_wake_runnable") -PERFCOUNTER(vcpu_wake_not_runnable, "sched: vcpu_wake_not_runnable") +PERFCOUNTER(item_alloc, "sched: item_alloc") +PERFCOUNTER(item_insert, "sched: item_insert") +PERFCOUNTER(item_remove, "sched: item_remove") +PERFCOUNTER(item_sleep, "sched: item_sleep") +PERFCOUNTER(item_wake_running, "sched: item_wake_running") +PERFCOUNTER(item_wake_onrunq, "sched: item_wake_onrunq") +PERFCOUNTER(item_wake_runnable, "sched: item_wake_runnable") +PERFCOUNTER(item_wake_not_runnable, "sched: item_wake_not_runnable") PERFCOUNTER(tickled_no_cpu, "sched: tickled_no_cpu") PERFCOUNTER(tickled_idle_cpu, "sched: tickled_idle_cpu") PERFCOUNTER(tickled_idle_cpu_excl, "sched: tickled_idle_cpu_exclusive") PERFCOUNTER(tickled_busy_cpu, "sched: tickled_busy_cpu") -PERFCOUNTER(vcpu_check, "sched: vcpu_check") +PERFCOUNTER(item_check, "sched: item_check") =20 /* credit specific counters */ PERFCOUNTER(delay_ms, "csched: delay") @@ -43,11 +43,11 @@ PERFCOUNTER(acct_no_work, "csched: acct_no_wo= rk") PERFCOUNTER(acct_balance, "csched: acct_balance") PERFCOUNTER(acct_reorder, "csched: acct_reorder") PERFCOUNTER(acct_min_credit, "csched: acct_min_credit") -PERFCOUNTER(acct_vcpu_active, "csched: acct_vcpu_active") -PERFCOUNTER(acct_vcpu_idle, "csched: acct_vcpu_idle") -PERFCOUNTER(vcpu_boost, "csched: vcpu_boost") -PERFCOUNTER(vcpu_park, "csched: vcpu_park") -PERFCOUNTER(vcpu_unpark, "csched: vcpu_unpark") +PERFCOUNTER(acct_item_active, "csched: acct_item_active") +PERFCOUNTER(acct_item_idle, "csched: acct_item_idle") +PERFCOUNTER(item_boost, "csched: item_boost") +PERFCOUNTER(item_park, "csched: item_park") +PERFCOUNTER(item_unpark, "csched: item_unpark") PERFCOUNTER(load_balance_idle, "csched: load_balance_idle") PERFCOUNTER(load_balance_over, "csched: load_balance_over") PERFCOUNTER(load_balance_other, "csched: load_balance_other") @@ -57,7 +57,7 @@ PERFCOUNTER(steal_peer_idle, "csched: steal_peer_i= dle") PERFCOUNTER(migrate_queued, "csched: migrate_queued") PERFCOUNTER(migrate_running, "csched: migrate_running") PERFCOUNTER(migrate_kicked_away, "csched: migrate_kicked_away") -PERFCOUNTER(vcpu_hot, "csched: vcpu_hot") +PERFCOUNTER(item_hot, "csched: item_hot") =20 /* credit2 specific counters */ PERFCOUNTER(burn_credits_t2c, "csched2: burn_credits_t2c") --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125918; cv=none; d=zoho.com; s=zohoarc; b=gj0kNYVNbEthCGdUbeXZeufqPSSeu5WxWOGxJTuXPq1cPK3SgLjKU1GgGRtNhwx2LERXXs/XEPvr+pRJb7ef/e/LElc/P5mKNRM4mEv2QcxnvFjTgYRIwZNTJc1HrrUqy1fqBNM4MjmqLwxb6xfTTXQE8A3rIGANm3HEZOrRpME= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125918; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=hpJNCuLAfqaHP1XDUYSuvlewCAxd4EVOgT8KFM25tUU=; b=g8/vqaKGanG5cTBTlCYs7TiGlkckCesmtB87j3mBJiW7CyCwM9Lu8Qj4hmGiIkhMEQTGzm+G3+st8DFUf4aWJDFI0QZuGfcC11UK4xJCBbCNIjV1UpjV4sYOgmeJlmiLf6aAC7OM9hXYmfCdLes7cRB0qU5M2LgZ6aUzS7LNwxA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125918355196.46898065815458; Sun, 5 May 2019 23:58:38 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYh-00026h-4f; Mon, 06 May 2019 06:57:07 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYe-00020S-7O for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:04 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 229d4a2e-6fcc-11e9-b435-93fc4e3b85a6; Mon, 06 May 2019 06:56:56 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 67A14AF1B; Mon, 6 May 2019 06:56:53 +0000 (UTC) X-Inumbo-ID: 229d4a2e-6fcc-11e9-b435-93fc4e3b85a6 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:15 +0200 Message-Id: <20190506065644.7415-17-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 16/45] xen/sched: switch struct task_slice from vcpu to sched_item X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Tim Deegan , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Robert VanVossen , Dario Faggioli , Julien Grall , Josh Whitehead , Meng Xu , Jan Beulich MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Let the schedulers put a sched_item pointer into struct task_slice instead of a vcpu pointer. Signed-off-by: Juergen Gross --- xen/common/sched_arinc653.c | 8 ++++---- xen/common/sched_credit.c | 4 ++-- xen/common/sched_credit2.c | 4 ++-- xen/common/sched_null.c | 12 ++++++------ xen/common/sched_rt.c | 2 +- xen/common/schedule.c | 2 +- xen/include/xen/sched-if.h | 6 +++--- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/xen/common/sched_arinc653.c b/xen/common/sched_arinc653.c index 9dc1ff6a73..5733a2a6b8 100644 --- a/xen/common/sched_arinc653.c +++ b/xen/common/sched_arinc653.c @@ -554,9 +554,9 @@ a653sched_do_schedule( =20 /* * If there are more domains to run in the current major frame, set - * new_task equal to the address of next domain's VCPU structure. - * Otherwise, set new_task equal to the address of the idle task's VCPU - * structure. + * new_task equal to the address of next domain's sched_item structure. + * Otherwise, set new_task equal to the address of the idle task's + * sched_item structure. */ new_task =3D (sched_index < sched_priv->num_schedule_entries) ? sched_priv->schedule[sched_index].vc @@ -592,7 +592,7 @@ a653sched_do_schedule( * of the selected task's VCPU structure. */ ret.time =3D next_switch_time - now; - ret.task =3D new_task; + ret.task =3D new_task->sched_item; ret.migrated =3D 0; =20 BUG_ON(ret.time <=3D 0); diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index 3ea0d40afb..29076e362b 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -2005,9 +2005,9 @@ out: */ ret.time =3D (is_idle_vcpu(snext->vcpu) ? -1 : tslice); - ret.task =3D snext->vcpu; + ret.task =3D snext->vcpu->sched_item; =20 - CSCHED_VCPU_CHECK(ret.task); + CSCHED_VCPU_CHECK(ret.task->vcpu); return ret; } =20 diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index 8bee7cb9a2..9bf045d20f 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -3636,9 +3636,9 @@ csched2_schedule( * Return task to run next... */ ret.time =3D csched2_runtime(ops, cpu, snext, now); - ret.task =3D snext->vcpu; + ret.task =3D snext->vcpu->sched_item; =20 - CSCHED2_VCPU_CHECK(ret.task); + CSCHED2_VCPU_CHECK(ret.task->vcpu); return ret; } =20 diff --git a/xen/common/sched_null.c b/xen/common/sched_null.c index 5570cc1a8c..62c51e2c83 100644 --- a/xen/common/sched_null.c +++ b/xen/common/sched_null.c @@ -746,10 +746,10 @@ static struct task_slice null_schedule(const struct s= cheduler *ops, if ( tasklet_work_scheduled ) { trace_var(TRC_SNULL_TASKLET, 1, 0, NULL); - ret.task =3D idle_vcpu[cpu]; + ret.task =3D idle_vcpu[cpu]->sched_item; } else - ret.task =3D per_cpu(npc, cpu).vcpu; + ret.task =3D per_cpu(npc, cpu).vcpu->sched_item; ret.migrated =3D 0; ret.time =3D -1; =20 @@ -784,7 +784,7 @@ static struct task_slice null_schedule(const struct sch= eduler *ops, { vcpu_assign(prv, wvc->vcpu, cpu); list_del_init(&wvc->waitq_elem); - ret.task =3D wvc->vcpu; + ret.task =3D wvc->vcpu->sched_item; goto unlock; } } @@ -793,10 +793,10 @@ static struct task_slice null_schedule(const struct s= cheduler *ops, spin_unlock(&prv->waitq_lock); } =20 - if ( unlikely(ret.task =3D=3D NULL || !vcpu_runnable(ret.task)) ) - ret.task =3D idle_vcpu[cpu]; + if ( unlikely(ret.task =3D=3D NULL || !item_runnable(ret.task)) ) + ret.task =3D idle_vcpu[cpu]->sched_item; =20 - NULL_VCPU_CHECK(ret.task); + NULL_VCPU_CHECK(ret.task->vcpu); return ret; } =20 diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index 0639cdce0a..374a9d2383 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -1138,7 +1138,7 @@ rt_schedule(const struct scheduler *ops, s_time_t now= , bool_t tasklet_work_sched } ret.time =3D snext->cur_budget; /* invoke the scheduler next time = */ } - ret.task =3D snext->vcpu; + ret.task =3D snext->vcpu->sched_item; =20 return ret; } diff --git a/xen/common/schedule.c b/xen/common/schedule.c index ffc0920e5f..2a2f36636a 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -1534,7 +1534,7 @@ static void schedule(void) sched =3D this_cpu(scheduler); next_slice =3D sched->do_schedule(sched, now, tasklet_work_scheduled); =20 - next =3D next_slice.task; + next =3D next_slice.task->vcpu; =20 sd->curr =3D next->sched_item; =20 diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index 51c3477580..295101f9ef 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -176,9 +176,9 @@ static inline spinlock_t *pcpu_schedule_trylock(unsigne= d int cpu) } =20 struct task_slice { - struct vcpu *task; - s_time_t time; - bool_t migrated; + struct sched_item *task; + s_time_t time; + bool_t migrated; }; =20 struct scheduler { --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125917; cv=none; d=zoho.com; s=zohoarc; b=Rn3vWBmTz3nVLXmOJHUjAP15tosXjzyCUJJperycjoTczkdGlL14L84Id310yCLuHkacqn/eXVSQBnXjJttL5wiyxbSxaMpZeV5hvpifJDuh3tQ9Hyup2aCWcSr3oa/W+lLVrFoGVQW1DlQQNXNyWJgCPaJoQ4k7MR5poGuNS14= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125917; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=HWep/wf+4vgpXhWr9NxsHoz9oEX6HC6eAztTQL2WhcU=; b=HnWSKCyzouHy3e7VRw88sNO3jPbnaOlYetT8f2wrIVGXCzqAv5jzuCVWwkbGjA2NJ7tEKPMARL28eWfqoS97YL6TYWy40vYaK0+GJo+zJLSCkd8uJ4tFAsKC4MOobN9mD8rlVXmSNDFIk3u2TcpsgrSQ6jUxMShjU8erS5QLa9E= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125917369207.95053828565062; Sun, 5 May 2019 23:58:37 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYe-000215-AG; Mon, 06 May 2019 06:57:04 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYc-0001xp-VE for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:02 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 2300004c-6fcc-11e9-9fac-bf81ad6d26d4; Mon, 06 May 2019 06:56:56 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id B1499AF1C; Mon, 6 May 2019 06:56:53 +0000 (UTC) X-Inumbo-ID: 2300004c-6fcc-11e9-9fac-bf81ad6d26d4 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:16 +0200 Message-Id: <20190506065644.7415-18-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 17/45] xen/sched: add is_running indicator to struct sched_item X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Tim Deegan , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Dario Faggioli , Julien Grall , Meng Xu , Jan Beulich MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Add an is_running indicator to struct sched_item which will be set whenever the item is being scheduled. Switch scheduler code to use item->is_running instead of vcpu->is_running for scheduling decisions. At the same time introduce a state_entry_time field in struct sched_item being updated whenever the is_running indicator is changed. Use that new field in the schedulers instead of the similar vcpu field. Signed-off-by: Juergen Gross --- RFC V2: fix arm build, don't drop v->is_running --- xen/common/sched_credit.c | 12 +++++++----- xen/common/sched_credit2.c | 18 +++++++++--------- xen/common/sched_rt.c | 2 +- xen/common/schedule.c | 15 +++++++++++---- xen/include/xen/sched.h | 4 ++++ 5 files changed, 32 insertions(+), 19 deletions(-) diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index 29076e362b..77bebf5b42 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -723,7 +723,7 @@ __csched_vcpu_is_migrateable(const struct csched_privat= e *prv, struct vcpu *vc, * The caller is supposed to have already checked that vc is also * not running. */ - ASSERT(!vc->is_running); + ASSERT(!vc->sched_item->is_running); =20 return !__csched_vcpu_is_cache_hot(prv, vc) && cpumask_test_cpu(dest_cpu, mask); @@ -1047,7 +1047,8 @@ csched_item_insert(const struct scheduler *ops, struc= t sched_item *item) =20 lock =3D item_schedule_lock_irq(item); =20 - if ( !__vcpu_on_runq(svc) && vcpu_runnable(vc) && !vc->is_running ) + if ( !__vcpu_on_runq(svc) && vcpu_runnable(vc) && + !vc->sched_item->is_running ) runq_insert(svc); =20 item_schedule_unlock_irq(lock, item); @@ -1659,8 +1660,9 @@ csched_runq_steal(int peer_cpu, int cpu, int pri, int= balance_step) * vCPUs with useful soft affinities in some sort of bitmap * or counter. */ - if ( vc->is_running || (balance_step =3D=3D BALANCE_SOFT_AFFINITY = && - !has_soft_affinity(vc->sched_item)) ) + if ( vc->sched_item->is_running || + (balance_step =3D=3D BALANCE_SOFT_AFFINITY && + !has_soft_affinity(vc->sched_item)) ) continue; =20 affinity_balance_cpumask(vc->sched_item, balance_step, cpumask_scr= atch); @@ -1868,7 +1870,7 @@ csched_schedule( (unsigned char *)&d); } =20 - runtime =3D now - current->runstate.state_entry_time; + runtime =3D now - current->sched_item->state_entry_time; if ( runtime < 0 ) /* Does this ever happen? */ runtime =3D 0; =20 diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index 9bf045d20f..0f0d6a3801 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -1283,7 +1283,7 @@ runq_insert(const struct scheduler *ops, struct csche= d2_item *svc) =20 ASSERT(&svc->rqd->runq =3D=3D runq); ASSERT(!is_idle_vcpu(svc->vcpu)); - ASSERT(!svc->vcpu->is_running); + ASSERT(!svc->vcpu->sched_item->is_running); ASSERT(!(svc->flags & CSFLAG_scheduled)); =20 list_for_each( iter, runq ) @@ -1340,8 +1340,8 @@ static inline bool is_preemptable(const struct csched= 2_item *svc, if ( ratelimit <=3D CSCHED2_RATELIMIT_TICKLE_TOLERANCE ) return true; =20 - ASSERT(svc->vcpu->is_running); - return now - svc->vcpu->runstate.state_entry_time > + ASSERT(svc->vcpu->sched_item->is_running); + return now - svc->vcpu->sched_item->state_entry_time > ratelimit - CSCHED2_RATELIMIT_TICKLE_TOLERANCE; } =20 @@ -2931,7 +2931,7 @@ csched2_dom_cntl( { svc =3D csched2_item(v->sched_item); lock =3D item_schedule_lock(svc->vcpu->sched_item); - if ( v->is_running ) + if ( v->sched_item->is_running ) { unsigned int cpu =3D v->processor; struct csched2_runqueue_data *rqd =3D c2rqd(ops, c= pu); @@ -3204,8 +3204,8 @@ csched2_runtime(const struct scheduler *ops, int cpu, if ( prv->ratelimit_us ) { s_time_t ratelimit_min =3D MICROSECS(prv->ratelimit_us); - if ( snext->vcpu->is_running ) - ratelimit_min =3D snext->vcpu->runstate.state_entry_time + + if ( snext->vcpu->sched_item->is_running ) + ratelimit_min =3D snext->vcpu->sched_item->state_entry_time + MICROSECS(prv->ratelimit_us) - now; if ( ratelimit_min > min_time ) min_time =3D ratelimit_min; @@ -3302,7 +3302,7 @@ runq_candidate(struct csched2_runqueue_data *rqd, * no point forcing it to do so until rate limiting expires. */ if ( !yield && prv->ratelimit_us && vcpu_runnable(scurr->vcpu) && - (now - scurr->vcpu->runstate.state_entry_time) < + (now - scurr->vcpu->sched_item->state_entry_time) < MICROSECS(prv->ratelimit_us) ) { if ( unlikely(tb_init_done) ) @@ -3313,7 +3313,7 @@ runq_candidate(struct csched2_runqueue_data *rqd, } d; d.dom =3D scurr->vcpu->domain->domain_id; d.vcpu =3D scurr->vcpu->vcpu_id; - d.runtime =3D now - scurr->vcpu->runstate.state_entry_time; + d.runtime =3D now - scurr->vcpu->sched_item->state_entry_time; __trace_var(TRC_CSCHED2_RATELIMIT, 1, sizeof(d), (unsigned char *)&d); @@ -3561,7 +3561,7 @@ csched2_schedule( if ( snext !=3D scurr ) { ASSERT(snext->rqd =3D=3D rqd); - ASSERT(!snext->vcpu->is_running); + ASSERT(!snext->vcpu->sched_item->is_running); =20 runq_remove(snext); __set_bit(__CSFLAG_scheduled, &snext->flags); diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index 374a9d2383..1861ef8c41 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -914,7 +914,7 @@ rt_item_insert(const struct scheduler *ops, struct sche= d_item *item) { replq_insert(ops, svc); =20 - if ( !vc->is_running ) + if ( !item->is_running ) runq_insert(ops, svc); } item_schedule_unlock_irq(lock, item); diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 2a2f36636a..dfd261d029 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -353,6 +353,8 @@ int sched_init_vcpu(struct vcpu *v, unsigned int proces= sor) { per_cpu(sched_res, v->processor)->curr =3D item; v->is_running =3D 1; + item->is_running =3D 1; + item->state_entry_time =3D NOW(); } else { @@ -673,7 +675,8 @@ static void vcpu_migrate_finish(struct vcpu *v) * context_saved(); and in any case, if the bit is cleared, then * someone else has already done the work so we don't need to. */ - if ( v->is_running || !test_bit(_VPF_migrating, &v->pause_flags) ) + if ( v->sched_item->is_running || + !test_bit(_VPF_migrating, &v->pause_flags) ) return; =20 old_cpu =3D new_cpu =3D v->processor; @@ -727,7 +730,7 @@ static void vcpu_migrate_finish(struct vcpu *v) * because they both happen in (different) spinlock regions, and those * regions are strictly serialised. */ - if ( v->is_running || + if ( v->sched_item->is_running || !test_and_clear_bit(_VPF_migrating, &v->pause_flags) ) { sched_spin_unlock_double(old_lock, new_lock, flags); @@ -755,7 +758,7 @@ void vcpu_force_reschedule(struct vcpu *v) { spinlock_t *lock =3D item_schedule_lock_irq(v->sched_item); =20 - if ( v->is_running ) + if ( v->sched_item->is_running ) vcpu_migrate_start(v); =20 item_schedule_unlock_irq(lock, v->sched_item); @@ -1582,8 +1585,10 @@ static void schedule(void) * switch, else lost_records resume will not work properly. */ =20 - ASSERT(!next->is_running); + ASSERT(!next->sched_item->is_running); next->is_running =3D 1; + next->sched_item->is_running =3D 1; + next->sched_item->state_entry_time =3D now; =20 pcpu_schedule_unlock_irq(lock, cpu); =20 @@ -1605,6 +1610,8 @@ void context_saved(struct vcpu *prev) smp_wmb(); =20 prev->is_running =3D 0; + prev->sched_item->is_running =3D 0; + prev->sched_item->state_entry_time =3D NOW(); =20 /* Check for migration request /after/ clearing running flag. */ smp_mb(); diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index ce7ead9971..da117365af 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -270,7 +270,11 @@ struct sched_item { =20 /* Last time when item has been scheduled out. */ uint64_t last_run_time; + /* Last time item got (de-)scheduled. */ + uint64_t state_entry_time; =20 + /* Currently running on a CPU? */ + bool is_running; /* Item needs affinity restored. */ bool affinity_broken; /* Does soft affinity actually play a role (given hard affinity)? */ --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125909; cv=none; d=zoho.com; s=zohoarc; b=JHorx1DAJWhhwZKNMVayg3wxhJKUTgog+8mcSu9NTRIxd3EzzqO49DQYUsCjRoh5EQmmxgzQHS2nthCKJl7BfPRacgtCEyVxbO100QQGtDjDdYlDQyci3ooP003XBPzuQY4CRyAziWjP9WQ1NQ4s3BpDhUBDK05gbTxxlG1mfa8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125909; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=vROm+MXaf0klb5Eb6ZGMAtdjwjiAnPRNL4jsV1+TtU8=; b=TZanZswgsAJ9hx+OI31sN8pDv2LjGMrOoeseNxQCFHuKB9v4R65Ukt5lglnkfhrhpY/PGKasaEIIbExJLCnSNyC+vWHbfRUYEE8dkugpe9kH2Q2MclyRpJu7fUqMelgRvjqxlbJ6xykmMCzwjgUpjoUW1w8zj+Q8pGQ2UEYUiKE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125909913745.9337584379205; Sun, 5 May 2019 23:58:29 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYo-0002Lp-GT; Mon, 06 May 2019 06:57:14 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYh-00028F-Tr for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:07 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 22ff9e54-6fcc-11e9-8291-1b98ce9c8cff; Mon, 06 May 2019 06:56:56 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id D5BBCAF1E; Mon, 6 May 2019 06:56:53 +0000 (UTC) X-Inumbo-ID: 22ff9e54-6fcc-11e9-8291-1b98ce9c8cff X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:17 +0200 Message-Id: <20190506065644.7415-19-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 18/45] xen/sched: make null scheduler vcpu agnostic. X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , George Dunlap , Dario Faggioli MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Switch null scheduler completely from vcpu to sched_item usage. Signed-off-by: Juergen Gross --- xen/common/sched_null.c | 304 ++++++++++++++++++++++++--------------------= ---- 1 file changed, 149 insertions(+), 155 deletions(-) diff --git a/xen/common/sched_null.c b/xen/common/sched_null.c index 62c51e2c83..ceb026c8af 100644 --- a/xen/common/sched_null.c +++ b/xen/common/sched_null.c @@ -18,10 +18,10 @@ =20 /* * The 'null' scheduler always choose to run, on each pCPU, either nothing - * (i.e., the pCPU stays idle) or always the same vCPU. + * (i.e., the pCPU stays idle) or always the same Item. * * It is aimed at supporting static scenarios, where there always are - * less vCPUs than pCPUs (and the vCPUs don't need to move among pCPUs + * less Items than pCPUs (and the Items don't need to move among pCPUs * for any reason) with the least possible overhead. * * Typical usecase are embedded applications, but also HPC, especially @@ -38,8 +38,8 @@ * null tracing events. Check include/public/trace.h for more details. */ #define TRC_SNULL_PICKED_CPU TRC_SCHED_CLASS_EVT(SNULL, 1) -#define TRC_SNULL_VCPU_ASSIGN TRC_SCHED_CLASS_EVT(SNULL, 2) -#define TRC_SNULL_VCPU_DEASSIGN TRC_SCHED_CLASS_EVT(SNULL, 3) +#define TRC_SNULL_ITEM_ASSIGN TRC_SCHED_CLASS_EVT(SNULL, 2) +#define TRC_SNULL_ITEM_DEASSIGN TRC_SCHED_CLASS_EVT(SNULL, 3) #define TRC_SNULL_MIGRATE TRC_SCHED_CLASS_EVT(SNULL, 4) #define TRC_SNULL_SCHEDULE TRC_SCHED_CLASS_EVT(SNULL, 5) #define TRC_SNULL_TASKLET TRC_SCHED_CLASS_EVT(SNULL, 6) @@ -48,13 +48,13 @@ * Locking: * - Scheduler-lock (a.k.a. runqueue lock): * + is per-pCPU; - * + serializes assignment and deassignment of vCPUs to a pCPU. + * + serializes assignment and deassignment of Items to a pCPU. * - Private data lock (a.k.a. private scheduler lock): * + is scheduler-wide; * + serializes accesses to the list of domains in this scheduler. * - Waitqueue lock: * + is scheduler-wide; - * + serialize accesses to the list of vCPUs waiting to be assigned + * + serialize accesses to the list of Items waiting to be assigned * to pCPUs. * * Ordering is: private lock, runqueue lock, waitqueue lock. Or, OTOH, @@ -78,25 +78,25 @@ struct null_private { spinlock_t lock; /* scheduler lock; nests inside cpupool_lock */ struct list_head ndom; /* Domains of this scheduler */ - struct list_head waitq; /* vCPUs not assigned to any pCPU */ + struct list_head waitq; /* Items not assigned to any pCPU */ spinlock_t waitq_lock; /* serializes waitq; nests inside runq locks */ - cpumask_t cpus_free; /* CPUs without a vCPU associated to them */ + cpumask_t cpus_free; /* CPUs without a Item associated to them */ }; =20 /* * Physical CPU */ struct null_pcpu { - struct vcpu *vcpu; + struct sched_item *item; }; DEFINE_PER_CPU(struct null_pcpu, npc); =20 /* - * Virtual CPU + * Schedule Item */ struct null_item { struct list_head waitq_elem; - struct vcpu *vcpu; + struct sched_item *item; }; =20 /* @@ -120,13 +120,13 @@ static inline struct null_item *null_item(const struc= t sched_item *item) return item->priv; } =20 -static inline bool vcpu_check_affinity(struct vcpu *v, unsigned int cpu, +static inline bool item_check_affinity(struct sched_item *item, + unsigned int cpu, unsigned int balance_step) { - affinity_balance_cpumask(v->sched_item, balance_step, - cpumask_scratch_cpu(cpu)); + affinity_balance_cpumask(item, balance_step, cpumask_scratch_cpu(cpu)); cpumask_and(cpumask_scratch_cpu(cpu), cpumask_scratch_cpu(cpu), - cpupool_domain_cpumask(v->domain)); + cpupool_domain_cpumask(item->domain)); =20 return cpumask_test_cpu(cpu, cpumask_scratch_cpu(cpu)); } @@ -161,9 +161,9 @@ static void null_deinit(struct scheduler *ops) =20 static void init_pdata(struct null_private *prv, unsigned int cpu) { - /* Mark the pCPU as free, and with no vCPU assigned */ + /* Mark the pCPU as free, and with no item assigned */ cpumask_set_cpu(cpu, &prv->cpus_free); - per_cpu(npc, cpu).vcpu =3D NULL; + per_cpu(npc, cpu).item =3D NULL; } =20 static void null_init_pdata(const struct scheduler *ops, void *pdata, int = cpu) @@ -191,13 +191,12 @@ static void null_deinit_pdata(const struct scheduler = *ops, void *pcpu, int cpu) ASSERT(!pcpu); =20 cpumask_clear_cpu(cpu, &prv->cpus_free); - per_cpu(npc, cpu).vcpu =3D NULL; + per_cpu(npc, cpu).item =3D NULL; } =20 static void *null_alloc_vdata(const struct scheduler *ops, struct sched_item *item, void *dd) { - struct vcpu *v =3D item->vcpu; struct null_item *nvc; =20 nvc =3D xzalloc(struct null_item); @@ -205,7 +204,7 @@ static void *null_alloc_vdata(const struct scheduler *o= ps, return NULL; =20 INIT_LIST_HEAD(&nvc->waitq_elem); - nvc->vcpu =3D v; + nvc->item =3D item; =20 SCHED_STAT_CRANK(item_alloc); =20 @@ -257,15 +256,15 @@ static void null_free_domdata(const struct scheduler = *ops, void *data) } =20 /* - * vCPU to pCPU assignment and placement. This _only_ happens: + * item to pCPU assignment and placement. This _only_ happens: * - on insert, * - on migrate. * - * Insert occurs when a vCPU joins this scheduler for the first time + * Insert occurs when a item joins this scheduler for the first time * (e.g., when the domain it's part of is moved to the scheduler's * cpupool). * - * Migration may be necessary if a pCPU (with a vCPU assigned to it) + * Migration may be necessary if a pCPU (with a item assigned to it) * is removed from the scheduler's cpupool. * * So this is not part of any hot path. @@ -274,9 +273,8 @@ static struct sched_resource * pick_res(struct null_private *prv, struct sched_item *item) { unsigned int bs; - struct vcpu *v =3D item->vcpu; - unsigned int cpu =3D v->processor, new_cpu; - cpumask_t *cpus =3D cpupool_domain_cpumask(v->domain); + unsigned int cpu =3D sched_item_cpu(item), new_cpu; + cpumask_t *cpus =3D cpupool_domain_cpumask(item->domain); =20 ASSERT(spin_is_locked(per_cpu(sched_res, cpu)->schedule_lock)); =20 @@ -291,11 +289,12 @@ pick_res(struct null_private *prv, struct sched_item = *item) /* * If our processor is free, or we are assigned to it, and it is a= lso * still valid and part of our affinity, just go for it. - * (Note that we may call vcpu_check_affinity(), but we deliberate= ly + * (Note that we may call item_check_affinity(), but we deliberate= ly * don't, so we get to keep in the scratch cpumask what we have ju= st * put in it.) */ - if ( likely((per_cpu(npc, cpu).vcpu =3D=3D NULL || per_cpu(npc, cp= u).vcpu =3D=3D v) + if ( likely((per_cpu(npc, cpu).item =3D=3D NULL || + per_cpu(npc, cpu).item =3D=3D item) && cpumask_test_cpu(cpu, cpumask_scratch_cpu(cpu))) ) { new_cpu =3D cpu; @@ -313,13 +312,13 @@ pick_res(struct null_private *prv, struct sched_item = *item) =20 /* * If we didn't find any free pCPU, just pick any valid pcpu, even if - * it has another vCPU assigned. This will happen during shutdown and + * it has another Item assigned. This will happen during shutdown and * suspend/resume, but it may also happen during "normal operation", if * all the pCPUs are busy. * * In fact, there must always be something sane in v->processor, or * item_schedule_lock() and friends won't work. This is not a problem, - * as we will actually assign the vCPU to the pCPU we return from here, + * as we will actually assign the Item to the pCPU we return from here, * only if the pCPU is free. */ cpumask_and(cpumask_scratch_cpu(cpu), cpus, item->cpu_hard_affinity); @@ -329,11 +328,11 @@ pick_res(struct null_private *prv, struct sched_item = *item) if ( unlikely(tb_init_done) ) { struct { - uint16_t vcpu, dom; + uint16_t item, dom; uint32_t new_cpu; } d; - d.dom =3D v->domain->domain_id; - d.vcpu =3D v->vcpu_id; + d.dom =3D item->domain->domain_id; + d.item =3D item->item_id; d.new_cpu =3D new_cpu; __trace_var(TRC_SNULL_PICKED_CPU, 1, sizeof(d), &d); } @@ -341,47 +340,47 @@ pick_res(struct null_private *prv, struct sched_item = *item) return per_cpu(sched_res, new_cpu); } =20 -static void vcpu_assign(struct null_private *prv, struct vcpu *v, +static void item_assign(struct null_private *prv, struct sched_item *item, unsigned int cpu) { - per_cpu(npc, cpu).vcpu =3D v; - v->processor =3D cpu; - v->sched_item->res =3D per_cpu(sched_res, cpu); + per_cpu(npc, cpu).item =3D item; + sched_set_res(item, per_cpu(sched_res, cpu)); cpumask_clear_cpu(cpu, &prv->cpus_free); =20 - dprintk(XENLOG_G_INFO, "%d <-- %pv\n", cpu, v); + dprintk(XENLOG_G_INFO, "%d <-- %pdv%d\n", cpu, item->domain, item->ite= m_id); =20 if ( unlikely(tb_init_done) ) { struct { - uint16_t vcpu, dom; + uint16_t item, dom; uint32_t cpu; } d; - d.dom =3D v->domain->domain_id; - d.vcpu =3D v->vcpu_id; + d.dom =3D item->domain->domain_id; + d.item =3D item->item_id; d.cpu =3D cpu; - __trace_var(TRC_SNULL_VCPU_ASSIGN, 1, sizeof(d), &d); + __trace_var(TRC_SNULL_ITEM_ASSIGN, 1, sizeof(d), &d); } } =20 -static void vcpu_deassign(struct null_private *prv, struct vcpu *v, +static void item_deassign(struct null_private *prv, struct sched_item *ite= m, unsigned int cpu) { - per_cpu(npc, cpu).vcpu =3D NULL; + per_cpu(npc, cpu).item =3D NULL; cpumask_set_cpu(cpu, &prv->cpus_free); =20 - dprintk(XENLOG_G_INFO, "%d <-- NULL (%pv)\n", cpu, v); + dprintk(XENLOG_G_INFO, "%d <-- NULL (%pdv%d)\n", cpu, item->domain, + item->item_id); =20 if ( unlikely(tb_init_done) ) { struct { - uint16_t vcpu, dom; + uint16_t item, dom; uint32_t cpu; } d; - d.dom =3D v->domain->domain_id; - d.vcpu =3D v->vcpu_id; + d.dom =3D item->domain->domain_id; + d.item =3D item->item_id; d.cpu =3D cpu; - __trace_var(TRC_SNULL_VCPU_DEASSIGN, 1, sizeof(d), &d); + __trace_var(TRC_SNULL_ITEM_DEASSIGN, 1, sizeof(d), &d); } } =20 @@ -393,9 +392,9 @@ static void null_switch_sched(struct scheduler *new_ops= , unsigned int cpu, struct null_private *prv =3D null_priv(new_ops); struct null_item *nvc =3D vdata; =20 - ASSERT(nvc && is_idle_vcpu(nvc->vcpu)); + ASSERT(nvc && is_idle_item(nvc->item)); =20 - idle_vcpu[cpu]->sched_item->priv =3D vdata; + sched_idle_item(cpu)->priv =3D vdata; =20 /* * We are holding the runqueue lock already (it's been taken in @@ -421,35 +420,34 @@ static void null_switch_sched(struct scheduler *new_o= ps, unsigned int cpu, static void null_item_insert(const struct scheduler *ops, struct sched_item *item) { - struct vcpu *v =3D item->vcpu; struct null_private *prv =3D null_priv(ops); struct null_item *nvc =3D null_item(item); unsigned int cpu; spinlock_t *lock; =20 - ASSERT(!is_idle_vcpu(v)); + ASSERT(!is_idle_item(item)); =20 lock =3D item_schedule_lock_irq(item); retry: =20 - item->res =3D pick_res(prv, item); - cpu =3D v->processor =3D item->res->processor; + sched_set_res(item, pick_res(prv, item)); + cpu =3D sched_item_cpu(item); =20 spin_unlock(lock); =20 lock =3D item_schedule_lock(item); =20 cpumask_and(cpumask_scratch_cpu(cpu), item->cpu_hard_affinity, - cpupool_domain_cpumask(v->domain)); + cpupool_domain_cpumask(item->domain)); =20 - /* If the pCPU is free, we assign v to it */ - if ( likely(per_cpu(npc, cpu).vcpu =3D=3D NULL) ) + /* If the pCPU is free, we assign item to it */ + if ( likely(per_cpu(npc, cpu).item =3D=3D NULL) ) { /* * Insert is followed by vcpu_wake(), so there's no need to poke * the pcpu with the SCHEDULE_SOFTIRQ, as wake will do that. */ - vcpu_assign(prv, v, cpu); + item_assign(prv, item, cpu); } else if ( cpumask_intersects(&prv->cpus_free, cpumask_scratch_cpu(cpu)= ) ) { @@ -468,7 +466,8 @@ static void null_item_insert(const struct scheduler *op= s, */ spin_lock(&prv->waitq_lock); list_add_tail(&nvc->waitq_elem, &prv->waitq); - dprintk(XENLOG_G_WARNING, "WARNING: %pv not assigned to any CPU!\n= ", v); + dprintk(XENLOG_G_WARNING, "WARNING: %pdv%d not assigned to any CPU= !\n", + item->domain, item->item_id); spin_unlock(&prv->waitq_lock); } spin_unlock_irq(lock); @@ -476,35 +475,34 @@ static void null_item_insert(const struct scheduler *= ops, SCHED_STAT_CRANK(item_insert); } =20 -static void _vcpu_remove(struct null_private *prv, struct vcpu *v) +static void _item_remove(struct null_private *prv, struct sched_item *item) { unsigned int bs; - unsigned int cpu =3D v->processor; + unsigned int cpu =3D sched_item_cpu(item); struct null_item *wvc; =20 - ASSERT(list_empty(&null_item(v->sched_item)->waitq_elem)); + ASSERT(list_empty(&null_item(item)->waitq_elem)); =20 - vcpu_deassign(prv, v, cpu); + item_deassign(prv, item, cpu); =20 spin_lock(&prv->waitq_lock); =20 /* - * If v is assigned to a pCPU, let's see if there is someone waiting, - * suitable to be assigned to it (prioritizing vcpus that have + * If item is assigned to a pCPU, let's see if there is someone waitin= g, + * suitable to be assigned to it (prioritizing items that have * soft-affinity with cpu). */ for_each_affinity_balance_step( bs ) { list_for_each_entry( wvc, &prv->waitq, waitq_elem ) { - if ( bs =3D=3D BALANCE_SOFT_AFFINITY && - !has_soft_affinity(wvc->vcpu->sched_item) ) + if ( bs =3D=3D BALANCE_SOFT_AFFINITY && !has_soft_affinity(wvc= ->item) ) continue; =20 - if ( vcpu_check_affinity(wvc->vcpu, cpu, bs) ) + if ( item_check_affinity(wvc->item, cpu, bs) ) { list_del_init(&wvc->waitq_elem); - vcpu_assign(prv, wvc->vcpu, cpu); + item_assign(prv, wvc->item, cpu); cpu_raise_softirq(cpu, SCHEDULE_SOFTIRQ); spin_unlock(&prv->waitq_lock); return; @@ -517,16 +515,15 @@ static void _vcpu_remove(struct null_private *prv, st= ruct vcpu *v) static void null_item_remove(const struct scheduler *ops, struct sched_item *item) { - struct vcpu *v =3D item->vcpu; struct null_private *prv =3D null_priv(ops); struct null_item *nvc =3D null_item(item); spinlock_t *lock; =20 - ASSERT(!is_idle_vcpu(v)); + ASSERT(!is_idle_item(item)); =20 lock =3D item_schedule_lock_irq(item); =20 - /* If v is in waitqueue, just get it out of there and bail */ + /* If item is in waitqueue, just get it out of there and bail */ if ( unlikely(!list_empty(&nvc->waitq_elem)) ) { spin_lock(&prv->waitq_lock); @@ -536,10 +533,10 @@ static void null_item_remove(const struct scheduler *= ops, goto out; } =20 - ASSERT(per_cpu(npc, v->processor).vcpu =3D=3D v); - ASSERT(!cpumask_test_cpu(v->processor, &prv->cpus_free)); + ASSERT(per_cpu(npc, sched_item_cpu(item)).item =3D=3D item); + ASSERT(!cpumask_test_cpu(sched_item_cpu(item), &prv->cpus_free)); =20 - _vcpu_remove(prv, v); + _item_remove(prv, item); =20 out: item_schedule_unlock_irq(lock, item); @@ -550,11 +547,9 @@ static void null_item_remove(const struct scheduler *o= ps, static void null_item_wake(const struct scheduler *ops, struct sched_item *item) { - struct vcpu *v =3D item->vcpu; + ASSERT(!is_idle_item(item)); =20 - ASSERT(!is_idle_vcpu(v)); - - if ( unlikely(curr_on_cpu(v->processor) =3D=3D item) ) + if ( unlikely(curr_on_cpu(sched_item_cpu(item)) =3D=3D item) ) { SCHED_STAT_CRANK(item_wake_running); return; @@ -567,25 +562,23 @@ static void null_item_wake(const struct scheduler *op= s, return; } =20 - if ( likely(vcpu_runnable(v)) ) + if ( likely(item_runnable(item)) ) SCHED_STAT_CRANK(item_wake_runnable); else SCHED_STAT_CRANK(item_wake_not_runnable); =20 - /* Note that we get here only for vCPUs assigned to a pCPU */ - cpu_raise_softirq(v->processor, SCHEDULE_SOFTIRQ); + /* Note that we get here only for items assigned to a pCPU */ + cpu_raise_softirq(sched_item_cpu(item), SCHEDULE_SOFTIRQ); } =20 static void null_item_sleep(const struct scheduler *ops, struct sched_item *item) { - struct vcpu *v =3D item->vcpu; - - ASSERT(!is_idle_vcpu(v)); + ASSERT(!is_idle_item(item)); =20 - /* If v is not assigned to a pCPU, or is not running, no need to bothe= r */ - if ( curr_on_cpu(v->processor) =3D=3D item ) - cpu_raise_softirq(v->processor, SCHEDULE_SOFTIRQ); + /* If item isn't assigned to a pCPU, or isn't running, no need to both= er */ + if ( curr_on_cpu(sched_item_cpu(item)) =3D=3D item ) + cpu_raise_softirq(sched_item_cpu(item), SCHEDULE_SOFTIRQ); =20 SCHED_STAT_CRANK(item_sleep); } @@ -593,37 +586,36 @@ static void null_item_sleep(const struct scheduler *o= ps, static struct sched_resource * null_res_pick(const struct scheduler *ops, struct sched_item *item) { - ASSERT(!is_idle_vcpu(item->vcpu)); + ASSERT(!is_idle_item(item)); return pick_res(null_priv(ops), item); } =20 static void null_item_migrate(const struct scheduler *ops, struct sched_item *item, unsigned int new_cp= u) { - struct vcpu *v =3D item->vcpu; struct null_private *prv =3D null_priv(ops); struct null_item *nvc =3D null_item(item); =20 - ASSERT(!is_idle_vcpu(v)); + ASSERT(!is_idle_item(item)); =20 - if ( v->processor =3D=3D new_cpu ) + if ( sched_item_cpu(item) =3D=3D new_cpu ) return; =20 if ( unlikely(tb_init_done) ) { struct { - uint16_t vcpu, dom; + uint16_t item, dom; uint16_t cpu, new_cpu; } d; - d.dom =3D v->domain->domain_id; - d.vcpu =3D v->vcpu_id; - d.cpu =3D v->processor; + d.dom =3D item->domain->domain_id; + d.item =3D item->item_id; + d.cpu =3D sched_item_cpu(item); d.new_cpu =3D new_cpu; __trace_var(TRC_SNULL_MIGRATE, 1, sizeof(d), &d); } =20 /* - * v is either assigned to a pCPU, or in the waitqueue. + * item is either assigned to a pCPU, or in the waitqueue. * * In the former case, the pCPU to which it was assigned would * become free, and we, therefore, should check whether there is @@ -633,7 +625,7 @@ static void null_item_migrate(const struct scheduler *o= ps, */ if ( likely(list_empty(&nvc->waitq_elem)) ) { - _vcpu_remove(prv, v); + _item_remove(prv, item); SCHED_STAT_CRANK(migrate_running); } else @@ -642,32 +634,34 @@ static void null_item_migrate(const struct scheduler = *ops, SCHED_STAT_CRANK(migrated); =20 /* - * Let's now consider new_cpu, which is where v is being sent. It can = be - * either free, or have a vCPU already assigned to it. + * Let's now consider new_cpu, which is where item is being sent. It c= an be + * either free, or have a item already assigned to it. * - * In the former case, we should assign v to it, and try to get it to = run, + * In the former case we should assign item to it, and try to get it t= o run, * if possible, according to affinity. * - * In latter, all we can do is to park v in the waitqueue. + * In latter, all we can do is to park item in the waitqueue. */ - if ( per_cpu(npc, new_cpu).vcpu =3D=3D NULL && - vcpu_check_affinity(v, new_cpu, BALANCE_HARD_AFFINITY) ) + if ( per_cpu(npc, new_cpu).item =3D=3D NULL && + item_check_affinity(item, new_cpu, BALANCE_HARD_AFFINITY) ) { - /* v might have been in the waitqueue, so remove it */ + /* item might have been in the waitqueue, so remove it */ spin_lock(&prv->waitq_lock); list_del_init(&nvc->waitq_elem); spin_unlock(&prv->waitq_lock); =20 - vcpu_assign(prv, v, new_cpu); + item_assign(prv, item, new_cpu); } else { - /* Put v in the waitqueue, if it wasn't there already */ + /* Put item in the waitqueue, if it wasn't there already */ spin_lock(&prv->waitq_lock); if ( list_empty(&nvc->waitq_elem) ) { list_add_tail(&nvc->waitq_elem, &prv->waitq); - dprintk(XENLOG_G_WARNING, "WARNING: %pv not assigned to any CP= U!\n", v); + dprintk(XENLOG_G_WARNING, + "WARNING: %pdv%d not assigned to any CPU!\n", item->do= main, + item->item_id); } spin_unlock(&prv->waitq_lock); } @@ -680,35 +674,34 @@ static void null_item_migrate(const struct scheduler = *ops, * at least. In case of suspend, any temporary inconsistency caused * by this, will be fixed-up during resume. */ - v->processor =3D new_cpu; - item->res =3D per_cpu(sched_res, new_cpu); + sched_set_res(item, per_cpu(sched_res, new_cpu)); } =20 #ifndef NDEBUG -static inline void null_vcpu_check(struct vcpu *v) +static inline void null_item_check(struct sched_item *item) { - struct null_item * const nvc =3D null_item(v->sched_item); - struct null_dom * const ndom =3D v->domain->sched_priv; + struct null_item * const nvc =3D null_item(item); + struct null_dom * const ndom =3D item->domain->sched_priv; =20 - BUG_ON(nvc->vcpu !=3D v); + BUG_ON(nvc->item !=3D item); =20 if ( ndom ) - BUG_ON(is_idle_vcpu(v)); + BUG_ON(is_idle_item(item)); else - BUG_ON(!is_idle_vcpu(v)); + BUG_ON(!is_idle_item(item)); =20 SCHED_STAT_CRANK(item_check); } -#define NULL_VCPU_CHECK(v) (null_vcpu_check(v)) +#define NULL_ITEM_CHECK(item) (null_item_check(item)) #else -#define NULL_VCPU_CHECK(v) +#define NULL_ITEM_CHECK(item) #endif =20 =20 /* * The most simple scheduling function of all times! We either return: - * - the vCPU assigned to the pCPU, if there's one and it can run; - * - the idle vCPU, otherwise. + * - the item assigned to the pCPU, if there's one and it can run; + * - the idle item, otherwise. */ static struct task_slice null_schedule(const struct scheduler *ops, s_time_t now, @@ -721,24 +714,24 @@ static struct task_slice null_schedule(const struct s= cheduler *ops, struct task_slice ret; =20 SCHED_STAT_CRANK(schedule); - NULL_VCPU_CHECK(current); + NULL_ITEM_CHECK(current->sched_item); =20 if ( unlikely(tb_init_done) ) { struct { uint16_t tasklet, cpu; - int16_t vcpu, dom; + int16_t item, dom; } d; d.cpu =3D cpu; d.tasklet =3D tasklet_work_scheduled; - if ( per_cpu(npc, cpu).vcpu =3D=3D NULL ) + if ( per_cpu(npc, cpu).item =3D=3D NULL ) { - d.vcpu =3D d.dom =3D -1; + d.item =3D d.dom =3D -1; } else { - d.vcpu =3D per_cpu(npc, cpu).vcpu->vcpu_id; - d.dom =3D per_cpu(npc, cpu).vcpu->domain->domain_id; + d.item =3D per_cpu(npc, cpu).item->item_id; + d.dom =3D per_cpu(npc, cpu).item->domain->domain_id; } __trace_var(TRC_SNULL_SCHEDULE, 1, sizeof(d), &d); } @@ -746,16 +739,16 @@ static struct task_slice null_schedule(const struct s= cheduler *ops, if ( tasklet_work_scheduled ) { trace_var(TRC_SNULL_TASKLET, 1, 0, NULL); - ret.task =3D idle_vcpu[cpu]->sched_item; + ret.task =3D sched_idle_item(cpu); } else - ret.task =3D per_cpu(npc, cpu).vcpu->sched_item; + ret.task =3D per_cpu(npc, cpu).item; ret.migrated =3D 0; ret.time =3D -1; =20 /* * We may be new in the cpupool, or just coming back online. In which - * case, there may be vCPUs in the waitqueue that we can assign to us + * case, there may be items in the waitqueue that we can assign to us * and run. */ if ( unlikely(ret.task =3D=3D NULL) ) @@ -766,10 +759,10 @@ static struct task_slice null_schedule(const struct s= cheduler *ops, goto unlock; =20 /* - * We scan the waitqueue twice, for prioritizing vcpus that have + * We scan the waitqueue twice, for prioritizing items that have * soft-affinity with cpu. This may look like something expensive = to - * do here in null_schedule(), but it's actually fine, beceuse we = do - * it only in cases where a pcpu has no vcpu associated (e.g., as + * do here in null_schedule(), but it's actually fine, because we = do + * it only in cases where a pcpu has no item associated (e.g., as * said above, the cpu has just joined a cpupool). */ for_each_affinity_balance_step( bs ) @@ -777,14 +770,14 @@ static struct task_slice null_schedule(const struct s= cheduler *ops, list_for_each_entry( wvc, &prv->waitq, waitq_elem ) { if ( bs =3D=3D BALANCE_SOFT_AFFINITY && - !has_soft_affinity(wvc->vcpu->sched_item) ) + !has_soft_affinity(wvc->item) ) continue; =20 - if ( vcpu_check_affinity(wvc->vcpu, cpu, bs) ) + if ( item_check_affinity(wvc->item, cpu, bs) ) { - vcpu_assign(prv, wvc->vcpu, cpu); + item_assign(prv, wvc->item, cpu); list_del_init(&wvc->waitq_elem); - ret.task =3D wvc->vcpu->sched_item; + ret.task =3D wvc->item; goto unlock; } } @@ -794,17 +787,17 @@ static struct task_slice null_schedule(const struct s= cheduler *ops, } =20 if ( unlikely(ret.task =3D=3D NULL || !item_runnable(ret.task)) ) - ret.task =3D idle_vcpu[cpu]->sched_item; + ret.task =3D sched_idle_item(cpu); =20 - NULL_VCPU_CHECK(ret.task->vcpu); + NULL_ITEM_CHECK(ret.task); return ret; } =20 -static inline void dump_vcpu(struct null_private *prv, struct null_item *n= vc) +static inline void dump_item(struct null_private *prv, struct null_item *n= vc) { - printk("[%i.%i] pcpu=3D%d", nvc->vcpu->domain->domain_id, - nvc->vcpu->vcpu_id, list_empty(&nvc->waitq_elem) ? - nvc->vcpu->processor : -1); + printk("[%i.%i] pcpu=3D%d", nvc->item->domain->domain_id, + nvc->item->item_id, list_empty(&nvc->waitq_elem) ? + sched_item_cpu(nvc->item) : -1); } =20 static void null_dump_pcpu(const struct scheduler *ops, int cpu) @@ -820,16 +813,17 @@ static void null_dump_pcpu(const struct scheduler *op= s, int cpu) cpu, nr_cpu_ids, cpumask_bits(per_cpu(cpu_sibling_mask, cpu)), nr_cpu_ids, cpumask_bits(per_cpu(cpu_core_mask, cpu))); - if ( per_cpu(npc, cpu).vcpu !=3D NULL ) - printk(", vcpu=3D%pv", per_cpu(npc, cpu).vcpu); + if ( per_cpu(npc, cpu).item !=3D NULL ) + printk(", item=3D%pdv%d", per_cpu(npc, cpu).item->domain, + per_cpu(npc, cpu).item->item_id); printk("\n"); =20 - /* current VCPU (nothing to say if that's the idle vcpu) */ + /* current item (nothing to say if that's the idle item) */ nvc =3D null_item(curr_on_cpu(cpu)); - if ( nvc && !is_idle_vcpu(nvc->vcpu) ) + if ( nvc && !is_idle_item(nvc->item) ) { printk("\trun: "); - dump_vcpu(prv, nvc); + dump_item(prv, nvc); printk("\n"); } =20 @@ -852,23 +846,23 @@ static void null_dump(const struct scheduler *ops) list_for_each( iter, &prv->ndom ) { struct null_dom *ndom; - struct vcpu *v; + struct sched_item *item; =20 ndom =3D list_entry(iter, struct null_dom, ndom_elem); =20 printk("\tDomain: %d\n", ndom->dom->domain_id); - for_each_vcpu( ndom->dom, v ) + for_each_sched_item( ndom->dom, item ) { - struct null_item * const nvc =3D null_item(v->sched_item); + struct null_item * const nvc =3D null_item(item); spinlock_t *lock; =20 - lock =3D item_schedule_lock(nvc->vcpu->sched_item); + lock =3D item_schedule_lock(item); =20 printk("\t%3d: ", ++loop); - dump_vcpu(prv, nvc); + dump_item(prv, nvc); printk("\n"); =20 - item_schedule_unlock(lock, nvc->vcpu->sched_item); + item_schedule_unlock(lock, item); } } =20 @@ -883,7 +877,7 @@ static void null_dump(const struct scheduler *ops) printk(", "); if ( loop % 24 =3D=3D 0 ) printk("\n\t"); - printk("%pv", nvc->vcpu); + printk("%pdv%d", nvc->item->domain, nvc->item->item_id); } printk("\n"); spin_unlock(&prv->waitq_lock); --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125905; cv=none; d=zoho.com; s=zohoarc; b=JO7CBakfjwn3YRMb1hlTVySWUXLr9HPv/moLgJYjPo9YKulYKo5k7YHeegItbhWAVIWCFPMhBmspeBcHXY9QhD5Ir7Ujw2ihdfGkj74ZrAUZRobR0e7iHGrFfx3JKCLPzZLFX89VMNtzh//ppTTUeQlvYZYHsD7YlvPXJKQ6pkY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125905; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=qVvj9Egukol5EqXMv/3c7IAW1gE0g/lQ2retpstWLik=; b=mUoAe1XDJ1agc3TIFDzwebIWiOhxTbqhlj0SnxJx/bz6HUaxn5zWQLntABv5MdVoaF5QCwZ6V3ww9/prv3KopO2VaM3hNLpa35ey8L5klIyBnEwTjcRWpVJHOwWBKVBRu6mMfS+NxwNkvbWMXsgdEuMqClfK4jIwBCWBeHEsdfU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 155712590527758.481998325153995; Sun, 5 May 2019 23:58:25 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYf-00023I-Kb; Mon, 06 May 2019 06:57:05 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYc-0001xq-V7 for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:03 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 236f1a00-6fcc-11e9-843c-bc764e045a96; Mon, 06 May 2019 06:56:57 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 0B9ADAF1F; Mon, 6 May 2019 06:56:54 +0000 (UTC) X-Inumbo-ID: 236f1a00-6fcc-11e9-843c-bc764e045a96 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:18 +0200 Message-Id: <20190506065644.7415-20-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 19/45] xen/sched: make rt scheduler vcpu agnostic. X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , George Dunlap , Meng Xu , Dario Faggioli MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Switch rt scheduler completely from vcpu to sched_item usage. Signed-off-by: Juergen Gross --- xen/common/sched_rt.c | 356 ++++++++++++++++++++++++----------------------= ---- 1 file changed, 174 insertions(+), 182 deletions(-) diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index 1861ef8c41..730aa292d4 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -36,7 +36,7 @@ * * Migration compensation and resist like credit2 to better use cache; * Lock Holder Problem, using yield? - * Self switch problem: VCPUs of the same domain may preempt each other; + * Self switch problem: ITEMs of the same domain may preempt each other; */ =20 /* @@ -44,30 +44,30 @@ * * This scheduler follows the Preemptive Global Earliest Deadline First (E= DF) * theory in real-time field. - * At any scheduling point, the VCPU with earlier deadline has higher prio= rity. - * The scheduler always picks highest priority VCPU to run on a feasible P= CPU. - * A PCPU is feasible if the VCPU can run on this PCPU and (the PCPU is id= le or - * has a lower-priority VCPU running on it.) + * At any scheduling point, the ITEM with earlier deadline has higher prio= rity. + * The scheduler always picks highest priority ITEM to run on a feasible P= CPU. + * A PCPU is feasible if the ITEM can run on this PCPU and (the PCPU is id= le or + * has a lower-priority ITEM running on it.) * - * Each VCPU has a dedicated period, budget and a extratime flag - * The deadline of a VCPU is at the end of each period; - * A VCPU has its budget replenished at the beginning of each period; - * While scheduled, a VCPU burns its budget. - * The VCPU needs to finish its budget before its deadline in each period; - * The VCPU discards its unused budget at the end of each period. - * When a VCPU runs out of budget in a period, if its extratime flag is se= t, - * the VCPU increases its priority_level by 1 and refills its budget; othe= rwise, + * Each ITEM has a dedicated period, budget and a extratime flag + * The deadline of an ITEM is at the end of each period; + * An ITEM has its budget replenished at the beginning of each period; + * While scheduled, an ITEM burns its budget. + * The ITEM needs to finish its budget before its deadline in each period; + * The ITEM discards its unused budget at the end of each period. + * When an ITEM runs out of budget in a period, if its extratime flag is s= et, + * the ITEM increases its priority_level by 1 and refills its budget; othe= rwise, * it has to wait until next period. * - * Each VCPU is implemented as a deferable server. - * When a VCPU has a task running on it, its budget is continuously burned; - * When a VCPU has no task but with budget left, its budget is preserved. + * Each ITEM is implemented as a deferable server. + * When an ITEM has a task running on it, its budget is continuously burne= d; + * When an ITEM has no task but with budget left, its budget is preserved. * * Queue scheme: * A global runqueue and a global depletedqueue for each CPU pool. - * The runqueue holds all runnable VCPUs with budget, + * The runqueue holds all runnable ITEMs with budget, * sorted by priority_level and deadline; - * The depletedqueue holds all VCPUs without budget, unsorted; + * The depletedqueue holds all ITEMs without budget, unsorted; * * Note: cpumask and cpupool is supported. */ @@ -82,7 +82,7 @@ * in schedule.c * * The functions involes RunQ and needs to grab locks are: - * vcpu_insert, vcpu_remove, context_saved, runq_insert + * item_insert, item_remove, context_saved, runq_insert */ =20 =20 @@ -95,7 +95,7 @@ =20 /* * Max period: max delta of time type, because period is added to the time - * a vcpu activates, so this must not overflow. + * an item activates, so this must not overflow. * Min period: 10 us, considering the scheduling overhead (when period is * too low, scheduling is invoked too frequently, causing high overhead). */ @@ -121,12 +121,12 @@ * Flags */ /* - * RTDS_scheduled: Is this vcpu either running on, or context-switching of= f, + * RTDS_scheduled: Is this item either running on, or context-switching of= f, * a phyiscal cpu? * + Accessed only with global lock held. * + Set when chosen as next in rt_schedule(). * + Cleared after context switch has been saved in rt_context_saved() - * + Checked in vcpu_wake to see if we can add to the Runqueue, or if we s= hould + * + Checked in item_wake to see if we can add to the Runqueue, or if we s= hould * set RTDS_delayed_runq_add * + Checked to be false in runq_insert. */ @@ -146,15 +146,15 @@ /* * RTDS_depleted: Does this vcp run out of budget? * This flag is - * + set in burn_budget() if a vcpu has zero budget left; + * + set in burn_budget() if an item has zero budget left; * + cleared and checked in the repenishment handler, - * for the vcpus that are being replenished. + * for the items that are being replenished. */ #define __RTDS_depleted 3 #define RTDS_depleted (1<<__RTDS_depleted) =20 /* - * RTDS_extratime: Can the vcpu run in the time that is + * RTDS_extratime: Can the item run in the time that is * not part of any real-time reservation, and would therefore * be otherwise left idle? */ @@ -183,11 +183,11 @@ struct rt_private { spinlock_t lock; /* the global coarse-grained lock */ struct list_head sdom; /* list of availalbe domains, used for dum= p */ =20 - struct list_head runq; /* ordered list of runnable vcpus */ - struct list_head depletedq; /* unordered list of depleted vcpus */ + struct list_head runq; /* ordered list of runnable items */ + struct list_head depletedq; /* unordered list of depleted items */ =20 struct timer repl_timer; /* replenishment timer */ - struct list_head replq; /* ordered list of vcpus that need repleni= shment */ + struct list_head replq; /* ordered list of items that need repleni= shment */ =20 cpumask_t tickled; /* cpus been tickled */ }; @@ -199,18 +199,18 @@ struct rt_item { struct list_head q_elem; /* on the runq/depletedq list */ struct list_head replq_elem; /* on the replenishment events list */ =20 - /* VCPU parameters, in nanoseconds */ + /* ITEM parameters, in nanoseconds */ s_time_t period; s_time_t budget; =20 - /* VCPU current information in nanosecond */ + /* ITEM current information in nanosecond */ s_time_t cur_budget; /* current budget */ s_time_t last_start; /* last start time */ s_time_t cur_deadline; /* current deadline for EDF */ =20 /* Up-pointers */ struct rt_dom *sdom; - struct vcpu *vcpu; + struct sched_item *item; =20 unsigned priority_level; =20 @@ -263,7 +263,7 @@ static inline bool has_extratime(const struct rt_item *= svc) * and the replenishment events queue. */ static int -vcpu_on_q(const struct rt_item *svc) +item_on_q(const struct rt_item *svc) { return !list_empty(&svc->q_elem); } @@ -281,7 +281,7 @@ replq_elem(struct list_head *elem) } =20 static int -vcpu_on_replq(const struct rt_item *svc) +item_on_replq(const struct rt_item *svc) { return !list_empty(&svc->replq_elem); } @@ -291,7 +291,7 @@ vcpu_on_replq(const struct rt_item *svc) * Otherwise, return value < 0 */ static s_time_t -compare_vcpu_priority(const struct rt_item *v1, const struct rt_item *v2) +compare_item_priority(const struct rt_item *v1, const struct rt_item *v2) { int prio =3D v2->priority_level - v1->priority_level; =20 @@ -302,15 +302,15 @@ compare_vcpu_priority(const struct rt_item *v1, const= struct rt_item *v2) } =20 /* - * Debug related code, dump vcpu/cpu information + * Debug related code, dump item/cpu information */ static void -rt_dump_vcpu(const struct scheduler *ops, const struct rt_item *svc) +rt_dump_item(const struct scheduler *ops, const struct rt_item *svc) { cpumask_t *cpupool_mask, *mask; =20 ASSERT(svc !=3D NULL); - /* idle vcpu */ + /* idle item */ if( svc->sdom =3D=3D NULL ) { printk("\n"); @@ -321,20 +321,20 @@ rt_dump_vcpu(const struct scheduler *ops, const struc= t rt_item *svc) * We can't just use 'cpumask_scratch' because the dumping can * happen from a pCPU outside of this scheduler's cpupool, and * hence it's not right to use its pCPU's scratch mask. - * On the other hand, it is safe to use svc->vcpu->processor's + * On the other hand, it is safe to use sched_item_cpu(svc->item)'s * own scratch space, since we hold the runqueue lock. */ - mask =3D cpumask_scratch_cpu(svc->vcpu->processor); + mask =3D cpumask_scratch_cpu(sched_item_cpu(svc->item)); =20 - cpupool_mask =3D cpupool_domain_cpumask(svc->vcpu->domain); - cpumask_and(mask, cpupool_mask, svc->vcpu->sched_item->cpu_hard_affini= ty); + cpupool_mask =3D cpupool_domain_cpumask(svc->item->domain); + cpumask_and(mask, cpupool_mask, svc->item->cpu_hard_affinity); printk("[%5d.%-2u] cpu %u, (%"PRI_stime", %"PRI_stime")," " cur_b=3D%"PRI_stime" cur_d=3D%"PRI_stime" last_start=3D%"PRI_= stime"\n" " \t\t priority_level=3D%d has_extratime=3D%d\n" " \t\t onQ=3D%d runnable=3D%d flags=3D%x effective hard_affinit= y=3D%*pbl\n", - svc->vcpu->domain->domain_id, - svc->vcpu->vcpu_id, - svc->vcpu->processor, + svc->item->domain->domain_id, + svc->item->item_id, + sched_item_cpu(svc->item), svc->period, svc->budget, svc->cur_budget, @@ -342,8 +342,8 @@ rt_dump_vcpu(const struct scheduler *ops, const struct = rt_item *svc) svc->last_start, svc->priority_level, has_extratime(svc), - vcpu_on_q(svc), - vcpu_runnable(svc->vcpu), + item_on_q(svc), + item_runnable(svc->item), svc->flags, nr_cpu_ids, cpumask_bits(mask)); } @@ -357,11 +357,11 @@ rt_dump_pcpu(const struct scheduler *ops, int cpu) =20 spin_lock_irqsave(&prv->lock, flags); printk("CPU[%02d]\n", cpu); - /* current VCPU (nothing to say if that's the idle vcpu). */ + /* current ITEM (nothing to say if that's the idle item). */ svc =3D rt_item(curr_on_cpu(cpu)); - if ( svc && !is_idle_vcpu(svc->vcpu) ) + if ( svc && !is_idle_item(svc->item) ) { - rt_dump_vcpu(ops, svc); + rt_dump_item(ops, svc); } spin_unlock_irqrestore(&prv->lock, flags); } @@ -388,35 +388,35 @@ rt_dump(const struct scheduler *ops) list_for_each ( iter, runq ) { svc =3D q_elem(iter); - rt_dump_vcpu(ops, svc); + rt_dump_item(ops, svc); } =20 printk("Global DepletedQueue info:\n"); list_for_each ( iter, depletedq ) { svc =3D q_elem(iter); - rt_dump_vcpu(ops, svc); + rt_dump_item(ops, svc); } =20 printk("Global Replenishment Events info:\n"); list_for_each ( iter, replq ) { svc =3D replq_elem(iter); - rt_dump_vcpu(ops, svc); + rt_dump_item(ops, svc); } =20 printk("Domain info:\n"); list_for_each ( iter, &prv->sdom ) { - struct vcpu *v; + struct sched_item *item; =20 sdom =3D list_entry(iter, struct rt_dom, sdom_elem); printk("\tdomain: %d\n", sdom->dom->domain_id); =20 - for_each_vcpu ( sdom->dom, v ) + for_each_sched_item ( sdom->dom, item ) { - svc =3D rt_item(v->sched_item); - rt_dump_vcpu(ops, svc); + svc =3D rt_item(item); + rt_dump_item(ops, svc); } } =20 @@ -458,12 +458,12 @@ rt_update_deadline(s_time_t now, struct rt_item *svc) /* TRACE */ { struct __packed { - unsigned vcpu:16, dom:16; + unsigned item:16, dom:16; unsigned priority_level; uint64_t cur_deadline, cur_budget; } d; - d.dom =3D svc->vcpu->domain->domain_id; - d.vcpu =3D svc->vcpu->vcpu_id; + d.dom =3D svc->item->domain->domain_id; + d.item =3D svc->item->item_id; d.priority_level =3D svc->priority_level; d.cur_deadline =3D (uint64_t) svc->cur_deadline; d.cur_budget =3D (uint64_t) svc->cur_budget; @@ -476,15 +476,15 @@ rt_update_deadline(s_time_t now, struct rt_item *svc) } =20 /* - * Helpers for removing and inserting a vcpu in a queue - * that is being kept ordered by the vcpus' deadlines (as EDF + * Helpers for removing and inserting an item in a queue + * that is being kept ordered by the items' deadlines (as EDF * mandates). * - * For callers' convenience, the vcpu removing helper returns - * true if the vcpu removed was the one at the front of the + * For callers' convenience, the item removing helper returns + * true if the item removed was the one at the front of the * queue; similarly, the inserting helper returns true if the * inserted ended at the front of the queue (i.e., in both - * cases, if the vcpu with the earliest deadline is what we + * cases, if the item with the earliest deadline is what we * are dealing with). */ static inline bool @@ -510,7 +510,7 @@ deadline_queue_insert(struct rt_item * (*qelem)(struct = list_head *), list_for_each ( iter, queue ) { struct rt_item * iter_svc =3D (*qelem)(iter); - if ( compare_vcpu_priority(svc, iter_svc) > 0 ) + if ( compare_item_priority(svc, iter_svc) > 0 ) break; pos++; } @@ -525,7 +525,7 @@ deadline_queue_insert(struct rt_item * (*qelem)(struct = list_head *), static inline void q_remove(struct rt_item *svc) { - ASSERT( vcpu_on_q(svc) ); + ASSERT( item_on_q(svc) ); list_del_init(&svc->q_elem); } =20 @@ -535,14 +535,14 @@ replq_remove(const struct scheduler *ops, struct rt_i= tem *svc) struct rt_private *prv =3D rt_priv(ops); struct list_head *replq =3D rt_replq(ops); =20 - ASSERT( vcpu_on_replq(svc) ); + ASSERT( item_on_replq(svc) ); =20 if ( deadline_queue_remove(replq, &svc->replq_elem) ) { /* * The replenishment timer needs to be set to fire when a - * replenishment for the vcpu at the front of the replenishment - * queue is due. If it is such vcpu that we just removed, we may + * replenishment for the item at the front of the replenishment + * queue is due. If it is such item that we just removed, we may * need to reprogram the timer. */ if ( !list_empty(replq) ) @@ -557,7 +557,7 @@ replq_remove(const struct scheduler *ops, struct rt_ite= m *svc) =20 /* * Insert svc with budget in RunQ according to EDF: - * vcpus with smaller deadlines go first. + * items with smaller deadlines go first. * Insert svc without budget in DepletedQ unsorted; */ static void @@ -567,8 +567,8 @@ runq_insert(const struct scheduler *ops, struct rt_item= *svc) struct list_head *runq =3D rt_runq(ops); =20 ASSERT( spin_is_locked(&prv->lock) ); - ASSERT( !vcpu_on_q(svc) ); - ASSERT( vcpu_on_replq(svc) ); + ASSERT( !item_on_q(svc) ); + ASSERT( item_on_replq(svc) ); =20 /* add svc to runq if svc still has budget or its extratime is set */ if ( svc->cur_budget > 0 || @@ -584,7 +584,7 @@ replq_insert(const struct scheduler *ops, struct rt_ite= m *svc) struct list_head *replq =3D rt_replq(ops); struct rt_private *prv =3D rt_priv(ops); =20 - ASSERT( !vcpu_on_replq(svc) ); + ASSERT( !item_on_replq(svc) ); =20 /* * The timer may be re-programmed if svc is inserted @@ -607,12 +607,12 @@ replq_reinsert(const struct scheduler *ops, struct rt= _item *svc) struct rt_item *rearm_svc =3D svc; bool_t rearm =3D 0; =20 - ASSERT( vcpu_on_replq(svc) ); + ASSERT( item_on_replq(svc) ); =20 /* * If svc was at the front of the replenishment queue, we certainly * need to re-program the timer, and we want to use the deadline of - * the vcpu which is now at the front of the queue (which may still + * the item which is now at the front of the queue (which may still * be svc or not). * * We may also need to re-program, if svc has been put at the front @@ -632,24 +632,23 @@ replq_reinsert(const struct scheduler *ops, struct rt= _item *svc) } =20 /* - * Pick a valid resource for the vcpu vc - * Valid resource of a vcpu is intesection of vcpu's affinity + * Pick a valid resource for the item vc + * Valid resource of an item is intesection of item's affinity * and available resources */ static struct sched_resource * rt_res_pick(const struct scheduler *ops, struct sched_item *item) { - struct vcpu *vc =3D item->vcpu; cpumask_t cpus; cpumask_t *online; int cpu; =20 - online =3D cpupool_domain_cpumask(vc->domain); + online =3D cpupool_domain_cpumask(item->domain); cpumask_and(&cpus, online, item->cpu_hard_affinity); =20 - cpu =3D cpumask_test_cpu(vc->processor, &cpus) - ? vc->processor - : cpumask_cycle(vc->processor, &cpus); + cpu =3D cpumask_test_cpu(sched_item_cpu(item), &cpus) + ? sched_item_cpu(item) + : cpumask_cycle(sched_item_cpu(item), &cpus); ASSERT( !cpumask_empty(&cpus) && cpumask_test_cpu(cpu, &cpus) ); =20 return per_cpu(sched_res, cpu); @@ -737,7 +736,7 @@ rt_switch_sched(struct scheduler *new_ops, unsigned int= cpu, struct rt_private *prv =3D rt_priv(new_ops); struct rt_item *svc =3D vdata; =20 - ASSERT(!pdata && svc && is_idle_vcpu(svc->vcpu)); + ASSERT(!pdata && svc && is_idle_item(svc->item)); =20 /* * We are holding the runqueue lock already (it's been taken in @@ -761,7 +760,7 @@ rt_switch_sched(struct scheduler *new_ops, unsigned int= cpu, dprintk(XENLOG_DEBUG, "RTDS: timer initialized on cpu %u\n", cpu); } =20 - idle_vcpu[cpu]->sched_item->priv =3D vdata; + sched_idle_item(cpu)->priv =3D vdata; per_cpu(scheduler, cpu) =3D new_ops; per_cpu(sched_res, cpu)->sched_priv =3D NULL; /* no pdata */ =20 @@ -849,10 +848,9 @@ rt_free_domdata(const struct scheduler *ops, void *dat= a) static void * rt_alloc_vdata(const struct scheduler *ops, struct sched_item *item, void = *dd) { - struct vcpu *vc =3D item->vcpu; struct rt_item *svc; =20 - /* Allocate per-VCPU info */ + /* Allocate per-ITEM info */ svc =3D xzalloc(struct rt_item); if ( svc =3D=3D NULL ) return NULL; @@ -861,13 +859,13 @@ rt_alloc_vdata(const struct scheduler *ops, struct sc= hed_item *item, void *dd) INIT_LIST_HEAD(&svc->replq_elem); svc->flags =3D 0U; svc->sdom =3D dd; - svc->vcpu =3D vc; + svc->item =3D item; svc->last_start =3D 0; =20 __set_bit(__RTDS_extratime, &svc->flags); svc->priority_level =3D 0; svc->period =3D RTDS_DEFAULT_PERIOD; - if ( !is_idle_vcpu(vc) ) + if ( !is_idle_item(item) ) svc->budget =3D RTDS_DEFAULT_BUDGET; =20 SCHED_STAT_CRANK(item_alloc); @@ -887,22 +885,20 @@ rt_free_vdata(const struct scheduler *ops, void *priv) * It is called in sched_move_domain() and sched_init_vcpu * in schedule.c. * When move a domain to a new cpupool. - * It inserts vcpus of moving domain to the scheduler's RunQ in + * It inserts items of moving domain to the scheduler's RunQ in * dest. cpupool. */ static void rt_item_insert(const struct scheduler *ops, struct sched_item *item) { - struct vcpu *vc =3D item->vcpu; struct rt_item *svc =3D rt_item(item); s_time_t now; spinlock_t *lock; =20 - BUG_ON( is_idle_vcpu(vc) ); + BUG_ON( is_idle_item(item) ); =20 - /* This is safe because vc isn't yet being scheduled */ - item->res =3D rt_res_pick(ops, item); - vc->processor =3D item->res->processor; + /* This is safe because item isn't yet being scheduled */ + sched_set_res(item, rt_res_pick(ops, item)); =20 lock =3D item_schedule_lock_irq(item); =20 @@ -910,7 +906,7 @@ rt_item_insert(const struct scheduler *ops, struct sche= d_item *item) if ( now >=3D svc->cur_deadline ) rt_update_deadline(now, svc); =20 - if ( !vcpu_on_q(svc) && vcpu_runnable(vc) ) + if ( !item_on_q(svc) && item_runnable(item) ) { replq_insert(ops, svc); =20 @@ -937,10 +933,10 @@ rt_item_remove(const struct scheduler *ops, struct sc= hed_item *item) BUG_ON( sdom =3D=3D NULL ); =20 lock =3D item_schedule_lock_irq(item); - if ( vcpu_on_q(svc) ) + if ( item_on_q(svc) ) q_remove(svc); =20 - if ( vcpu_on_replq(svc) ) + if ( item_on_replq(svc) ) replq_remove(ops,svc); =20 item_schedule_unlock_irq(lock, item); @@ -954,8 +950,8 @@ burn_budget(const struct scheduler *ops, struct rt_item= *svc, s_time_t now) { s_time_t delta; =20 - /* don't burn budget for idle VCPU */ - if ( is_idle_vcpu(svc->vcpu) ) + /* don't burn budget for idle ITEM */ + if ( is_idle_item(svc->item) ) return; =20 /* burn at nanoseconds level */ @@ -992,14 +988,14 @@ burn_budget(const struct scheduler *ops, struct rt_it= em *svc, s_time_t now) /* TRACE */ { struct __packed { - unsigned vcpu:16, dom:16; + unsigned item:16, dom:16; uint64_t cur_budget; int delta; unsigned priority_level; bool has_extratime; } d; - d.dom =3D svc->vcpu->domain->domain_id; - d.vcpu =3D svc->vcpu->vcpu_id; + d.dom =3D svc->item->domain->domain_id; + d.item =3D svc->item->item_id; d.cur_budget =3D (uint64_t) svc->cur_budget; d.delta =3D delta; d.priority_level =3D svc->priority_level; @@ -1029,9 +1025,8 @@ runq_pick(const struct scheduler *ops, const cpumask_= t *mask) iter_svc =3D q_elem(iter); =20 /* mask cpu_hard_affinity & cpupool & mask */ - online =3D cpupool_domain_cpumask(iter_svc->vcpu->domain); - cpumask_and(&cpu_common, online, - iter_svc->vcpu->sched_item->cpu_hard_affinity); + online =3D cpupool_domain_cpumask(iter_svc->item->domain); + cpumask_and(&cpu_common, online, iter_svc->item->cpu_hard_affinity= ); cpumask_and(&cpu_common, mask, &cpu_common); if ( cpumask_empty(&cpu_common) ) continue; @@ -1047,11 +1042,11 @@ runq_pick(const struct scheduler *ops, const cpumas= k_t *mask) if( svc !=3D NULL ) { struct __packed { - unsigned vcpu:16, dom:16; + unsigned item:16, dom:16; uint64_t cur_deadline, cur_budget; } d; - d.dom =3D svc->vcpu->domain->domain_id; - d.vcpu =3D svc->vcpu->vcpu_id; + d.dom =3D svc->item->domain->domain_id; + d.item =3D svc->item->item_id; d.cur_deadline =3D (uint64_t) svc->cur_deadline; d.cur_budget =3D (uint64_t) svc->cur_budget; trace_var(TRC_RTDS_RUNQ_PICK, 1, @@ -1075,6 +1070,7 @@ rt_schedule(const struct scheduler *ops, s_time_t now= , bool_t tasklet_work_sched struct rt_item *const scurr =3D rt_item(current->sched_item); struct rt_item *snext =3D NULL; struct task_slice ret =3D { .migrated =3D 0 }; + struct sched_item *curritem =3D current->sched_item; =20 /* TRACE */ { @@ -1084,7 +1080,7 @@ rt_schedule(const struct scheduler *ops, s_time_t now= , bool_t tasklet_work_sched d.cpu =3D cpu; d.tasklet =3D tasklet_work_scheduled; d.tickled =3D cpumask_test_cpu(cpu, &prv->tickled); - d.idle =3D is_idle_vcpu(current); + d.idle =3D is_idle_item(curritem); trace_var(TRC_RTDS_SCHEDULE, 1, sizeof(d), (unsigned char *)&d); @@ -1093,72 +1089,70 @@ rt_schedule(const struct scheduler *ops, s_time_t n= ow, bool_t tasklet_work_sched /* clear ticked bit now that we've been scheduled */ cpumask_clear_cpu(cpu, &prv->tickled); =20 - /* burn_budget would return for IDLE VCPU */ + /* burn_budget would return for IDLE ITEM */ burn_budget(ops, scurr, now); =20 if ( tasklet_work_scheduled ) { trace_var(TRC_RTDS_SCHED_TASKLET, 1, 0, NULL); - snext =3D rt_item(idle_vcpu[cpu]->sched_item); + snext =3D rt_item(sched_idle_item(cpu)); } else { snext =3D runq_pick(ops, cpumask_of(cpu)); if ( snext =3D=3D NULL ) - snext =3D rt_item(idle_vcpu[cpu]->sched_item); + snext =3D rt_item(sched_idle_item(cpu)); =20 /* if scurr has higher priority and budget, still pick scurr */ - if ( !is_idle_vcpu(current) && - vcpu_runnable(current) && + if ( !is_idle_item(curritem) && + item_runnable(curritem) && scurr->cur_budget > 0 && - ( is_idle_vcpu(snext->vcpu) || - compare_vcpu_priority(scurr, snext) > 0 ) ) + ( is_idle_item(snext->item) || + compare_item_priority(scurr, snext) > 0 ) ) snext =3D scurr; } =20 if ( snext !=3D scurr && - !is_idle_vcpu(current) && - vcpu_runnable(current) ) + !is_idle_item(curritem) && + item_runnable(curritem) ) __set_bit(__RTDS_delayed_runq_add, &scurr->flags); =20 snext->last_start =3D now; - ret.time =3D -1; /* if an idle vcpu is picked */ - if ( !is_idle_vcpu(snext->vcpu) ) + ret.time =3D -1; /* if an idle item is picked */ + if ( !is_idle_item(snext->item) ) { if ( snext !=3D scurr ) { q_remove(snext); __set_bit(__RTDS_scheduled, &snext->flags); } - if ( snext->vcpu->processor !=3D cpu ) + if ( sched_item_cpu(snext->item) !=3D cpu ) { - snext->vcpu->processor =3D cpu; - snext->vcpu->sched_item->res =3D per_cpu(sched_res, cpu); + sched_set_res(snext->item, per_cpu(sched_res, cpu)); ret.migrated =3D 1; } ret.time =3D snext->cur_budget; /* invoke the scheduler next time = */ } - ret.task =3D snext->vcpu->sched_item; + ret.task =3D snext->item; =20 return ret; } =20 /* - * Remove VCPU from RunQ + * Remove ITEM from RunQ * The lock is already grabbed in schedule.c, no need to lock here */ static void rt_item_sleep(const struct scheduler *ops, struct sched_item *item) { - struct vcpu *vc =3D item->vcpu; struct rt_item * const svc =3D rt_item(item); =20 - BUG_ON( is_idle_vcpu(vc) ); + BUG_ON( is_idle_item(item) ); SCHED_STAT_CRANK(item_sleep); =20 - if ( curr_on_cpu(vc->processor) =3D=3D item ) - cpu_raise_softirq(vc->processor, SCHEDULE_SOFTIRQ); - else if ( vcpu_on_q(svc) ) + if ( curr_on_cpu(sched_item_cpu(item)) =3D=3D item ) + cpu_raise_softirq(sched_item_cpu(item), SCHEDULE_SOFTIRQ); + else if ( item_on_q(svc) ) { q_remove(svc); replq_remove(ops, svc); @@ -1168,20 +1162,20 @@ rt_item_sleep(const struct scheduler *ops, struct s= ched_item *item) } =20 /* - * Pick a cpu where to run a vcpu, - * possibly kicking out the vcpu running there + * Pick a cpu where to run an item, + * possibly kicking out the item running there * Called by wake() and context_saved() * We have a running candidate here, the kick logic is: * Among all the cpus that are within the cpu affinity * 1) if there are any idle CPUs, kick one. For cache benefit, we check new->cpu as first * 2) now all pcpus are busy; - * among all the running vcpus, pick lowest priority one + * among all the running items, pick lowest priority one * if snext has higher priority, kick it. * * TODO: - * 1) what if these two vcpus belongs to the same domain? - * replace a vcpu belonging to the same domain introduces more overhead + * 1) what if these two items belongs to the same domain? + * replace an item belonging to the same domain introduces more overhead * * lock is grabbed before calling this function */ @@ -1189,18 +1183,18 @@ static void runq_tickle(const struct scheduler *ops, struct rt_item *new) { struct rt_private *prv =3D rt_priv(ops); - struct rt_item *latest_deadline_vcpu =3D NULL; /* lowest priority */ + struct rt_item *latest_deadline_item =3D NULL; /* lowest priority */ struct rt_item *iter_svc; - struct vcpu *iter_vc; + struct sched_item *iter_item; int cpu =3D 0, cpu_to_tickle =3D 0; cpumask_t not_tickled; cpumask_t *online; =20 - if ( new =3D=3D NULL || is_idle_vcpu(new->vcpu) ) + if ( new =3D=3D NULL || is_idle_item(new->item) ) return; =20 - online =3D cpupool_domain_cpumask(new->vcpu->domain); - cpumask_and(¬_tickled, online, new->vcpu->sched_item->cpu_hard_affi= nity); + online =3D cpupool_domain_cpumask(new->item->domain); + cpumask_and(¬_tickled, online, new->item->cpu_hard_affinity); cpumask_andnot(¬_tickled, ¬_tickled, &prv->tickled); =20 /* @@ -1208,31 +1202,31 @@ runq_tickle(const struct scheduler *ops, struct rt_= item *new) * For cache benefit,we first search new->cpu. * The same loop also find the one with lowest priority. */ - cpu =3D cpumask_test_or_cycle(new->vcpu->processor, ¬_tickled); + cpu =3D cpumask_test_or_cycle(sched_item_cpu(new->item), ¬_tickled); while ( cpu!=3D nr_cpu_ids ) { - iter_vc =3D curr_on_cpu(cpu)->vcpu; - if ( is_idle_vcpu(iter_vc) ) + iter_item =3D curr_on_cpu(cpu); + if ( is_idle_item(iter_item) ) { SCHED_STAT_CRANK(tickled_idle_cpu); cpu_to_tickle =3D cpu; goto out; } - iter_svc =3D rt_item(iter_vc->sched_item); - if ( latest_deadline_vcpu =3D=3D NULL || - compare_vcpu_priority(iter_svc, latest_deadline_vcpu) < 0 ) - latest_deadline_vcpu =3D iter_svc; + iter_svc =3D rt_item(iter_item); + if ( latest_deadline_item =3D=3D NULL || + compare_item_priority(iter_svc, latest_deadline_item) < 0 ) + latest_deadline_item =3D iter_svc; =20 cpumask_clear_cpu(cpu, ¬_tickled); cpu =3D cpumask_cycle(cpu, ¬_tickled); } =20 - /* 2) candicate has higher priority, kick out lowest priority vcpu */ - if ( latest_deadline_vcpu !=3D NULL && - compare_vcpu_priority(latest_deadline_vcpu, new) < 0 ) + /* 2) candicate has higher priority, kick out lowest priority item */ + if ( latest_deadline_item !=3D NULL && + compare_item_priority(latest_deadline_item, new) < 0 ) { SCHED_STAT_CRANK(tickled_busy_cpu); - cpu_to_tickle =3D latest_deadline_vcpu->vcpu->processor; + cpu_to_tickle =3D sched_item_cpu(latest_deadline_item->item); goto out; } =20 @@ -1258,35 +1252,34 @@ runq_tickle(const struct scheduler *ops, struct rt_= item *new) } =20 /* - * Should always wake up runnable vcpu, put it back to RunQ. + * Should always wake up runnable item, put it back to RunQ. * Check priority to raise interrupt * The lock is already grabbed in schedule.c, no need to lock here - * TODO: what if these two vcpus belongs to the same domain? + * TODO: what if these two items belongs to the same domain? */ static void rt_item_wake(const struct scheduler *ops, struct sched_item *item) { - struct vcpu *vc =3D item->vcpu; struct rt_item * const svc =3D rt_item(item); s_time_t now; bool_t missed; =20 - BUG_ON( is_idle_vcpu(vc) ); + BUG_ON( is_idle_item(item) ); =20 - if ( unlikely(curr_on_cpu(vc->processor) =3D=3D item) ) + if ( unlikely(curr_on_cpu(sched_item_cpu(item)) =3D=3D item) ) { SCHED_STAT_CRANK(item_wake_running); return; } =20 /* on RunQ/DepletedQ, just update info is ok */ - if ( unlikely(vcpu_on_q(svc)) ) + if ( unlikely(item_on_q(svc)) ) { SCHED_STAT_CRANK(item_wake_onrunq); return; } =20 - if ( likely(vcpu_runnable(vc)) ) + if ( likely(item_runnable(item)) ) SCHED_STAT_CRANK(item_wake_runnable); else SCHED_STAT_CRANK(item_wake_not_runnable); @@ -1302,16 +1295,16 @@ rt_item_wake(const struct scheduler *ops, struct sc= hed_item *item) rt_update_deadline(now, svc); =20 /* - * If context hasn't been saved for this vcpu yet, we can't put it on + * If context hasn't been saved for this item yet, we can't put it on * the run-queue/depleted-queue. Instead, we set the appropriate flag, - * the vcpu will be put back on queue after the context has been saved + * the item will be put back on queue after the context has been saved * (in rt_context_save()). */ if ( unlikely(svc->flags & RTDS_scheduled) ) { __set_bit(__RTDS_delayed_runq_add, &svc->flags); /* - * The vcpu is waking up already, and we didn't even had the time = to + * The item is waking up already, and we didn't even had the time = to * remove its next replenishment event from the replenishment queue * when it blocked! No big deal. If we did not miss the deadline in * the meantime, let's just leave it there. If we did, let's remov= e it @@ -1332,22 +1325,21 @@ rt_item_wake(const struct scheduler *ops, struct sc= hed_item *item) =20 /* * scurr has finished context switch, insert it back to the RunQ, - * and then pick the highest priority vcpu from runq to run + * and then pick the highest priority item from runq to run */ static void rt_context_saved(const struct scheduler *ops, struct sched_item *item) { - struct vcpu *vc =3D item->vcpu; struct rt_item *svc =3D rt_item(item); spinlock_t *lock =3D item_schedule_lock_irq(item); =20 __clear_bit(__RTDS_scheduled, &svc->flags); - /* not insert idle vcpu to runq */ - if ( is_idle_vcpu(vc) ) + /* not insert idle item to runq */ + if ( is_idle_item(item) ) goto out; =20 if ( __test_and_clear_bit(__RTDS_delayed_runq_add, &svc->flags) && - likely(vcpu_runnable(vc)) ) + likely(item_runnable(item)) ) { runq_insert(ops, svc); runq_tickle(ops, svc); @@ -1360,7 +1352,7 @@ out: } =20 /* - * set/get each vcpu info of each domain + * set/get each item info of each domain */ static int rt_dom_cntl( @@ -1370,7 +1362,7 @@ rt_dom_cntl( { struct rt_private *prv =3D rt_priv(ops); struct rt_item *svc; - struct vcpu *v; + struct sched_item *item; unsigned long flags; int rc =3D 0; struct xen_domctl_schedparam_vcpu local_sched; @@ -1391,9 +1383,9 @@ rt_dom_cntl( break; } spin_lock_irqsave(&prv->lock, flags); - for_each_vcpu ( d, v ) + for_each_sched_item ( d, item ) { - svc =3D rt_item(v->sched_item); + svc =3D rt_item(item); svc->period =3D MICROSECS(op->u.rtds.period); /* transfer to n= anosec */ svc->budget =3D MICROSECS(op->u.rtds.budget); } @@ -1461,7 +1453,7 @@ rt_dom_cntl( break; } if ( !rc ) - /* notify upper caller how many vcpus have been processed. */ + /* notify upper caller how many items have been processed. */ op->u.v.nr_vcpus =3D index; break; } @@ -1470,7 +1462,7 @@ rt_dom_cntl( } =20 /* - * The replenishment timer handler picks vcpus + * The replenishment timer handler picks items * from the replq and does the actual replenishment. */ static void repl_timer_handler(void *data){ @@ -1488,7 +1480,7 @@ static void repl_timer_handler(void *data){ now =3D NOW(); =20 /* - * Do the replenishment and move replenished vcpus + * Do the replenishment and move replenished items * to the temporary list to tickle. * If svc is on run queue, we need to put it at * the correct place since its deadline changes. @@ -1504,7 +1496,7 @@ static void repl_timer_handler(void *data){ rt_update_deadline(now, svc); list_add(&svc->replq_elem, &tmp_replq); =20 - if ( vcpu_on_q(svc) ) + if ( item_on_q(svc) ) { q_remove(svc); runq_insert(ops, svc); @@ -1512,26 +1504,26 @@ static void repl_timer_handler(void *data){ } =20 /* - * Iterate through the list of updated vcpus. - * If an updated vcpu is running, tickle the head of the + * Iterate through the list of updated items. + * If an updated item is running, tickle the head of the * runqueue if it has a higher priority. - * If an updated vcpu was depleted and on the runqueue, tickle it. - * Finally, reinsert the vcpus back to replenishement events list. + * If an updated item was depleted and on the runqueue, tickle it. + * Finally, reinsert the items back to replenishement events list. */ list_for_each_safe ( iter, tmp, &tmp_replq ) { svc =3D replq_elem(iter); =20 - if ( curr_on_cpu(svc->vcpu->processor) =3D=3D svc->vcpu->sched_ite= m && + if ( curr_on_cpu(sched_item_cpu(svc->item)) =3D=3D svc->item && !list_empty(runq) ) { struct rt_item *next_on_runq =3D q_elem(runq->next); =20 - if ( compare_vcpu_priority(svc, next_on_runq) < 0 ) + if ( compare_item_priority(svc, next_on_runq) < 0 ) runq_tickle(ops, next_on_runq); } else if ( __test_and_clear_bit(__RTDS_depleted, &svc->flags) && - vcpu_on_q(svc) ) + item_on_q(svc) ) runq_tickle(ops, svc); =20 list_del(&svc->replq_elem); @@ -1539,7 +1531,7 @@ static void repl_timer_handler(void *data){ } =20 /* - * If there are vcpus left in the replenishment event list, + * If there are items left in the replenishment event list, * set the next replenishment to happen at the deadline of * the one in the front. */ --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125918; cv=none; d=zoho.com; s=zohoarc; b=LCn8do32bCxbOLlOC8UyISu0P753vjgCVhq/3T+xU0g33VjOGR35mNGxjdQrqZ2wo6COQ9vL5FzCw6kYfK/eblgzrLJiAs2K6a/bu+wr6ji+dlP/LVzCHpoBGRl4CTe8kB7kWqdLHRxyp393rLWntQ5BvZA5yRMi1EduI6rPBjc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125918; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=/qaSiHGIto8KKJdxdcM3DhnnzaO4xEWjRfXsTi+p3+c=; b=IJvSliEfpbODQKruTaSE3iOuewr/yyu+eS9NtizSkNxd9gdlcqSuPbfTFY4oKm/27aLB0WbodyPREvlWrqEkFHLnPU/oSq0b31huua25Z58plsSnk+SC6SbYVVaFOBbi11SA0h60I/LAgJHW9HkdX9UMEOVsYhxZtXt1zsbWUws= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125918434977.0522386414559; Sun, 5 May 2019 23:58:38 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXZ6-000350-Gf; Mon, 06 May 2019 06:57:32 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYn-0002K0-Ey for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:13 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 236f0133-6fcc-11e9-843c-bc764e045a96; Mon, 06 May 2019 06:56:57 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 31FFFAF21; Mon, 6 May 2019 06:56:54 +0000 (UTC) X-Inumbo-ID: 236f0133-6fcc-11e9-843c-bc764e045a96 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:19 +0200 Message-Id: <20190506065644.7415-21-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 20/45] xen/sched: make credit scheduler vcpu agnostic. X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , George Dunlap , Dario Faggioli MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Switch credit scheduler completely from vcpu to sched_item usage. Signed-off-by: Juergen Gross --- xen/common/sched_credit.c | 504 +++++++++++++++++++++++-------------------= ---- 1 file changed, 251 insertions(+), 253 deletions(-) diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index 77bebf5b42..babccb69f7 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -70,10 +70,10 @@ * inconsistent set of locks. Therefore atomic-safe bit operations must * be used for accessing it. */ -#define CSCHED_FLAG_VCPU_PARKED 0x0 /* VCPU over capped credits */ -#define CSCHED_FLAG_VCPU_YIELD 0x1 /* VCPU yielding */ -#define CSCHED_FLAG_VCPU_MIGRATING 0x2 /* VCPU may have moved to a new pc= pu */ -#define CSCHED_FLAG_VCPU_PINNED 0x4 /* VCPU can run only on 1 pcpu */ +#define CSCHED_FLAG_ITEM_PARKED 0x0 /* ITEM over capped credits */ +#define CSCHED_FLAG_ITEM_YIELD 0x1 /* ITEM yielding */ +#define CSCHED_FLAG_ITEM_MIGRATING 0x2 /* ITEM may have moved to a new pc= pu */ +#define CSCHED_FLAG_ITEM_PINNED 0x4 /* ITEM can run only on 1 pcpu */ =20 =20 /* @@ -91,7 +91,7 @@ /* * CSCHED_STATS * - * Manage very basic per-vCPU counters and stats. + * Manage very basic per-item counters and stats. * * Useful for debugging live systems. The stats are displayed * with runq dumps ('r' on the Xen console). @@ -100,23 +100,23 @@ =20 #define CSCHED_STATS =20 -#define SCHED_VCPU_STATS_RESET(_V) \ +#define SCHED_ITEM_STATS_RESET(_V) \ do \ { \ memset(&(_V)->stats, 0, sizeof((_V)->stats)); \ } while ( 0 ) =20 -#define SCHED_VCPU_STAT_CRANK(_V, _X) (((_V)->stats._X)++) +#define SCHED_ITEM_STAT_CRANK(_V, _X) (((_V)->stats._X)++) =20 -#define SCHED_VCPU_STAT_SET(_V, _X, _Y) (((_V)->stats._X) =3D (_Y)) +#define SCHED_ITEM_STAT_SET(_V, _X, _Y) (((_V)->stats._X) =3D (_Y)) =20 #else /* !SCHED_STATS */ =20 #undef CSCHED_STATS =20 -#define SCHED_VCPU_STATS_RESET(_V) do {} while ( 0 ) -#define SCHED_VCPU_STAT_CRANK(_V, _X) do {} while ( 0 ) -#define SCHED_VCPU_STAT_SET(_V, _X, _Y) do {} while ( 0 ) +#define SCHED_ITEM_STATS_RESET(_V) do {} while ( 0 ) +#define SCHED_ITEM_STAT_CRANK(_V, _X) do {} while ( 0 ) +#define SCHED_ITEM_STAT_SET(_V, _X, _Y) do {} while ( 0 ) =20 #endif /* SCHED_STATS */ =20 @@ -128,7 +128,7 @@ #define TRC_CSCHED_SCHED_TASKLET TRC_SCHED_CLASS_EVT(CSCHED, 1) #define TRC_CSCHED_ACCOUNT_START TRC_SCHED_CLASS_EVT(CSCHED, 2) #define TRC_CSCHED_ACCOUNT_STOP TRC_SCHED_CLASS_EVT(CSCHED, 3) -#define TRC_CSCHED_STOLEN_VCPU TRC_SCHED_CLASS_EVT(CSCHED, 4) +#define TRC_CSCHED_STOLEN_ITEM TRC_SCHED_CLASS_EVT(CSCHED, 4) #define TRC_CSCHED_PICKED_CPU TRC_SCHED_CLASS_EVT(CSCHED, 5) #define TRC_CSCHED_TICKLE TRC_SCHED_CLASS_EVT(CSCHED, 6) #define TRC_CSCHED_BOOST_START TRC_SCHED_CLASS_EVT(CSCHED, 7) @@ -158,15 +158,15 @@ struct csched_pcpu { }; =20 /* - * Virtual CPU + * Virtual ITEM */ struct csched_item { struct list_head runq_elem; - struct list_head active_vcpu_elem; + struct list_head active_item_elem; =20 /* Up-pointers */ struct csched_dom *sdom; - struct vcpu *vcpu; + struct sched_item *item; =20 s_time_t start_time; /* When we were scheduled (used for credit) */ unsigned flags; @@ -192,10 +192,10 @@ struct csched_item { * Domain */ struct csched_dom { - struct list_head active_vcpu; + struct list_head active_item; struct list_head active_sdom_elem; struct domain *dom; - uint16_t active_vcpu_count; + uint16_t active_item_count; uint16_t weight; uint16_t cap; }; @@ -215,7 +215,7 @@ struct csched_private { =20 /* Period of master and tick in milliseconds */ unsigned int tick_period_us, ticks_per_tslice; - s_time_t ratelimit, tslice, vcpu_migr_delay; + s_time_t ratelimit, tslice, item_migr_delay; =20 struct list_head active_sdom; uint32_t weight; @@ -231,7 +231,7 @@ static void csched_tick(void *_cpu); static void csched_acct(void *dummy); =20 static inline int -__vcpu_on_runq(struct csched_item *svc) +__item_on_runq(struct csched_item *svc) { return !list_empty(&svc->runq_elem); } @@ -242,7 +242,7 @@ __runq_elem(struct list_head *elem) return list_entry(elem, struct csched_item, runq_elem); } =20 -/* Is the first element of cpu's runq (if any) cpu's idle vcpu? */ +/* Is the first element of cpu's runq (if any) cpu's idle item? */ static inline bool_t is_runq_idle(unsigned int cpu) { /* @@ -251,7 +251,7 @@ static inline bool_t is_runq_idle(unsigned int cpu) ASSERT(spin_is_locked(per_cpu(sched_res, cpu)->schedule_lock)); =20 return list_empty(RUNQ(cpu)) || - is_idle_vcpu(__runq_elem(RUNQ(cpu)->next)->vcpu); + is_idle_item(__runq_elem(RUNQ(cpu)->next)->item); } =20 static inline void @@ -273,11 +273,11 @@ dec_nr_runnable(unsigned int cpu) static inline void __runq_insert(struct csched_item *svc) { - unsigned int cpu =3D svc->vcpu->processor; + unsigned int cpu =3D sched_item_cpu(svc->item); const struct list_head * const runq =3D RUNQ(cpu); struct list_head *iter; =20 - BUG_ON( __vcpu_on_runq(svc) ); + BUG_ON( __item_on_runq(svc) ); =20 list_for_each( iter, runq ) { @@ -286,10 +286,10 @@ __runq_insert(struct csched_item *svc) break; } =20 - /* If the vcpu yielded, try to put it behind one lower-priority - * runnable vcpu if we can. The next runq_sort will bring it forward + /* If the item yielded, try to put it behind one lower-priority + * runnable item if we can. The next runq_sort will bring it forward * within 30ms if the queue too long. */ - if ( test_bit(CSCHED_FLAG_VCPU_YIELD, &svc->flags) + if ( test_bit(CSCHED_FLAG_ITEM_YIELD, &svc->flags) && __runq_elem(iter)->pri > CSCHED_PRI_IDLE ) { iter=3Diter->next; @@ -305,20 +305,20 @@ static inline void runq_insert(struct csched_item *svc) { __runq_insert(svc); - inc_nr_runnable(svc->vcpu->processor); + inc_nr_runnable(sched_item_cpu(svc->item)); } =20 static inline void __runq_remove(struct csched_item *svc) { - BUG_ON( !__vcpu_on_runq(svc) ); + BUG_ON( !__item_on_runq(svc) ); list_del_init(&svc->runq_elem); } =20 static inline void runq_remove(struct csched_item *svc) { - dec_nr_runnable(svc->vcpu->processor); + dec_nr_runnable(sched_item_cpu(svc->item)); __runq_remove(svc); } =20 @@ -329,7 +329,7 @@ static void burn_credits(struct csched_item *svc, s_tim= e_t now) unsigned int credits; =20 /* Assert svc is current */ - ASSERT( svc =3D=3D CSCHED_ITEM(curr_on_cpu(svc->vcpu->processor)) ); + ASSERT( svc =3D=3D CSCHED_ITEM(curr_on_cpu(sched_item_cpu(svc->item)))= ); =20 if ( (delta =3D now - svc->start_time) <=3D 0 ) return; @@ -349,8 +349,8 @@ DEFINE_PER_CPU(unsigned int, last_tickle_cpu); =20 static inline void __runq_tickle(struct csched_item *new) { - unsigned int cpu =3D new->vcpu->processor; - struct sched_item *item =3D new->vcpu->sched_item; + unsigned int cpu =3D sched_item_cpu(new->item); + struct sched_item *item =3D new->item; struct csched_item * const cur =3D CSCHED_ITEM(curr_on_cpu(cpu)); struct csched_private *prv =3D CSCHED_PRIV(per_cpu(scheduler, cpu)); cpumask_t mask, idle_mask, *online; @@ -364,16 +364,16 @@ static inline void __runq_tickle(struct csched_item *= new) idlers_empty =3D cpumask_empty(&idle_mask); =20 /* - * Exclusive pinning is when a vcpu has hard-affinity with only one - * cpu, and there is no other vcpu that has hard-affinity with that + * Exclusive pinning is when a item has hard-affinity with only one + * cpu, and there is no other item that has hard-affinity with that * same cpu. This is infrequent, but if it happens, is for achieving * the most possible determinism, and least possible overhead for - * the vcpus in question. + * the items in question. * * Try to identify the vast majority of these situations, and deal * with them quickly. */ - if ( unlikely(test_bit(CSCHED_FLAG_VCPU_PINNED, &new->flags) && + if ( unlikely(test_bit(CSCHED_FLAG_ITEM_PINNED, &new->flags) && cpumask_test_cpu(cpu, &idle_mask)) ) { ASSERT(cpumask_cycle(cpu, item->cpu_hard_affinity) =3D=3D cpu); @@ -384,7 +384,7 @@ static inline void __runq_tickle(struct csched_item *ne= w) =20 /* * If the pcpu is idle, or there are no idlers and the new - * vcpu is a higher priority than the old vcpu, run it here. + * item is a higher priority than the old item, run it here. * * If there are idle cpus, first try to find one suitable to run * new, so we can avoid preempting cur. If we cannot find a @@ -403,7 +403,7 @@ static inline void __runq_tickle(struct csched_item *ne= w) else if ( !idlers_empty ) { /* - * Soft and hard affinity balancing loop. For vcpus without + * Soft and hard affinity balancing loop. For items without * a useful soft affinity, consider hard affinity only. */ for_each_affinity_balance_step( balance_step ) @@ -446,10 +446,10 @@ static inline void __runq_tickle(struct csched_item *= new) { if ( cpumask_intersects(item->cpu_hard_affinity, &idle_mas= k) ) { - SCHED_VCPU_STAT_CRANK(cur, kicked_away); - SCHED_VCPU_STAT_CRANK(cur, migrate_r); + SCHED_ITEM_STAT_CRANK(cur, kicked_away); + SCHED_ITEM_STAT_CRANK(cur, migrate_r); SCHED_STAT_CRANK(migrate_kicked_away); - set_bit(_VPF_migrating, &cur->vcpu->pause_flags); + sched_set_pause_flags_atomic(cur->item, _VPF_migrating= ); } /* Tickle cpu anyway, to let new preempt cur. */ SCHED_STAT_CRANK(tickled_busy_cpu); @@ -605,7 +605,7 @@ init_pdata(struct csched_private *prv, struct csched_pc= pu *spc, int cpu) spc->idle_bias =3D nr_cpu_ids - 1; =20 /* Start off idling... */ - BUG_ON(!is_idle_vcpu(curr_on_cpu(cpu)->vcpu)); + BUG_ON(!is_idle_item(curr_on_cpu(cpu))); cpumask_set_cpu(cpu, prv->idlers); spc->nr_runnable =3D 0; } @@ -639,9 +639,9 @@ csched_switch_sched(struct scheduler *new_ops, unsigned= int cpu, struct csched_private *prv =3D CSCHED_PRIV(new_ops); struct csched_item *svc =3D vdata; =20 - ASSERT(svc && is_idle_vcpu(svc->vcpu)); + ASSERT(svc && is_idle_item(svc->item)); =20 - idle_vcpu[cpu]->sched_item->priv =3D vdata; + sched_idle_item(cpu)->priv =3D vdata; =20 /* * We are holding the runqueue lock already (it's been taken in @@ -667,33 +667,33 @@ csched_switch_sched(struct scheduler *new_ops, unsign= ed int cpu, =20 #ifndef NDEBUG static inline void -__csched_vcpu_check(struct vcpu *vc) +__csched_item_check(struct sched_item *item) { - struct csched_item * const svc =3D CSCHED_ITEM(vc->sched_item); + struct csched_item * const svc =3D CSCHED_ITEM(item); struct csched_dom * const sdom =3D svc->sdom; =20 - BUG_ON( svc->vcpu !=3D vc ); - BUG_ON( sdom !=3D CSCHED_DOM(vc->domain) ); + BUG_ON( svc->item !=3D item ); + BUG_ON( sdom !=3D CSCHED_DOM(item->domain) ); if ( sdom ) { - BUG_ON( is_idle_vcpu(vc) ); - BUG_ON( sdom->dom !=3D vc->domain ); + BUG_ON( is_idle_item(item) ); + BUG_ON( sdom->dom !=3D item->domain ); } else { - BUG_ON( !is_idle_vcpu(vc) ); + BUG_ON( !is_idle_item(item) ); } =20 SCHED_STAT_CRANK(item_check); } -#define CSCHED_VCPU_CHECK(_vc) (__csched_vcpu_check(_vc)) +#define CSCHED_ITEM_CHECK(item) (__csched_item_check(item)) #else -#define CSCHED_VCPU_CHECK(_vc) +#define CSCHED_ITEM_CHECK(item) #endif =20 /* - * Delay, in microseconds, between migrations of a VCPU between PCPUs. - * This prevents rapid fluttering of a VCPU between CPUs, and reduces the + * Delay, in microseconds, between migrations of a ITEM between PCPUs. + * This prevents rapid fluttering of a ITEM between CPUs, and reduces the * implicit overheads such as cache-warming. 1ms (1000) has been measured * as a good value. */ @@ -701,10 +701,11 @@ static unsigned int vcpu_migration_delay_us; integer_param("vcpu_migration_delay", vcpu_migration_delay_us); =20 static inline bool -__csched_vcpu_is_cache_hot(const struct csched_private *prv, struct vcpu *= v) +__csched_item_is_cache_hot(const struct csched_private *prv, + struct sched_item *item) { - bool hot =3D prv->vcpu_migr_delay && - (NOW() - v->sched_item->last_run_time) < prv->vcpu_migr_del= ay; + bool hot =3D prv->item_migr_delay && + (NOW() - item->last_run_time) < prv->item_migr_delay; =20 if ( hot ) SCHED_STAT_CRANK(item_hot); @@ -713,36 +714,38 @@ __csched_vcpu_is_cache_hot(const struct csched_privat= e *prv, struct vcpu *v) } =20 static inline int -__csched_vcpu_is_migrateable(const struct csched_private *prv, struct vcpu= *vc, +__csched_item_is_migrateable(const struct csched_private *prv, + struct sched_item *item, int dest_cpu, cpumask_t *mask) { /* * Don't pick up work that's hot on peer PCPU, or that can't (or * would prefer not to) run on cpu. * - * The caller is supposed to have already checked that vc is also + * The caller is supposed to have already checked that item is also * not running. */ - ASSERT(!vc->sched_item->is_running); + ASSERT(!item->is_running); =20 - return !__csched_vcpu_is_cache_hot(prv, vc) && + return !__csched_item_is_cache_hot(prv, item) && cpumask_test_cpu(dest_cpu, mask); } =20 static int -_csched_cpu_pick(const struct scheduler *ops, struct vcpu *vc, bool_t comm= it) +_csched_cpu_pick(const struct scheduler *ops, struct sched_item *item, + bool_t commit) { - /* We must always use vc->procssor's scratch space */ - cpumask_t *cpus =3D cpumask_scratch_cpu(vc->processor); + int cpu =3D sched_item_cpu(item); + /* We must always use cpu's scratch space */ + cpumask_t *cpus =3D cpumask_scratch_cpu(cpu); cpumask_t idlers; - cpumask_t *online =3D cpupool_domain_cpumask(vc->domain); + cpumask_t *online =3D cpupool_domain_cpumask(item->domain); struct csched_pcpu *spc =3D NULL; - int cpu =3D vc->processor; int balance_step; =20 for_each_affinity_balance_step( balance_step ) { - affinity_balance_cpumask(vc->sched_item, balance_step, cpus); + affinity_balance_cpumask(item, balance_step, cpus); cpumask_and(cpus, online, cpus); /* * We want to pick up a pcpu among the ones that are online and @@ -761,12 +764,13 @@ _csched_cpu_pick(const struct scheduler *ops, struct = vcpu *vc, bool_t commit) * balancing step all together. */ if ( balance_step =3D=3D BALANCE_SOFT_AFFINITY && - (!has_soft_affinity(vc->sched_item) || cpumask_empty(cpus)) ) + (!has_soft_affinity(item) || cpumask_empty(cpus)) ) continue; =20 /* If present, prefer vc's current processor */ - cpu =3D cpumask_test_cpu(vc->processor, cpus) - ? vc->processor : cpumask_cycle(vc->processor, cpus); + cpu =3D cpumask_test_cpu(sched_item_cpu(item), cpus) + ? sched_item_cpu(item) + : cpumask_cycle(sched_item_cpu(item), cpus); ASSERT(cpumask_test_cpu(cpu, cpus)); =20 /* @@ -778,15 +782,15 @@ _csched_cpu_pick(const struct scheduler *ops, struct = vcpu *vc, bool_t commit) * We give preference to the idle execution vehicle with the most * idling neighbours in its grouping. This distributes work across * distinct cores first and guarantees we don't do something stupid - * like run two VCPUs on co-hyperthreads while there are idle cores + * like run two ITEMs on co-hyperthreads while there are idle cores * or sockets. * * Notice that, when computing the "idleness" of cpu, we may want = to - * discount vc. That is, iff vc is the currently running and the o= nly - * runnable vcpu on cpu, we add cpu to the idlers. + * discount item. That is, iff item is the currently running and t= he + * only runnable item on cpu, we add cpu to the idlers. */ cpumask_and(&idlers, &cpu_online_map, CSCHED_PRIV(ops)->idlers); - if ( vc->processor =3D=3D cpu && is_runq_idle(cpu) ) + if ( sched_item_cpu(item) =3D=3D cpu && is_runq_idle(cpu) ) __cpumask_set_cpu(cpu, &idlers); cpumask_and(cpus, &idlers, cpus); =20 @@ -796,7 +800,7 @@ _csched_cpu_pick(const struct scheduler *ops, struct vc= pu *vc, bool_t commit) * CPU, as we just &&-ed it with idlers). In fact, if we are on SM= T, and * cpu points to a busy thread with an idle sibling, both the thre= ads * will be considered the same, from the "idleness" calculation po= int - * of view", preventing vcpu from being moved to the thread that is + * of view", preventing item from being moved to the thread that is * actually idle. * * Notice that cpumask_test_cpu() is quicker than cpumask_empty(),= so @@ -862,7 +866,8 @@ _csched_cpu_pick(const struct scheduler *ops, struct vc= pu *vc, bool_t commit) if ( commit && spc ) spc->idle_bias =3D cpu; =20 - TRACE_3D(TRC_CSCHED_PICKED_CPU, vc->domain->domain_id, vc->vcpu_id, cp= u); + TRACE_3D(TRC_CSCHED_PICKED_CPU, item->domain->domain_id, item->item_id, + cpu); =20 return cpu; } @@ -870,7 +875,6 @@ _csched_cpu_pick(const struct scheduler *ops, struct vc= pu *vc, bool_t commit) static struct sched_resource * csched_res_pick(const struct scheduler *ops, struct sched_item *item) { - struct vcpu *vc =3D item->vcpu; struct csched_item *svc =3D CSCHED_ITEM(item); =20 /* @@ -880,26 +884,26 @@ csched_res_pick(const struct scheduler *ops, struct s= ched_item *item) * csched_item_wake() (still called from vcpu_migrate()) we won't * get boosted, which we don't deserve as we are "only" migrating. */ - set_bit(CSCHED_FLAG_VCPU_MIGRATING, &svc->flags); - return per_cpu(sched_res, _csched_cpu_pick(ops, vc, 1)); + set_bit(CSCHED_FLAG_ITEM_MIGRATING, &svc->flags); + return per_cpu(sched_res, _csched_cpu_pick(ops, item, 1)); } =20 static inline void -__csched_vcpu_acct_start(struct csched_private *prv, struct csched_item *s= vc) +__csched_item_acct_start(struct csched_private *prv, struct csched_item *s= vc) { struct csched_dom * const sdom =3D svc->sdom; unsigned long flags; =20 spin_lock_irqsave(&prv->lock, flags); =20 - if ( list_empty(&svc->active_vcpu_elem) ) + if ( list_empty(&svc->active_item_elem) ) { - SCHED_VCPU_STAT_CRANK(svc, state_active); + SCHED_ITEM_STAT_CRANK(svc, state_active); SCHED_STAT_CRANK(acct_item_active); =20 - sdom->active_vcpu_count++; - list_add(&svc->active_vcpu_elem, &sdom->active_vcpu); - /* Make weight per-vcpu */ + sdom->active_item_count++; + list_add(&svc->active_item_elem, &sdom->active_item); + /* Make weight per-item */ prv->weight +=3D sdom->weight; if ( list_empty(&sdom->active_sdom_elem) ) { @@ -908,56 +912,56 @@ __csched_vcpu_acct_start(struct csched_private *prv, = struct csched_item *svc) } =20 TRACE_3D(TRC_CSCHED_ACCOUNT_START, sdom->dom->domain_id, - svc->vcpu->vcpu_id, sdom->active_vcpu_count); + svc->item->item_id, sdom->active_item_count); =20 spin_unlock_irqrestore(&prv->lock, flags); } =20 static inline void -__csched_vcpu_acct_stop_locked(struct csched_private *prv, +__csched_item_acct_stop_locked(struct csched_private *prv, struct csched_item *svc) { struct csched_dom * const sdom =3D svc->sdom; =20 - BUG_ON( list_empty(&svc->active_vcpu_elem) ); + BUG_ON( list_empty(&svc->active_item_elem) ); =20 - SCHED_VCPU_STAT_CRANK(svc, state_idle); + SCHED_ITEM_STAT_CRANK(svc, state_idle); SCHED_STAT_CRANK(acct_item_idle); =20 BUG_ON( prv->weight < sdom->weight ); - sdom->active_vcpu_count--; - list_del_init(&svc->active_vcpu_elem); + sdom->active_item_count--; + list_del_init(&svc->active_item_elem); prv->weight -=3D sdom->weight; - if ( list_empty(&sdom->active_vcpu) ) + if ( list_empty(&sdom->active_item) ) { list_del_init(&sdom->active_sdom_elem); } =20 TRACE_3D(TRC_CSCHED_ACCOUNT_STOP, sdom->dom->domain_id, - svc->vcpu->vcpu_id, sdom->active_vcpu_count); + svc->item->item_id, sdom->active_item_count); } =20 static void -csched_vcpu_acct(struct csched_private *prv, unsigned int cpu) +csched_item_acct(struct csched_private *prv, unsigned int cpu) { struct sched_item *curritem =3D current->sched_item; struct csched_item * const svc =3D CSCHED_ITEM(curritem); const struct scheduler *ops =3D per_cpu(scheduler, cpu); =20 - ASSERT( current->processor =3D=3D cpu ); + ASSERT( sched_item_cpu(curritem) =3D=3D cpu ); ASSERT( svc->sdom !=3D NULL ); - ASSERT( !is_idle_vcpu(svc->vcpu) ); + ASSERT( !is_idle_item(svc->item) ); =20 /* - * If this VCPU's priority was boosted when it last awoke, reset it. - * If the VCPU is found here, then it's consuming a non-negligeable + * If this ITEM's priority was boosted when it last awoke, reset it. + * If the ITEM is found here, then it's consuming a non-negligeable * amount of CPU resources and should no longer be boosted. */ if ( svc->pri =3D=3D CSCHED_PRI_TS_BOOST ) { svc->pri =3D CSCHED_PRI_TS_UNDER; TRACE_2D(TRC_CSCHED_BOOST_END, svc->sdom->dom->domain_id, - svc->vcpu->vcpu_id); + svc->item->item_id); } =20 /* @@ -966,12 +970,12 @@ csched_vcpu_acct(struct csched_private *prv, unsigned= int cpu) burn_credits(svc, NOW()); =20 /* - * Put this VCPU and domain back on the active list if it was + * Put this ITEM and domain back on the active list if it was * idling. */ - if ( list_empty(&svc->active_vcpu_elem) ) + if ( list_empty(&svc->active_item_elem) ) { - __csched_vcpu_acct_start(prv, svc); + __csched_item_acct_start(prv, svc); } else { @@ -984,15 +988,15 @@ csched_vcpu_acct(struct csched_private *prv, unsigned= int cpu) * migrating it to run elsewhere (see multi-core and multi-thread * support in csched_res_pick()). */ - new_cpu =3D _csched_cpu_pick(ops, current, 0); + new_cpu =3D _csched_cpu_pick(ops, curritem, 0); =20 item_schedule_unlock_irqrestore(lock, flags, curritem); =20 if ( new_cpu !=3D cpu ) { - SCHED_VCPU_STAT_CRANK(svc, migrate_r); + SCHED_ITEM_STAT_CRANK(svc, migrate_r); SCHED_STAT_CRANK(migrate_running); - set_bit(_VPF_migrating, ¤t->pause_flags); + sched_set_pause_flags_atomic(curritem, _VPF_migrating); /* * As we are about to tickle cpu, we should clear its bit in * idlers. But, if we are here, it means there is someone runn= ing @@ -1009,21 +1013,20 @@ static void * csched_alloc_vdata(const struct scheduler *ops, struct sched_item *item, void *dd) { - struct vcpu *vc =3D item->vcpu; struct csched_item *svc; =20 - /* Allocate per-VCPU info */ + /* Allocate per-ITEM info */ svc =3D xzalloc(struct csched_item); if ( svc =3D=3D NULL ) return NULL; =20 INIT_LIST_HEAD(&svc->runq_elem); - INIT_LIST_HEAD(&svc->active_vcpu_elem); + INIT_LIST_HEAD(&svc->active_item_elem); svc->sdom =3D dd; - svc->vcpu =3D vc; - svc->pri =3D is_idle_domain(vc->domain) ? + svc->item =3D item; + svc->pri =3D is_idle_item(item) ? CSCHED_PRI_IDLE : CSCHED_PRI_TS_UNDER; - SCHED_VCPU_STATS_RESET(svc); + SCHED_ITEM_STATS_RESET(svc); SCHED_STAT_CRANK(item_alloc); return svc; } @@ -1031,24 +1034,21 @@ csched_alloc_vdata(const struct scheduler *ops, str= uct sched_item *item, static void csched_item_insert(const struct scheduler *ops, struct sched_item *item) { - struct vcpu *vc =3D item->vcpu; struct csched_item *svc =3D item->priv; spinlock_t *lock; =20 - BUG_ON( is_idle_vcpu(vc) ); + BUG_ON( is_idle_item(item) ); =20 /* csched_res_pick() looks in vc->processor's runq, so we need the loc= k. */ lock =3D item_schedule_lock_irq(item); =20 - item->res =3D csched_res_pick(ops, item); - vc->processor =3D item->res->processor; + sched_set_res(item, csched_res_pick(ops, item)); =20 spin_unlock_irq(lock); =20 lock =3D item_schedule_lock_irq(item); =20 - if ( !__vcpu_on_runq(svc) && vcpu_runnable(vc) && - !vc->sched_item->is_running ) + if ( !__item_on_runq(svc) && item_runnable(item) && !item->is_running ) runq_insert(svc); =20 item_schedule_unlock_irq(lock, item); @@ -1075,18 +1075,18 @@ csched_item_remove(const struct scheduler *ops, str= uct sched_item *item) =20 SCHED_STAT_CRANK(item_remove); =20 - ASSERT(!__vcpu_on_runq(svc)); + ASSERT(!__item_on_runq(svc)); =20 - if ( test_and_clear_bit(CSCHED_FLAG_VCPU_PARKED, &svc->flags) ) + if ( test_and_clear_bit(CSCHED_FLAG_ITEM_PARKED, &svc->flags) ) { SCHED_STAT_CRANK(item_unpark); - vcpu_unpause(svc->vcpu); + vcpu_unpause(svc->item->vcpu); } =20 spin_lock_irq(&prv->lock); =20 - if ( !list_empty(&svc->active_vcpu_elem) ) - __csched_vcpu_acct_stop_locked(prv, svc); + if ( !list_empty(&svc->active_item_elem) ) + __csched_item_acct_stop_locked(prv, svc); =20 spin_unlock_irq(&prv->lock); =20 @@ -1096,86 +1096,85 @@ csched_item_remove(const struct scheduler *ops, str= uct sched_item *item) static void csched_item_sleep(const struct scheduler *ops, struct sched_item *item) { - struct vcpu *vc =3D item->vcpu; struct csched_item * const svc =3D CSCHED_ITEM(item); - unsigned int cpu =3D vc->processor; + unsigned int cpu =3D sched_item_cpu(item); =20 SCHED_STAT_CRANK(item_sleep); =20 - BUG_ON( is_idle_vcpu(vc) ); + BUG_ON( is_idle_item(item) ); =20 if ( curr_on_cpu(cpu) =3D=3D item ) { /* * We are about to tickle cpu, so we should clear its bit in idler= s. - * But, we are here because vc is going to sleep while running on = cpu, + * But, we are here because item is going to sleep while running o= n cpu, * so the bit must be zero already. */ ASSERT(!cpumask_test_cpu(cpu, CSCHED_PRIV(per_cpu(scheduler, cpu))= ->idlers)); cpu_raise_softirq(cpu, SCHEDULE_SOFTIRQ); } - else if ( __vcpu_on_runq(svc) ) + else if ( __item_on_runq(svc) ) runq_remove(svc); } =20 static void csched_item_wake(const struct scheduler *ops, struct sched_item *item) { - struct vcpu *vc =3D item->vcpu; struct csched_item * const svc =3D CSCHED_ITEM(item); bool_t migrating; =20 - BUG_ON( is_idle_vcpu(vc) ); + BUG_ON( is_idle_item(item) ); =20 - if ( unlikely(curr_on_cpu(vc->processor) =3D=3D item) ) + if ( unlikely(curr_on_cpu(sched_item_cpu(item)) =3D=3D item) ) { SCHED_STAT_CRANK(item_wake_running); return; } - if ( unlikely(__vcpu_on_runq(svc)) ) + if ( unlikely(__item_on_runq(svc)) ) { SCHED_STAT_CRANK(item_wake_onrunq); return; } =20 - if ( likely(vcpu_runnable(vc)) ) + if ( likely(item_runnable(item)) ) SCHED_STAT_CRANK(item_wake_runnable); else SCHED_STAT_CRANK(item_wake_not_runnable); =20 /* - * We temporarly boost the priority of awaking VCPUs! + * We temporarily boost the priority of awaking ITEMs! * - * If this VCPU consumes a non negligeable amount of CPU, it + * If this ITEM consumes a non negligible amount of CPU, it * will eventually find itself in the credit accounting code * path where its priority will be reset to normal. * - * If on the other hand the VCPU consumes little CPU and is + * If on the other hand the ITEM consumes little CPU and is * blocking and awoken a lot (doing I/O for example), its * priority will remain boosted, optimizing it's wake-to-run * latencies. * - * This allows wake-to-run latency sensitive VCPUs to preempt - * more CPU resource intensive VCPUs without impacting overall=20 + * This allows wake-to-run latency sensitive ITEMs to preempt + * more CPU resource intensive ITEMs without impacting overall * system fairness. * * There are two cases, when we don't want to boost: - * - VCPUs that are waking up after a migration, rather than + * - ITEMs that are waking up after a migration, rather than * after having block; - * - VCPUs of capped domains unpausing after earning credits + * - ITEMs of capped domains unpausing after earning credits * they had overspent. */ - migrating =3D test_and_clear_bit(CSCHED_FLAG_VCPU_MIGRATING, &svc->fla= gs); + migrating =3D test_and_clear_bit(CSCHED_FLAG_ITEM_MIGRATING, &svc->fla= gs); =20 if ( !migrating && svc->pri =3D=3D CSCHED_PRI_TS_UNDER && - !test_bit(CSCHED_FLAG_VCPU_PARKED, &svc->flags) ) + !test_bit(CSCHED_FLAG_ITEM_PARKED, &svc->flags) ) { - TRACE_2D(TRC_CSCHED_BOOST_START, vc->domain->domain_id, vc->vcpu_i= d); + TRACE_2D(TRC_CSCHED_BOOST_START, item->domain->domain_id, + item->item_id); SCHED_STAT_CRANK(item_boost); svc->pri =3D CSCHED_PRI_TS_BOOST; } =20 - /* Put the VCPU on the runq and tickle CPUs */ + /* Put the ITEM on the runq and tickle CPUs */ runq_insert(svc); __runq_tickle(svc); } @@ -1186,7 +1185,7 @@ csched_item_yield(const struct scheduler *ops, struct= sched_item *item) struct csched_item * const svc =3D CSCHED_ITEM(item); =20 /* Let the scheduler know that this vcpu is trying to yield */ - set_bit(CSCHED_FLAG_VCPU_YIELD, &svc->flags); + set_bit(CSCHED_FLAG_ITEM_YIELD, &svc->flags); } =20 static int @@ -1215,8 +1214,8 @@ csched_dom_cntl( { if ( !list_empty(&sdom->active_sdom_elem) ) { - prv->weight -=3D sdom->weight * sdom->active_vcpu_count; - prv->weight +=3D op->u.credit.weight * sdom->active_vcpu_c= ount; + prv->weight -=3D sdom->weight * sdom->active_item_count; + prv->weight +=3D op->u.credit.weight * sdom->active_item_c= ount; } sdom->weight =3D op->u.credit.weight; } @@ -1245,9 +1244,9 @@ csched_aff_cntl(const struct scheduler *ops, struct s= ched_item *item, =20 /* Are we becoming exclusively pinned? */ if ( cpumask_weight(hard) =3D=3D 1 ) - set_bit(CSCHED_FLAG_VCPU_PINNED, &svc->flags); + set_bit(CSCHED_FLAG_ITEM_PINNED, &svc->flags); else - clear_bit(CSCHED_FLAG_VCPU_PINNED, &svc->flags); + clear_bit(CSCHED_FLAG_ITEM_PINNED, &svc->flags); } =20 static inline void @@ -1290,14 +1289,14 @@ csched_sys_cntl(const struct scheduler *ops, else if ( prv->ratelimit && !params->ratelimit_us ) printk(XENLOG_INFO "Disabling context switch rate limiting\n"); prv->ratelimit =3D MICROSECS(params->ratelimit_us); - prv->vcpu_migr_delay =3D MICROSECS(params->vcpu_migr_delay_us); + prv->item_migr_delay =3D MICROSECS(params->vcpu_migr_delay_us); spin_unlock_irqrestore(&prv->lock, flags); =20 /* FALLTHRU */ case XEN_SYSCTL_SCHEDOP_getinfo: params->tslice_ms =3D prv->tslice / MILLISECS(1); params->ratelimit_us =3D prv->ratelimit / MICROSECS(1); - params->vcpu_migr_delay_us =3D prv->vcpu_migr_delay / MICROSECS(1); + params->vcpu_migr_delay_us =3D prv->item_migr_delay / MICROSECS(1); rc =3D 0; break; } @@ -1315,7 +1314,7 @@ csched_alloc_domdata(const struct scheduler *ops, str= uct domain *dom) return ERR_PTR(-ENOMEM); =20 /* Initialize credit and weight */ - INIT_LIST_HEAD(&sdom->active_vcpu); + INIT_LIST_HEAD(&sdom->active_item); INIT_LIST_HEAD(&sdom->active_sdom_elem); sdom->dom =3D dom; sdom->weight =3D CSCHED_DEFAULT_WEIGHT; @@ -1332,7 +1331,7 @@ csched_free_domdata(const struct scheduler *ops, void= *data) /* * This is a O(n) optimized sort of the runq. * - * Time-share VCPUs can only be one of two priorities, UNDER or OVER. We w= alk + * Time-share ITEMs can only be one of two priorities, UNDER or OVER. We w= alk * through the runq and move up any UNDERs that are preceded by OVERS. We * remember the last UNDER to make the move up operation O(1). */ @@ -1385,7 +1384,7 @@ csched_acct(void* dummy) { struct csched_private *prv =3D dummy; unsigned long flags; - struct list_head *iter_vcpu, *next_vcpu; + struct list_head *iter_item, *next_item; struct list_head *iter_sdom, *next_sdom; struct csched_item *svc; struct csched_dom *sdom; @@ -1432,26 +1431,26 @@ csched_acct(void* dummy) sdom =3D list_entry(iter_sdom, struct csched_dom, active_sdom_elem= ); =20 BUG_ON( is_idle_domain(sdom->dom) ); - BUG_ON( sdom->active_vcpu_count =3D=3D 0 ); + BUG_ON( sdom->active_item_count =3D=3D 0 ); BUG_ON( sdom->weight =3D=3D 0 ); - BUG_ON( (sdom->weight * sdom->active_vcpu_count) > weight_left ); + BUG_ON( (sdom->weight * sdom->active_item_count) > weight_left ); =20 - weight_left -=3D ( sdom->weight * sdom->active_vcpu_count ); + weight_left -=3D ( sdom->weight * sdom->active_item_count ); =20 /* * A domain's fair share is computed using its weight in competiti= on * with that of all other active domains. * - * At most, a domain can use credits to run all its active VCPUs + * At most, a domain can use credits to run all its active ITEMs * for one full accounting period. We allow a domain to earn more * only when the system-wide credit balance is negative. */ - credit_peak =3D sdom->active_vcpu_count * prv->credits_per_tslice; + credit_peak =3D sdom->active_item_count * prv->credits_per_tslice; if ( prv->credit_balance < 0 ) { credit_peak +=3D ( ( -prv->credit_balance * sdom->weight - * sdom->active_vcpu_count) + + * sdom->active_item_count) + (weight_total - 1) ) / weight_total; } @@ -1462,14 +1461,14 @@ csched_acct(void* dummy) if ( credit_cap < credit_peak ) credit_peak =3D credit_cap; =20 - /* FIXME -- set cap per-vcpu as well...? */ - credit_cap =3D ( credit_cap + ( sdom->active_vcpu_count - 1 ) - ) / sdom->active_vcpu_count; + /* FIXME -- set cap per-item as well...? */ + credit_cap =3D ( credit_cap + ( sdom->active_item_count - 1 ) + ) / sdom->active_item_count; } =20 credit_fair =3D ( ( credit_total * sdom->weight - * sdom->active_vcpu_count ) + * sdom->active_item_count ) + (weight_total - 1) ) / weight_total; =20 @@ -1503,14 +1502,14 @@ csched_acct(void* dummy) credit_fair =3D credit_peak; } =20 - /* Compute fair share per VCPU */ - credit_fair =3D ( credit_fair + ( sdom->active_vcpu_count - 1 ) - ) / sdom->active_vcpu_count; + /* Compute fair share per ITEM */ + credit_fair =3D ( credit_fair + ( sdom->active_item_count - 1 ) + ) / sdom->active_item_count; =20 =20 - list_for_each_safe( iter_vcpu, next_vcpu, &sdom->active_vcpu ) + list_for_each_safe( iter_item, next_item, &sdom->active_item ) { - svc =3D list_entry(iter_vcpu, struct csched_item, active_vcpu_= elem); + svc =3D list_entry(iter_item, struct csched_item, active_item_= elem); BUG_ON( sdom !=3D svc->sdom ); =20 /* Increment credit */ @@ -1518,20 +1517,20 @@ csched_acct(void* dummy) credit =3D atomic_read(&svc->credit); =20 /* - * Recompute priority or, if VCPU is idling, remove it from + * Recompute priority or, if ITEM is idling, remove it from * the active list. */ if ( credit < 0 ) { svc->pri =3D CSCHED_PRI_TS_OVER; =20 - /* Park running VCPUs of capped-out domains */ + /* Park running ITEMs of capped-out domains */ if ( sdom->cap !=3D 0U && credit < -credit_cap && - !test_and_set_bit(CSCHED_FLAG_VCPU_PARKED, &svc->flag= s) ) + !test_and_set_bit(CSCHED_FLAG_ITEM_PARKED, &svc->flag= s) ) { SCHED_STAT_CRANK(item_park); - vcpu_pause_nosync(svc->vcpu); + vcpu_pause_nosync(svc->item->vcpu); } =20 /* Lower bound on credits */ @@ -1547,21 +1546,21 @@ csched_acct(void* dummy) svc->pri =3D CSCHED_PRI_TS_UNDER; =20 /* Unpark any capped domains whose credits go positive */ - if ( test_and_clear_bit(CSCHED_FLAG_VCPU_PARKED, &svc->fla= gs) ) + if ( test_and_clear_bit(CSCHED_FLAG_ITEM_PARKED, &svc->fla= gs) ) { /* * It's important to unset the flag AFTER the unpause() - * call to make sure the VCPU's priority is not boosted + * call to make sure the ITEM's priority is not boosted * if it is woken up here. */ SCHED_STAT_CRANK(item_unpark); - vcpu_unpause(svc->vcpu); + vcpu_unpause(svc->item->vcpu); } =20 - /* Upper bound on credits means VCPU stops earning */ + /* Upper bound on credits means ITEM stops earning */ if ( credit > prv->credits_per_tslice ) { - __csched_vcpu_acct_stop_locked(prv, svc); + __csched_item_acct_stop_locked(prv, svc); /* Divide credits in half, so that when it starts * accounting again, it starts a little bit "ahead" */ credit /=3D 2; @@ -1569,8 +1568,8 @@ csched_acct(void* dummy) } } =20 - SCHED_VCPU_STAT_SET(svc, credit_last, credit); - SCHED_VCPU_STAT_SET(svc, credit_incr, credit_fair); + SCHED_ITEM_STAT_SET(svc, credit_last, credit); + SCHED_ITEM_STAT_SET(svc, credit_incr, credit_fair); credit_balance +=3D credit; } } @@ -1596,10 +1595,10 @@ csched_tick(void *_cpu) spc->tick++; =20 /* - * Accounting for running VCPU + * Accounting for running ITEM */ - if ( !is_idle_vcpu(current) ) - csched_vcpu_acct(prv, cpu); + if ( !is_idle_item(current->sched_item) ) + csched_item_acct(prv, cpu); =20 /* * Check if runq needs to be sorted @@ -1620,7 +1619,7 @@ csched_runq_steal(int peer_cpu, int cpu, int pri, int= balance_step) const struct csched_pcpu * const peer_pcpu =3D CSCHED_PCPU(peer_cpu); struct csched_item *speer; struct list_head *iter; - struct vcpu *vc; + struct sched_item *item; =20 ASSERT(peer_pcpu !=3D NULL); =20 @@ -1628,7 +1627,7 @@ csched_runq_steal(int peer_cpu, int cpu, int pri, int= balance_step) * Don't steal from an idle CPU's runq because it's about to * pick up work from it itself. */ - if ( unlikely(is_idle_vcpu(curr_on_cpu(peer_cpu)->vcpu)) ) + if ( unlikely(is_idle_item(curr_on_cpu(peer_cpu))) ) goto out; =20 list_for_each( iter, &peer_pcpu->runq ) @@ -1636,46 +1635,44 @@ csched_runq_steal(int peer_cpu, int cpu, int pri, i= nt balance_step) speer =3D __runq_elem(iter); =20 /* - * If next available VCPU here is not of strictly higher + * If next available ITEM here is not of strictly higher * priority than ours, this PCPU is useless to us. */ if ( speer->pri <=3D pri ) break; =20 - /* Is this VCPU runnable on our PCPU? */ - vc =3D speer->vcpu; - BUG_ON( is_idle_vcpu(vc) ); + /* Is this ITEM runnable on our PCPU? */ + item =3D speer->item; + BUG_ON( is_idle_item(item) ); =20 /* - * If the vcpu is still in peer_cpu's scheduling tail, or if it + * If the item is still in peer_cpu's scheduling tail, or if it * has no useful soft affinity, skip it. * * In fact, what we want is to check if we have any "soft-affine * work" to steal, before starting to look at "hard-affine work". * - * Notice that, if not even one vCPU on this runq has a useful + * Notice that, if not even one item on this runq has a useful * soft affinity, we could have avoid considering this runq for * a soft balancing step in the first place. This, for instance, * can be implemented by taking note of on what runq there are - * vCPUs with useful soft affinities in some sort of bitmap + * items with useful soft affinities in some sort of bitmap * or counter. */ - if ( vc->sched_item->is_running || - (balance_step =3D=3D BALANCE_SOFT_AFFINITY && - !has_soft_affinity(vc->sched_item)) ) + if ( item->is_running || (balance_step =3D=3D BALANCE_SOFT_AFFINIT= Y && + !has_soft_affinity(item)) ) continue; =20 - affinity_balance_cpumask(vc->sched_item, balance_step, cpumask_scr= atch); - if ( __csched_vcpu_is_migrateable(prv, vc, cpu, cpumask_scratch) ) + affinity_balance_cpumask(item, balance_step, cpumask_scratch); + if ( __csched_item_is_migrateable(prv, item, cpu, cpumask_scratch)= ) { /* We got a candidate. Grab it! */ - TRACE_3D(TRC_CSCHED_STOLEN_VCPU, peer_cpu, - vc->domain->domain_id, vc->vcpu_id); - SCHED_VCPU_STAT_CRANK(speer, migrate_q); + TRACE_3D(TRC_CSCHED_STOLEN_ITEM, peer_cpu, + item->domain->domain_id, item->item_id); + SCHED_ITEM_STAT_CRANK(speer, migrate_q); SCHED_STAT_CRANK(migrate_queued); - WARN_ON(vc->is_urgent); runq_remove(speer); - sched_set_res(vc->sched_item, per_cpu(sched_res, cpu)); + sched_set_res(item, per_cpu(sched_res, cpu)); /* * speer will start executing directly on cpu, without having = to * go through runq_insert(). So we must update the runnable co= unt @@ -1701,7 +1698,7 @@ csched_load_balance(struct csched_private *prv, int c= pu, int peer_cpu, first_cpu, peer_node, bstep; int node =3D cpu_to_node(cpu); =20 - BUG_ON( cpu !=3D snext->vcpu->processor ); + BUG_ON( cpu !=3D sched_item_cpu(snext->item) ); online =3D cpupool_online_cpumask(c); =20 /* @@ -1730,7 +1727,7 @@ csched_load_balance(struct csched_private *prv, int c= pu, /* * We peek at the non-idling CPUs in a node-wise fashion. In fact, * it is more likely that we find some affine work on our same - * node, not to mention that migrating vcpus within the same node + * node, not to mention that migrating items within the same node * could well expected to be cheaper than across-nodes (memory * stays local, there might be some node-wide cache[s], etc.). */ @@ -1751,7 +1748,7 @@ csched_load_balance(struct csched_private *prv, int c= pu, spinlock_t *lock; =20 /* - * If there is only one runnable vCPU on peer_cpu, it means + * If there is only one runnable item on peer_cpu, it means * there's no one to be stolen in its runqueue, so skip it. * * Checking this without holding the lock is racy... But t= hat's @@ -1764,13 +1761,13 @@ csched_load_balance(struct csched_private *prv, int= cpu, * And we can avoid that by re-checking nr_runnable after * having grabbed the lock, if we want; * - if we race with inc_nr_runnable(), we skip a pCPU tha= t may - * have runnable vCPUs in its runqueue, but that's not a + * have runnable items in its runqueue, but that's not a * problem because: * + if racing with csched_item_insert() or csched_item_= wake(), - * __runq_tickle() will be called afterwords, so the v= CPU + * __runq_tickle() will be called afterwords, so the i= tem * won't get stuck in the runqueue for too long; - * + if racing with csched_runq_steal(), it may be that a - * vCPU that we could have picked up, stays in a runqu= eue + * + if racing with csched_runq_steal(), it may be that = an + * item that we could have picked up, stays in a runqu= eue * until someone else tries to steal it again. But thi= s is * no worse than what can happen already (without this * optimization), it the pCPU would schedule right aft= er we @@ -1805,7 +1802,7 @@ csched_load_balance(struct csched_private *prv, int c= pu, csched_runq_steal(peer_cpu, cpu, snext->pri, bstep) : = NULL; pcpu_schedule_unlock(lock, peer_cpu); =20 - /* As soon as one vcpu is found, balancing ends */ + /* As soon as one item is found, balancing ends */ if ( speer !=3D NULL ) { *stolen =3D 1; @@ -1844,14 +1841,15 @@ csched_schedule( { const int cpu =3D smp_processor_id(); struct list_head * const runq =3D RUNQ(cpu); - struct csched_item * const scurr =3D CSCHED_ITEM(current->sched_item); + struct sched_item *item =3D current->sched_item; + struct csched_item * const scurr =3D CSCHED_ITEM(item); struct csched_private *prv =3D CSCHED_PRIV(ops); struct csched_item *snext; struct task_slice ret; s_time_t runtime, tslice; =20 SCHED_STAT_CRANK(schedule); - CSCHED_VCPU_CHECK(current); + CSCHED_ITEM_CHECK(item); =20 /* * Here in Credit1 code, we usually just call TRACE_nD() helpers, and @@ -1865,30 +1863,30 @@ csched_schedule( } d; d.cpu =3D cpu; d.tasklet =3D tasklet_work_scheduled; - d.idle =3D is_idle_vcpu(current); + d.idle =3D is_idle_item(item); __trace_var(TRC_CSCHED_SCHEDULE, 1, sizeof(d), (unsigned char *)&d); } =20 - runtime =3D now - current->sched_item->state_entry_time; + runtime =3D now - item->state_entry_time; if ( runtime < 0 ) /* Does this ever happen? */ runtime =3D 0; =20 - if ( !is_idle_vcpu(scurr->vcpu) ) + if ( !is_idle_item(item) ) { - /* Update credits of a non-idle VCPU. */ + /* Update credits of a non-idle ITEM. */ burn_credits(scurr, now); scurr->start_time -=3D now; } else { - /* Re-instate a boosted idle VCPU as normal-idle. */ + /* Re-instate a boosted idle ITEM as normal-idle. */ scurr->pri =3D CSCHED_PRI_IDLE; } =20 /* Choices, choices: - * - If we have a tasklet, we need to run the idle vcpu no matter what. - * - If sched rate limiting is in effect, and the current vcpu has + * - If we have a tasklet, we need to run the idle item no matter what. + * - If sched rate limiting is in effect, and the current item has * run for less than that amount of time, continue the current one, * but with a shorter timeslice and return it immediately * - Otherwise, chose the one with the highest priority (which may @@ -1906,11 +1904,11 @@ csched_schedule( * In fact, it may be the case that scurr is about to spin, and there's * no point forcing it to do so until rate limiting expires. */ - if ( !test_bit(CSCHED_FLAG_VCPU_YIELD, &scurr->flags) + if ( !test_bit(CSCHED_FLAG_ITEM_YIELD, &scurr->flags) && !tasklet_work_scheduled && prv->ratelimit - && vcpu_runnable(current) - && !is_idle_vcpu(current) + && item_runnable(item) + && !is_idle_item(item) && runtime < prv->ratelimit ) { snext =3D scurr; @@ -1928,11 +1926,11 @@ csched_schedule( if ( unlikely(tb_init_done) ) { struct { - unsigned vcpu:16, dom:16; + unsigned item:16, dom:16; unsigned runtime; } d; - d.dom =3D scurr->vcpu->domain->domain_id; - d.vcpu =3D scurr->vcpu->vcpu_id; + d.dom =3D item->domain->domain_id; + d.item =3D item->item_id; d.runtime =3D runtime; __trace_var(TRC_CSCHED_RATELIMIT, 1, sizeof(d), (unsigned char *)&d); @@ -1944,13 +1942,13 @@ csched_schedule( tslice =3D prv->tslice; =20 /* - * Select next runnable local VCPU (ie top of local runq) + * Select next runnable local ITEM (ie top of local runq) */ - if ( vcpu_runnable(current) ) + if ( item_runnable(item) ) __runq_insert(scurr); else { - BUG_ON( is_idle_vcpu(current) || list_empty(runq) ); + BUG_ON( is_idle_item(item) || list_empty(runq) ); /* Current has blocked. Update the runnable counter for this cpu. = */ dec_nr_runnable(cpu); } @@ -1958,23 +1956,23 @@ csched_schedule( snext =3D __runq_elem(runq->next); ret.migrated =3D 0; =20 - /* Tasklet work (which runs in idle VCPU context) overrides all else. = */ + /* Tasklet work (which runs in idle ITEM context) overrides all else. = */ if ( tasklet_work_scheduled ) { TRACE_0D(TRC_CSCHED_SCHED_TASKLET); - snext =3D CSCHED_ITEM(idle_vcpu[cpu]->sched_item); + snext =3D CSCHED_ITEM(sched_idle_item(cpu)); snext->pri =3D CSCHED_PRI_TS_BOOST; } =20 /* * Clear YIELD flag before scheduling out */ - clear_bit(CSCHED_FLAG_VCPU_YIELD, &scurr->flags); + clear_bit(CSCHED_FLAG_ITEM_YIELD, &scurr->flags); =20 /* * SMP Load balance: * - * If the next highest priority local runnable VCPU has already eaten + * If the next highest priority local runnable ITEM has already eaten * through its credits, look on other PCPUs to see if we have more * urgent work... If not, csched_load_balance() will return snext, but * already removed from the runq. @@ -1998,32 +1996,32 @@ csched_schedule( cpumask_clear_cpu(cpu, prv->idlers); } =20 - if ( !is_idle_vcpu(snext->vcpu) ) + if ( !is_idle_item(snext->item) ) snext->start_time +=3D now; =20 out: /* * Return task to run next... */ - ret.time =3D (is_idle_vcpu(snext->vcpu) ? + ret.time =3D (is_idle_item(snext->item) ? -1 : tslice); - ret.task =3D snext->vcpu->sched_item; + ret.task =3D snext->item; =20 - CSCHED_VCPU_CHECK(ret.task->vcpu); + CSCHED_ITEM_CHECK(ret.task); return ret; } =20 static void -csched_dump_vcpu(struct csched_item *svc) +csched_dump_item(struct csched_item *svc) { struct csched_dom * const sdom =3D svc->sdom; =20 printk("[%i.%i] pri=3D%i flags=3D%x cpu=3D%i", - svc->vcpu->domain->domain_id, - svc->vcpu->vcpu_id, + svc->item->domain->domain_id, + svc->item->item_id, svc->pri, svc->flags, - svc->vcpu->processor); + sched_item_cpu(svc->item)); =20 if ( sdom ) { @@ -2057,7 +2055,7 @@ csched_dump_pcpu(const struct scheduler *ops, int cpu) =20 /* * We need both locks: - * - csched_dump_vcpu() wants to access domains' scheduling + * - csched_dump_item() wants to access domains' scheduling * parameters, which are protected by the private scheduler lock; * - we scan through the runqueue, so we need the proper runqueue * lock (the one of the runqueue of this cpu). @@ -2073,12 +2071,12 @@ csched_dump_pcpu(const struct scheduler *ops, int c= pu) nr_cpu_ids, cpumask_bits(per_cpu(cpu_sibling_mask, cpu)), nr_cpu_ids, cpumask_bits(per_cpu(cpu_core_mask, cpu))); =20 - /* current VCPU (nothing to say if that's the idle vcpu). */ + /* current ITEM (nothing to say if that's the idle item). */ svc =3D CSCHED_ITEM(curr_on_cpu(cpu)); - if ( svc && !is_idle_vcpu(svc->vcpu) ) + if ( svc && !is_idle_item(svc->item) ) { printk("\trun: "); - csched_dump_vcpu(svc); + csched_dump_item(svc); } =20 loop =3D 0; @@ -2088,7 +2086,7 @@ csched_dump_pcpu(const struct scheduler *ops, int cpu) if ( svc ) { printk("\t%3d: ", ++loop); - csched_dump_vcpu(svc); + csched_dump_item(svc); } } =20 @@ -2130,29 +2128,29 @@ csched_dump(const struct scheduler *ops) prv->ratelimit / MICROSECS(1), CSCHED_CREDITS_PER_MSEC, prv->ticks_per_tslice, - prv->vcpu_migr_delay/ MICROSECS(1)); + prv->item_migr_delay/ MICROSECS(1)); =20 printk("idlers: %*pb\n", nr_cpu_ids, cpumask_bits(prv->idlers)); =20 - printk("active vcpus:\n"); + printk("active items:\n"); loop =3D 0; list_for_each( iter_sdom, &prv->active_sdom ) { struct csched_dom *sdom; sdom =3D list_entry(iter_sdom, struct csched_dom, active_sdom_elem= ); =20 - list_for_each( iter_svc, &sdom->active_vcpu ) + list_for_each( iter_svc, &sdom->active_item ) { struct csched_item *svc; spinlock_t *lock; =20 - svc =3D list_entry(iter_svc, struct csched_item, active_vcpu_e= lem); - lock =3D item_schedule_lock(svc->vcpu->sched_item); + svc =3D list_entry(iter_svc, struct csched_item, active_item_e= lem); + lock =3D item_schedule_lock(svc->item); =20 printk("\t%3d: ", ++loop); - csched_dump_vcpu(svc); + csched_dump_item(svc); =20 - item_schedule_unlock(lock, svc->vcpu->sched_item); + item_schedule_unlock(lock, svc->item); } } =20 @@ -2226,7 +2224,7 @@ csched_init(struct scheduler *ops) else prv->ratelimit =3D MICROSECS(sched_ratelimit_us); =20 - prv->vcpu_migr_delay =3D MICROSECS(vcpu_migration_delay_us); + prv->item_migr_delay =3D MICROSECS(vcpu_migration_delay_us); =20 return 0; } --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125918; cv=none; d=zoho.com; s=zohoarc; b=ZL6KO5HvRJ3JLFYQg5x3QGgvm/PpGEdgWD7ZZ5UJom7Ffuh4kBt8UQNFLxNCH2WIOevSbGq0U9U50NPHDmrZdZmLMGp0B0boWJeOqRqcmW62tN5Md7wxcPk83TmA/UQACgUe0ZKl29NBtWnL8kgLd14Kbg5OEmJY3m5njVtBuCc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125918; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=oQn+m12OEt7vPdqWbdocM4RASzoI2lPKtxfkT5otoa0=; b=oEuKDIvYQsn/WUknfUo11yfSk3pkwIy6cs/dc93MKvywxBBRWOVpHFyvj7n288ogefwTcvOyoqwAZO0i34177nhCv04GtAX3TLOpha85gFg12p30xOYLIYbm3Ho8yb0F9hmEx+zwQ569atUaHwTbtgBOT2NFEQlyKcKXmP1O3TM= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125918121649.319399057834; Sun, 5 May 2019 23:58:38 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXZ7-000395-Uu; Mon, 06 May 2019 06:57:33 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYn-0002K2-IL for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:13 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 23e28f46-6fcc-11e9-843c-bc764e045a96; Mon, 06 May 2019 06:56:58 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 60602AF22; Mon, 6 May 2019 06:56:54 +0000 (UTC) X-Inumbo-ID: 23e28f46-6fcc-11e9-843c-bc764e045a96 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:20 +0200 Message-Id: <20190506065644.7415-22-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 21/45] xen/sched: make credit2 scheduler vcpu agnostic. X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , George Dunlap , Dario Faggioli MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Switch credit2 scheduler completely from vcpu to sched_item usage. As we are touching lots of lines remove some white space at the end of the line, too. Signed-off-by: Juergen Gross --- xen/common/sched_credit2.c | 820 ++++++++++++++++++++++-------------------= ---- 1 file changed, 403 insertions(+), 417 deletions(-) diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index 0f0d6a3801..7918d46a23 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -45,7 +45,7 @@ #define TRC_CSCHED2_SCHED_TASKLET TRC_SCHED_CLASS_EVT(CSCHED2, 8) #define TRC_CSCHED2_UPDATE_LOAD TRC_SCHED_CLASS_EVT(CSCHED2, 9) #define TRC_CSCHED2_RUNQ_ASSIGN TRC_SCHED_CLASS_EVT(CSCHED2, 10) -#define TRC_CSCHED2_UPDATE_VCPU_LOAD TRC_SCHED_CLASS_EVT(CSCHED2, 11) +#define TRC_CSCHED2_UPDATE_ITEM_LOAD TRC_SCHED_CLASS_EVT(CSCHED2, 11) #define TRC_CSCHED2_UPDATE_RUNQ_LOAD TRC_SCHED_CLASS_EVT(CSCHED2, 12) #define TRC_CSCHED2_TICKLE_NEW TRC_SCHED_CLASS_EVT(CSCHED2, 13) #define TRC_CSCHED2_RUNQ_MAX_WEIGHT TRC_SCHED_CLASS_EVT(CSCHED2, 14) @@ -74,13 +74,13 @@ * Design: * * VMs "burn" credits based on their weight; higher weight means - * credits burn more slowly. The highest weight vcpu burns credits at + * credits burn more slowly. The highest weight item burns credits at * a rate of 1 credit per nanosecond. Others burn proportionally * more. * - * vcpus are inserted into the runqueue by credit order. + * items are inserted into the runqueue by credit order. * - * Credits are "reset" when the next vcpu in the runqueue is less than + * Credits are "reset" when the next item in the runqueue is less than * or equal to zero. At that point, everyone's credits are "clipped" * to a small value, and a fixed credit is added to everyone. */ @@ -95,33 +95,33 @@ * be given a cap of 25%; a domain that must not use more than 1+1/2 of * physical CPU time, will be given a cap of 150%; * - * - caps are per-domain (not per-vCPU). If a domain has only 1 vCPU, and - * a 40% cap, that one vCPU will use 40% of one pCPU. If a somain has 4 - * vCPUs, and a 200% cap, the equivalent of 100% time on 2 pCPUs will be - * split among the v vCPUs. How much each of the vCPUs will actually get, + * - caps are per-domain (not per-item). If a domain has only 1 item, and + * a 40% cap, that one item will use 40% of one pCPU. If a somain has 4 + * items, and a 200% cap, the equivalent of 100% time on 2 pCPUs will be + * split among the v items. How much each of the items will actually get, * during any given interval of time, is unspecified (as it depends on * various aspects: workload, system load, etc.). For instance, it is - * possible that, during a given time interval, 2 vCPUs use 100% each, + * possible that, during a given time interval, 2 items use 100% each, * and the other two use nothing; while during another time interval, - * two vCPUs use 80%, one uses 10% and the other 30%; or that each use + * two items use 80%, one uses 10% and the other 30%; or that each use * 50% (and so on and so forth). * * For implementing this, we use the following approach: * * - each domain is given a 'budget', an each domain has a timer, which * replenishes the domain's budget periodically. The budget is the amount - * of time the vCPUs of the domain can use every 'period'; + * of time the items of the domain can use every 'period'; * * - the period is CSCHED2_BDGT_REPL_PERIOD, and is the same for all domai= ns * (but each domain has its own timer; so the all are periodic by the sa= me * period, but replenishment of the budgets of the various domains, at * periods boundaries, are not synchronous); * - * - when vCPUs run, they consume budget. When they don't run, they don't - * consume budget. If there is no budget left for the domain, no vCPU of - * that domain can run. If a vCPU tries to run and finds that there is no + * - when items run, they consume budget. When they don't run, they don't + * consume budget. If there is no budget left for the domain, no item of + * that domain can run. If an item tries to run and finds that there is = no * budget, it blocks. - * At whatever time a vCPU wants to run, it must check the domain's budg= et, + * At whatever time an item wants to run, it must check the domain's bud= get, * and if there is some, it can use it. * * - budget is replenished to the top of the capacity for the domain once @@ -129,39 +129,39 @@ * though, the budget after a replenishment will always be at most equal * to the total capacify of the domain ('tot_budget'); * - * - when a budget replenishment occurs, if there are vCPUs that had been + * - when a budget replenishment occurs, if there are items that had been * blocked because of lack of budget, they'll be unblocked, and they will * (potentially) be able to run again. * * Finally, some even more implementation related detail: * - * - budget is stored in a domain-wide pool. vCPUs of the domain that want + * - budget is stored in a domain-wide pool. Items of the domain that want * to run go to such pool, and grub some. When they do so, the amount * they grabbed is _immediately_ removed from the pool. This happens in - * vcpu_grab_budget(); + * item_grab_budget(); * - * - when vCPUs stop running, if they've not consumed all the budget they + * - when items stop running, if they've not consumed all the budget they * took, the leftover is put back in the pool. This happens in - * vcpu_return_budget(); + * item_return_budget(); * - * - the above means that a vCPU can find out that there is no budget and + * - the above means that an item can find out that there is no budget and * block, not only if the cap has actually been reached (for this period= ), - * but also if some other vCPUs, in order to run, have grabbed a certain + * but also if some other items, in order to run, have grabbed a certain * quota of budget, no matter whether they've already used it all or not. - * A vCPU blocking because (any form of) lack of budget is said to be - * "parked", and such blocking happens in park_vcpu(); + * An item blocking because (any form of) lack of budget is said to be + * "parked", and such blocking happens in park_item(); * - * - when a vCPU stops running, and puts back some budget in the domain po= ol, + * - when an item stops running, and puts back some budget in the domain p= ool, * we need to check whether there is someone which has been parked and t= hat - * can be unparked. This happens in unpark_parked_vcpus(), called from + * can be unparked. This happens in unpark_parked_items(), called from * csched2_context_saved(); * * - of course, unparking happens also as a consequence of the domain's bu= dget * being replenished by the periodic timer. This also occurs by means of * calling csched2_context_saved() (but from replenish_domain_budget()); * - * - parked vCPUs of a domain are kept in a (per-domain) list, called - * 'parked_vcpus'). Manipulation of the list and of the domain-wide budg= et + * - parked items of a domain are kept in a (per-domain) list, called + * 'parked_items'). Manipulation of the list and of the domain-wide budg= et * pool, must occur only when holding the 'budget_lock'. */ =20 @@ -174,9 +174,9 @@ * pcpu_schedule_lock() / item_schedule_lock() (and friends), * * a cpu may (try to) take a "remote" runqueue lock, e.g., for * load balancing; - * + serializes runqueue operations (removing and inserting vcpus); + * + serializes runqueue operations (removing and inserting items); * + protects runqueue-wide data in csched2_runqueue_data; - * + protects vcpu parameters in csched2_item for the vcpu in the + * + protects item parameters in csched2_item for the item in the * runqueue. * * - Private scheduler lock @@ -190,8 +190,8 @@ * + it is per-domain; * + protects, in domains that have an utilization cap; * * manipulation of the total budget of the domain (as it is shared - * among all vCPUs of the domain), - * * manipulation of the list of vCPUs that are blocked waiting for + * among all items of the domain), + * * manipulation of the list of items that are blocked waiting for * some budget to be available. * * - Type: @@ -228,9 +228,9 @@ */ #define CSCHED2_CREDIT_INIT MILLISECS(10) /* - * Amount of credit the idle vcpus have. It never changes, as idle - * vcpus does not consume credits, and it must be lower than whatever - * amount of credit 'regular' vcpu would end up with. + * Amount of credit the idle items have. It never changes, as idle + * items does not consume credits, and it must be lower than whatever + * amount of credit 'regular' item would end up with. */ #define CSCHED2_IDLE_CREDIT (-(1U<<30)) /* @@ -243,9 +243,9 @@ * MIN_TIMER. */ #define CSCHED2_MIGRATE_RESIST ((opt_migrate_resist)*MICROSECS(1)) -/* How much to "compensate" a vcpu for L2 migration. */ +/* How much to "compensate" an item for L2 migration. */ #define CSCHED2_MIGRATE_COMPENSATION MICROSECS(50) -/* How tolerant we should be when peeking at runtime of vcpus on other cpu= s */ +/* How tolerant we should be when peeking at runtime of items on other cpu= s */ #define CSCHED2_RATELIMIT_TICKLE_TOLERANCE MICROSECS(50) /* Reset: Value below which credit will be reset. */ #define CSCHED2_CREDIT_RESET 0 @@ -258,7 +258,7 @@ * Flags */ /* - * CSFLAG_scheduled: Is this vcpu either running on, or context-switching = off, + * CSFLAG_scheduled: Is this item either running on, or context-switching = off, * a physical cpu? * + Accessed only with runqueue lock held * + Set when chosen as next in csched2_schedule(). @@ -280,21 +280,21 @@ #define __CSFLAG_delayed_runq_add 2 #define CSFLAG_delayed_runq_add (1U<<__CSFLAG_delayed_runq_add) /* - * CSFLAG_runq_migrate_request: This vcpu is being migrated as a result of= a + * CSFLAG_runq_migrate_request: This item is being migrated as a result of= a * credit2-initiated runq migrate request; migrate it to the runqueue indi= cated - * in the svc struct.=20 + * in the svc struct. */ #define __CSFLAG_runq_migrate_request 3 #define CSFLAG_runq_migrate_request (1U<<__CSFLAG_runq_migrate_request) /* - * CSFLAG_vcpu_yield: this vcpu was running, and has called vcpu_yield(). = The + * CSFLAG_item_yield: this item was running, and has called vcpu_yield(). = The * scheduler is invoked to see if we can give the cpu to someone else, and - * get back to the yielding vcpu in a while. + * get back to the yielding item in a while. */ -#define __CSFLAG_vcpu_yield 4 -#define CSFLAG_vcpu_yield (1U<<__CSFLAG_vcpu_yield) +#define __CSFLAG_item_yield 4 +#define CSFLAG_item_yield (1U<<__CSFLAG_item_yield) /* - * CSFLAGS_pinned: this vcpu is currently 'pinned', i.e., has its hard + * CSFLAGS_pinned: this item is currently 'pinned', i.e., has its hard * affinity set to one and only 1 cpu (and, hence, can only run there). */ #define __CSFLAG_pinned 5 @@ -306,7 +306,7 @@ integer_param("sched_credit2_migrate_resist", opt_migra= te_resist); /* * Load tracking and load balancing * - * Load history of runqueues and vcpus is accounted for by using an + * Load history of runqueues and items is accounted for by using an * exponential weighted moving average algorithm. However, instead of using * fractions,we shift everything to left by the number of bits we want to * use for representing the fractional part (Q-format). @@ -326,7 +326,7 @@ integer_param("sched_credit2_migrate_resist", opt_migra= te_resist); * * where W is the length of the window, P the multiplier for transitiong i= nto * Q-format fixed point arithmetic and load is the instantaneous load of a - * runqueue, which basically is the number of runnable vcpus there are on = the + * runqueue, which basically is the number of runnable items there are on = the * runqueue (for the meaning of the other terms, look at the doc comment to * update_runq_load()). * @@ -338,7 +338,7 @@ integer_param("sched_credit2_migrate_resist", opt_migra= te_resist); * The maximum possible value for the average load, which we want to store= in * s_time_t type variables (i.e., we have 63 bits available) is load*P. Th= is * means that, with P 18 bits wide, load can occupy 45 bits. This in turn - * means we can have 2^45 vcpus in each runqueue, before overflow occurs! + * means we can have 2^45 items in each runqueue, before overflow occurs! * * However, it can happen that, at step j+1, if: * @@ -354,13 +354,13 @@ integer_param("sched_credit2_migrate_resist", opt_mig= rate_resist); * * 2^(63 - 30 - 18) =3D 2^15 =3D 32768 * - * So 32768 is the maximum number of vcpus the we can have in a runqueue, + * So 32768 is the maximum number of items the we can have in a runqueue, * at any given time, and still not have problems with the load tracking * calculations... and this is more than fine. * * As a matter of fact, since we are using microseconds granularity, we ha= ve * W=3D2^20. So, still with 18 fractional bits and a 1 second long window,= there - * may be 2^25 =3D 33554432 vcpus in a runq before we have to start thinki= ng + * may be 2^25 =3D 33554432 items in a runq before we have to start thinki= ng * about overflow. */ =20 @@ -468,7 +468,7 @@ struct csched2_runqueue_data { struct list_head runq; /* Ordered list of runnable vms = */ int id; /* ID of this runqueue (-1 if invalid) = */ =20 - int load; /* Instantaneous load (num of non-idle vcpu= s) */ + int load; /* Instantaneous load (num of non-idle item= s) */ s_time_t load_last_update; /* Last time average was updated = */ s_time_t avgload; /* Decaying queue load = */ s_time_t b_avgload; /* Decaying queue load modified by balancin= g */ @@ -478,8 +478,8 @@ struct csched2_runqueue_data { tickled, /* Have been asked to go through schedule = */ idle; /* Currently idle pcpus = */ =20 - struct list_head svc; /* List of all vcpus assigned to the runque= ue */ - unsigned int max_weight; /* Max weight of the vcpus in this runqueue= */ + struct list_head svc; /* List of all items assigned to the runque= ue */ + unsigned int max_weight; /* Max weight of the items in this runqueue= */ unsigned int pick_bias; /* Last picked pcpu. Start from it next tim= e */ }; =20 @@ -509,20 +509,20 @@ struct csched2_pcpu { }; =20 /* - * Virtual CPU + * Schedule Item */ struct csched2_item { struct csched2_dom *sdom; /* Up-pointer to domain = */ - struct vcpu *vcpu; /* Up-pointer, to vcpu = */ + struct sched_item *item; /* Up-pointer, to schedule item = */ struct csched2_runqueue_data *rqd; /* Up-pointer to the runqueue = */ =20 int credit; /* Current amount of credit = */ - unsigned int weight; /* Weight of this vcpu = */ + unsigned int weight; /* Weight of this item = */ unsigned int residual; /* Reminder of div(max_weight/weigh= t) */ unsigned flags; /* Status flags (16 bits would be o= k, */ s_time_t budget; /* Current budget (if domains has c= ap) */ /* but clear_bit() does not like th= at) */ - s_time_t budget_quota; /* Budget to which vCPU is entitled= */ + s_time_t budget_quota; /* Budget to which item is entitled= */ =20 s_time_t start_time; /* Time we were scheduled (for cred= it) */ =20 @@ -531,7 +531,7 @@ struct csched2_item { s_time_t avgload; /* Decaying queue load = */ =20 struct list_head runq_elem; /* On the runqueue (rqd->runq) = */ - struct list_head parked_elem; /* On the parked_vcpus list = */ + struct list_head parked_elem; /* On the parked_items list = */ struct list_head rqd_elem; /* On csched2_runqueue_data's svc l= ist */ struct csched2_runqueue_data *migrate_rqd; /* Pre-determined migr. tar= get */ int tickled_cpu; /* Cpu that will pick us (-1 if non= e) */ @@ -549,12 +549,12 @@ struct csched2_dom { =20 struct timer repl_timer; /* Timer for periodic replenishment of bud= get */ s_time_t next_repl; /* Time at which next replenishment occurs= */ - struct list_head parked_vcpus; /* List of CPUs waiting for budget = */ + struct list_head parked_items; /* List of CPUs waiting for budget = */ =20 struct list_head sdom_elem; /* On csched2_runqueue_data's sdom list = */ uint16_t weight; /* User specified weight = */ uint16_t cap; /* User specified cap = */ - uint16_t nr_vcpus; /* Number of vcpus of this domain = */ + uint16_t nr_items; /* Number of items of this domain = */ }; =20 /* @@ -593,7 +593,7 @@ static inline struct csched2_runqueue_data *c2rqd(const= struct scheduler *ops, return &csched2_priv(ops)->rqd[c2r(cpu)]; } =20 -/* Does the domain of this vCPU have a cap? */ +/* Does the domain of this item have a cap? */ static inline bool has_cap(const struct csched2_item *svc) { return svc->budget !=3D STIME_MAX; @@ -611,24 +611,24 @@ static inline bool has_cap(const struct csched2_item = *svc) * smt_idle mask. * * Once we have such a mask, it is easy to implement a policy that, either: - * - uses fully idle cores first: it is enough to try to schedule the vcp= us + * - uses fully idle cores first: it is enough to try to schedule the ite= ms * on pcpus from smt_idle mask first. This is what happens if * sched_smt_power_savings was not set at boot (default), and it maximi= zes * true parallelism, and hence performance; - * - uses already busy cores first: it is enough to try to schedule the v= cpus + * - uses already busy cores first: it is enough to try to schedule the i= tems * on pcpus that are idle, but are not in smt_idle. This is what happen= s if * sched_smt_power_savings is set at boot, and it allows as more cores = as * possible to stay in low power states, minimizing power consumption. * * This logic is entirely implemented in runq_tickle(), and that is enough. - * In fact, in this scheduler, placement of a vcpu on one of the pcpus of a + * In fact, in this scheduler, placement of an item on one of the pcpus of= a * runq, _always_ happens by means of tickling: - * - when a vcpu wakes up, it calls csched2_item_wake(), which calls + * - when an item wakes up, it calls csched2_item_wake(), which calls * runq_tickle(); * - when a migration is initiated in schedule.c, we call csched2_res_pic= k(), * csched2_item_migrate() (which calls migrate()) and csched2_item_wake= (). * csched2_res_pick() looks for the least loaded runq and return just a= ny - * of its processors. Then, csched2_item_migrate() just moves the vcpu = to + * of its processors. Then, csched2_item_migrate() just moves the item = to * the chosen runq, and it is again runq_tickle(), called by * csched2_item_wake() that actually decides what pcpu to use within the * chosen runq; @@ -643,7 +643,7 @@ static inline bool has_cap(const struct csched2_item *s= vc) * * NB that rqd->smt_idle is different than rqd->idle. rqd->idle * records pcpus that at are merely idle (i.e., at the moment do not - * have a vcpu running on them). But you have to manually filter out + * have an item running on them). But you have to manually filter out * which pcpus have been tickled in order to find cores that are not * going to be busy soon. Filtering out tickled cpus pairwise is a * lot of extra pain; so for rqd->smt_idle, we explicitly make so that @@ -690,24 +690,24 @@ void smt_idle_mask_clear(unsigned int cpu, cpumask_t = *mask) */ static int get_fallback_cpu(struct csched2_item *svc) { - struct vcpu *v =3D svc->vcpu; + struct sched_item *item =3D svc->item; unsigned int bs; =20 SCHED_STAT_CRANK(need_fallback_cpu); =20 for_each_affinity_balance_step( bs ) { - int cpu =3D v->processor; + int cpu =3D sched_item_cpu(item); =20 - if ( bs =3D=3D BALANCE_SOFT_AFFINITY && !has_soft_affinity(v->sche= d_item) ) + if ( bs =3D=3D BALANCE_SOFT_AFFINITY && !has_soft_affinity(item) ) continue; =20 - affinity_balance_cpumask(v->sched_item, bs, cpumask_scratch_cpu(cp= u)); + affinity_balance_cpumask(item, bs, cpumask_scratch_cpu(cpu)); cpumask_and(cpumask_scratch_cpu(cpu), cpumask_scratch_cpu(cpu), - cpupool_domain_cpumask(v->domain)); + cpupool_domain_cpumask(item->domain)); =20 /* - * This is cases 1 or 3 (depending on bs): if v->processor is (sti= ll) + * This is cases 1 or 3 (depending on bs): if processor is (still) * in our affinity, go for it, for cache betterness. */ if ( likely(cpumask_test_cpu(cpu, cpumask_scratch_cpu(cpu))) ) @@ -729,7 +729,7 @@ static int get_fallback_cpu(struct csched2_item *svc) * We may well pick any valid pcpu from our soft-affinity, outside * of our current runqueue, but we decide not to. In fact, changing * runqueue is slow, affects load distribution, and is a source of - * overhead for the vcpus running on the other runqueue (we need t= he + * overhead for the items running on the other runqueue (we need t= he * lock). So, better do that as a consequence of a well informed * decision (or if we really don't have any other chance, as we wi= ll, * at step 5, if we get to there). @@ -761,7 +761,7 @@ static int get_fallback_cpu(struct csched2_item *svc) * We can't be here. But if that somehow happen (in non-debug builds), * at least return something which both online and in our hard-affinit= y. */ - return cpumask_any(cpumask_scratch_cpu(v->processor)); + return cpumask_any(cpumask_scratch_cpu(sched_item_cpu(item))); } =20 /* @@ -790,7 +790,7 @@ static s_time_t c2t(struct csched2_runqueue_data *rqd, = s_time_t credit, struct c * Runqueue related code. */ =20 -static inline int vcpu_on_runq(struct csched2_item *svc) +static inline int item_on_runq(struct csched2_item *svc) { return !list_empty(&svc->runq_elem); } @@ -948,17 +948,17 @@ _runq_assign(struct csched2_item *svc, struct csched2= _runqueue_data *rqd) =20 update_max_weight(svc->rqd, svc->weight, 0); =20 - /* Expected new load based on adding this vcpu */ + /* Expected new load based on adding this item */ rqd->b_avgload +=3D svc->avgload; =20 if ( unlikely(tb_init_done) ) { struct { - unsigned vcpu:16, dom:16; + unsigned item:16, dom:16; unsigned rqi:16; } d; - d.dom =3D svc->vcpu->domain->domain_id; - d.vcpu =3D svc->vcpu->vcpu_id; + d.dom =3D svc->item->domain->domain_id; + d.item =3D svc->item->item_id; d.rqi=3Drqd->id; __trace_var(TRC_CSCHED2_RUNQ_ASSIGN, 1, sizeof(d), @@ -968,13 +968,13 @@ _runq_assign(struct csched2_item *svc, struct csched2= _runqueue_data *rqd) } =20 static void -runq_assign(const struct scheduler *ops, struct vcpu *vc) +runq_assign(const struct scheduler *ops, struct sched_item *item) { - struct csched2_item *svc =3D vc->sched_item->priv; + struct csched2_item *svc =3D item->priv; =20 ASSERT(svc->rqd =3D=3D NULL); =20 - _runq_assign(svc, c2rqd(ops, vc->processor)); + _runq_assign(svc, c2rqd(ops, sched_item_cpu(item))); } =20 static void @@ -982,24 +982,24 @@ _runq_deassign(struct csched2_item *svc) { struct csched2_runqueue_data *rqd =3D svc->rqd; =20 - ASSERT(!vcpu_on_runq(svc)); + ASSERT(!item_on_runq(svc)); ASSERT(!(svc->flags & CSFLAG_scheduled)); =20 list_del_init(&svc->rqd_elem); update_max_weight(rqd, 0, svc->weight); =20 - /* Expected new load based on removing this vcpu */ + /* Expected new load based on removing this item */ rqd->b_avgload =3D max_t(s_time_t, rqd->b_avgload - svc->avgload, 0); =20 svc->rqd =3D NULL; } =20 static void -runq_deassign(const struct scheduler *ops, struct vcpu *vc) +runq_deassign(const struct scheduler *ops, struct sched_item *item) { - struct csched2_item *svc =3D vc->sched_item->priv; + struct csched2_item *svc =3D item->priv; =20 - ASSERT(svc->rqd =3D=3D c2rqd(ops, vc->processor)); + ASSERT(svc->rqd =3D=3D c2rqd(ops, sched_item_cpu(item))); =20 _runq_deassign(svc); } @@ -1202,15 +1202,15 @@ update_svc_load(const struct scheduler *ops, struct csched2_item *svc, int change, s_time_t now) { struct csched2_private *prv =3D csched2_priv(ops); - s_time_t delta, vcpu_load; + s_time_t delta, item_load; unsigned int P, W; =20 if ( change =3D=3D -1 ) - vcpu_load =3D 1; + item_load =3D 1; else if ( change =3D=3D 1 ) - vcpu_load =3D 0; + item_load =3D 0; else - vcpu_load =3D vcpu_runnable(svc->vcpu); + item_load =3D item_runnable(svc->item); =20 W =3D prv->load_window_shift; P =3D prv->load_precision_shift; @@ -1218,7 +1218,7 @@ update_svc_load(const struct scheduler *ops, =20 if ( svc->load_last_update + (1ULL << W) < now ) { - svc->avgload =3D vcpu_load << P; + svc->avgload =3D item_load << P; } else { @@ -1231,7 +1231,7 @@ update_svc_load(const struct scheduler *ops, } =20 svc->avgload =3D svc->avgload + - ((delta * (vcpu_load << P)) >> W) - + ((delta * (item_load << P)) >> W) - ((delta * svc->avgload) >> W); } svc->load_last_update =3D now; @@ -1243,14 +1243,14 @@ update_svc_load(const struct scheduler *ops, { struct { uint64_t v_avgload; - unsigned vcpu:16, dom:16; + unsigned item:16, dom:16; unsigned shift; } d; - d.dom =3D svc->vcpu->domain->domain_id; - d.vcpu =3D svc->vcpu->vcpu_id; + d.dom =3D svc->item->domain->domain_id; + d.item =3D svc->item->item_id; d.v_avgload =3D svc->avgload; d.shift =3D P; - __trace_var(TRC_CSCHED2_UPDATE_VCPU_LOAD, 1, + __trace_var(TRC_CSCHED2_UPDATE_ITEM_LOAD, 1, sizeof(d), (unsigned char *)&d); } @@ -1272,18 +1272,18 @@ static void runq_insert(const struct scheduler *ops, struct csched2_item *svc) { struct list_head *iter; - unsigned int cpu =3D svc->vcpu->processor; + unsigned int cpu =3D sched_item_cpu(svc->item); struct list_head * runq =3D &c2rqd(ops, cpu)->runq; int pos =3D 0; =20 ASSERT(spin_is_locked(per_cpu(sched_res, cpu)->schedule_lock)); =20 - ASSERT(!vcpu_on_runq(svc)); - ASSERT(c2r(cpu) =3D=3D c2r(svc->vcpu->processor)); + ASSERT(!item_on_runq(svc)); + ASSERT(c2r(cpu) =3D=3D c2r(sched_item_cpu(svc->item))); =20 ASSERT(&svc->rqd->runq =3D=3D runq); - ASSERT(!is_idle_vcpu(svc->vcpu)); - ASSERT(!svc->vcpu->sched_item->is_running); + ASSERT(!is_idle_item(svc->item)); + ASSERT(!svc->item->is_running); ASSERT(!(svc->flags & CSFLAG_scheduled)); =20 list_for_each( iter, runq ) @@ -1300,11 +1300,11 @@ runq_insert(const struct scheduler *ops, struct csc= hed2_item *svc) if ( unlikely(tb_init_done) ) { struct { - unsigned vcpu:16, dom:16; + unsigned item:16, dom:16; unsigned pos; } d; - d.dom =3D svc->vcpu->domain->domain_id; - d.vcpu =3D svc->vcpu->vcpu_id; + d.dom =3D svc->item->domain->domain_id; + d.item =3D svc->item->item_id; d.pos =3D pos; __trace_var(TRC_CSCHED2_RUNQ_POS, 1, sizeof(d), @@ -1314,7 +1314,7 @@ runq_insert(const struct scheduler *ops, struct csche= d2_item *svc) =20 static inline void runq_remove(struct csched2_item *svc) { - ASSERT(vcpu_on_runq(svc)); + ASSERT(item_on_runq(svc)); list_del_init(&svc->runq_elem); } =20 @@ -1340,8 +1340,8 @@ static inline bool is_preemptable(const struct csched= 2_item *svc, if ( ratelimit <=3D CSCHED2_RATELIMIT_TICKLE_TOLERANCE ) return true; =20 - ASSERT(svc->vcpu->sched_item->is_running); - return now - svc->vcpu->sched_item->state_entry_time > + ASSERT(svc->item->is_running); + return now - svc->item->state_entry_time > ratelimit - CSCHED2_RATELIMIT_TICKLE_TOLERANCE; } =20 @@ -1369,17 +1369,17 @@ static s_time_t tickle_score(const struct scheduler= *ops, s_time_t now, =20 /* * We are dealing with cpus that are marked non-idle (i.e., that are n= ot - * in rqd->idle). However, some of them may be running their idle vcpu, + * in rqd->idle). However, some of them may be running their idle item, * if taking care of tasklets. In that case, we want to leave it alone. */ - if ( unlikely(is_idle_vcpu(cur->vcpu) || + if ( unlikely(is_idle_item(cur->item) || !is_preemptable(cur, now, MICROSECS(prv->ratelimit_us))) ) return -1; =20 burn_credits(rqd, cur, now); =20 score =3D new->credit - cur->credit; - if ( new->vcpu->processor !=3D cpu ) + if ( sched_item_cpu(new->item) !=3D cpu ) score -=3D CSCHED2_MIGRATE_RESIST; =20 /* @@ -1390,21 +1390,21 @@ static s_time_t tickle_score(const struct scheduler= *ops, s_time_t now, */ if ( score > 0 ) { - if ( cpumask_test_cpu(cpu, new->vcpu->sched_item->cpu_soft_affinit= y) ) + if ( cpumask_test_cpu(cpu, new->item->cpu_soft_affinity) ) score +=3D CSCHED2_CREDIT_INIT; =20 - if ( !cpumask_test_cpu(cpu, cur->vcpu->sched_item->cpu_soft_affini= ty) ) + if ( !cpumask_test_cpu(cpu, cur->item->cpu_soft_affinity) ) score +=3D CSCHED2_CREDIT_INIT; } =20 if ( unlikely(tb_init_done) ) { struct { - unsigned vcpu:16, dom:16; + unsigned item:16, dom:16; int credit, score; } d; - d.dom =3D cur->vcpu->domain->domain_id; - d.vcpu =3D cur->vcpu->vcpu_id; + d.dom =3D cur->item->domain->domain_id; + d.item =3D cur->item->item_id; d.credit =3D cur->credit; d.score =3D score; __trace_var(TRC_CSCHED2_TICKLE_CHECK, 1, @@ -1416,14 +1416,14 @@ static s_time_t tickle_score(const struct scheduler= *ops, s_time_t now, } =20 /* - * Check what processor it is best to 'wake', for picking up a vcpu that h= as + * Check what processor it is best to 'wake', for picking up an item that = has * just been put (back) in the runqueue. Logic is as follows: * 1. if there are idle processors in the runq, wake one of them; - * 2. if there aren't idle processor, check the one were the vcpu was + * 2. if there aren't idle processor, check the one were the item was * running before to see if we can preempt what's running there now * (and hence doing just one migration); - * 3. last stand: check all processors and see if the vcpu is in right - * of preempting any of the other vcpus running on them (this requires + * 3. last stand: check all processors and see if the item is in right + * of preempting any of the other items running on them (this requires * two migrations, and that's indeed why it is left as the last stand). * * Note that when we say 'idle processors' what we really mean is (pretty @@ -1436,10 +1436,10 @@ runq_tickle(const struct scheduler *ops, struct csc= hed2_item *new, s_time_t now) { int i, ipid =3D -1; s_time_t max =3D 0; - struct sched_item *item =3D new->vcpu->sched_item; - unsigned int bs, cpu =3D new->vcpu->processor; + struct sched_item *item =3D new->item; + unsigned int bs, cpu =3D sched_item_cpu(item); struct csched2_runqueue_data *rqd =3D c2rqd(ops, cpu); - cpumask_t *online =3D cpupool_domain_cpumask(new->vcpu->domain); + cpumask_t *online =3D cpupool_domain_cpumask(item->domain); cpumask_t mask; =20 ASSERT(new->rqd =3D=3D rqd); @@ -1447,13 +1447,13 @@ runq_tickle(const struct scheduler *ops, struct csc= hed2_item *new, s_time_t now) if ( unlikely(tb_init_done) ) { struct { - unsigned vcpu:16, dom:16; + unsigned item:16, dom:16; unsigned processor; int credit; } d; - d.dom =3D new->vcpu->domain->domain_id; - d.vcpu =3D new->vcpu->vcpu_id; - d.processor =3D new->vcpu->processor; + d.dom =3D item->domain->domain_id; + d.item =3D item->item_id; + d.processor =3D cpu; d.credit =3D new->credit; __trace_var(TRC_CSCHED2_TICKLE_NEW, 1, sizeof(d), @@ -1461,11 +1461,11 @@ runq_tickle(const struct scheduler *ops, struct csc= hed2_item *new, s_time_t now) } =20 /* - * Exclusive pinning is when a vcpu has hard-affinity with only one - * cpu, and there is no other vcpu that has hard-affinity with that + * Exclusive pinning is when an item has hard-affinity with only one + * cpu, and there is no other item that has hard-affinity with that * same cpu. This is infrequent, but if it happens, is for achieving * the most possible determinism, and least possible overhead for - * the vcpus in question. + * the items in question. * * Try to identify the vast majority of these situations, and deal * with them quickly. @@ -1532,7 +1532,7 @@ runq_tickle(const struct scheduler *ops, struct csche= d2_item *new, s_time_t now) /* * Note that, if we are here, it means we have done the hard-affinity * balancing step of the loop, and hence what we have in cpumask_scrat= ch - * is what we put there for last, i.e., new's vcpu_hard_affinity & onl= ine + * is what we put there for last, i.e., new's item_hard_affinity & onl= ine * which is exactly what we need for the next part of the function. */ =20 @@ -1543,7 +1543,7 @@ runq_tickle(const struct scheduler *ops, struct csche= d2_item *new, s_time_t now) * * For deciding which cpu to tickle, we use tickle_score(), which will * factor in both new's soft-affinity, and the soft-affinity of the - * vcpu running on each cpu that we consider. + * item running on each cpu that we consider. */ cpumask_andnot(&mask, &rqd->active, &rqd->idle); cpumask_andnot(&mask, &mask, &rqd->tickled); @@ -1588,7 +1588,7 @@ runq_tickle(const struct scheduler *ops, struct csche= d2_item *new, s_time_t now) return; } =20 - ASSERT(!is_idle_vcpu(curr_on_cpu(ipid)->vcpu)); + ASSERT(!is_idle_item(curr_on_cpu(ipid))); SCHED_STAT_CRANK(tickled_busy_cpu); tickle: BUG_ON(ipid =3D=3D -1); @@ -1623,16 +1623,16 @@ static void reset_credit(const struct scheduler *op= s, int cpu, s_time_t now, =20 /* * Under normal circumstances, snext->credit should never be less - * than -CSCHED2_MIN_TIMER. However, under some circumstances, a - * vcpu with low credits may be allowed to run long enough that + * than -CSCHED2_MIN_TIMER. However, under some circumstances, an + * item with low credits may be allowed to run long enough that * its credits are actually less than -CSCHED2_CREDIT_INIT. - * (Instances have been observed, for example, where a vcpu with + * (Instances have been observed, for example, where an item with * 200us of credit was allowed to run for 11ms, giving it -10.8ms * of credit. Thus it was still negative even after the reset.) * * If this is the case for snext, we simply want to keep moving * everyone up until it is in the black again. This fair because - * none of the other vcpus want to run at the moment. + * none of the other items want to run at the moment. * * Rather than looping, however, we just calculate a multiplier, * avoiding an integer division and multiplication in the common @@ -1649,16 +1649,16 @@ static void reset_credit(const struct scheduler *op= s, int cpu, s_time_t now, int start_credit; =20 svc =3D list_entry(iter, struct csched2_item, rqd_elem); - svc_cpu =3D svc->vcpu->processor; + svc_cpu =3D sched_item_cpu(svc->item); =20 - ASSERT(!is_idle_vcpu(svc->vcpu)); + ASSERT(!is_idle_item(svc->item)); ASSERT(svc->rqd =3D=3D rqd); =20 /* * If svc is running, it is our responsibility to make sure, here, * that the credit it has spent so far get accounted. */ - if ( svc->vcpu =3D=3D curr_on_cpu(svc_cpu)->vcpu ) + if ( svc->item =3D=3D curr_on_cpu(svc_cpu) ) { burn_credits(rqd, svc, now); /* @@ -1689,12 +1689,12 @@ static void reset_credit(const struct scheduler *op= s, int cpu, s_time_t now, if ( unlikely(tb_init_done) ) { struct { - unsigned vcpu:16, dom:16; + unsigned item:16, dom:16; int credit_start, credit_end; unsigned multiplier; } d; - d.dom =3D svc->vcpu->domain->domain_id; - d.vcpu =3D svc->vcpu->vcpu_id; + d.dom =3D svc->item->domain->domain_id; + d.item =3D svc->item->item_id; d.credit_start =3D start_credit; d.credit_end =3D svc->credit; d.multiplier =3D m; @@ -1714,9 +1714,9 @@ void burn_credits(struct csched2_runqueue_data *rqd, { s_time_t delta; =20 - ASSERT(svc =3D=3D csched2_item(curr_on_cpu(svc->vcpu->processor))); + ASSERT(svc =3D=3D csched2_item(curr_on_cpu(sched_item_cpu(svc->item)))= ); =20 - if ( unlikely(is_idle_vcpu(svc->vcpu)) ) + if ( unlikely(is_idle_item(svc->item)) ) { ASSERT(svc->credit =3D=3D CSCHED2_IDLE_CREDIT); return; @@ -1745,12 +1745,12 @@ void burn_credits(struct csched2_runqueue_data *rqd, if ( unlikely(tb_init_done) ) { struct { - unsigned vcpu:16, dom:16; + unsigned item:16, dom:16; int credit, budget; int delta; } d; - d.dom =3D svc->vcpu->domain->domain_id; - d.vcpu =3D svc->vcpu->vcpu_id; + d.dom =3D svc->item->domain->domain_id; + d.item =3D svc->item->item_id; d.credit =3D svc->credit; d.budget =3D has_cap(svc) ? svc->budget : INT_MIN; d.delta =3D delta; @@ -1764,39 +1764,39 @@ void burn_credits(struct csched2_runqueue_data *rqd, * Budget-related code. */ =20 -static void park_vcpu(struct csched2_item *svc) +static void park_item(struct csched2_item *svc) { - struct vcpu *v =3D svc->vcpu; + struct sched_item *item =3D svc->item; =20 ASSERT(spin_is_locked(&svc->sdom->budget_lock)); =20 /* - * It was impossible to find budget for this vCPU, so it has to be + * It was impossible to find budget for this item, so it has to be * "parked". This implies it is not runnable, so we mark it as such in - * its pause_flags. If the vCPU is currently scheduled (which means we + * its pause_flags. If the item is currently scheduled (which means we * are here after being called from within csched_schedule()), flagging * is enough, as we'll choose someone else, and then context_saved() * will take care of updating the load properly. * - * If, OTOH, the vCPU is sitting in the runqueue (which means we are h= ere + * If, OTOH, the item is sitting in the runqueue (which means we are h= ere * after being called from within runq_candidate()), we must go all the * way down to taking it out of there, and updating the load according= ly. * - * In both cases, we also add it to the list of parked vCPUs of the do= main. + * In both cases, we also add it to the list of parked items of the do= main. */ - __set_bit(_VPF_parked, &v->pause_flags); - if ( vcpu_on_runq(svc) ) + sched_set_pause_flags(item, _VPF_parked); + if ( item_on_runq(svc) ) { runq_remove(svc); update_load(svc->sdom->dom->cpupool->sched, svc->rqd, svc, -1, NOW= ()); } - list_add(&svc->parked_elem, &svc->sdom->parked_vcpus); + list_add(&svc->parked_elem, &svc->sdom->parked_items); } =20 -static bool vcpu_grab_budget(struct csched2_item *svc) +static bool item_grab_budget(struct csched2_item *svc) { struct csched2_dom *sdom =3D svc->sdom; - unsigned int cpu =3D svc->vcpu->processor; + unsigned int cpu =3D sched_item_cpu(svc->item); =20 ASSERT(spin_is_locked(per_cpu(sched_res, cpu)->schedule_lock)); =20 @@ -1808,9 +1808,9 @@ static bool vcpu_grab_budget(struct csched2_item *svc) =20 /* * Here, svc->budget is <=3D 0 (as, if it was > 0, we'd have taken the= if - * above!). That basically means the vCPU has overrun a bit --because = of + * above!). That basically means the item has overrun a bit --because = of * various reasons-- and we want to take that into account. With the += =3D, - * we are actually subtracting the amount of budget the vCPU has + * we are actually subtracting the amount of budget the item has * overconsumed, from the total domain budget. */ sdom->budget +=3D svc->budget; @@ -1831,7 +1831,7 @@ static bool vcpu_grab_budget(struct csched2_item *svc) else { svc->budget =3D 0; - park_vcpu(svc); + park_item(svc); } =20 spin_unlock(&sdom->budget_lock); @@ -1840,10 +1840,10 @@ static bool vcpu_grab_budget(struct csched2_item *s= vc) } =20 static void -vcpu_return_budget(struct csched2_item *svc, struct list_head *parked) +item_return_budget(struct csched2_item *svc, struct list_head *parked) { struct csched2_dom *sdom =3D svc->sdom; - unsigned int cpu =3D svc->vcpu->processor; + unsigned int cpu =3D sched_item_cpu(svc->item); =20 ASSERT(spin_is_locked(per_cpu(sched_res, cpu)->schedule_lock)); ASSERT(list_empty(parked)); @@ -1852,7 +1852,7 @@ vcpu_return_budget(struct csched2_item *svc, struct l= ist_head *parked) spin_lock(&sdom->budget_lock); =20 /* - * The vCPU is stopping running (e.g., because it's blocking, or it has + * The item is stopping running (e.g., because it's blocking, or it has * been preempted). If it hasn't consumed all the budget it got when, * starting to run, put that remaining amount back in the domain's bud= get * pool. @@ -1861,58 +1861,58 @@ vcpu_return_budget(struct csched2_item *svc, struct= list_head *parked) svc->budget =3D 0; =20 /* - * Making budget available again to the domain means that parked vCPUs - * may be unparked and run. They are, if any, in the domain's parked_v= cpus + * Making budget available again to the domain means that parked items + * may be unparked and run. They are, if any, in the domain's parked_i= tems * list, so we want to go through that and unpark them (so they can try * to get some budget). * * Touching the list requires the budget_lock, which we hold. Let's * therefore put everyone in that list in another, temporary list, whi= ch - * then the caller will traverse, unparking the vCPUs it finds there. + * then the caller will traverse, unparking the items it finds there. * * In fact, we can't do the actual unparking here, because that requir= es - * taking the runqueue lock of the vCPUs being unparked, and we can't + * taking the runqueue lock of the items being unparked, and we can't * take any runqueue locks while we hold a budget_lock. */ if ( sdom->budget > 0 ) - list_splice_init(&sdom->parked_vcpus, parked); + list_splice_init(&sdom->parked_items, parked); =20 spin_unlock(&sdom->budget_lock); } =20 static void -unpark_parked_vcpus(const struct scheduler *ops, struct list_head *vcpus) +unpark_parked_items(const struct scheduler *ops, struct list_head *items) { struct csched2_item *svc, *tmp; spinlock_t *lock; =20 - list_for_each_entry_safe(svc, tmp, vcpus, parked_elem) + list_for_each_entry_safe(svc, tmp, items, parked_elem) { unsigned long flags; s_time_t now; =20 - lock =3D item_schedule_lock_irqsave(svc->vcpu->sched_item, &flags); + lock =3D item_schedule_lock_irqsave(svc->item, &flags); =20 - __clear_bit(_VPF_parked, &svc->vcpu->pause_flags); + sched_clear_pause_flags(svc->item, _VPF_parked); if ( unlikely(svc->flags & CSFLAG_scheduled) ) { /* * We end here if a budget replenishment arrived between * csched2_schedule() (and, in particular, after a call to - * vcpu_grab_budget() that returned false), and + * item_grab_budget() that returned false), and * context_saved(). By setting __CSFLAG_delayed_runq_add, - * we tell context_saved() to put the vCPU back in the + * we tell context_saved() to put the item back in the * runqueue, from where it will compete with the others * for the newly replenished budget. */ ASSERT( svc->rqd !=3D NULL ); - ASSERT( c2rqd(ops, svc->vcpu->processor) =3D=3D svc->rqd ); + ASSERT( c2rqd(ops, sched_item_cpu(svc->item)) =3D=3D svc->rqd = ); __set_bit(__CSFLAG_delayed_runq_add, &svc->flags); } - else if ( vcpu_runnable(svc->vcpu) ) + else if ( item_runnable(svc->item) ) { /* - * The vCPU should go back to the runqueue, and compete for + * The item should go back to the runqueue, and compete for * the newly replenished budget, but only if it is actually * runnable (and was therefore offline only because of the * lack of budget). @@ -1924,7 +1924,7 @@ unpark_parked_vcpus(const struct scheduler *ops, stru= ct list_head *vcpus) } list_del_init(&svc->parked_elem); =20 - item_schedule_unlock_irqrestore(lock, flags, svc->vcpu->sched_item= ); + item_schedule_unlock_irqrestore(lock, flags, svc->item); } } =20 @@ -1954,7 +1954,7 @@ static void replenish_domain_budget(void* data) * * Even in cases of overrun or delay, however, we expect that in 99% of * cases, doing just one replenishment will be good enough for being a= ble - * to unpark the vCPUs that are waiting for some budget. + * to unpark the items that are waiting for some budget. */ do_replenish(sdom); =20 @@ -1974,7 +1974,7 @@ static void replenish_domain_budget(void* data) } /* * 2) if we overrun by more than tot_budget, then budget+tot_budget is - * still < 0, which means that we can't unpark the vCPUs. Let's bail, + * still < 0, which means that we can't unpark the items. Let's bail, * and wait for future replenishments. */ if ( unlikely(sdom->budget <=3D 0) ) @@ -1988,14 +1988,14 @@ static void replenish_domain_budget(void* data) =20 /* * As above, let's prepare the temporary list, out of the domain's - * parked_vcpus list, now that we hold the budget_lock. Then, drop such + * parked_items list, now that we hold the budget_lock. Then, drop such * lock, and pass the list to the unparking function. */ - list_splice_init(&sdom->parked_vcpus, &parked); + list_splice_init(&sdom->parked_items, &parked); =20 spin_unlock_irqrestore(&sdom->budget_lock, flags); =20 - unpark_parked_vcpus(sdom->dom->cpupool->sched, &parked); + unpark_parked_items(sdom->dom->cpupool->sched, &parked); =20 out: set_timer(&sdom->repl_timer, sdom->next_repl); @@ -2003,37 +2003,36 @@ static void replenish_domain_budget(void* data) =20 #ifndef NDEBUG static inline void -csched2_vcpu_check(struct vcpu *vc) +csched2_item_check(struct sched_item *item) { - struct csched2_item * const svc =3D csched2_item(vc->sched_item); + struct csched2_item * const svc =3D csched2_item(item); struct csched2_dom * const sdom =3D svc->sdom; =20 - BUG_ON( svc->vcpu !=3D vc ); - BUG_ON( sdom !=3D csched2_dom(vc->domain) ); + BUG_ON( svc->item !=3D item ); + BUG_ON( sdom !=3D csched2_dom(item->domain) ); if ( sdom ) { - BUG_ON( is_idle_vcpu(vc) ); - BUG_ON( sdom->dom !=3D vc->domain ); + BUG_ON( is_idle_item(item) ); + BUG_ON( sdom->dom !=3D item->domain ); } else { - BUG_ON( !is_idle_vcpu(vc) ); + BUG_ON( !is_idle_item(item) ); } SCHED_STAT_CRANK(item_check); } -#define CSCHED2_VCPU_CHECK(_vc) (csched2_vcpu_check(_vc)) +#define CSCHED2_ITEM_CHECK(item) (csched2_item_check(item)) #else -#define CSCHED2_VCPU_CHECK(_vc) +#define CSCHED2_ITEM_CHECK(item) #endif =20 static void * csched2_alloc_vdata(const struct scheduler *ops, struct sched_item *item, void *dd) { - struct vcpu *vc =3D item->vcpu; struct csched2_item *svc; =20 - /* Allocate per-VCPU info */ + /* Allocate per-ITEM info */ svc =3D xzalloc(struct csched2_item); if ( svc =3D=3D NULL ) return NULL; @@ -2042,10 +2041,10 @@ csched2_alloc_vdata(const struct scheduler *ops, st= ruct sched_item *item, INIT_LIST_HEAD(&svc->runq_elem); =20 svc->sdom =3D dd; - svc->vcpu =3D vc; + svc->item =3D item; svc->flags =3D 0U; =20 - if ( ! is_idle_vcpu(vc) ) + if ( ! is_idle_item(item) ) { ASSERT(svc->sdom !=3D NULL); svc->credit =3D CSCHED2_CREDIT_INIT; @@ -2074,19 +2073,18 @@ csched2_alloc_vdata(const struct scheduler *ops, st= ruct sched_item *item, static void csched2_item_sleep(const struct scheduler *ops, struct sched_item *item) { - struct vcpu *vc =3D item->vcpu; struct csched2_item * const svc =3D csched2_item(item); =20 - ASSERT(!is_idle_vcpu(vc)); + ASSERT(!is_idle_item(item)); SCHED_STAT_CRANK(item_sleep); =20 - if ( curr_on_cpu(vc->processor) =3D=3D item ) + if ( curr_on_cpu(sched_item_cpu(item)) =3D=3D item ) { - tickle_cpu(vc->processor, svc->rqd); + tickle_cpu(sched_item_cpu(item), svc->rqd); } - else if ( vcpu_on_runq(svc) ) + else if ( item_on_runq(svc) ) { - ASSERT(svc->rqd =3D=3D c2rqd(ops, vc->processor)); + ASSERT(svc->rqd =3D=3D c2rqd(ops, sched_item_cpu(item))); update_load(ops, svc->rqd, svc, -1, NOW()); runq_remove(svc); } @@ -2097,14 +2095,13 @@ csched2_item_sleep(const struct scheduler *ops, str= uct sched_item *item) static void csched2_item_wake(const struct scheduler *ops, struct sched_item *item) { - struct vcpu *vc =3D item->vcpu; struct csched2_item * const svc =3D csched2_item(item); - unsigned int cpu =3D vc->processor; + unsigned int cpu =3D sched_item_cpu(item); s_time_t now; =20 ASSERT(spin_is_locked(per_cpu(sched_res, cpu)->schedule_lock)); =20 - ASSERT(!is_idle_vcpu(vc)); + ASSERT(!is_idle_item(item)); =20 if ( unlikely(curr_on_cpu(cpu) =3D=3D item) ) { @@ -2112,18 +2109,18 @@ csched2_item_wake(const struct scheduler *ops, stru= ct sched_item *item) goto out; } =20 - if ( unlikely(vcpu_on_runq(svc)) ) + if ( unlikely(item_on_runq(svc)) ) { SCHED_STAT_CRANK(item_wake_onrunq); goto out; } =20 - if ( likely(vcpu_runnable(vc)) ) + if ( likely(item_runnable(item)) ) SCHED_STAT_CRANK(item_wake_runnable); else SCHED_STAT_CRANK(item_wake_not_runnable); =20 - /* If the context hasn't been saved for this vcpu yet, we can't put it= on + /* If the context hasn't been saved for this item yet, we can't put it= on * another runqueue. Instead, we set a flag so that it will be put on= the runqueue * after the context has been saved. */ if ( unlikely(svc->flags & CSFLAG_scheduled) ) @@ -2134,15 +2131,15 @@ csched2_item_wake(const struct scheduler *ops, stru= ct sched_item *item) =20 /* Add into the new runqueue if necessary */ if ( svc->rqd =3D=3D NULL ) - runq_assign(ops, vc); + runq_assign(ops, item); else - ASSERT(c2rqd(ops, vc->processor) =3D=3D svc->rqd ); + ASSERT(c2rqd(ops, sched_item_cpu(item)) =3D=3D svc->rqd ); =20 now =3D NOW(); =20 update_load(ops, svc->rqd, svc, 1, now); - =20 - /* Put the VCPU on the runq */ + + /* Put the ITEM on the runq */ runq_insert(ops, svc); runq_tickle(ops, svc, now); =20 @@ -2155,49 +2152,48 @@ csched2_item_yield(const struct scheduler *ops, str= uct sched_item *item) { struct csched2_item * const svc =3D csched2_item(item); =20 - __set_bit(__CSFLAG_vcpu_yield, &svc->flags); + __set_bit(__CSFLAG_item_yield, &svc->flags); } =20 static void csched2_context_saved(const struct scheduler *ops, struct sched_item *item) { - struct vcpu *vc =3D item->vcpu; struct csched2_item * const svc =3D csched2_item(item); spinlock_t *lock =3D item_schedule_lock_irq(item); s_time_t now =3D NOW(); LIST_HEAD(were_parked); =20 - BUG_ON( !is_idle_vcpu(vc) && svc->rqd !=3D c2rqd(ops, vc->processor)); - ASSERT(is_idle_vcpu(vc) || svc->rqd =3D=3D c2rqd(ops, vc->processor)); + BUG_ON( !is_idle_item(item) && svc->rqd !=3D c2rqd(ops, sched_item_cpu= (item))); + ASSERT(is_idle_item(item) || svc->rqd =3D=3D c2rqd(ops, sched_item_cpu= (item))); =20 - /* This vcpu is now eligible to be put on the runqueue again */ + /* This item is now eligible to be put on the runqueue again */ __clear_bit(__CSFLAG_scheduled, &svc->flags); =20 if ( unlikely(has_cap(svc) && svc->budget > 0) ) - vcpu_return_budget(svc, &were_parked); + item_return_budget(svc, &were_parked); =20 /* If someone wants it on the runqueue, put it there. */ /* * NB: We can get rid of CSFLAG_scheduled by checking for - * vc->is_running and vcpu_on_runq(svc) here. However, + * vc->is_running and item_on_runq(svc) here. However, * since we're accessing the flags cacheline anyway, * it seems a bit pointless; especially as we have plenty of * bits free. */ if ( __test_and_clear_bit(__CSFLAG_delayed_runq_add, &svc->flags) - && likely(vcpu_runnable(vc)) ) + && likely(item_runnable(item)) ) { - ASSERT(!vcpu_on_runq(svc)); + ASSERT(!item_on_runq(svc)); =20 runq_insert(ops, svc); runq_tickle(ops, svc, now); } - else if ( !is_idle_vcpu(vc) ) + else if ( !is_idle_item(item) ) update_load(ops, svc->rqd, svc, -1, now); =20 item_schedule_unlock_irq(lock, item); =20 - unpark_parked_vcpus(ops, &were_parked); + unpark_parked_items(ops, &were_parked); } =20 #define MAX_LOAD (STIME_MAX) @@ -2205,9 +2201,8 @@ static struct sched_resource * csched2_res_pick(const struct scheduler *ops, struct sched_item *item) { struct csched2_private *prv =3D csched2_priv(ops); - struct vcpu *vc =3D item->vcpu; int i, min_rqi =3D -1, min_s_rqi =3D -1; - unsigned int new_cpu, cpu =3D vc->processor; + unsigned int new_cpu, cpu =3D sched_item_cpu(item); struct csched2_item *svc =3D csched2_item(item); s_time_t min_avgload =3D MAX_LOAD, min_s_avgload =3D MAX_LOAD; bool has_soft; @@ -2245,7 +2240,7 @@ csched2_res_pick(const struct scheduler *ops, struct = sched_item *item) } =20 cpumask_and(cpumask_scratch_cpu(cpu), item->cpu_hard_affinity, - cpupool_domain_cpumask(vc->domain)); + cpupool_domain_cpumask(item->domain)); =20 /* * First check to see if we're here because someone else suggested a p= lace @@ -2356,7 +2351,7 @@ csched2_res_pick(const struct scheduler *ops, struct = sched_item *item) * We have soft affinity, and we have a candidate runq, so go for = it. * * Note that, to obtain the soft-affinity mask, we "just" put what= we - * have in cpumask_scratch in && with vc->cpu_soft_affinity. This = is + * have in cpumask_scratch in && with item->cpu_soft_affinity. Thi= s is * ok because: * - we know that item->cpu_hard_affinity and ->cpu_soft_affinity = have * a non-empty intersection (because has_soft is true); @@ -2379,7 +2374,7 @@ csched2_res_pick(const struct scheduler *ops, struct = sched_item *item) * any suitable runq. But we did find one when considering hard * affinity, so go for it. * - * cpumask_scratch already has vc->cpu_hard_affinity & + * cpumask_scratch already has item->cpu_hard_affinity & * cpupool_domain_cpumask() in it, so it's enough that we filter * with the cpus of the runq. */ @@ -2410,11 +2405,11 @@ csched2_res_pick(const struct scheduler *ops, struc= t sched_item *item) { struct { uint64_t b_avgload; - unsigned vcpu:16, dom:16; + unsigned item:16, dom:16; unsigned rq_id:16, new_cpu:16; } d; - d.dom =3D vc->domain->domain_id; - d.vcpu =3D vc->vcpu_id; + d.dom =3D item->domain->domain_id; + d.item =3D item->item_id; d.rq_id =3D min_rqi; d.b_avgload =3D min_avgload; d.new_cpu =3D new_cpu; @@ -2433,10 +2428,10 @@ typedef struct { struct csched2_item * best_push_svc, *best_pull_svc; /* NB: Read by consider() */ struct csched2_runqueue_data *lrqd; - struct csched2_runqueue_data *orqd; =20 + struct csched2_runqueue_data *orqd; } balance_state_t; =20 -static void consider(balance_state_t *st,=20 +static void consider(balance_state_t *st, struct csched2_item *push_svc, struct csched2_item *pull_svc) { @@ -2475,17 +2470,17 @@ static void migrate(const struct scheduler *ops, struct csched2_runqueue_data *trqd, s_time_t now) { - int cpu =3D svc->vcpu->processor; - struct sched_item *item =3D svc->vcpu->sched_item; + struct sched_item *item =3D svc->item; + int cpu =3D sched_item_cpu(item); =20 if ( unlikely(tb_init_done) ) { struct { - unsigned vcpu:16, dom:16; + unsigned item:16, dom:16; unsigned rqi:16, trqi:16; } d; - d.dom =3D svc->vcpu->domain->domain_id; - d.vcpu =3D svc->vcpu->vcpu_id; + d.dom =3D item->domain->domain_id; + d.item =3D item->item_id; d.rqi =3D svc->rqd->id; d.trqi =3D trqd->id; __trace_var(TRC_CSCHED2_MIGRATE, 1, @@ -2497,7 +2492,7 @@ static void migrate(const struct scheduler *ops, { /* It's running; mark it to migrate. */ svc->migrate_rqd =3D trqd; - __set_bit(_VPF_migrating, &svc->vcpu->pause_flags); + sched_set_pause_flags(item, _VPF_migrating); __set_bit(__CSFLAG_runq_migrate_request, &svc->flags); SCHED_STAT_CRANK(migrate_requested); tickle_cpu(cpu, svc->rqd); @@ -2506,7 +2501,7 @@ static void migrate(const struct scheduler *ops, { int on_runq =3D 0; /* It's not running; just move it */ - if ( vcpu_on_runq(svc) ) + if ( item_on_runq(svc) ) { runq_remove(svc); update_load(ops, svc->rqd, NULL, -1, now); @@ -2515,14 +2510,14 @@ static void migrate(const struct scheduler *ops, _runq_deassign(svc); =20 cpumask_and(cpumask_scratch_cpu(cpu), item->cpu_hard_affinity, - cpupool_domain_cpumask(svc->vcpu->domain)); + cpupool_domain_cpumask(item->domain)); cpumask_and(cpumask_scratch_cpu(cpu), cpumask_scratch_cpu(cpu), &trqd->active); - svc->vcpu->processor =3D cpumask_cycle(trqd->pick_bias, - cpumask_scratch_cpu(cpu)); - svc->vcpu->sched_item->res =3D per_cpu(sched_res, svc->vcpu->proce= ssor); - trqd->pick_bias =3D svc->vcpu->processor; - ASSERT(svc->vcpu->processor < nr_cpu_ids); + sched_set_res(item, per_cpu(sched_res, + cpumask_cycle(trqd->pick_bias, + cpumask_scratch_cpu(cpu)= ))); + trqd->pick_bias =3D sched_item_cpu(item); + ASSERT(sched_item_cpu(item) < nr_cpu_ids); =20 _runq_assign(svc, trqd); if ( on_runq ) @@ -2542,14 +2537,14 @@ static void migrate(const struct scheduler *ops, * - svc is not already flagged to migrate, * - if svc is allowed to run on at least one of the pcpus of rqd. */ -static bool vcpu_is_migrateable(struct csched2_item *svc, +static bool item_is_migrateable(struct csched2_item *svc, struct csched2_runqueue_data *rqd) { - struct vcpu *v =3D svc->vcpu; - int cpu =3D svc->vcpu->processor; + struct sched_item *item =3D svc->item; + int cpu =3D sched_item_cpu(item); =20 - cpumask_and(cpumask_scratch_cpu(cpu), v->sched_item->cpu_hard_affinity, - cpupool_domain_cpumask(v->domain)); + cpumask_and(cpumask_scratch_cpu(cpu), item->cpu_hard_affinity, + cpupool_domain_cpumask(item->domain)); =20 return !(svc->flags & CSFLAG_runq_migrate_request) && cpumask_intersects(cpumask_scratch_cpu(cpu), &rqd->active); @@ -2586,7 +2581,7 @@ retry: for_each_cpu(i, &prv->active_queues) { s_time_t delta; - =20 + st.orqd =3D prv->rqd + i; =20 if ( st.orqd =3D=3D st.lrqd @@ -2594,7 +2589,7 @@ retry: continue; =20 update_runq_load(ops, st.orqd, 0, now); - =20 + delta =3D st.lrqd->b_avgload - st.orqd->b_avgload; if ( delta < 0 ) delta =3D -delta; @@ -2617,7 +2612,7 @@ retry: s_time_t load_max; int cpus_max; =20 - =20 + load_max =3D st.lrqd->b_avgload; if ( st.orqd->b_avgload > load_max ) load_max =3D st.orqd->b_avgload; @@ -2656,7 +2651,7 @@ retry: opt_overload_balance_tolerance)= ) ) goto out; } - =20 + /* Try to grab the other runqueue lock; if it's been taken in the * meantime, try the process over again. This can't deadlock * because if it doesn't get any other rqd locks, it will simply @@ -2696,17 +2691,17 @@ retry: =20 update_svc_load(ops, push_svc, 0, now); =20 - if ( !vcpu_is_migrateable(push_svc, st.orqd) ) + if ( !item_is_migrateable(push_svc, st.orqd) ) continue; =20 list_for_each( pull_iter, &st.orqd->svc ) { struct csched2_item * pull_svc =3D list_entry(pull_iter, struc= t csched2_item, rqd_elem); - =20 + if ( !inner_load_updated ) update_svc_load(ops, pull_svc, 0, now); - =20 - if ( !vcpu_is_migrateable(pull_svc, st.lrqd) ) + + if ( !item_is_migrateable(pull_svc, st.lrqd) ) continue; =20 consider(&st, push_svc, pull_svc); @@ -2721,8 +2716,8 @@ retry: list_for_each( pull_iter, &st.orqd->svc ) { struct csched2_item * pull_svc =3D list_entry(pull_iter, struct cs= ched2_item, rqd_elem); - =20 - if ( !vcpu_is_migrateable(pull_svc, st.lrqd) ) + + if ( !item_is_migrateable(pull_svc, st.lrqd) ) continue; =20 /* Consider pull only */ @@ -2745,8 +2740,7 @@ static void csched2_item_migrate( const struct scheduler *ops, struct sched_item *item, unsigned int new= _cpu) { - struct vcpu *vc =3D item->vcpu; - struct domain *d =3D vc->domain; + struct domain *d =3D item->domain; struct csched2_item * const svc =3D csched2_item(item); struct csched2_runqueue_data *trqd; s_time_t now =3D NOW(); @@ -2758,25 +2752,24 @@ csched2_item_migrate( * cpupool. * * And since there indeed is the chance that it is not part of it, all - * we must do is remove _and_ unassign the vCPU from any runqueue, as + * we must do is remove _and_ unassign the item from any runqueue, as * well as updating v->processor with the target, so that the suspend * process can continue. * * It will then be during resume that a new, meaningful, value for * v->processor will be chosen, and during actual domain unpause that - * the vCPU will be assigned to and added to the proper runqueue. + * the item will be assigned to and added to the proper runqueue. */ if ( unlikely(!cpumask_test_cpu(new_cpu, cpupool_domain_cpumask(d))) ) { ASSERT(system_state =3D=3D SYS_STATE_suspend); - if ( vcpu_on_runq(svc) ) + if ( item_on_runq(svc) ) { runq_remove(svc); update_load(ops, svc->rqd, NULL, -1, now); } _runq_deassign(svc); - vc->processor =3D new_cpu; - item->res =3D per_cpu(sched_res, new_cpu); + sched_set_res(item, per_cpu(sched_res, new_cpu)); return; } =20 @@ -2790,17 +2783,14 @@ csched2_item_migrate( * Do the actual movement toward new_cpu, and update vc->processor. * If we are changing runqueue, migrate() takes care of everything. * If we are not changing runqueue, we need to update vc->processor - * here. In fact, if, for instance, we are here because the vcpu's + * here. In fact, if, for instance, we are here because the item's * hard affinity changed, we don't want to risk leaving vc->processor * pointing to a pcpu where we can't run any longer. */ if ( trqd !=3D svc->rqd ) migrate(ops, svc, trqd, now); else - { - vc->processor =3D new_cpu; - item->res =3D per_cpu(sched_res, new_cpu); - } + sched_set_res(item, per_cpu(sched_res, new_cpu)); } =20 static int @@ -2812,18 +2802,18 @@ csched2_dom_cntl( struct csched2_dom * const sdom =3D csched2_dom(d); struct csched2_private *prv =3D csched2_priv(ops); unsigned long flags; - struct vcpu *v; + struct sched_item *item; int rc =3D 0; =20 /* * Locking: * - we must take the private lock for accessing the weights of the - * vcpus of d, and/or the cap; + * items of d, and/or the cap; * - in the putinfo case, we also need the runqueue lock(s), for * updating the max waight of the runqueue(s). * If changing the cap, we also need the budget_lock, for updating * the value of the domain budget pool (and the runqueue lock, - * for adjusting the parameters and rescheduling any vCPU that is + * for adjusting the parameters and rescheduling any item that is * running at the time of the change). */ switch ( op->cmd ) @@ -2845,18 +2835,18 @@ csched2_dom_cntl( =20 sdom->weight =3D op->u.credit2.weight; =20 - /* Update weights for vcpus, and max_weight for runqueues on w= hich they reside */ - for_each_vcpu ( d, v ) + /* Update weights for items, and max_weight for runqueues on w= hich they reside */ + for_each_sched_item ( d, item ) { - struct csched2_item *svc =3D csched2_item(v->sched_item); - spinlock_t *lock =3D item_schedule_lock(svc->vcpu->sched_i= tem); + struct csched2_item *svc =3D csched2_item(item); + spinlock_t *lock =3D item_schedule_lock(item); =20 - ASSERT(svc->rqd =3D=3D c2rqd(ops, svc->vcpu->processor)); + ASSERT(svc->rqd =3D=3D c2rqd(ops, sched_item_cpu(item))); =20 svc->weight =3D sdom->weight; update_max_weight(svc->rqd, svc->weight, old_weight); =20 - item_schedule_unlock(lock, svc->vcpu->sched_item); + item_schedule_unlock(lock, item); } } /* Cap */ @@ -2865,8 +2855,8 @@ csched2_dom_cntl( struct csched2_item *svc; spinlock_t *lock; =20 - /* Cap is only valid if it's below 100 * nr_of_vCPUS */ - if ( op->u.credit2.cap > 100 * sdom->nr_vcpus ) + /* Cap is only valid if it's below 100 * nr_of_items */ + if ( op->u.credit2.cap > 100 * sdom->nr_items ) { rc =3D -EINVAL; write_unlock_irqrestore(&prv->lock, flags); @@ -2879,23 +2869,23 @@ csched2_dom_cntl( spin_unlock(&sdom->budget_lock); =20 /* - * When trying to get some budget and run, each vCPU will grab - * from the pool 1/N (with N =3D nr of vCPUs of the domain) of - * the total budget. Roughly speaking, this means each vCPU wi= ll + * When trying to get some budget and run, each item will grab + * from the pool 1/N (with N =3D nr of items of the domain) of + * the total budget. Roughly speaking, this means each item wi= ll * have at least one chance to run during every period. */ - for_each_vcpu ( d, v ) + for_each_sched_item ( d, item ) { - svc =3D csched2_item(v->sched_item); - lock =3D item_schedule_lock(svc->vcpu->sched_item); + svc =3D csched2_item(item); + lock =3D item_schedule_lock(item); /* * Too small quotas would in theory cause a lot of overhea= d, * which then won't happen because, in csched2_runtime(), * CSCHED2_MIN_TIMER is what would be used anyway. */ - svc->budget_quota =3D max(sdom->tot_budget / sdom->nr_vcpu= s, + svc->budget_quota =3D max(sdom->tot_budget / sdom->nr_item= s, CSCHED2_MIN_TIMER); - item_schedule_unlock(lock, svc->vcpu->sched_item); + item_schedule_unlock(lock, item); } =20 if ( sdom->cap =3D=3D 0 ) @@ -2905,7 +2895,7 @@ csched2_dom_cntl( * and queue its first replenishment event. * * Since cap is currently disabled for this domain, we - * know no vCPU is messing with the domain's budget, and + * know no item is messing with the domain's budget, and * the replenishment timer is still off. * For these reasons, it is safe to do the following witho= ut * taking the budget_lock. @@ -2915,42 +2905,42 @@ csched2_dom_cntl( set_timer(&sdom->repl_timer, sdom->next_repl); =20 /* - * Now, let's enable budget accounting for all the vCPUs. + * Now, let's enable budget accounting for all the items. * For making sure that they will start to honour the doma= in's * cap, we set their budget to 0. * This way, as soon as they will try to run, they will ha= ve * to get some budget. * - * For the vCPUs that are already running, we trigger the + * For the items that are already running, we trigger the * scheduler on their pCPU. When, as a consequence of this, * csched2_schedule() will run, it will figure out there is - * no budget, and the vCPU will try to get some (and be pa= rked, + * no budget, and the item will try to get some (and be pa= rked, * if there's none, and we'll switch to someone else). */ - for_each_vcpu ( d, v ) + for_each_sched_item ( d, item ) { - svc =3D csched2_item(v->sched_item); - lock =3D item_schedule_lock(svc->vcpu->sched_item); - if ( v->sched_item->is_running ) + svc =3D csched2_item(item); + lock =3D item_schedule_lock(item); + if ( item->is_running ) { - unsigned int cpu =3D v->processor; + unsigned int cpu =3D sched_item_cpu(item); struct csched2_runqueue_data *rqd =3D c2rqd(ops, c= pu); =20 - ASSERT(curr_on_cpu(cpu)->vcpu =3D=3D v); + ASSERT(curr_on_cpu(cpu) =3D=3D item); =20 /* - * We are triggering a reschedule on the vCPU's + * We are triggering a reschedule on the item's * pCPU. That will run burn_credits() and, since - * the vCPU is capped now, it would charge all the + * the item is capped now, it would charge all the * execution time of this last round as budget as - * well. That will make the vCPU budget go negativ= e, + * well. That will make the item budget go negativ= e, * potentially by a large amount, and it's unfair. * * To avoid that, call burn_credit() here, to do t= he * accounting of this current running instance now, * with budgetting still disabled. This does not * prevent some small amount of budget being charg= ed - * to the vCPU (i.e., the amount of time it runs f= rom + * to the item (i.e., the amount of time it runs f= rom * now, to when scheduling happens). The budget wi= ll * also go below 0, but a lot less than how it wou= ld * if we don't do this. @@ -2961,7 +2951,7 @@ csched2_dom_cntl( cpu_raise_softirq(cpu, SCHEDULE_SOFTIRQ); } svc->budget =3D 0; - item_schedule_unlock(lock, svc->vcpu->sched_item); + item_schedule_unlock(lock, item); } } =20 @@ -2973,30 +2963,30 @@ csched2_dom_cntl( =20 stop_timer(&sdom->repl_timer); =20 - /* Disable budget accounting for all the vCPUs. */ - for_each_vcpu ( d, v ) + /* Disable budget accounting for all the items. */ + for_each_sched_item ( d, item ) { - struct csched2_item *svc =3D csched2_item(v->sched_item); - spinlock_t *lock =3D item_schedule_lock(svc->vcpu->sched_i= tem); + struct csched2_item *svc =3D csched2_item(item); + spinlock_t *lock =3D item_schedule_lock(item); =20 svc->budget =3D STIME_MAX; svc->budget_quota =3D 0; =20 - item_schedule_unlock(lock, svc->vcpu->sched_item); + item_schedule_unlock(lock, item); } sdom->cap =3D 0; /* * We are disabling the cap for this domain, which may have - * vCPUs waiting for a replenishment, so we unpark them all. + * items waiting for a replenishment, so we unpark them all. * Note that, since we have already disabled budget accounting - * for all the vCPUs of the domain, no currently running vCPU - * will be added to the parked vCPUs list any longer. + * for all the items of the domain, no currently running item + * will be added to the parked items list any longer. */ spin_lock(&sdom->budget_lock); - list_splice_init(&sdom->parked_vcpus, &parked); + list_splice_init(&sdom->parked_items, &parked); spin_unlock(&sdom->budget_lock); =20 - unpark_parked_vcpus(ops, &parked); + unpark_parked_items(ops, &parked); } write_unlock_irqrestore(&prv->lock, flags); break; @@ -3073,12 +3063,12 @@ csched2_alloc_domdata(const struct scheduler *ops, = struct domain *dom) sdom->dom =3D dom; sdom->weight =3D CSCHED2_DEFAULT_WEIGHT; sdom->cap =3D 0U; - sdom->nr_vcpus =3D 0; + sdom->nr_items =3D 0; =20 init_timer(&sdom->repl_timer, replenish_domain_budget, sdom, cpumask_any(cpupool_domain_cpumask(dom))); spin_lock_init(&sdom->budget_lock); - INIT_LIST_HEAD(&sdom->parked_vcpus); + INIT_LIST_HEAD(&sdom->parked_items); =20 write_lock_irqsave(&prv->lock, flags); =20 @@ -3112,34 +3102,32 @@ csched2_free_domdata(const struct scheduler *ops, v= oid *data) static void csched2_item_insert(const struct scheduler *ops, struct sched_item *item) { - struct vcpu *vc =3D item->vcpu; struct csched2_item *svc =3D item->priv; struct csched2_dom * const sdom =3D svc->sdom; spinlock_t *lock; =20 - ASSERT(!is_idle_vcpu(vc)); + ASSERT(!is_idle_item(item)); ASSERT(list_empty(&svc->runq_elem)); =20 /* csched2_res_pick() expects the pcpu lock to be held */ lock =3D item_schedule_lock_irq(item); =20 - item->res =3D csched2_res_pick(ops, item); - vc->processor =3D item->res->processor; + sched_set_res(item, csched2_res_pick(ops, item)); =20 spin_unlock_irq(lock); =20 lock =3D item_schedule_lock_irq(item); =20 - /* Add vcpu to runqueue of initial processor */ - runq_assign(ops, vc); + /* Add item to runqueue of initial processor */ + runq_assign(ops, item); =20 item_schedule_unlock_irq(lock, item); =20 - sdom->nr_vcpus++; + sdom->nr_items++; =20 SCHED_STAT_CRANK(item_insert); =20 - CSCHED2_VCPU_CHECK(vc); + CSCHED2_ITEM_CHECK(item); } =20 static void @@ -3153,11 +3141,10 @@ csched2_free_vdata(const struct scheduler *ops, voi= d *priv) static void csched2_item_remove(const struct scheduler *ops, struct sched_item *item) { - struct vcpu *vc =3D item->vcpu; struct csched2_item * const svc =3D csched2_item(item); spinlock_t *lock; =20 - ASSERT(!is_idle_vcpu(vc)); + ASSERT(!is_idle_item(item)); ASSERT(list_empty(&svc->runq_elem)); =20 SCHED_STAT_CRANK(item_remove); @@ -3165,14 +3152,14 @@ csched2_item_remove(const struct scheduler *ops, st= ruct sched_item *item) /* Remove from runqueue */ lock =3D item_schedule_lock_irq(item); =20 - runq_deassign(ops, vc); + runq_deassign(ops, item); =20 item_schedule_unlock_irq(lock, item); =20 - svc->sdom->nr_vcpus--; + svc->sdom->nr_items--; } =20 -/* How long should we let this vcpu run for? */ +/* How long should we let this item run for? */ static s_time_t csched2_runtime(const struct scheduler *ops, int cpu, struct csched2_item *snext, s_time_t now) @@ -3187,7 +3174,7 @@ csched2_runtime(const struct scheduler *ops, int cpu, * If we're idle, just stay so. Others (or external events) * will poke us when necessary. */ - if ( is_idle_vcpu(snext->vcpu) ) + if ( is_idle_item(snext->item) ) return -1; =20 /* General algorithm: @@ -3204,8 +3191,8 @@ csched2_runtime(const struct scheduler *ops, int cpu, if ( prv->ratelimit_us ) { s_time_t ratelimit_min =3D MICROSECS(prv->ratelimit_us); - if ( snext->vcpu->sched_item->is_running ) - ratelimit_min =3D snext->vcpu->sched_item->state_entry_time + + if ( snext->item->is_running ) + ratelimit_min =3D snext->item->state_entry_time + MICROSECS(prv->ratelimit_us) - now; if ( ratelimit_min > min_time ) min_time =3D ratelimit_min; @@ -3222,7 +3209,7 @@ csched2_runtime(const struct scheduler *ops, int cpu, { struct csched2_item *swait =3D runq_elem(runq->next); =20 - if ( ! is_idle_vcpu(swait->vcpu) + if ( ! is_idle_item(swait->item) && swait->credit > 0 ) { rt_credit =3D snext->credit - swait->credit; @@ -3236,7 +3223,7 @@ csched2_runtime(const struct scheduler *ops, int cpu, * * FIXME: See if we can eliminate this conversion if we know time * will be outside (MIN,MAX). Probably requires pre-calculating - * credit values of MIN,MAX per vcpu, since each vcpu burns credit + * credit values of MIN,MAX per item, since each item burns credit * at a different rate. */ if ( rt_credit > 0 ) @@ -3284,36 +3271,35 @@ runq_candidate(struct csched2_runqueue_data *rqd, =20 *skipped =3D 0; =20 - if ( unlikely(is_idle_vcpu(scurr->vcpu)) ) + if ( unlikely(is_idle_item(scurr->item)) ) { snext =3D scurr; goto check_runq; } =20 - yield =3D __test_and_clear_bit(__CSFLAG_vcpu_yield, &scurr->flags); + yield =3D __test_and_clear_bit(__CSFLAG_item_yield, &scurr->flags); =20 /* - * Return the current vcpu if it has executed for less than ratelimit. - * Adjuststment for the selected vcpu's credit and decision + * Return the current item if it has executed for less than ratelimit. + * Adjuststment for the selected item's credit and decision * for how long it will run will be taken in csched2_runtime. * * Note that, if scurr is yielding, we don't let rate limiting kick in. * In fact, it may be the case that scurr is about to spin, and there's * no point forcing it to do so until rate limiting expires. */ - if ( !yield && prv->ratelimit_us && vcpu_runnable(scurr->vcpu) && - (now - scurr->vcpu->sched_item->state_entry_time) < - MICROSECS(prv->ratelimit_us) ) + if ( !yield && prv->ratelimit_us && item_runnable(scurr->item) && + (now - scurr->item->state_entry_time) < MICROSECS(prv->ratelimit_= us) ) { if ( unlikely(tb_init_done) ) { struct { - unsigned vcpu:16, dom:16; + unsigned item:16, dom:16; unsigned runtime; } d; - d.dom =3D scurr->vcpu->domain->domain_id; - d.vcpu =3D scurr->vcpu->vcpu_id; - d.runtime =3D now - scurr->vcpu->sched_item->state_entry_time; + d.dom =3D scurr->item->domain->domain_id; + d.item =3D scurr->item->item_id; + d.runtime =3D now - scurr->item->state_entry_time; __trace_var(TRC_CSCHED2_RATELIMIT, 1, sizeof(d), (unsigned char *)&d); @@ -3322,13 +3308,13 @@ runq_candidate(struct csched2_runqueue_data *rqd, } =20 /* If scurr has a soft-affinity, let's check whether cpu is part of it= */ - if ( has_soft_affinity(scurr->vcpu->sched_item) ) + if ( has_soft_affinity(scurr->item) ) { - affinity_balance_cpumask(scurr->vcpu->sched_item, BALANCE_SOFT_AFF= INITY, + affinity_balance_cpumask(scurr->item, BALANCE_SOFT_AFFINITY, cpumask_scratch); if ( unlikely(!cpumask_test_cpu(cpu, cpumask_scratch)) ) { - cpumask_t *online =3D cpupool_domain_cpumask(scurr->vcpu->doma= in); + cpumask_t *online =3D cpupool_domain_cpumask(scurr->item->doma= in); =20 /* Ok, is any of the pcpus in scurr soft-affinity idle? */ cpumask_and(cpumask_scratch, cpumask_scratch, &rqd->idle); @@ -3356,10 +3342,10 @@ runq_candidate(struct csched2_runqueue_data *rqd, * * Of course, we also default to idle also if scurr is not runnable. */ - if ( vcpu_runnable(scurr->vcpu) && !soft_aff_preempt ) + if ( item_runnable(scurr->item) && !soft_aff_preempt ) snext =3D scurr; else - snext =3D csched2_item(idle_vcpu[cpu]->sched_item); + snext =3D csched2_item(sched_idle_item(cpu)); =20 check_runq: list_for_each_safe( iter, temp, &rqd->runq ) @@ -3369,24 +3355,24 @@ runq_candidate(struct csched2_runqueue_data *rqd, if ( unlikely(tb_init_done) ) { struct { - unsigned vcpu:16, dom:16; + unsigned item:16, dom:16; } d; - d.dom =3D svc->vcpu->domain->domain_id; - d.vcpu =3D svc->vcpu->vcpu_id; + d.dom =3D svc->item->domain->domain_id; + d.item =3D svc->item->item_id; __trace_var(TRC_CSCHED2_RUNQ_CAND_CHECK, 1, sizeof(d), (unsigned char *)&d); } =20 - /* Only consider vcpus that are allowed to run on this processor. = */ - if ( !cpumask_test_cpu(cpu, svc->vcpu->sched_item->cpu_hard_affini= ty) ) + /* Only consider items that are allowed to run on this processor. = */ + if ( !cpumask_test_cpu(cpu, svc->item->cpu_hard_affinity) ) { (*skipped)++; continue; } =20 /* - * If a vcpu is meant to be picked up by another processor, and su= ch + * If an item is meant to be picked up by another processor, and s= uch * processor has not scheduled yet, leave it in the runqueue for h= im. */ if ( svc->tickled_cpu !=3D -1 && svc->tickled_cpu !=3D cpu && @@ -3401,7 +3387,7 @@ runq_candidate(struct csched2_runqueue_data *rqd, * If this is on a different processor, don't pull it unless * its credit is at least CSCHED2_MIGRATE_RESIST higher. */ - if ( svc->vcpu->processor !=3D cpu + if ( sched_item_cpu(svc->item) !=3D cpu && snext->credit + CSCHED2_MIGRATE_RESIST > svc->credit ) { (*skipped)++; @@ -3416,7 +3402,7 @@ runq_candidate(struct csched2_runqueue_data *rqd, * some budget, then choose it. */ if ( (yield || svc->credit > snext->credit) && - (!has_cap(svc) || vcpu_grab_budget(svc)) ) + (!has_cap(svc) || item_grab_budget(svc)) ) snext =3D svc; =20 /* In any case, if we got this far, break. */ @@ -3426,12 +3412,12 @@ runq_candidate(struct csched2_runqueue_data *rqd, if ( unlikely(tb_init_done) ) { struct { - unsigned vcpu:16, dom:16; + unsigned item:16, dom:16; unsigned tickled_cpu, skipped; int credit; } d; - d.dom =3D snext->vcpu->domain->domain_id; - d.vcpu =3D snext->vcpu->vcpu_id; + d.dom =3D snext->item->domain->domain_id; + d.item =3D snext->item->item_id; d.credit =3D snext->credit; d.tickled_cpu =3D snext->tickled_cpu; d.skipped =3D *skipped; @@ -3463,14 +3449,15 @@ csched2_schedule( { const int cpu =3D smp_processor_id(); struct csched2_runqueue_data *rqd; - struct csched2_item * const scurr =3D csched2_item(current->sched_item= ); + struct sched_item *curritem =3D current->sched_item; + struct csched2_item * const scurr =3D csched2_item(curritem); struct csched2_item *snext =3D NULL; - unsigned int skipped_vcpus =3D 0; + unsigned int skipped_items =3D 0; struct task_slice ret; bool tickled; =20 SCHED_STAT_CRANK(schedule); - CSCHED2_VCPU_CHECK(current); + CSCHED2_ITEM_CHECK(curritem); =20 BUG_ON(!cpumask_test_cpu(cpu, &csched2_priv(ops)->initialized)); =20 @@ -3479,7 +3466,7 @@ csched2_schedule( =20 ASSERT(spin_is_locked(per_cpu(sched_res, cpu)->schedule_lock)); =20 - BUG_ON(!is_idle_vcpu(scurr->vcpu) && scurr->rqd !=3D rqd); + BUG_ON(!is_idle_item(curritem) && scurr->rqd !=3D rqd); =20 /* Clear "tickled" bit now that we've been scheduled */ tickled =3D cpumask_test_cpu(cpu, &rqd->tickled); @@ -3499,7 +3486,7 @@ csched2_schedule( d.cpu =3D cpu; d.rq_id =3D c2r(cpu); d.tasklet =3D tasklet_work_scheduled; - d.idle =3D is_idle_vcpu(current); + d.idle =3D is_idle_item(curritem); d.smt_idle =3D cpumask_test_cpu(cpu, &rqd->smt_idle); d.tickled =3D tickled; __trace_var(TRC_CSCHED2_SCHEDULE, 1, @@ -3513,55 +3500,55 @@ csched2_schedule( /* * Below 0, means that we are capped and we have overrun our budget. * Let's try to get some more but, if we fail (e.g., because of the - * other running vcpus), we will be parked. + * other running items), we will be parked. */ if ( unlikely(scurr->budget <=3D 0) ) - vcpu_grab_budget(scurr); + item_grab_budget(scurr); =20 /* - * Select next runnable local VCPU (ie top of local runq). + * Select next runnable local ITEM (ie top of local runq). * - * If the current vcpu is runnable, and has higher credit than + * If the current item is runnable, and has higher credit than * the next guy on the queue (or there is noone else), we want to * run him again. * - * If there's tasklet work to do, we want to chose the idle vcpu + * If there's tasklet work to do, we want to chose the idle item * for this processor, and mark the current for delayed runqueue * add. * - * If the current vcpu is runnable, and there's another runnable + * If the current item is runnable, and there's another runnable * candidate, we want to mark current for delayed runqueue add, * and remove the next guy from the queue. * - * If the current vcpu is not runnable, we want to chose the idle - * vcpu for this processor. + * If the current item is not runnable, we want to chose the idle + * item for this processor. */ if ( tasklet_work_scheduled ) { - __clear_bit(__CSFLAG_vcpu_yield, &scurr->flags); + __clear_bit(__CSFLAG_item_yield, &scurr->flags); trace_var(TRC_CSCHED2_SCHED_TASKLET, 1, 0, NULL); - snext =3D csched2_item(idle_vcpu[cpu]->sched_item); + snext =3D csched2_item(sched_idle_item(cpu)); } else - snext =3D runq_candidate(rqd, scurr, cpu, now, &skipped_vcpus); + snext =3D runq_candidate(rqd, scurr, cpu, now, &skipped_items); =20 - /* If switching from a non-idle runnable vcpu, put it + /* If switching from a non-idle runnable item, put it * back on the runqueue. */ if ( snext !=3D scurr - && !is_idle_vcpu(scurr->vcpu) - && vcpu_runnable(current) ) + && !is_idle_item(curritem) + && item_runnable(curritem) ) __set_bit(__CSFLAG_delayed_runq_add, &scurr->flags); =20 ret.migrated =3D 0; =20 /* Accounting for non-idle tasks */ - if ( !is_idle_vcpu(snext->vcpu) ) + if ( !is_idle_item(snext->item) ) { /* If switching, remove this from the runqueue and mark it schedul= ed */ if ( snext !=3D scurr ) { ASSERT(snext->rqd =3D=3D rqd); - ASSERT(!snext->vcpu->sched_item->is_running); + ASSERT(!snext->item->is_running); =20 runq_remove(snext); __set_bit(__CSFLAG_scheduled, &snext->flags); @@ -3576,19 +3563,19 @@ csched2_schedule( =20 /* * 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 + * The way this is enforced is checking whether the item at the top * of the runqueue has negative credits. This means the epochs have * variable length, as in one epoch expores when: - * 1) the vcpu at the top of the runqueue has executed for + * 1) the item 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. + * 2) no other item 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 ha= ve - * not returned the first vcpu in the runqueue, for various reasons + * proper item is being used. In fact, runqueue_candidate() may ha= ve + * not returned the first item in the runqueue, for various reasons * (e.g., affinity). Only trigger a reset when it does. */ - if ( skipped_vcpus =3D=3D 0 && snext->credit <=3D CSCHED2_CREDIT_R= ESET ) + if ( skipped_items =3D=3D 0 && snext->credit <=3D CSCHED2_CREDIT_R= ESET ) { reset_credit(ops, cpu, now, snext); balance_load(ops, cpu, now); @@ -3598,11 +3585,10 @@ csched2_schedule( snext->tickled_cpu =3D -1; =20 /* Safe because lock for old processor is held */ - if ( snext->vcpu->processor !=3D cpu ) + if ( sched_item_cpu(snext->item) !=3D cpu ) { snext->credit +=3D CSCHED2_MIGRATE_COMPENSATION; - snext->vcpu->processor =3D cpu; - snext->vcpu->sched_item->res =3D per_cpu(sched_res, cpu); + sched_set_res(snext->item, per_cpu(sched_res, cpu)); SCHED_STAT_CRANK(migrated); ret.migrated =3D 1; } @@ -3636,20 +3622,20 @@ csched2_schedule( * Return task to run next... */ ret.time =3D csched2_runtime(ops, cpu, snext, now); - ret.task =3D snext->vcpu->sched_item; + ret.task =3D snext->item; =20 - CSCHED2_VCPU_CHECK(ret.task->vcpu); + CSCHED2_ITEM_CHECK(ret.task); return ret; } =20 static void -csched2_dump_vcpu(struct csched2_private *prv, struct csched2_item *svc) +csched2_dump_item(struct csched2_private *prv, struct csched2_item *svc) { printk("[%i.%i] flags=3D%x cpu=3D%i", - svc->vcpu->domain->domain_id, - svc->vcpu->vcpu_id, + svc->item->domain->domain_id, + svc->item->item_id, svc->flags, - svc->vcpu->processor); + sched_item_cpu(svc->item)); =20 printk(" credit=3D%" PRIi32" [w=3D%u]", svc->credit, svc->weight); =20 @@ -3674,12 +3660,12 @@ dump_pcpu(const struct scheduler *ops, int cpu) nr_cpu_ids, cpumask_bits(per_cpu(cpu_sibling_mask, cpu)), nr_cpu_ids, cpumask_bits(per_cpu(cpu_core_mask, cpu))); =20 - /* current VCPU (nothing to say if that's the idle vcpu) */ + /* current ITEM (nothing to say if that's the idle item) */ svc =3D csched2_item(curr_on_cpu(cpu)); - if ( svc && !is_idle_vcpu(svc->vcpu) ) + if ( svc && !is_idle_item(svc->item) ) { printk("\trun: "); - csched2_dump_vcpu(prv, svc); + csched2_dump_item(prv, svc); } } =20 @@ -3736,7 +3722,7 @@ csched2_dump(const struct scheduler *ops) list_for_each( iter_sdom, &prv->sdom ) { struct csched2_dom *sdom; - struct vcpu *v; + struct sched_item *item; =20 sdom =3D list_entry(iter_sdom, struct csched2_dom, sdom_elem); =20 @@ -3744,19 +3730,19 @@ csched2_dump(const struct scheduler *ops) sdom->dom->domain_id, sdom->weight, sdom->cap, - sdom->nr_vcpus); + sdom->nr_items); =20 - for_each_vcpu( sdom->dom, v ) + for_each_sched_item( sdom->dom, item ) { - struct csched2_item * const svc =3D csched2_item(v->sched_item= ); + struct csched2_item * const svc =3D csched2_item(item); spinlock_t *lock; =20 - lock =3D item_schedule_lock(svc->vcpu->sched_item); + lock =3D item_schedule_lock(item); =20 printk("\t%3d: ", ++loop); - csched2_dump_vcpu(prv, svc); + csched2_dump_item(prv, svc); =20 - item_schedule_unlock(lock, svc->vcpu->sched_item); + item_schedule_unlock(lock, item); } } =20 @@ -3782,7 +3768,7 @@ csched2_dump(const struct scheduler *ops) if ( svc ) { printk("\t%3d: ", loop++); - csched2_dump_vcpu(prv, svc); + csched2_dump_item(prv, svc); } } spin_unlock(&rqd->lock); @@ -3882,7 +3868,7 @@ csched2_switch_sched(struct scheduler *new_ops, unsig= ned int cpu, struct csched2_item *svc =3D vdata; unsigned rqi; =20 - ASSERT(pdata && svc && is_idle_vcpu(svc->vcpu)); + ASSERT(pdata && svc && is_idle_item(svc->item)); =20 /* * We own one runqueue lock already (from schedule_cpu_switch()). This @@ -3895,7 +3881,7 @@ csched2_switch_sched(struct scheduler *new_ops, unsig= ned int cpu, ASSERT(!local_irq_is_enabled()); write_lock(&prv->lock); =20 - idle_vcpu[cpu]->sched_item->priv =3D vdata; + sched_idle_item(cpu)->priv =3D vdata; =20 rqi =3D init_pdata(prv, pdata, cpu); =20 @@ -3946,7 +3932,7 @@ csched2_deinit_pdata(const struct scheduler *ops, voi= d *pcpu, int cpu) */ ASSERT(spc && spc->runq_id !=3D -1); ASSERT(cpumask_test_cpu(cpu, &prv->initialized)); - =20 + /* Find the old runqueue and remove this cpu from it */ rqd =3D prv->rqd + spc->runq_id; =20 --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125907; cv=none; d=zoho.com; s=zohoarc; b=DvRkduWaxOWChrUXw4xs4WzF3d6pYce+Bxb95XVyzE0TwcrU8uxSYJ9Unp4E/bvZfu0+2o9hgsaX1+F8X4LVWUNkh8K800p+thwg3bLEV9eSnKeOQMi+Q18gdmabgvpuugV4tZJ0iEGpI0pYu1aoi0BSuUexBQg6w0c7Q49LWLA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125907; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=zEa8YZ2YCgf2y4aTaHbT+xw3XB2yAmBPx7DHcj4HspU=; b=AC/JnmRisJLNgLkW8XzE3QJCt6Vw5EkVV6iK16rPGdEv42PTM+MhGcElOiZfiR+vcOy/L9Dl459N28Qu9fguYBCq+OpVhu5bop644xTNy7qRwD2ESnb2tRMuRbcIyRXd5nHreyxTP1NEF53EyjZix3U37O6tKPZEquFemuh5vkU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125907260637.3797408213691; Sun, 5 May 2019 23:58:27 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYl-0002F7-85; Mon, 06 May 2019 06:57:11 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYf-000234-Ik for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:05 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 23da1c8c-6fcc-11e9-af09-dfa1d5d5247e; Mon, 06 May 2019 06:56:58 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 8CBDEAC8E; Mon, 6 May 2019 06:56:54 +0000 (UTC) X-Inumbo-ID: 23da1c8c-6fcc-11e9-af09-dfa1d5d5247e X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:21 +0200 Message-Id: <20190506065644.7415-23-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 22/45] xen/sched: make arinc653 scheduler vcpu agnostic. X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , George Dunlap , Josh Whitehead , Robert VanVossen , Dario Faggioli MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Switch arinc653 scheduler completely from vcpu to sched_item usage. Signed-off-by: Juergen Gross --- xen/common/sched_arinc653.c | 208 +++++++++++++++++++++-------------------= ---- 1 file changed, 101 insertions(+), 107 deletions(-) diff --git a/xen/common/sched_arinc653.c b/xen/common/sched_arinc653.c index 5733a2a6b8..61f9ea6824 100644 --- a/xen/common/sched_arinc653.c +++ b/xen/common/sched_arinc653.c @@ -45,15 +45,15 @@ #define DEFAULT_TIMESLICE MILLISECS(10) =20 /** - * Retrieve the idle VCPU for a given physical CPU + * Retrieve the idle ITEM for a given physical CPU */ -#define IDLETASK(cpu) (idle_vcpu[cpu]) +#define IDLETASK(cpu) (sched_idle_item(cpu)) =20 /** * Return a pointer to the ARINC 653-specific scheduler data information - * associated with the given VCPU (vc) + * associated with the given ITEM (item) */ -#define AVCPU(vc) ((arinc653_vcpu_t *)(vc)->sched_item->priv) +#define AITEM(item) ((arinc653_item_t *)(item)->priv) =20 /** * Return the global scheduler private data given the scheduler ops pointer @@ -65,20 +65,20 @@ *************************************************************************= */ =20 /** - * The arinc653_vcpu_t structure holds ARINC 653-scheduler-specific - * information for all non-idle VCPUs + * The arinc653_item_t structure holds ARINC 653-scheduler-specific + * information for all non-idle ITEMs */ -typedef struct arinc653_vcpu_s +typedef struct arinc653_item_s { - /* vc points to Xen's struct vcpu so we can get to it from an - * arinc653_vcpu_t pointer. */ - struct vcpu * vc; - /* awake holds whether the VCPU has been woken with vcpu_wake() */ + /* item points to Xen's struct sched_item so we can get to it from an + * arinc653_item_t pointer. */ + struct sched_item * item; + /* awake holds whether the ITEM has been woken with vcpu_wake() */ bool_t awake; - /* list holds the linked list information for the list this VCPU + /* list holds the linked list information for the list this ITEM * is stored in */ struct list_head list; -} arinc653_vcpu_t; +} arinc653_item_t; =20 /** * The sched_entry_t structure holds a single entry of the @@ -89,14 +89,14 @@ typedef struct sched_entry_s /* dom_handle holds the handle ("UUID") for the domain that this * schedule entry refers to. */ xen_domain_handle_t dom_handle; - /* vcpu_id holds the VCPU number for the VCPU that this schedule + /* item_id holds the ITEM number for the ITEM that this schedule * entry refers to. */ - int vcpu_id; - /* runtime holds the number of nanoseconds that the VCPU for this + int item_id; + /* runtime holds the number of nanoseconds that the ITEM for this * schedule entry should be allowed to run per major frame. */ s_time_t runtime; - /* vc holds a pointer to the Xen VCPU structure */ - struct vcpu * vc; + /* item holds a pointer to the Xen sched_item structure */ + struct sched_item * item; } sched_entry_t; =20 /** @@ -110,9 +110,9 @@ typedef struct a653sched_priv_s /** * This array holds the active ARINC 653 schedule. * - * When the system tries to start a new VCPU, this schedule is scanned - * to look for a matching (handle, VCPU #) pair. If both the handle (U= UID) - * and VCPU number match, then the VCPU is allowed to run. Its run time + * When the system tries to start a new ITEM, this schedule is scanned + * to look for a matching (handle, ITEM #) pair. If both the handle (U= UID) + * and ITEM number match, then the ITEM is allowed to run. Its run time * (per major frame) is given in the third entry of the schedule. */ sched_entry_t schedule[ARINC653_MAX_DOMAINS_PER_SCHEDULE]; @@ -123,8 +123,8 @@ typedef struct a653sched_priv_s * * This is not necessarily the same as the number of domains in the * schedule. A domain could be listed multiple times within the schedu= le, - * or a domain with multiple VCPUs could have a different - * schedule entry for each VCPU. + * or a domain with multiple ITEMs could have a different + * schedule entry for each ITEM. */ unsigned int num_schedule_entries; =20 @@ -139,9 +139,9 @@ typedef struct a653sched_priv_s s_time_t next_major_frame; =20 /** - * pointers to all Xen VCPU structures for iterating through + * pointers to all Xen ITEM structures for iterating through */ - struct list_head vcpu_list; + struct list_head item_list; } a653sched_priv_t; =20 /************************************************************************** @@ -167,50 +167,50 @@ static int dom_handle_cmp(const xen_domain_handle_t h= 1, } =20 /** - * This function searches the vcpu list to find a VCPU that matches - * the domain handle and VCPU ID specified. + * This function searches the item list to find a ITEM that matches + * the domain handle and ITEM ID specified. * * @param ops Pointer to this instance of the scheduler structure * @param handle Pointer to handler - * @param vcpu_id VCPU ID + * @param item_id ITEM ID * * @return
    - *
  • Pointer to the matching VCPU if one is found + *
  • Pointer to the matching ITEM if one is found *
  • NULL otherwise *
*/ -static struct vcpu *find_vcpu( +static struct sched_item *find_item( const struct scheduler *ops, xen_domain_handle_t handle, - int vcpu_id) + int item_id) { - arinc653_vcpu_t *avcpu; + arinc653_item_t *aitem; =20 - /* loop through the vcpu_list looking for the specified VCPU */ - list_for_each_entry ( avcpu, &SCHED_PRIV(ops)->vcpu_list, list ) - if ( (dom_handle_cmp(avcpu->vc->domain->handle, handle) =3D=3D 0) - && (vcpu_id =3D=3D avcpu->vc->vcpu_id) ) - return avcpu->vc; + /* loop through the item_list looking for the specified ITEM */ + list_for_each_entry ( aitem, &SCHED_PRIV(ops)->item_list, list ) + if ( (dom_handle_cmp(aitem->item->domain->handle, handle) =3D=3D 0) + && (item_id =3D=3D aitem->item->item_id) ) + return aitem->item; =20 return NULL; } =20 /** - * This function updates the pointer to the Xen VCPU structure for each en= try + * This function updates the pointer to the Xen ITEM structure for each en= try * in the ARINC 653 schedule. * * @param ops Pointer to this instance of the scheduler structure * @return */ -static void update_schedule_vcpus(const struct scheduler *ops) +static void update_schedule_items(const struct scheduler *ops) { unsigned int i, n_entries =3D SCHED_PRIV(ops)->num_schedule_entries; =20 for ( i =3D 0; i < n_entries; i++ ) - SCHED_PRIV(ops)->schedule[i].vc =3D - find_vcpu(ops, + SCHED_PRIV(ops)->schedule[i].item =3D + find_item(ops, SCHED_PRIV(ops)->schedule[i].dom_handle, - SCHED_PRIV(ops)->schedule[i].vcpu_id); + SCHED_PRIV(ops)->schedule[i].item_id); } =20 /** @@ -268,12 +268,12 @@ arinc653_sched_set( memcpy(sched_priv->schedule[i].dom_handle, schedule->sched_entries[i].dom_handle, sizeof(sched_priv->schedule[i].dom_handle)); - sched_priv->schedule[i].vcpu_id =3D + sched_priv->schedule[i].item_id =3D schedule->sched_entries[i].vcpu_id; sched_priv->schedule[i].runtime =3D schedule->sched_entries[i].runtime; } - update_schedule_vcpus(ops); + update_schedule_items(ops); =20 /* * The newly-installed schedule takes effect immediately. We do not ev= en @@ -319,7 +319,7 @@ arinc653_sched_get( memcpy(schedule->sched_entries[i].dom_handle, sched_priv->schedule[i].dom_handle, sizeof(sched_priv->schedule[i].dom_handle)); - schedule->sched_entries[i].vcpu_id =3D sched_priv->schedule[i].vcp= u_id; + schedule->sched_entries[i].vcpu_id =3D sched_priv->schedule[i].ite= m_id; schedule->sched_entries[i].runtime =3D sched_priv->schedule[i].run= time; } =20 @@ -355,7 +355,7 @@ a653sched_init(struct scheduler *ops) =20 prv->next_major_frame =3D 0; spin_lock_init(&prv->lock); - INIT_LIST_HEAD(&prv->vcpu_list); + INIT_LIST_HEAD(&prv->item_list); =20 return 0; } @@ -373,7 +373,7 @@ a653sched_deinit(struct scheduler *ops) } =20 /** - * This function allocates scheduler-specific data for a VCPU + * This function allocates scheduler-specific data for a ITEM * * @param ops Pointer to this instance of the scheduler structure * @param item Pointer to struct sched_item @@ -385,35 +385,34 @@ a653sched_alloc_vdata(const struct scheduler *ops, st= ruct sched_item *item, void *dd) { a653sched_priv_t *sched_priv =3D SCHED_PRIV(ops); - struct vcpu *vc =3D item->vcpu; - arinc653_vcpu_t *svc; + arinc653_item_t *svc; unsigned int entry; unsigned long flags; =20 /* * Allocate memory for the ARINC 653-specific scheduler data informati= on - * associated with the given VCPU (vc). + * associated with the given ITEM (item). */ - svc =3D xmalloc(arinc653_vcpu_t); + svc =3D xmalloc(arinc653_item_t); if ( svc =3D=3D NULL ) return NULL; =20 spin_lock_irqsave(&sched_priv->lock, flags); =20 - /*=20 - * Add every one of dom0's vcpus to the schedule, as long as there are + /* + * Add every one of dom0's items to the schedule, as long as there are * slots available. */ - if ( vc->domain->domain_id =3D=3D 0 ) + if ( item->domain->domain_id =3D=3D 0 ) { entry =3D sched_priv->num_schedule_entries; =20 if ( entry < ARINC653_MAX_DOMAINS_PER_SCHEDULE ) { sched_priv->schedule[entry].dom_handle[0] =3D '\0'; - sched_priv->schedule[entry].vcpu_id =3D vc->vcpu_id; + sched_priv->schedule[entry].item_id =3D item->item_id; sched_priv->schedule[entry].runtime =3D DEFAULT_TIMESLICE; - sched_priv->schedule[entry].vc =3D vc; + sched_priv->schedule[entry].item =3D item; =20 sched_priv->major_frame +=3D DEFAULT_TIMESLICE; ++sched_priv->num_schedule_entries; @@ -421,16 +420,16 @@ a653sched_alloc_vdata(const struct scheduler *ops, st= ruct sched_item *item, } =20 /* - * Initialize our ARINC 653 scheduler-specific information for the VCP= U. - * The VCPU starts "asleep." When Xen is ready for the VCPU to run, it + * Initialize our ARINC 653 scheduler-specific information for the ITE= M. + * The ITEM starts "asleep." When Xen is ready for the ITEM to run, it * will call the vcpu_wake scheduler callback function and our schedul= er - * will mark the VCPU awake. + * will mark the ITEM awake. */ - svc->vc =3D vc; + svc->item =3D item; svc->awake =3D 0; - if ( !is_idle_vcpu(vc) ) - list_add(&svc->list, &SCHED_PRIV(ops)->vcpu_list); - update_schedule_vcpus(ops); + if ( !is_idle_item(item) ) + list_add(&svc->list, &SCHED_PRIV(ops)->item_list); + update_schedule_items(ops); =20 spin_unlock_irqrestore(&sched_priv->lock, flags); =20 @@ -438,27 +437,27 @@ a653sched_alloc_vdata(const struct scheduler *ops, st= ruct sched_item *item, } =20 /** - * This function frees scheduler-specific VCPU data + * This function frees scheduler-specific ITEM data * * @param ops Pointer to this instance of the scheduler structure */ static void a653sched_free_vdata(const struct scheduler *ops, void *priv) { - arinc653_vcpu_t *av =3D priv; + arinc653_item_t *av =3D priv; =20 if (av =3D=3D NULL) return; =20 - if ( !is_idle_vcpu(av->vc) ) + if ( !is_idle_item(av->item) ) list_del(&av->list); =20 xfree(av); - update_schedule_vcpus(ops); + update_schedule_items(ops); } =20 /** - * Xen scheduler callback function to sleep a VCPU + * Xen scheduler callback function to sleep a ITEM * * @param ops Pointer to this instance of the scheduler structure * @param item Pointer to struct sched_item @@ -466,21 +465,19 @@ a653sched_free_vdata(const struct scheduler *ops, voi= d *priv) static void a653sched_item_sleep(const struct scheduler *ops, struct sched_item *item) { - struct vcpu *vc =3D item->vcpu; - - if ( AVCPU(vc) !=3D NULL ) - AVCPU(vc)->awake =3D 0; + if ( AITEM(item) !=3D NULL ) + AITEM(item)->awake =3D 0; =20 /* - * If the VCPU being put to sleep is the same one that is currently + * If the ITEM being put to sleep is the same one that is currently * running, raise a softirq to invoke the scheduler to switch domains. */ - if ( per_cpu(sched_res, vc->processor)->curr =3D=3D item ) - cpu_raise_softirq(vc->processor, SCHEDULE_SOFTIRQ); + if ( per_cpu(sched_res, sched_item_cpu(item))->curr =3D=3D item ) + cpu_raise_softirq(sched_item_cpu(item), SCHEDULE_SOFTIRQ); } =20 /** - * Xen scheduler callback function to wake up a VCPU + * Xen scheduler callback function to wake up a ITEM * * @param ops Pointer to this instance of the scheduler structure * @param item Pointer to struct sched_item @@ -488,24 +485,22 @@ a653sched_item_sleep(const struct scheduler *ops, str= uct sched_item *item) static void a653sched_item_wake(const struct scheduler *ops, struct sched_item *item) { - struct vcpu *vc =3D item->vcpu; + if ( AITEM(item) !=3D NULL ) + AITEM(item)->awake =3D 1; =20 - if ( AVCPU(vc) !=3D NULL ) - AVCPU(vc)->awake =3D 1; - - cpu_raise_softirq(vc->processor, SCHEDULE_SOFTIRQ); + cpu_raise_softirq(sched_item_cpu(item), SCHEDULE_SOFTIRQ); } =20 /** - * Xen scheduler callback function to select a VCPU to run. + * Xen scheduler callback function to select a ITEM to run. * This is the main scheduler routine. * * @param ops Pointer to this instance of the scheduler structure * @param now Current time * - * @return Address of the VCPU structure scheduled to be run next - * Amount of time to execute the returned VCPU - * Flag for whether the VCPU was migrated + * @return Address of the ITEM structure scheduled to be run next + * Amount of time to execute the returned ITEM + * Flag for whether the ITEM was migrated */ static struct task_slice a653sched_do_schedule( @@ -514,7 +509,7 @@ a653sched_do_schedule( bool_t tasklet_work_scheduled) { struct task_slice ret; /* hold the chosen domain = */ - struct vcpu * new_task =3D NULL; + struct sched_item *new_task =3D NULL; static unsigned int sched_index =3D 0; static s_time_t next_switch_time; a653sched_priv_t *sched_priv =3D SCHED_PRIV(ops); @@ -559,14 +554,14 @@ a653sched_do_schedule( * sched_item structure. */ new_task =3D (sched_index < sched_priv->num_schedule_entries) - ? sched_priv->schedule[sched_index].vc + ? sched_priv->schedule[sched_index].item : IDLETASK(cpu); =20 /* Check to see if the new task can be run (awake & runnable). */ if ( !((new_task !=3D NULL) - && (AVCPU(new_task) !=3D NULL) - && AVCPU(new_task)->awake - && vcpu_runnable(new_task)) ) + && (AITEM(new_task) !=3D NULL) + && AITEM(new_task)->awake + && item_runnable(new_task)) ) new_task =3D IDLETASK(cpu); BUG_ON(new_task =3D=3D NULL); =20 @@ -578,21 +573,21 @@ a653sched_do_schedule( =20 spin_unlock_irqrestore(&sched_priv->lock, flags); =20 - /* Tasklet work (which runs in idle VCPU context) overrides all else. = */ + /* Tasklet work (which runs in idle ITEM context) overrides all else. = */ if ( tasklet_work_scheduled ) new_task =3D IDLETASK(cpu); =20 /* Running this task would result in a migration */ - if ( !is_idle_vcpu(new_task) - && (new_task->processor !=3D cpu) ) + if ( !is_idle_item(new_task) + && (sched_item_cpu(new_task) !=3D cpu) ) new_task =3D IDLETASK(cpu); =20 /* * Return the amount of time the next domain has to run and the address - * of the selected task's VCPU structure. + * of the selected task's ITEM structure. */ ret.time =3D next_switch_time - now; - ret.task =3D new_task->sched_item; + ret.task =3D new_task; ret.migrated =3D 0; =20 BUG_ON(ret.time <=3D 0); @@ -601,7 +596,7 @@ a653sched_do_schedule( } =20 /** - * Xen scheduler callback function to select a resource for the VCPU to ru= n on + * Xen scheduler callback function to select a resource for the ITEM to ru= n on * * @param ops Pointer to this instance of the scheduler structure * @param item Pointer to struct sched_item @@ -611,21 +606,20 @@ a653sched_do_schedule( static struct sched_resource * a653sched_pick_resource(const struct scheduler *ops, struct sched_item *it= em) { - struct vcpu *vc =3D item->vcpu; cpumask_t *online; unsigned int cpu; =20 - /*=20 - * If present, prefer vc's current processor, else - * just find the first valid vcpu . + /* + * If present, prefer item's current processor, else + * just find the first valid item. */ - online =3D cpupool_domain_cpumask(vc->domain); + online =3D cpupool_domain_cpumask(item->domain); =20 cpu =3D cpumask_first(online); =20 - if ( cpumask_test_cpu(vc->processor, online) + if ( cpumask_test_cpu(sched_item_cpu(item), online) || (cpu >=3D nr_cpu_ids) ) - cpu =3D vc->processor; + cpu =3D sched_item_cpu(item); =20 return per_cpu(sched_res, cpu); } @@ -636,18 +630,18 @@ a653sched_pick_resource(const struct scheduler *ops, = struct sched_item *item) * @param new_ops Pointer to this instance of the scheduler structure * @param cpu The cpu that is changing scheduler * @param pdata scheduler specific PCPU data (we don't have any) - * @param vdata scheduler specific VCPU data of the idle vcpu + * @param vdata scheduler specific ITEM data of the idle item */ static void a653_switch_sched(struct scheduler *new_ops, unsigned int cpu, void *pdata, void *vdata) { struct sched_resource *sd =3D per_cpu(sched_res, cpu); - arinc653_vcpu_t *svc =3D vdata; + arinc653_item_t *svc =3D vdata; =20 - ASSERT(!pdata && svc && is_idle_vcpu(svc->vc)); + ASSERT(!pdata && svc && is_idle_item(svc->item)); =20 - idle_vcpu[cpu]->sched_item->priv =3D vdata; + sched_idle_item(cpu)->priv =3D vdata; =20 per_cpu(scheduler, cpu) =3D new_ops; per_cpu(sched_res, cpu)->sched_priv =3D NULL; /* no pdata */ --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125914; cv=none; d=zoho.com; s=zohoarc; b=MLSOYk6/Rq4GfrCRrWedyyV9pXUaH0LmffINeoVIz4Ncmuaz0pinNDZ3HECMCdRaJmN07HdR05mutU3g1VTkeUyyMkQ9pnxb4bUbzWkZaUJ49cvdmiUjzErRxWUgx9KAmz3KIa5cNn7NjxgB10GB3BtXDGi2/jroUM+x8rvC+go= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125914; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=pYRVsJjIxM5mkPwNlLYOrPthOa5WvaEFrVZ5LIEufak=; b=R8eMXHInPWGmJBQalyao/z3F+Lf4Kb2aZKxqywmGhprMEA1y6zoqS3UFR0IPU4ZdcYrwgOHy+bZl4GdxfjpaFx5r91qXlbvxJGkRgq/F1apKsVIQCUkRuIG4PcStV2AvovyIjsZuYcLFTLOkpe7x71K4cp5SuxcAkSJDniMibH4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125914715415.16252708933223; Sun, 5 May 2019 23:58:34 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYg-00024q-B5; Mon, 06 May 2019 06:57:06 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYd-0001yH-95 for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:03 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 2508aaf4-6fcc-11e9-843c-bc764e045a96; Mon, 06 May 2019 06:57:00 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id DE197AF24; Mon, 6 May 2019 06:56:54 +0000 (UTC) X-Inumbo-ID: 2508aaf4-6fcc-11e9-843c-bc764e045a96 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:22 +0200 Message-Id: <20190506065644.7415-24-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 23/45] xen: add sched_item_pause_nosync() and sched_item_unpause() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Tim Deegan , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Dario Faggioli , Julien Grall , Jan Beulich MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The credit scheduler calls vcpu_pause_nosync() and vcpu_unpause() today. Add sched_item_pause_nosync() and sched_item_unpause() to perform the same operations on scheduler items instead. Signed-off-by: Juergen Gross --- xen/common/sched_credit.c | 6 +++--- xen/include/xen/sched-if.h | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index babccb69f7..9db5c3fc71 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -1080,7 +1080,7 @@ csched_item_remove(const struct scheduler *ops, struc= t sched_item *item) if ( test_and_clear_bit(CSCHED_FLAG_ITEM_PARKED, &svc->flags) ) { SCHED_STAT_CRANK(item_unpark); - vcpu_unpause(svc->item->vcpu); + sched_item_unpause(svc->item); } =20 spin_lock_irq(&prv->lock); @@ -1530,7 +1530,7 @@ csched_acct(void* dummy) !test_and_set_bit(CSCHED_FLAG_ITEM_PARKED, &svc->flag= s) ) { SCHED_STAT_CRANK(item_park); - vcpu_pause_nosync(svc->item->vcpu); + sched_item_pause_nosync(svc->item); } =20 /* Lower bound on credits */ @@ -1554,7 +1554,7 @@ csched_acct(void* dummy) * if it is woken up here. */ SCHED_STAT_CRANK(item_unpark); - vcpu_unpause(svc->item->vcpu); + sched_item_unpause(svc->item); } =20 /* Upper bound on credits means ITEM stops earning */ diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index 295101f9ef..65e2c3bba8 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -451,6 +451,16 @@ static inline int sched_adjust_cpupool(const struct sc= heduler *s, return 0; } =20 +static inline void sched_item_pause_nosync(struct sched_item *item) +{ + vcpu_pause_nosync(item->vcpu); +} + +static inline void sched_item_unpause(struct sched_item *item) +{ + vcpu_unpause(item->vcpu); +} + #define REGISTER_SCHEDULER(x) static const struct scheduler *x##_entry \ __used_section(".data.schedulers") =3D &x; =20 --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125912; cv=none; d=zoho.com; s=zohoarc; b=NCyHY8X1k3o/077L/5omEL72Gz+aWTnJBeYCWTCCENJE2UGVf30M2gLTVteGpJ/36i+piC/lDuYxkaY2Wj1meWSpmhK45orJvhqRm6JE4hzNBrOFqxEmnU0bLxacR26OYr7WZsSdXo9lxZnfEWcyzQB4MmwY1aDppGowkFLVqK0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125912; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=EFXW/wbDKzvFqjekFcdDCjnRYm+Ibs4x5TmDqH8rOW4=; b=gYWoTXwHPD1I9MxYqmCqc0LlatAIjCS8RRj4I7cZ/byBofeV7YbskE20KC0wBhBkSiVr2l6oRkbBTN8vCFaXd6n56+VMAfGZfWaVRjuw4lVc9z7sgqW4zqe+jIgLvWiYqn+cpWyMIKQ5grPi9+Fg2e8fxWx49jZtP+xEBVeDzsE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125912023839.6548400916831; Sun, 5 May 2019 23:58:32 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYp-0002OG-CP; Mon, 06 May 2019 06:57:15 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYi-00028X-3a for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:08 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 250093d4-6fcc-11e9-ab88-e374a13293b4; Mon, 06 May 2019 06:57:00 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 36C47AF25; Mon, 6 May 2019 06:56:55 +0000 (UTC) X-Inumbo-ID: 250093d4-6fcc-11e9-ab88-e374a13293b4 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:23 +0200 Message-Id: <20190506065644.7415-25-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 24/45] xen: let vcpu_create() select processor X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , Dario Faggioli , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Today there are two distinct scenarios for vcpu_create(): either for creation of idle-domain vcpus (vcpuid =3D=3D processor) or for creation of "normal" domain vcpus (including dom0), where the caller selects the initial processor on a round-robin scheme of the allowed processors (allowed being based on cpupool and affinities). Instead of passing the initial processor to vcpu_create() and passing on to sched_init_vcpu() let sched_init_vcpu() do the processor selection. For supporting dom0 vcpu creation use the node_affinity of the domain as a base for selecting the processors. User domains will have initially all nodes set, so this is no different behavior compared to today. Signed-off-by: Juergen Gross Acked-by: Andrew Cooper --- RFC V2: add ASSERT(), modify error message (Andrew Cooper) --- xen/arch/arm/domain_build.c | 13 ++++++------- xen/arch/x86/dom0_build.c | 10 +++------- xen/arch/x86/hvm/dom0_build.c | 9 ++------- xen/arch/x86/pv/dom0_build.c | 10 ++-------- xen/common/domain.c | 5 ++--- xen/common/domctl.c | 10 ++-------- xen/common/schedule.c | 34 +++++++++++++++++++++++++++++++--- xen/include/asm-x86/dom0_build.h | 3 +-- xen/include/xen/domain.h | 3 +-- xen/include/xen/sched.h | 2 +- 10 files changed, 51 insertions(+), 48 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index d9836779d1..86a6e4bf7b 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -80,7 +80,7 @@ unsigned int __init dom0_max_vcpus(void) =20 struct vcpu *__init alloc_dom0_vcpu0(struct domain *dom0) { - return vcpu_create(dom0, 0, 0); + return vcpu_create(dom0, 0); } =20 static unsigned int __init get_allocation_size(paddr_t size) @@ -1923,7 +1923,7 @@ static void __init find_gnttab_region(struct domain *= d, =20 static int __init construct_domain(struct domain *d, struct kernel_info *k= info) { - int i, cpu; + int i; struct vcpu *v =3D d->vcpu[0]; struct cpu_user_regs *regs =3D &v->arch.cpu_info->guest_cpu_user_regs; =20 @@ -1986,12 +1986,11 @@ static int __init construct_domain(struct domain *d= , struct kernel_info *kinfo) } #endif =20 - for ( i =3D 1, cpu =3D 0; i < d->max_vcpus; i++ ) + for ( i =3D 1; i < d->max_vcpus; i++ ) { - cpu =3D cpumask_cycle(cpu, &cpu_online_map); - if ( vcpu_create(d, i, cpu) =3D=3D NULL ) + if ( vcpu_create(d, i) =3D=3D NULL ) { - printk("Failed to allocate dom0 vcpu %d on pcpu %d\n", i, cpu); + printk("Failed to allocate d0v%u\n", i); break; } =20 @@ -2026,7 +2025,7 @@ static int __init construct_domU(struct domain *d, =20 kinfo.vpl011 =3D dt_property_read_bool(node, "vpl011"); =20 - if ( vcpu_create(d, 0, 0) =3D=3D NULL ) + if ( vcpu_create(d, 0) =3D=3D NULL ) return -ENOMEM; d->max_pages =3D ~0U; =20 diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c index 73f5407b0d..e550db8b03 100644 --- a/xen/arch/x86/dom0_build.c +++ b/xen/arch/x86/dom0_build.c @@ -198,12 +198,9 @@ custom_param("dom0_nodes", parse_dom0_nodes); =20 static cpumask_t __initdata dom0_cpus; =20 -struct vcpu *__init dom0_setup_vcpu(struct domain *d, - unsigned int vcpu_id, - unsigned int prev_cpu) +struct vcpu *__init dom0_setup_vcpu(struct domain *d, unsigned int vcpu_id) { - unsigned int cpu =3D cpumask_cycle(prev_cpu, &dom0_cpus); - struct vcpu *v =3D vcpu_create(d, vcpu_id, cpu); + struct vcpu *v =3D vcpu_create(d, vcpu_id); =20 if ( v ) { @@ -273,8 +270,7 @@ struct vcpu *__init alloc_dom0_vcpu0(struct domain *dom= 0) dom0->node_affinity =3D dom0_nodes; dom0->auto_node_affinity =3D !dom0_nr_pxms; =20 - return dom0_setup_vcpu(dom0, 0, - cpumask_last(&dom0_cpus) /* so it wraps around = to first pcpu */); + return dom0_setup_vcpu(dom0, 0); } =20 #ifdef CONFIG_SHADOW_PAGING diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c index aa599f09ef..15166bbaa9 100644 --- a/xen/arch/x86/hvm/dom0_build.c +++ b/xen/arch/x86/hvm/dom0_build.c @@ -614,7 +614,7 @@ static int __init pvh_setup_cpus(struct domain *d, padd= r_t entry, paddr_t start_info) { struct vcpu *v =3D d->vcpu[0]; - unsigned int cpu =3D v->processor, i; + unsigned int i; int rc; /* * This sets the vCPU state according to the state described in @@ -636,12 +636,7 @@ static int __init pvh_setup_cpus(struct domain *d, pad= dr_t entry, }; =20 for ( i =3D 1; i < d->max_vcpus; i++ ) - { - const struct vcpu *p =3D dom0_setup_vcpu(d, i, cpu); - - if ( p ) - cpu =3D p->processor; - } + dom0_setup_vcpu(d, i); =20 domain_update_node_affinity(d); =20 diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c index cef2d42254..800b3e6b7d 100644 --- a/xen/arch/x86/pv/dom0_build.c +++ b/xen/arch/x86/pv/dom0_build.c @@ -285,7 +285,7 @@ int __init dom0_construct_pv(struct domain *d, module_t *initrd, char *cmdline) { - int i, cpu, rc, compatible, order, machine; + int i, rc, compatible, order, machine; struct cpu_user_regs *regs; unsigned long pfn, mfn; unsigned long nr_pages; @@ -693,14 +693,8 @@ int __init dom0_construct_pv(struct domain *d, =20 printk("Dom%u has maximum %u VCPUs\n", d->domain_id, d->max_vcpus); =20 - cpu =3D v->processor; for ( i =3D 1; i < d->max_vcpus; i++ ) - { - const struct vcpu *p =3D dom0_setup_vcpu(d, i, cpu); - - if ( p ) - cpu =3D p->processor; - } + dom0_setup_vcpu(d, i); =20 domain_update_node_affinity(d); d->arch.paging.mode =3D 0; diff --git a/xen/common/domain.c b/xen/common/domain.c index 1c0abda66f..78a838fab3 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -129,8 +129,7 @@ static void vcpu_destroy(struct vcpu *v) free_vcpu_struct(v); } =20 -struct vcpu *vcpu_create( - struct domain *d, unsigned int vcpu_id, unsigned int cpu_id) +struct vcpu *vcpu_create(struct domain *d, unsigned int vcpu_id) { struct vcpu *v; =20 @@ -162,7 +161,7 @@ struct vcpu *vcpu_create( init_waitqueue_vcpu(v); } =20 - if ( sched_init_vcpu(v, cpu_id) !=3D 0 ) + if ( sched_init_vcpu(v) !=3D 0 ) goto fail_wq; =20 if ( arch_vcpu_create(v) !=3D 0 ) diff --git a/xen/common/domctl.c b/xen/common/domctl.c index 8464713d2b..3f86a336cc 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -540,8 +540,7 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_d= omctl) =20 case XEN_DOMCTL_max_vcpus: { - unsigned int i, max =3D op->u.max_vcpus.max, cpu; - cpumask_t *online; + unsigned int i, max =3D op->u.max_vcpus.max; =20 ret =3D -EINVAL; if ( (d =3D=3D current->domain) || /* no domain_pause() */ @@ -552,18 +551,13 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u= _domctl) domain_pause(d); =20 ret =3D -ENOMEM; - online =3D cpupool_domain_cpumask(d); =20 for ( i =3D 0; i < max; i++ ) { if ( d->vcpu[i] !=3D NULL ) continue; =20 - cpu =3D (i =3D=3D 0) ? - cpumask_any(online) : - cpumask_cycle(d->vcpu[i-1]->processor, online); - - if ( vcpu_create(d, i, cpu) =3D=3D NULL ) + if ( vcpu_create(d, i) =3D=3D NULL ) goto maxvcpu_out; } =20 diff --git a/xen/common/schedule.c b/xen/common/schedule.c index dfd261d029..9c54811e86 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -314,14 +314,42 @@ static struct sched_item *sched_alloc_item(struct vcp= u *v) return NULL; } =20 -int sched_init_vcpu(struct vcpu *v, unsigned int processor) +static unsigned int sched_select_initial_cpu(struct vcpu *v) +{ + struct domain *d =3D v->domain; + nodeid_t node; + cpumask_t cpus; + + cpumask_clear(&cpus); + for_each_node_mask ( node, d->node_affinity ) + cpumask_or(&cpus, &cpus, &node_to_cpumask(node)); + cpumask_and(&cpus, &cpus, cpupool_domain_cpumask(d)); + if ( cpumask_empty(&cpus) ) + cpumask_copy(&cpus, cpupool_domain_cpumask(d)); + + if ( v->vcpu_id =3D=3D 0 ) + return cpumask_first(&cpus); + + /* We can rely on previous vcpu being available. */ + ASSERT(!is_idle_domain(d)); + + return cpumask_cycle(d->vcpu[v->vcpu_id - 1]->processor, &cpus); +} + +int sched_init_vcpu(struct vcpu *v) { struct domain *d =3D v->domain; struct sched_item *item; + unsigned int processor; =20 if ( (item =3D sched_alloc_item(v)) =3D=3D NULL ) return 1; =20 + if ( is_idle_domain(d) ) + processor =3D v->vcpu_id; + else + processor =3D sched_select_initial_cpu(v); + sched_set_res(item, per_cpu(sched_res, processor)); =20 /* Initialise the per-vcpu timers. */ @@ -1673,7 +1701,7 @@ static int cpu_schedule_up(unsigned int cpu) return 0; =20 if ( idle_vcpu[cpu] =3D=3D NULL ) - vcpu_create(idle_vcpu[0]->domain, cpu, cpu); + vcpu_create(idle_vcpu[0]->domain, cpu); else { struct vcpu *idle =3D idle_vcpu[cpu]; @@ -1867,7 +1895,7 @@ void __init scheduler_init(void) BUG_ON(nr_cpu_ids > ARRAY_SIZE(idle_vcpu)); idle_domain->vcpu =3D idle_vcpu; idle_domain->max_vcpus =3D nr_cpu_ids; - if ( vcpu_create(idle_domain, 0, 0) =3D=3D NULL ) + if ( vcpu_create(idle_domain, 0) =3D=3D NULL ) BUG(); this_cpu(sched_res)->curr =3D idle_vcpu[0]->sched_item; this_cpu(sched_res)->sched_priv =3D sched_alloc_pdata(&ops, 0); diff --git a/xen/include/asm-x86/dom0_build.h b/xen/include/asm-x86/dom0_bu= ild.h index 33a5483739..3eb4b036e1 100644 --- a/xen/include/asm-x86/dom0_build.h +++ b/xen/include/asm-x86/dom0_build.h @@ -11,8 +11,7 @@ extern unsigned int dom0_memflags; unsigned long dom0_compute_nr_pages(struct domain *d, struct elf_dom_parms *parms, unsigned long initrd_len); -struct vcpu *dom0_setup_vcpu(struct domain *d, unsigned int vcpu_id, - unsigned int cpu); +struct vcpu *dom0_setup_vcpu(struct domain *d, unsigned int vcpu_id); int dom0_setup_permissions(struct domain *d); =20 int dom0_construct_pv(struct domain *d, const module_t *image, diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h index d1bfc82f57..a6e929685c 100644 --- a/xen/include/xen/domain.h +++ b/xen/include/xen/domain.h @@ -13,8 +13,7 @@ typedef union { struct compat_vcpu_guest_context *cmp; } vcpu_guest_context_u __attribute__((__transparent_union__)); =20 -struct vcpu *vcpu_create( - struct domain *d, unsigned int vcpu_id, unsigned int cpu_id); +struct vcpu *vcpu_create(struct domain *d, unsigned int vcpu_id); =20 unsigned int dom0_max_vcpus(void); struct vcpu *alloc_dom0_vcpu0(struct domain *dom0); diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index da117365af..8052f98780 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -663,7 +663,7 @@ void __domain_crash(struct domain *d); void noreturn asm_domain_crash_synchronous(unsigned long addr); =20 void scheduler_init(void); -int sched_init_vcpu(struct vcpu *v, unsigned int processor); +int sched_init_vcpu(struct vcpu *v); void sched_destroy_vcpu(struct vcpu *v); int sched_init_domain(struct domain *d, int poolid); void sched_destroy_domain(struct domain *d); --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125905; cv=none; d=zoho.com; s=zohoarc; b=J1KdHRNRecukx3J54JsRIFaXLOSFbqp5PyLcudqQC6ZEOFiWbGkxz2W2hazUl38W6uAn7MntF0r8amHtg5BApJPBQl014f+b4o5PK5r6cbVJhC5zV2L1RAgcr5RS3KYhqzKQMnT1BY/y6W/aYH8te/dT3TDr60B/wvYCybejdCc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125905; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=aCNUI+P4NyYTjn06gAaHJI5xMmuzyqk8WeMfBQLoCY4=; b=g94QWX1sG80AZ0i7+QCup3stDizhpbCNg+JqRuNiW7PLRY6twahibj5lWV0y2TPkhKB+XKnkxoCwu4JC1UNEdVlF6TsOuG2QjGWiqdl9eI/8Lnqj/WrlOw958Haha742d6hPEEZOC+xlK+ngBRWucT2kujXPsxRuDDC+/HV7BPo= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125905845544.1715647605505; Sun, 5 May 2019 23:58:25 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYj-0002Al-2z; Mon, 06 May 2019 06:57:09 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYf-00022t-ES for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:05 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 2508648d-6fcc-11e9-843c-bc764e045a96; Mon, 06 May 2019 06:57:00 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 9731FAF26; Mon, 6 May 2019 06:56:55 +0000 (UTC) X-Inumbo-ID: 2508648d-6fcc-11e9-843c-bc764e045a96 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:24 +0200 Message-Id: <20190506065644.7415-26-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 25/45] xen/sched: use sched_resource cpu instead smp_processor_id in schedulers X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Tim Deegan , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Robert VanVossen , Dario Faggioli , Julien Grall , Josh Whitehead , Meng Xu , Jan Beulich MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Especially in the do_schedule() functions of the different schedulers using smp_processor_id() for the local cpu number is correct only if the sched_item is a single vcpu. As soon as larger sched_items are used most uses should be replaced by the cpu number of the local sched_resource instead. Add a helper to get that sched_resource cpu and modify the schedulers to use it in a correct way. Signed-off-by: Juergen Gross --- xen/common/sched_arinc653.c | 2 +- xen/common/sched_credit.c | 19 ++++++++-------- xen/common/sched_credit2.c | 53 +++++++++++++++++++++++------------------= ---- xen/common/sched_null.c | 17 ++++++++------- xen/common/sched_rt.c | 17 ++++++++------- xen/include/xen/sched-if.h | 5 +++++ 6 files changed, 61 insertions(+), 52 deletions(-) diff --git a/xen/common/sched_arinc653.c b/xen/common/sched_arinc653.c index 61f9ea6824..3919c0a3e9 100644 --- a/xen/common/sched_arinc653.c +++ b/xen/common/sched_arinc653.c @@ -513,7 +513,7 @@ a653sched_do_schedule( static unsigned int sched_index =3D 0; static s_time_t next_switch_time; a653sched_priv_t *sched_priv =3D SCHED_PRIV(ops); - const unsigned int cpu =3D smp_processor_id(); + const unsigned int cpu =3D sched_get_resource_cpu(smp_processor_id()); unsigned long flags; =20 spin_lock_irqsave(&sched_priv->lock, flags); diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index 9db5c3fc71..4734f52fc7 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -1839,8 +1839,9 @@ static struct task_slice csched_schedule( const struct scheduler *ops, s_time_t now, bool_t tasklet_work_schedul= ed) { - const int cpu =3D smp_processor_id(); - struct list_head * const runq =3D RUNQ(cpu); + const unsigned int cpu =3D smp_processor_id(); + const unsigned int sched_cpu =3D sched_get_resource_cpu(cpu); + struct list_head * const runq =3D RUNQ(sched_cpu); struct sched_item *item =3D current->sched_item; struct csched_item * const scurr =3D CSCHED_ITEM(item); struct csched_private *prv =3D CSCHED_PRIV(ops); @@ -1950,7 +1951,7 @@ csched_schedule( { BUG_ON( is_idle_item(item) || list_empty(runq) ); /* Current has blocked. Update the runnable counter for this cpu. = */ - dec_nr_runnable(cpu); + dec_nr_runnable(sched_cpu); } =20 snext =3D __runq_elem(runq->next); @@ -1960,7 +1961,7 @@ csched_schedule( if ( tasklet_work_scheduled ) { TRACE_0D(TRC_CSCHED_SCHED_TASKLET); - snext =3D CSCHED_ITEM(sched_idle_item(cpu)); + snext =3D CSCHED_ITEM(sched_idle_item(sched_cpu)); snext->pri =3D CSCHED_PRI_TS_BOOST; } =20 @@ -1980,7 +1981,7 @@ csched_schedule( if ( snext->pri > CSCHED_PRI_TS_OVER ) __runq_remove(snext); else - snext =3D csched_load_balance(prv, cpu, snext, &ret.migrated); + snext =3D csched_load_balance(prv, sched_cpu, snext, &ret.migrated= ); =20 /* * Update idlers mask if necessary. When we're idling, other CPUs @@ -1988,12 +1989,12 @@ csched_schedule( */ if ( !tasklet_work_scheduled && snext->pri =3D=3D CSCHED_PRI_IDLE ) { - if ( !cpumask_test_cpu(cpu, prv->idlers) ) - cpumask_set_cpu(cpu, prv->idlers); + if ( !cpumask_test_cpu(sched_cpu, prv->idlers) ) + cpumask_set_cpu(sched_cpu, prv->idlers); } - else if ( cpumask_test_cpu(cpu, prv->idlers) ) + else if ( cpumask_test_cpu(sched_cpu, prv->idlers) ) { - cpumask_clear_cpu(cpu, prv->idlers); + cpumask_clear_cpu(sched_cpu, prv->idlers); } =20 if ( !is_idle_item(snext->item) ) diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index 7918d46a23..d5cb8c0200 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -3447,7 +3447,8 @@ static struct task_slice csched2_schedule( const struct scheduler *ops, s_time_t now, bool tasklet_work_scheduled) { - const int cpu =3D smp_processor_id(); + const unsigned int cpu =3D smp_processor_id(); + const unsigned int sched_cpu =3D sched_get_resource_cpu(cpu); struct csched2_runqueue_data *rqd; struct sched_item *curritem =3D current->sched_item; struct csched2_item * const scurr =3D csched2_item(curritem); @@ -3459,22 +3460,22 @@ csched2_schedule( SCHED_STAT_CRANK(schedule); CSCHED2_ITEM_CHECK(curritem); =20 - BUG_ON(!cpumask_test_cpu(cpu, &csched2_priv(ops)->initialized)); + BUG_ON(!cpumask_test_cpu(sched_cpu, &csched2_priv(ops)->initialized)); =20 - rqd =3D c2rqd(ops, cpu); - BUG_ON(!cpumask_test_cpu(cpu, &rqd->active)); + rqd =3D c2rqd(ops, sched_cpu); + BUG_ON(!cpumask_test_cpu(sched_cpu, &rqd->active)); =20 - ASSERT(spin_is_locked(per_cpu(sched_res, cpu)->schedule_lock)); + ASSERT(spin_is_locked(per_cpu(sched_res, sched_cpu)->schedule_lock)); =20 BUG_ON(!is_idle_item(curritem) && scurr->rqd !=3D rqd); =20 /* Clear "tickled" bit now that we've been scheduled */ - tickled =3D cpumask_test_cpu(cpu, &rqd->tickled); + tickled =3D cpumask_test_cpu(sched_cpu, &rqd->tickled); if ( tickled ) { - __cpumask_clear_cpu(cpu, &rqd->tickled); + __cpumask_clear_cpu(sched_cpu, &rqd->tickled); cpumask_andnot(cpumask_scratch, &rqd->idle, &rqd->tickled); - smt_idle_mask_set(cpu, cpumask_scratch, &rqd->smt_idle); + smt_idle_mask_set(sched_cpu, cpumask_scratch, &rqd->smt_idle); } =20 if ( unlikely(tb_init_done) ) @@ -3484,10 +3485,10 @@ csched2_schedule( unsigned tasklet:8, idle:8, smt_idle:8, tickled:8; } d; d.cpu =3D cpu; - d.rq_id =3D c2r(cpu); + d.rq_id =3D c2r(sched_cpu); d.tasklet =3D tasklet_work_scheduled; d.idle =3D is_idle_item(curritem); - d.smt_idle =3D cpumask_test_cpu(cpu, &rqd->smt_idle); + d.smt_idle =3D cpumask_test_cpu(sched_cpu, &rqd->smt_idle); d.tickled =3D tickled; __trace_var(TRC_CSCHED2_SCHEDULE, 1, sizeof(d), @@ -3527,10 +3528,10 @@ csched2_schedule( { __clear_bit(__CSFLAG_item_yield, &scurr->flags); trace_var(TRC_CSCHED2_SCHED_TASKLET, 1, 0, NULL); - snext =3D csched2_item(sched_idle_item(cpu)); + snext =3D csched2_item(sched_idle_item(sched_cpu)); } else - snext =3D runq_candidate(rqd, scurr, cpu, now, &skipped_items); + snext =3D runq_candidate(rqd, scurr, sched_cpu, now, &skipped_item= s); =20 /* If switching from a non-idle runnable item, put it * back on the runqueue. */ @@ -3555,10 +3556,10 @@ csched2_schedule( } =20 /* Clear the idle mask if necessary */ - if ( cpumask_test_cpu(cpu, &rqd->idle) ) + if ( cpumask_test_cpu(sched_cpu, &rqd->idle) ) { - __cpumask_clear_cpu(cpu, &rqd->idle); - smt_idle_mask_clear(cpu, &rqd->smt_idle); + __cpumask_clear_cpu(sched_cpu, &rqd->idle); + smt_idle_mask_clear(sched_cpu, &rqd->smt_idle); } =20 /* @@ -3577,18 +3578,18 @@ csched2_schedule( */ if ( skipped_items =3D=3D 0 && snext->credit <=3D CSCHED2_CREDIT_R= ESET ) { - reset_credit(ops, cpu, now, snext); - balance_load(ops, cpu, now); + reset_credit(ops, sched_cpu, now, snext); + balance_load(ops, sched_cpu, now); } =20 snext->start_time =3D now; snext->tickled_cpu =3D -1; =20 /* Safe because lock for old processor is held */ - if ( sched_item_cpu(snext->item) !=3D cpu ) + if ( sched_item_cpu(snext->item) !=3D sched_cpu ) { snext->credit +=3D CSCHED2_MIGRATE_COMPENSATION; - sched_set_res(snext->item, per_cpu(sched_res, cpu)); + sched_set_res(snext->item, per_cpu(sched_res, sched_cpu)); SCHED_STAT_CRANK(migrated); ret.migrated =3D 1; } @@ -3601,17 +3602,17 @@ csched2_schedule( */ if ( tasklet_work_scheduled ) { - if ( cpumask_test_cpu(cpu, &rqd->idle) ) + if ( cpumask_test_cpu(sched_cpu, &rqd->idle) ) { - __cpumask_clear_cpu(cpu, &rqd->idle); - smt_idle_mask_clear(cpu, &rqd->smt_idle); + __cpumask_clear_cpu(sched_cpu, &rqd->idle); + smt_idle_mask_clear(sched_cpu, &rqd->smt_idle); } } - else if ( !cpumask_test_cpu(cpu, &rqd->idle) ) + else if ( !cpumask_test_cpu(sched_cpu, &rqd->idle) ) { - __cpumask_set_cpu(cpu, &rqd->idle); + __cpumask_set_cpu(sched_cpu, &rqd->idle); cpumask_andnot(cpumask_scratch, &rqd->idle, &rqd->tickled); - smt_idle_mask_set(cpu, cpumask_scratch, &rqd->smt_idle); + smt_idle_mask_set(sched_cpu, cpumask_scratch, &rqd->smt_idle); } /* Make sure avgload gets updated periodically even * if there's no activity */ @@ -3621,7 +3622,7 @@ csched2_schedule( /* * Return task to run next... */ - ret.time =3D csched2_runtime(ops, cpu, snext, now); + ret.time =3D csched2_runtime(ops, sched_cpu, snext, now); ret.task =3D snext->item; =20 CSCHED2_ITEM_CHECK(ret.task); diff --git a/xen/common/sched_null.c b/xen/common/sched_null.c index ceb026c8af..34ce7a05d3 100644 --- a/xen/common/sched_null.c +++ b/xen/common/sched_null.c @@ -709,6 +709,7 @@ static struct task_slice null_schedule(const struct sch= eduler *ops, { unsigned int bs; const unsigned int cpu =3D smp_processor_id(); + const unsigned int sched_cpu =3D sched_get_resource_cpu(cpu); struct null_private *prv =3D null_priv(ops); struct null_item *wvc; struct task_slice ret; @@ -724,14 +725,14 @@ static struct task_slice null_schedule(const struct s= cheduler *ops, } d; d.cpu =3D cpu; d.tasklet =3D tasklet_work_scheduled; - if ( per_cpu(npc, cpu).item =3D=3D NULL ) + if ( per_cpu(npc, sched_cpu).item =3D=3D NULL ) { d.item =3D d.dom =3D -1; } else { - d.item =3D per_cpu(npc, cpu).item->item_id; - d.dom =3D per_cpu(npc, cpu).item->domain->domain_id; + d.item =3D per_cpu(npc, sched_cpu).item->item_id; + d.dom =3D per_cpu(npc, sched_cpu).item->domain->domain_id; } __trace_var(TRC_SNULL_SCHEDULE, 1, sizeof(d), &d); } @@ -739,10 +740,10 @@ static struct task_slice null_schedule(const struct s= cheduler *ops, if ( tasklet_work_scheduled ) { trace_var(TRC_SNULL_TASKLET, 1, 0, NULL); - ret.task =3D sched_idle_item(cpu); + ret.task =3D sched_idle_item(sched_cpu); } else - ret.task =3D per_cpu(npc, cpu).item; + ret.task =3D per_cpu(npc, sched_cpu).item; ret.migrated =3D 0; ret.time =3D -1; =20 @@ -773,9 +774,9 @@ static struct task_slice null_schedule(const struct sch= eduler *ops, !has_soft_affinity(wvc->item) ) continue; =20 - if ( item_check_affinity(wvc->item, cpu, bs) ) + if ( item_check_affinity(wvc->item, sched_cpu, bs) ) { - item_assign(prv, wvc->item, cpu); + item_assign(prv, wvc->item, sched_cpu); list_del_init(&wvc->waitq_elem); ret.task =3D wvc->item; goto unlock; @@ -787,7 +788,7 @@ static struct task_slice null_schedule(const struct sch= eduler *ops, } =20 if ( unlikely(ret.task =3D=3D NULL || !item_runnable(ret.task)) ) - ret.task =3D sched_idle_item(cpu); + ret.task =3D sched_idle_item(sched_cpu); =20 NULL_ITEM_CHECK(ret.task); return ret; diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index 730aa292d4..2366e33beb 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -1065,7 +1065,8 @@ runq_pick(const struct scheduler *ops, const cpumask_= t *mask) static struct task_slice rt_schedule(const struct scheduler *ops, s_time_t now, bool_t tasklet_work= _scheduled) { - const int cpu =3D smp_processor_id(); + const unsigned int cpu =3D smp_processor_id(); + const unsigned int sched_cpu =3D sched_get_resource_cpu(cpu); struct rt_private *prv =3D rt_priv(ops); struct rt_item *const scurr =3D rt_item(current->sched_item); struct rt_item *snext =3D NULL; @@ -1079,7 +1080,7 @@ rt_schedule(const struct scheduler *ops, s_time_t now= , bool_t tasklet_work_sched } d; d.cpu =3D cpu; d.tasklet =3D tasklet_work_scheduled; - d.tickled =3D cpumask_test_cpu(cpu, &prv->tickled); + d.tickled =3D cpumask_test_cpu(sched_cpu, &prv->tickled); d.idle =3D is_idle_item(curritem); trace_var(TRC_RTDS_SCHEDULE, 1, sizeof(d), @@ -1087,7 +1088,7 @@ rt_schedule(const struct scheduler *ops, s_time_t now= , bool_t tasklet_work_sched } =20 /* clear ticked bit now that we've been scheduled */ - cpumask_clear_cpu(cpu, &prv->tickled); + cpumask_clear_cpu(sched_cpu, &prv->tickled); =20 /* burn_budget would return for IDLE ITEM */ burn_budget(ops, scurr, now); @@ -1095,13 +1096,13 @@ rt_schedule(const struct scheduler *ops, s_time_t n= ow, bool_t tasklet_work_sched if ( tasklet_work_scheduled ) { trace_var(TRC_RTDS_SCHED_TASKLET, 1, 0, NULL); - snext =3D rt_item(sched_idle_item(cpu)); + snext =3D rt_item(sched_idle_item(sched_cpu)); } else { - snext =3D runq_pick(ops, cpumask_of(cpu)); + snext =3D runq_pick(ops, cpumask_of(sched_cpu)); if ( snext =3D=3D NULL ) - snext =3D rt_item(sched_idle_item(cpu)); + snext =3D rt_item(sched_idle_item(sched_cpu)); =20 /* if scurr has higher priority and budget, still pick scurr */ if ( !is_idle_item(curritem) && @@ -1126,9 +1127,9 @@ rt_schedule(const struct scheduler *ops, s_time_t now= , bool_t tasklet_work_sched q_remove(snext); __set_bit(__RTDS_scheduled, &snext->flags); } - if ( sched_item_cpu(snext->item) !=3D cpu ) + if ( sched_item_cpu(snext->item) !=3D sched_cpu ) { - sched_set_res(snext->item, per_cpu(sched_res, cpu)); + sched_set_res(snext->item, per_cpu(sched_res, sched_cpu)); ret.migrated =3D 1; } ret.time =3D snext->cur_budget; /* invoke the scheduler next time = */ diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index 65e2c3bba8..2506538649 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -100,6 +100,11 @@ static inline struct sched_item *sched_idle_item(unsig= ned int cpu) return idle_vcpu[cpu]->sched_item; } =20 +static inline unsigned int sched_get_resource_cpu(unsigned int cpu) +{ + return per_cpu(sched_res, cpu)->processor; +} + /* * Scratch space, for avoiding having too many cpumask_t on the stack. * Within each scheduler, when using the scratch mask of one pCPU: --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125905; cv=none; d=zoho.com; s=zohoarc; b=OOSrjICaDNV5ogxJ0lRx/ZrIYI4bMjsrljkYMYXcCrSJ8yfZcoAQpfTxcNSj7+BbJ9XWOGRdH+vjsUlvuC3KWcph5yCwo7xM8+mMxH/yWQ4JJKtOU9eGsPciQ5iQ49K8Zwu+mb6GAY0/R4g0HCpwcoVTRKHfkx5vyD0dRlEE0M0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125905; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=e7wek2UPkXt7bRxe86Ko6laFQ3bKfanx+9Co4MET+6U=; b=Ph875u+peL4izr3/T64raOPzxHqCV2Una6ryaHEK7qKz3EbqQ9Z2uE3UYuPWSF+lAkM6pxNlSVLJl9s55ziZel9A7IODR8G3xz0wWOLmCJQPZn+ZtMwiqFwYlabPm3eMFdkrVTi5PcG14EkVp7WNnjkP88SRr2GTOndcGbHqaQ8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125905561685.2374794344472; Sun, 5 May 2019 23:58:25 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYm-0002Gu-0X; Mon, 06 May 2019 06:57:12 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYf-000237-Jj for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:05 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 25008ed4-6fcc-11e9-a0a0-7b6c7a018715; Mon, 06 May 2019 06:57:00 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id BBA92AF27; Mon, 6 May 2019 06:56:55 +0000 (UTC) X-Inumbo-ID: 25008ed4-6fcc-11e9-a0a0-7b6c7a018715 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:25 +0200 Message-Id: <20190506065644.7415-27-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 26/45] xen/sched: switch schedule() from vcpus to sched_items X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , George Dunlap , Dario Faggioli MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Use sched_items instead of vcpus in schedule(). This includes the introduction of sched_item_runstate_change() as a replacement of vcpu_runstate_change() in schedule(). Signed-off-by: Juergen Gross --- xen/common/schedule.c | 70 +++++++++++++++++++++++++++++------------------= ---- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 9c54811e86..e9d7e437ac 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -192,6 +192,20 @@ static inline void vcpu_runstate_change( v->runstate.state =3D new_state; } =20 +static inline void sched_item_runstate_change(struct sched_item *item, + bool running, s_time_t new_entry_time) +{ + struct vcpu *v =3D item->vcpu; + + if ( running ) + vcpu_runstate_change(v, RUNSTATE_running, new_entry_time); + else + vcpu_runstate_change(v, + ((v->pause_flags & VPF_blocked) ? RUNSTATE_blocked : + (vcpu_runnable(v) ? RUNSTATE_runnable : RUNSTATE_offline)), + new_entry_time); +} + void vcpu_runstate_get(struct vcpu *v, struct vcpu_runstate_info *runstate) { spinlock_t *lock =3D likely(v =3D=3D current) @@ -1521,7 +1535,7 @@ static void vcpu_periodic_timer_work(struct vcpu *v) */ static void schedule(void) { - struct vcpu *prev =3D current, *next =3D NULL; + struct sched_item *prev =3D current->sched_item, *next =3D NULL; s_time_t now; struct scheduler *sched; unsigned long *tasklet_work =3D &this_cpu(tasklet_work_to_do); @@ -1565,9 +1579,9 @@ static void schedule(void) sched =3D this_cpu(scheduler); next_slice =3D sched->do_schedule(sched, now, tasklet_work_scheduled); =20 - next =3D next_slice.task->vcpu; + next =3D next_slice.task; =20 - sd->curr =3D next->sched_item; + sd->curr =3D next; =20 if ( next_slice.time >=3D 0 ) /* -ve means no limit */ set_timer(&sd->s_timer, now + next_slice.time); @@ -1576,60 +1590,56 @@ static void schedule(void) { pcpu_schedule_unlock_irq(lock, cpu); TRACE_4D(TRC_SCHED_SWITCH_INFCONT, - next->domain->domain_id, next->vcpu_id, - now - prev->runstate.state_entry_time, + next->domain->domain_id, next->item_id, + now - prev->state_entry_time, next_slice.time); - trace_continue_running(next); - return continue_running(prev); + trace_continue_running(next->vcpu); + return continue_running(prev->vcpu); } =20 TRACE_3D(TRC_SCHED_SWITCH_INFPREV, - prev->domain->domain_id, prev->vcpu_id, - now - prev->runstate.state_entry_time); + prev->domain->domain_id, prev->item_id, + now - prev->state_entry_time); TRACE_4D(TRC_SCHED_SWITCH_INFNEXT, - next->domain->domain_id, next->vcpu_id, - (next->runstate.state =3D=3D RUNSTATE_runnable) ? - (now - next->runstate.state_entry_time) : 0, + next->domain->domain_id, next->item_id, + (next->vcpu->runstate.state =3D=3D RUNSTATE_runnable) ? + (now - next->state_entry_time) : 0, next_slice.time); =20 - ASSERT(prev->runstate.state =3D=3D RUNSTATE_running); + ASSERT(prev->vcpu->runstate.state =3D=3D RUNSTATE_running); =20 TRACE_4D(TRC_SCHED_SWITCH, - prev->domain->domain_id, prev->vcpu_id, - next->domain->domain_id, next->vcpu_id); + prev->domain->domain_id, prev->item_id, + next->domain->domain_id, next->item_id); =20 - vcpu_runstate_change( - prev, - ((prev->pause_flags & VPF_blocked) ? RUNSTATE_blocked : - (vcpu_runnable(prev) ? RUNSTATE_runnable : RUNSTATE_offline)), - now); - prev->sched_item->last_run_time =3D now; + sched_item_runstate_change(prev, false, now); + prev->last_run_time =3D now; =20 - ASSERT(next->runstate.state !=3D RUNSTATE_running); - vcpu_runstate_change(next, RUNSTATE_running, now); + ASSERT(next->vcpu->runstate.state !=3D RUNSTATE_running); + sched_item_runstate_change(next, true, now); =20 /* * NB. Don't add any trace records from here until the actual context * switch, else lost_records resume will not work properly. */ =20 - ASSERT(!next->sched_item->is_running); + ASSERT(!next->is_running); + next->vcpu->is_running =3D 1; next->is_running =3D 1; - next->sched_item->is_running =3D 1; - next->sched_item->state_entry_time =3D now; + next->state_entry_time =3D now; =20 pcpu_schedule_unlock_irq(lock, cpu); =20 SCHED_STAT_CRANK(sched_ctx); =20 - stop_timer(&prev->periodic_timer); + stop_timer(&prev->vcpu->periodic_timer); =20 if ( next_slice.migrated ) - sched_move_irqs(next); + sched_move_irqs(next->vcpu); =20 - vcpu_periodic_timer_work(next); + vcpu_periodic_timer_work(next->vcpu); =20 - context_switch(prev, next); + context_switch(prev->vcpu, next->vcpu); } =20 void context_saved(struct vcpu *prev) --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125917; cv=none; d=zoho.com; s=zohoarc; b=SOQIBTSoW9Kc5o7obJGQ3TGSESKvR2oQKK7ZERk8BvX5/oIx7r3NdxhZ8yO6CfDDDCoTsFFnL/bP9kZoZF6AGzfkw5lgkYheV1UKIy4wd/v2AQlxxxrwk1LQK6mz8GdJG+Ufb0Ti4a7JBwVYh3LJnyTBYsRCWGlg7gDMF1aHblc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125917; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=MnT+VoajkniAF25v3A5Eo5OZMJoTfR4KC9fQbFc7lfk=; b=bdo6ICstvboIcw7s7kCl9nOGJ/7OfG+RTAQhRzrJ6eUH6dzvuHXy2RHKYqQV0ZNNticmMNgyLGrjpPU1G2vt7A0+4xPsC8ESv2/HAGZ9KbAJ0PVamSMzHg3X9LxPum9R0S2EEdsRTPlllyfa+oSulkFt45Q1ArbWRXgOjQHa9Rw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125917241815.0621014266262; Sun, 5 May 2019 23:58:37 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYg-00025y-MU; Mon, 06 May 2019 06:57:06 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYd-0001z1-H0 for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:03 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 25092881-6fcc-11e9-843c-bc764e045a96; Mon, 06 May 2019 06:57:00 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id DD36BAF2D; Mon, 6 May 2019 06:56:55 +0000 (UTC) X-Inumbo-ID: 25092881-6fcc-11e9-843c-bc764e045a96 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:26 +0200 Message-Id: <20190506065644.7415-28-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 27/45] xen/sched: switch sched_move_irqs() to take sched_item as parameter X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , George Dunlap , Dario Faggioli MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" sched_move_irqs() should work on a sched_item as that is the item moved between cpus. Rename the current function to vcpu_move_irqs() as it is still needed in schedule(). Signed-off-by: Juergen Gross --- xen/common/schedule.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index e9d7e437ac..5368d66cfc 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -406,12 +406,20 @@ int sched_init_vcpu(struct vcpu *v) return 0; } =20 -static void sched_move_irqs(struct vcpu *v) +static void vcpu_move_irqs(struct vcpu *v) { arch_move_irqs(v); evtchn_move_pirqs(v); } =20 +static void sched_move_irqs(struct sched_item *item) +{ + struct vcpu *v; + + for_each_sched_item_vcpu( item, v ) + vcpu_move_irqs(v); +} + int sched_move_domain(struct domain *d, struct cpupool *c) { struct vcpu *v; @@ -491,7 +499,7 @@ int sched_move_domain(struct domain *d, struct cpupool = *c) =20 v->sched_item->priv =3D vcpu_priv[v->vcpu_id]; if ( !d->is_dying ) - sched_move_irqs(v); + sched_move_irqs(v->sched_item); =20 new_p =3D cpumask_cycle(new_p, c->cpu_valid); =20 @@ -784,7 +792,7 @@ static void vcpu_migrate_finish(struct vcpu *v) sched_spin_unlock_double(old_lock, new_lock, flags); =20 if ( old_cpu !=3D new_cpu ) - sched_move_irqs(v); + sched_move_irqs(v->sched_item); =20 /* Wake on new CPU. */ vcpu_wake(v); @@ -862,7 +870,7 @@ void restore_vcpu_affinity(struct domain *d) spin_unlock_irq(lock); =20 if ( old_cpu !=3D v->processor ) - sched_move_irqs(v); + sched_move_irqs(v->sched_item); } =20 domain_update_node_affinity(d); @@ -1635,7 +1643,7 @@ static void schedule(void) stop_timer(&prev->vcpu->periodic_timer); =20 if ( next_slice.migrated ) - sched_move_irqs(next->vcpu); + vcpu_move_irqs(next->vcpu); =20 vcpu_periodic_timer_work(next->vcpu); =20 --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125909; cv=none; d=zoho.com; s=zohoarc; b=MljP9bum0RgunEIzs0BJxSpePQA4h/vcnexmC4KXmCmqgpry1G92bBMFobrnmEWRSFXkYycLOn7gIQmFPUJmtQVqkjw7HY9hj7oRG7tOQiscG+nYmpoBUKmw1sxApNZopGsXdnj+LJoqGR72SZYHDxUL2tXjmHcFY0O4vWlCy0o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125909; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=OsIDmDng3/WoHlVU/r/KDZekPqQtSGyqACdd8q3xCzs=; b=juWMxhAjl5jIkVJPmqF+Epy+IOiGhIk8p4ndMOv/oWfwMpQepze0Qk8xUARSqgVQ177dAOqivYaSzn4HnsBczy6GIPt1j0jRpurAkT52RK8Nsxp2DjTVJpYzkKH9m46RdKs7JMYgGoP0TQaklN5Cmg2omzaKPzbU1MvNQGtquH4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125909607601.1704378004817; Sun, 5 May 2019 23:58:29 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYm-0002Ic-P1; Mon, 06 May 2019 06:57:12 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYf-00023Z-OX for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:05 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 2508fa17-6fcc-11e9-843c-bc764e045a96; Mon, 06 May 2019 06:57:00 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 37678AF2F; Mon, 6 May 2019 06:56:56 +0000 (UTC) X-Inumbo-ID: 2508fa17-6fcc-11e9-843c-bc764e045a96 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:27 +0200 Message-Id: <20190506065644.7415-29-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 28/45] xen: switch from for_each_vcpu() to for_each_sched_item() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , Dario Faggioli MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Where appropriate switch from for_each_vcpu() to for_each_sched_item() in order to prepare core scheduling. Signed-off-by: Juergen Gross --- xen/common/domain.c | 9 ++--- xen/common/schedule.c | 107 ++++++++++++++++++++++++++--------------------= ---- 2 files changed, 59 insertions(+), 57 deletions(-) diff --git a/xen/common/domain.c b/xen/common/domain.c index 78a838fab3..d0f9e5e86a 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -510,7 +510,7 @@ void domain_update_node_affinity(struct domain *d) cpumask_var_t dom_cpumask, dom_cpumask_soft; cpumask_t *dom_affinity; const cpumask_t *online; - struct vcpu *v; + struct sched_item *item; unsigned int cpu; =20 /* Do we have vcpus already? If not, no need to update node-affinity. = */ @@ -543,12 +543,11 @@ void domain_update_node_affinity(struct domain *d) * and the full mask of where it would prefer to run (the union of * the soft affinity of all its various vcpus). Let's build them. */ - for_each_vcpu ( d, v ) + for_each_sched_item ( d, item ) { - cpumask_or(dom_cpumask, dom_cpumask, - v->sched_item->cpu_hard_affinity); + cpumask_or(dom_cpumask, dom_cpumask, item->cpu_hard_affinity); cpumask_or(dom_cpumask_soft, dom_cpumask_soft, - v->sched_item->cpu_soft_affinity); + item->cpu_soft_affinity); } /* Filter out non-online cpus */ cpumask_and(dom_cpumask, dom_cpumask, online); diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 5368d66cfc..bc0554f2da 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -423,16 +423,17 @@ static void sched_move_irqs(struct sched_item *item) int sched_move_domain(struct domain *d, struct cpupool *c) { struct vcpu *v; + struct sched_item *item; unsigned int new_p; - void **vcpu_priv; + void **item_priv; void *domdata; - void *vcpudata; + void *itemdata; struct scheduler *old_ops; void *old_domdata; =20 - for_each_vcpu ( d, v ) + for_each_sched_item ( d, item ) { - if ( v->sched_item->affinity_broken ) + if ( item->affinity_broken ) return -EBUSY; } =20 @@ -440,22 +441,21 @@ int sched_move_domain(struct domain *d, struct cpupoo= l *c) if ( IS_ERR(domdata) ) return PTR_ERR(domdata); =20 - vcpu_priv =3D xzalloc_array(void *, d->max_vcpus); - if ( vcpu_priv =3D=3D NULL ) + item_priv =3D xzalloc_array(void *, d->max_vcpus); + if ( item_priv =3D=3D NULL ) { sched_free_domdata(c->sched, domdata); return -ENOMEM; } =20 - for_each_vcpu ( d, v ) + for_each_sched_item ( d, item ) { - vcpu_priv[v->vcpu_id] =3D sched_alloc_vdata(c->sched, v->sched_ite= m, - domdata); - if ( vcpu_priv[v->vcpu_id] =3D=3D NULL ) + item_priv[item->item_id] =3D sched_alloc_vdata(c->sched, item, dom= data); + if ( item_priv[item->item_id] =3D=3D NULL ) { - for_each_vcpu ( d, v ) - xfree(vcpu_priv[v->vcpu_id]); - xfree(vcpu_priv); + for_each_sched_item ( d, item ) + xfree(item_priv[item->item_id]); + xfree(item_priv); sched_free_domdata(c->sched, domdata); return -ENOMEM; } @@ -466,30 +466,35 @@ int sched_move_domain(struct domain *d, struct cpupoo= l *c) old_ops =3D dom_scheduler(d); old_domdata =3D d->sched_priv; =20 - for_each_vcpu ( d, v ) + for_each_sched_item ( d, item ) { - sched_remove_item(old_ops, v->sched_item); + sched_remove_item(old_ops, item); } =20 d->cpupool =3D c; d->sched_priv =3D domdata; =20 new_p =3D cpumask_first(c->cpu_valid); - for_each_vcpu ( d, v ) + for_each_sched_item ( d, item ) { spinlock_t *lock; + unsigned int item_p =3D new_p; =20 - vcpudata =3D v->sched_item->priv; + itemdata =3D item->priv; =20 - migrate_timer(&v->periodic_timer, new_p); - migrate_timer(&v->singleshot_timer, new_p); - migrate_timer(&v->poll_timer, new_p); + for_each_sched_item_vcpu( item, v ) + { + migrate_timer(&v->periodic_timer, new_p); + migrate_timer(&v->singleshot_timer, new_p); + migrate_timer(&v->poll_timer, new_p); + new_p =3D cpumask_cycle(new_p, c->cpu_valid); + } =20 - lock =3D item_schedule_lock_irq(v->sched_item); + lock =3D item_schedule_lock_irq(item); =20 - sched_set_affinity(v, &cpumask_all, &cpumask_all); + sched_set_affinity(item->vcpu, &cpumask_all, &cpumask_all); =20 - sched_set_res(v->sched_item, per_cpu(sched_res, new_p)); + sched_set_res(item, per_cpu(sched_res, item_p)); /* * With v->processor modified we must not * - make any further changes assuming we hold the scheduler lock, @@ -497,15 +502,13 @@ int sched_move_domain(struct domain *d, struct cpupoo= l *c) */ spin_unlock_irq(lock); =20 - v->sched_item->priv =3D vcpu_priv[v->vcpu_id]; + item->priv =3D item_priv[item->item_id]; if ( !d->is_dying ) sched_move_irqs(v->sched_item); =20 - new_p =3D cpumask_cycle(new_p, c->cpu_valid); + sched_insert_item(c->sched, item); =20 - sched_insert_item(c->sched, v->sched_item); - - sched_free_vdata(old_ops, vcpudata); + sched_free_vdata(old_ops, itemdata); } =20 domain_update_node_affinity(d); @@ -514,7 +517,7 @@ int sched_move_domain(struct domain *d, struct cpupool = *c) =20 sched_free_domdata(old_ops, old_domdata); =20 - xfree(vcpu_priv); + xfree(item_priv); =20 return 0; } @@ -819,15 +822,14 @@ void vcpu_force_reschedule(struct vcpu *v) void restore_vcpu_affinity(struct domain *d) { unsigned int cpu =3D smp_processor_id(); - struct vcpu *v; + struct sched_item *item; =20 ASSERT(system_state =3D=3D SYS_STATE_resume); =20 - for_each_vcpu ( d, v ) + for_each_sched_item ( d, item ) { spinlock_t *lock; - unsigned int old_cpu =3D v->processor; - struct sched_item *item =3D v->sched_item; + unsigned int old_cpu =3D sched_item_cpu(item); struct sched_resource *res; =20 ASSERT(!item_runnable(item)); @@ -846,7 +848,8 @@ void restore_vcpu_affinity(struct domain *d) { if ( item->affinity_broken ) { - sched_set_affinity(v, item->cpu_hard_affinity_saved, NULL); + sched_set_affinity(item->vcpu, item->cpu_hard_affinity_sav= ed, + NULL); item->affinity_broken =3D 0; cpumask_and(cpumask_scratch_cpu(cpu), item->cpu_hard_affin= ity, cpupool_domain_cpumask(d)); @@ -854,8 +857,8 @@ void restore_vcpu_affinity(struct domain *d) =20 if ( cpumask_empty(cpumask_scratch_cpu(cpu)) ) { - printk(XENLOG_DEBUG "Breaking affinity for %pv\n", v); - sched_set_affinity(v, &cpumask_all, NULL); + printk(XENLOG_DEBUG "Breaking affinity for %pv\n", item->v= cpu); + sched_set_affinity(item->vcpu, &cpumask_all, NULL); cpumask_and(cpumask_scratch_cpu(cpu), item->cpu_hard_affin= ity, cpupool_domain_cpumask(d)); } @@ -865,12 +868,12 @@ void restore_vcpu_affinity(struct domain *d) sched_set_res(item, res); =20 lock =3D item_schedule_lock_irq(item); - res =3D sched_pick_resource(vcpu_scheduler(v), item); + res =3D sched_pick_resource(vcpu_scheduler(item->vcpu), item); sched_set_res(item, res); spin_unlock_irq(lock); =20 - if ( old_cpu !=3D v->processor ) - sched_move_irqs(v->sched_item); + if ( old_cpu !=3D sched_item_cpu(item) ) + sched_move_irqs(item); } =20 domain_update_node_affinity(d); @@ -884,7 +887,6 @@ void restore_vcpu_affinity(struct domain *d) int cpu_disable_scheduler(unsigned int cpu) { struct domain *d; - struct vcpu *v; struct cpupool *c; cpumask_t online_affinity; int ret =3D 0; @@ -895,10 +897,11 @@ int cpu_disable_scheduler(unsigned int cpu) =20 for_each_domain_in_cpupool ( d, c ) { - for_each_vcpu ( d, v ) + struct sched_item *item; + + for_each_sched_item ( d, item ) { unsigned long flags; - struct sched_item *item =3D v->sched_item; spinlock_t *lock =3D item_schedule_lock_irqsave(item, &flags); =20 cpumask_and(&online_affinity, item->cpu_hard_affinity, c->cpu_= valid); @@ -913,14 +916,14 @@ int cpu_disable_scheduler(unsigned int cpu) break; } =20 - printk(XENLOG_DEBUG "Breaking affinity for %pv\n", v); + printk(XENLOG_DEBUG "Breaking affinity for %pv\n", item->v= cpu); =20 - sched_set_affinity(v, &cpumask_all, NULL); + sched_set_affinity(item->vcpu, &cpumask_all, NULL); } =20 - if ( v->processor !=3D cpu ) + if ( sched_item_cpu(item) !=3D sched_get_resource_cpu(cpu) ) { - /* The vcpu is not on this cpu, so we can move on. */ + /* The item is not on this cpu, so we can move on. */ item_schedule_unlock_irqrestore(lock, flags, item); continue; } @@ -933,17 +936,17 @@ int cpu_disable_scheduler(unsigned int cpu) * * the scheduler will always find a suitable solution, or * things would have failed before getting in here. */ - vcpu_migrate_start(v); + vcpu_migrate_start(item->vcpu); item_schedule_unlock_irqrestore(lock, flags, item); =20 - vcpu_migrate_finish(v); + vcpu_migrate_finish(item->vcpu); =20 /* * The only caveat, in this case, is that if a vcpu active in * the hypervisor isn't migratable. In this case, the caller * should try again after releasing and reaquiring all locks. */ - if ( v->processor =3D=3D cpu ) + if ( sched_item_cpu(item) =3D=3D sched_get_resource_cpu(cpu) ) ret =3D -EAGAIN; } } @@ -954,16 +957,16 @@ int cpu_disable_scheduler(unsigned int cpu) static int cpu_disable_scheduler_check(unsigned int cpu) { struct domain *d; - struct vcpu *v; struct cpupool *c; + struct sched_item *item; =20 c =3D per_cpu(cpupool, cpu); if ( c =3D=3D NULL ) return 0; =20 for_each_domain_in_cpupool ( d, c ) - for_each_vcpu ( d, v ) - if ( v->sched_item->affinity_broken ) + for_each_sched_item ( d, item ) + if ( item->affinity_broken ) return -EADDRINUSE; =20 return 0; --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125907; cv=none; d=zoho.com; s=zohoarc; b=LVT2E90KQN+qtzUoxurudpxcII5KN4eKKnnOs0+o7FIl3jxMkpz+rg5Ce37YPskbd8FtcVFFyJBm7M6auczJZQby2/UD2tA71k2wQSBxI/57MQuTwvyz85N+BakUePyBubdXIueRmW+lqvIqYjd4vQirmq9Xkl/Xbn0r/yXp0NQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125907; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=N9B4C32YafoHla3ovXuwZZ/GMEBBsrODiIcens1t06o=; b=Ha4XLHWnV4CQ4kHSX11apWmx1nE96fPv50Hcv1MIJqamKvonvv8SqTKiGENW8LLr0mgmGJ40iDUQQJCgj1I6I5+q/dfcP8zwwr/5Xum3xNZYvsyu147eXOomH7v41izlTIgJbRPZoFvqF9aw4utR5VazWtibjym6WUvRzgo5UjM= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125907493229.8341666157594; Sun, 5 May 2019 23:58:27 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYn-0002Jo-Ae; Mon, 06 May 2019 06:57:13 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYh-00026W-3w for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:07 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 26267acc-6fcc-11e9-843c-bc764e045a96; Mon, 06 May 2019 06:57:02 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 7FC76AF31; Mon, 6 May 2019 06:56:56 +0000 (UTC) X-Inumbo-ID: 26267acc-6fcc-11e9-843c-bc764e045a96 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:28 +0200 Message-Id: <20190506065644.7415-30-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 29/45] xen/sched: add runstate counters to struct sched_item X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Tim Deegan , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Dario Faggioli , Julien Grall , Jan Beulich MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Add counters to struct sched_item summing up runstates of associated vcpus. Signed-off-by: Juergen Gross --- RFC V2: add counters for each possible runstate --- xen/common/schedule.c | 6 ++++++ xen/include/xen/sched.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index bc0554f2da..67871b6618 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -174,6 +174,7 @@ static inline void vcpu_runstate_change( struct vcpu *v, int new_state, s_time_t new_entry_time) { s_time_t delta; + struct sched_item *item =3D v->sched_item; =20 ASSERT(v->runstate.state !=3D new_state); ASSERT(spin_is_locked(per_cpu(sched_res, v->processor)->schedule_lock)= ); @@ -182,6 +183,9 @@ static inline void vcpu_runstate_change( =20 trace_runstate_change(v, new_state); =20 + item->runstate_cnt[v->runstate.state]--; + item->runstate_cnt[new_state]++; + delta =3D new_entry_time - v->runstate.state_entry_time; if ( delta > 0 ) { @@ -359,6 +363,8 @@ int sched_init_vcpu(struct vcpu *v) if ( (item =3D sched_alloc_item(v)) =3D=3D NULL ) return 1; =20 + item->runstate_cnt[v->runstate.state]++; + if ( is_idle_domain(d) ) processor =3D v->vcpu_id; else diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 8052f98780..571631f217 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -272,6 +272,8 @@ struct sched_item { uint64_t last_run_time; /* Last time item got (de-)scheduled. */ uint64_t state_entry_time; + /* Vcpu state summary. */ + unsigned int runstate_cnt[4]; =20 /* Currently running on a CPU? */ bool is_running; --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125915; cv=none; d=zoho.com; s=zohoarc; b=L0tsF3IW8UWahLI2KdsnQTQrNKjE83JZ9qMZrrL3Bo609Ftxa2stm7cLzDKI6Hb0IaETMcaAjfzMPj5BwDnvCTRn1MmtpXtK7vwtHxc5g6mivItMuoG450SIVuw3P/19G3oFNcLISAjNMSyd/AQbsOKfkeHr0I+mvGMTkZ/Ouck= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125915; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=fcudlWVrrwUeTXv59b2v+c65aPPCKDkHe44lTR7bDP0=; b=Czo55qv8MqZbD8n6Gn+1d7i/RyLFx6Y7RKi2sgJiBcOEs77jVPqBQP5/2IWJOvgKC7ihyKxCop+bB/RhhRKg1lqOGJ4kopDarh12P0BC8Z37L1OgWwRtgiwuPwSimPp57CjTdSZLPgMTH1XZe4aTOJyUks8yKMIoDkbxQLm8V5M= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125915278553.9728275905846; Sun, 5 May 2019 23:58:35 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYr-0002Tt-SD; Mon, 06 May 2019 06:57:17 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYj-0002CJ-Tg for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:09 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 261eecc0-6fcc-11e9-9e4d-9bcd72c1e9c5; Mon, 06 May 2019 06:57:02 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id CECB5AF32; Mon, 6 May 2019 06:56:56 +0000 (UTC) X-Inumbo-ID: 261eecc0-6fcc-11e9-9e4d-9bcd72c1e9c5 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:29 +0200 Message-Id: <20190506065644.7415-31-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 30/45] xen/sched: rework and rename vcpu_force_reschedule() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , Dario Faggioli , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" vcpu_force_reschedule() is only used for modifying the periodic timer of a vcpu. Forcing a vcpu to give up the physical cpu for that purpose is kind of brutal. So instead of doing the reschedule dance just operate on the timer directly. In case we are modifying the timer of the currently running vcpu we can just do that. In case it is for a foreign vcpu we should pause it for that purpose like we do for all other vcpu state modifications. Rename the function to vcpu_set_periodic_timer() as this now reflects the functionality. Signed-off-by: Juergen Gross --- xen/arch/x86/pv/shim.c | 4 +--- xen/common/domain.c | 6 ++---- xen/common/schedule.c | 23 +++++++++++++---------- xen/include/xen/sched.h | 2 +- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/xen/arch/x86/pv/shim.c b/xen/arch/x86/pv/shim.c index 324ca27f93..5edbcd9ac5 100644 --- a/xen/arch/x86/pv/shim.c +++ b/xen/arch/x86/pv/shim.c @@ -410,7 +410,7 @@ int pv_shim_shutdown(uint8_t reason) unmap_vcpu_info(v); =20 /* Reset the periodic timer to the default value. */ - v->periodic_period =3D MILLISECS(10); + vcpu_set_periodic_timer(v, MILLISECS(10)); /* Stop the singleshot timer. */ stop_timer(&v->singleshot_timer); =20 @@ -419,8 +419,6 @@ int pv_shim_shutdown(uint8_t reason) =20 if ( v !=3D current ) vcpu_unpause_by_systemcontroller(v); - else - vcpu_force_reschedule(v); } =20 return 0; diff --git a/xen/common/domain.c b/xen/common/domain.c index d0f9e5e86a..63ef64e4d4 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -1441,15 +1441,13 @@ long do_vcpu_op(int cmd, unsigned int vcpuid, XEN_G= UEST_HANDLE_PARAM(void) arg) if ( set.period_ns > STIME_DELTA_MAX ) return -EINVAL; =20 - v->periodic_period =3D set.period_ns; - vcpu_force_reschedule(v); + vcpu_set_periodic_timer(v, set.period_ns); =20 break; } =20 case VCPUOP_stop_periodic_timer: - v->periodic_period =3D 0; - vcpu_force_reschedule(v); + vcpu_set_periodic_timer(v, 0); break; =20 case VCPUOP_set_singleshot_timer: diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 67871b6618..52da5d5a30 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -808,21 +808,24 @@ static void vcpu_migrate_finish(struct vcpu *v) } =20 /* - * Force a VCPU through a deschedule/reschedule path. - * For example, using this when setting the periodic timer period means th= at - * most periodic-timer state need only be touched from within the scheduler - * which can thus be done without need for synchronisation. + * Set the periodic timer of a vcpu. */ -void vcpu_force_reschedule(struct vcpu *v) +void vcpu_set_periodic_timer(struct vcpu *v, s_time_t value) { - spinlock_t *lock =3D item_schedule_lock_irq(v->sched_item); + s_time_t now =3D NOW(); =20 - if ( v->sched_item->is_running ) - vcpu_migrate_start(v); + if ( v !=3D current ) + vcpu_pause(v); + else + stop_timer(&v->periodic_timer); =20 - item_schedule_unlock_irq(lock, v->sched_item); + v->periodic_period =3D value; + v->periodic_last_event =3D now; =20 - vcpu_migrate_finish(v); + if ( v !=3D current ) + vcpu_unpause(v); + else if ( value !=3D 0 ) + set_timer(&v->periodic_timer, now + value); } =20 void restore_vcpu_affinity(struct domain *d) diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 571631f217..cbd97f34c7 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -897,7 +897,7 @@ struct scheduler *scheduler_get_default(void); struct scheduler *scheduler_alloc(unsigned int sched_id, int *perr); void scheduler_free(struct scheduler *sched); int schedule_cpu_switch(unsigned int cpu, struct cpupool *c); -void vcpu_force_reschedule(struct vcpu *v); +void vcpu_set_periodic_timer(struct vcpu *v, s_time_t value); int cpu_disable_scheduler(unsigned int cpu); /* We need it in dom0_setup_vcpu */ void sched_set_affinity(struct vcpu *v, const cpumask_t *hard, --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125916; cv=none; d=zoho.com; s=zohoarc; b=TF8ardMVeJPjNJj+6NdgE7jDAz+HHuaNDQhRoEt84O+seUqbMZHv7MSCzk1FCEsU/283SQC6sN0DnP0HiqSe6xOOi7egDH8laKdGioUaMlXtspl3QZrZ5TjT9UsXCUkOBddNtlztsbXJoRXYBXwxAw906UmihEYx1DfN0MLr51I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125916; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=iygXSumuXBvlGGJStQ2xAUt0/H7RN8vEyYQZowyC90k=; b=oCMyK7jHuYwF22rNneG0cbZLHMqcl8NyD3r7QA6n4yWtyhDOlcX/Ya5LbaAY1VhoFPMGzndtiDAD68cBlfHLcSO1VVfIfK8sstpYXzZPHb4kOfPaeaq1OA5sRxrRd17dRIeIqUxbfagyFOLjlrKTgRYxkOOIkh8OGRptqhwa/LA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125916590279.5527840542053; Sun, 5 May 2019 23:58:36 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYw-0002gl-T3; Mon, 06 May 2019 06:57:22 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYl-0002FE-BO for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:11 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 26a2f0b0-6fcc-11e9-82a0-03eb74c4322f; Mon, 06 May 2019 06:57:02 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id EECE3AF34; Mon, 6 May 2019 06:56:56 +0000 (UTC) X-Inumbo-ID: 26a2f0b0-6fcc-11e9-82a0-03eb74c4322f X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:30 +0200 Message-Id: <20190506065644.7415-32-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 31/45] xen/sched: Change vcpu_migrate_*() to operate on schedule item X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , George Dunlap , Dario Faggioli MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Now that vcpu_migrate_start() and vcpu_migrate_finish() are used only to ensure a vcpu is running on a suitable processor they can be switched to operate on schedule items instead of vcpus. While doing that rename them accordingly and make the _start() variant static. vcpu_move_locked() is switched to schedule item, too. Signed-off-by: Juergen Gross --- xen/common/schedule.c | 102 +++++++++++++++++++++++++++++-----------------= ---- 1 file changed, 59 insertions(+), 43 deletions(-) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 52da5d5a30..9f9d6eb95b 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -664,35 +664,40 @@ void vcpu_unblock(struct vcpu *v) } =20 /* - * Do the actual movement of a vcpu from old to new CPU. Locks for *both* + * Do the actual movement of an item from old to new CPU. Locks for *both* * CPUs needs to have been taken already when calling this! */ -static void vcpu_move_locked(struct vcpu *v, unsigned int new_cpu) +static void sched_item_move_locked(struct sched_item *item, + unsigned int new_cpu) { - unsigned int old_cpu =3D v->processor; + unsigned int old_cpu =3D item->res->processor; + struct vcpu *v; =20 /* * Transfer urgency status to new CPU before switching CPUs, as * once the switch occurs, v->is_urgent is no longer protected by * the per-CPU scheduler lock we are holding. */ - if ( unlikely(v->is_urgent) && (old_cpu !=3D new_cpu) ) + for_each_sched_item_vcpu ( item, v ) { - atomic_inc(&per_cpu(sched_res, new_cpu)->urgent_count); - atomic_dec(&per_cpu(sched_res, old_cpu)->urgent_count); + if ( unlikely(v->is_urgent) && (old_cpu !=3D new_cpu) ) + { + atomic_inc(&per_cpu(sched_res, new_cpu)->urgent_count); + atomic_dec(&per_cpu(sched_res, old_cpu)->urgent_count); + } } =20 /* * Actual CPU switch to new CPU. This is safe because the lock * pointer can't change while the current lock is held. */ - sched_migrate(vcpu_scheduler(v), v->sched_item, new_cpu); + sched_migrate(vcpu_scheduler(item->vcpu), item, new_cpu); } =20 /* * Initiating migration * - * In order to migrate, we need the vcpu in question to have stopped + * In order to migrate, we need the item in question to have stopped * running and had sched_sleep() called (to take it off any * runqueues, for instance); and if it is currently running, it needs * to be scheduled out. Finally, we need to hold the scheduling locks @@ -708,37 +713,45 @@ static void vcpu_move_locked(struct vcpu *v, unsigned= int new_cpu) * should be called like this: * * lock =3D item_schedule_lock_irq(item); - * vcpu_migrate_start(v); + * sched_item_migrate_start(item); * item_schedule_unlock_irq(lock, item) - * vcpu_migrate_finish(v); + * sched_item_migrate_finish(item); * - * vcpu_migrate_finish() will do the work now if it can, or simply - * return if it can't (because v is still running); in that case - * vcpu_migrate_finish() will be called by context_saved(). + * sched_item_migrate_finish() will do the work now if it can, or simply + * return if it can't (because item is still running); in that case + * sched_item_migrate_finish() will be called by context_saved(). */ -static void vcpu_migrate_start(struct vcpu *v) +static void sched_item_migrate_start(struct sched_item *item) { - set_bit(_VPF_migrating, &v->pause_flags); - vcpu_sleep_nosync_locked(v); + struct vcpu *v; + + for_each_sched_item_vcpu ( item, v ) + { + set_bit(_VPF_migrating, &v->pause_flags); + vcpu_sleep_nosync_locked(v); + } } =20 -static void vcpu_migrate_finish(struct vcpu *v) +static void sched_item_migrate_finish(struct sched_item *item) { unsigned long flags; unsigned int old_cpu, new_cpu; spinlock_t *old_lock, *new_lock; bool_t pick_called =3D 0; + struct vcpu *v; =20 /* - * If the vcpu is currently running, this will be handled by + * If the item is currently running, this will be handled by * context_saved(); and in any case, if the bit is cleared, then * someone else has already done the work so we don't need to. */ - if ( v->sched_item->is_running || - !test_bit(_VPF_migrating, &v->pause_flags) ) - return; + for_each_sched_item_vcpu ( item, v ) + { + if ( item->is_running || !test_bit(_VPF_migrating, &v->pause_flags= ) ) + return; + } =20 - old_cpu =3D new_cpu =3D v->processor; + old_cpu =3D new_cpu =3D item->res->processor; for ( ; ; ) { /* @@ -751,7 +764,7 @@ static void vcpu_migrate_finish(struct vcpu *v) =20 sched_spin_lock_double(old_lock, new_lock, &flags); =20 - old_cpu =3D v->processor; + old_cpu =3D item->res->processor; if ( old_lock =3D=3D per_cpu(sched_res, old_cpu)->schedule_lock ) { /* @@ -760,15 +773,15 @@ static void vcpu_migrate_finish(struct vcpu *v) */ if ( pick_called && (new_lock =3D=3D per_cpu(sched_res, new_cpu)->schedule_lo= ck) && - cpumask_test_cpu(new_cpu, v->sched_item->cpu_hard_affinit= y) && - cpumask_test_cpu(new_cpu, v->domain->cpupool->cpu_valid) ) + cpumask_test_cpu(new_cpu, item->cpu_hard_affinity) && + cpumask_test_cpu(new_cpu, item->domain->cpupool->cpu_vali= d) ) break; =20 /* Select a new CPU. */ - new_cpu =3D sched_pick_resource(vcpu_scheduler(v), - v->sched_item)->processor; + new_cpu =3D sched_pick_resource(vcpu_scheduler(item->vcpu), + item)->processor; if ( (new_lock =3D=3D per_cpu(sched_res, new_cpu)->schedule_lo= ck) && - cpumask_test_cpu(new_cpu, v->domain->cpupool->cpu_valid) ) + cpumask_test_cpu(new_cpu, item->domain->cpupool->cpu_vali= d) ) break; pick_called =3D 1; } @@ -789,22 +802,26 @@ static void vcpu_migrate_finish(struct vcpu *v) * because they both happen in (different) spinlock regions, and those * regions are strictly serialised. */ - if ( v->sched_item->is_running || - !test_and_clear_bit(_VPF_migrating, &v->pause_flags) ) + for_each_sched_item_vcpu ( item, v ) { - sched_spin_unlock_double(old_lock, new_lock, flags); - return; + if ( item->is_running || + !test_and_clear_bit(_VPF_migrating, &v->pause_flags) ) + { + sched_spin_unlock_double(old_lock, new_lock, flags); + return; + } } =20 - vcpu_move_locked(v, new_cpu); + sched_item_move_locked(item, new_cpu); =20 sched_spin_unlock_double(old_lock, new_lock, flags); =20 if ( old_cpu !=3D new_cpu ) - sched_move_irqs(v->sched_item); + sched_move_irqs(item); =20 /* Wake on new CPU. */ - vcpu_wake(v); + for_each_sched_item_vcpu ( item, v ) + vcpu_wake(v); } =20 /* @@ -945,10 +962,9 @@ int cpu_disable_scheduler(unsigned int cpu) * * the scheduler will always find a suitable solution, or * things would have failed before getting in here. */ - vcpu_migrate_start(item->vcpu); + sched_item_migrate_start(item); item_schedule_unlock_irqrestore(lock, flags, item); - - vcpu_migrate_finish(item->vcpu); + sched_item_migrate_finish(item); =20 /* * The only caveat, in this case, is that if a vcpu active in @@ -1032,14 +1048,14 @@ static int vcpu_set_affinity( ASSERT(which =3D=3D item->cpu_soft_affinity); sched_set_affinity(v, NULL, affinity); } - vcpu_migrate_start(v); + sched_item_migrate_start(item); } =20 item_schedule_unlock_irq(lock, item); =20 domain_update_node_affinity(v->domain); =20 - vcpu_migrate_finish(v); + sched_item_migrate_finish(item); =20 return ret; } @@ -1283,13 +1299,13 @@ int vcpu_pin_override(struct vcpu *v, int cpu) } =20 if ( ret =3D=3D 0 ) - vcpu_migrate_start(v); + sched_item_migrate_start(item); =20 item_schedule_unlock_irq(lock, item); =20 domain_update_node_affinity(v->domain); =20 - vcpu_migrate_finish(v); + sched_item_migrate_finish(item); =20 return ret; } @@ -1676,7 +1692,7 @@ void context_saved(struct vcpu *prev) =20 sched_context_saved(vcpu_scheduler(prev), prev->sched_item); =20 - vcpu_migrate_finish(prev); + sched_item_migrate_finish(prev->sched_item); } =20 /* The scheduler timer: force a run through the scheduler */ --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125917; cv=none; d=zoho.com; s=zohoarc; b=hODmslQ/m3brx4l+VzzbOICvNetkw80MldaePuFagbxS1dvEQhyKAic9GfYyft4w/ake5ASnM2UNG6Qqb5VQHQT07Fl3hkjNfzbbfefGQ/ztg3QEzRNuRZjXPWZuxVfrDu6YxrAc6ZOv8vQCPezrrXtkt/TxOpGPl26Fhyc/U9c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125917; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=kE/OuPqRcv/TNuYTpySgkNuiq3ymt0DVq53RKqVjBAs=; b=l462oxekHdspQ1W5uik8527CAKcai3Lzkn29qb3mETueT1Zgf5hJl3sRLTrbn09GvbkFU1Vg4QjRHErJ/C7O0FVt+dUZnfBjTPUK9aRO45WA67AYR4TndJvaGBeyNpW6dxpvr1gOmJ2WrL8bq87NZehNm5B5GwRWpmamGuWDy9w= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125917321916.8538356178703; Sun, 5 May 2019 23:58:37 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYu-0002aD-2a; Mon, 06 May 2019 06:57:20 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYk-0002Ck-4y for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:10 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 26aa375c-6fcc-11e9-843c-bc764e045a96; Mon, 06 May 2019 06:57:03 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 5AF5DAF35; Mon, 6 May 2019 06:56:57 +0000 (UTC) X-Inumbo-ID: 26aa375c-6fcc-11e9-843c-bc764e045a96 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:31 +0200 Message-Id: <20190506065644.7415-33-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 32/45] xen/sched: move struct task_slice into struct sched_item X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Tim Deegan , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Robert VanVossen , Dario Faggioli , Julien Grall , Josh Whitehead , Meng Xu , Jan Beulich MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" In order to prepare for multiple vcpus per schedule item move struct task_slice in schedule() from the local stack into struct sched_item of the currently running item. To make access easier for the single schedulers add the pointer of the currently running item as a parameter of do_schedule(). While at it switch the tasklet_work_scheduled parameter of do_schedule() from bool_t to bool. As struct task_slice is only ever modified with the local schedule lock held it is safe to directly set the different items in struct sched_item instead of using an on-stack copy for returning the data. Signed-off-by: Juergen Gross --- xen/common/sched_arinc653.c | 20 +++++++------------- xen/common/sched_credit.c | 25 +++++++++++-------------- xen/common/sched_credit2.c | 21 +++++++++------------ xen/common/sched_null.c | 26 ++++++++++++-------------- xen/common/sched_rt.c | 22 +++++++++++----------- xen/common/schedule.c | 21 ++++++++++----------- xen/include/xen/sched-if.h | 11 +++-------- xen/include/xen/sched.h | 6 ++++++ 8 files changed, 69 insertions(+), 83 deletions(-) diff --git a/xen/common/sched_arinc653.c b/xen/common/sched_arinc653.c index 3919c0a3e9..e98e98116b 100644 --- a/xen/common/sched_arinc653.c +++ b/xen/common/sched_arinc653.c @@ -497,18 +497,14 @@ a653sched_item_wake(const struct scheduler *ops, stru= ct sched_item *item) * * @param ops Pointer to this instance of the scheduler structure * @param now Current time - * - * @return Address of the ITEM structure scheduled to be run next - * Amount of time to execute the returned ITEM - * Flag for whether the ITEM was migrated */ -static struct task_slice +static void a653sched_do_schedule( const struct scheduler *ops, + struct sched_item *prev, s_time_t now, - bool_t tasklet_work_scheduled) + bool tasklet_work_scheduled) { - struct task_slice ret; /* hold the chosen domain = */ struct sched_item *new_task =3D NULL; static unsigned int sched_index =3D 0; static s_time_t next_switch_time; @@ -586,13 +582,11 @@ a653sched_do_schedule( * Return the amount of time the next domain has to run and the address * of the selected task's ITEM structure. */ - ret.time =3D next_switch_time - now; - ret.task =3D new_task; - ret.migrated =3D 0; - - BUG_ON(ret.time <=3D 0); + prev->next_time =3D next_switch_time - now; + prev->next_task =3D new_task; + new_task->migrated =3D false; =20 - return ret; + BUG_ON(prev->next_time <=3D 0); } =20 /** diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index 4734f52fc7..064f88ab23 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -1689,7 +1689,7 @@ csched_runq_steal(int peer_cpu, int cpu, int pri, int= balance_step) =20 static struct csched_item * csched_load_balance(struct csched_private *prv, int cpu, - struct csched_item *snext, bool_t *stolen) + struct csched_item *snext, bool *stolen) { struct cpupool *c =3D per_cpu(cpupool, cpu); struct csched_item *speer; @@ -1805,7 +1805,7 @@ csched_load_balance(struct csched_private *prv, int c= pu, /* As soon as one item is found, balancing ends */ if ( speer !=3D NULL ) { - *stolen =3D 1; + *stolen =3D true; /* * Next time we'll look for work to steal on this node= , we * will start from the next pCPU, with respect to this= one, @@ -1835,19 +1835,18 @@ csched_load_balance(struct csched_private *prv, int= cpu, * This function is in the critical path. It is designed to be simple and * fast for the common case. */ -static struct task_slice -csched_schedule( - const struct scheduler *ops, s_time_t now, bool_t tasklet_work_schedul= ed) +static void csched_schedule( + const struct scheduler *ops, struct sched_item *item, s_time_t now, + bool tasklet_work_scheduled) { const unsigned int cpu =3D smp_processor_id(); const unsigned int sched_cpu =3D sched_get_resource_cpu(cpu); struct list_head * const runq =3D RUNQ(sched_cpu); - struct sched_item *item =3D current->sched_item; struct csched_item * const scurr =3D CSCHED_ITEM(item); struct csched_private *prv =3D CSCHED_PRIV(ops); struct csched_item *snext; - struct task_slice ret; s_time_t runtime, tslice; + bool migrated =3D false; =20 SCHED_STAT_CRANK(schedule); CSCHED_ITEM_CHECK(item); @@ -1937,7 +1936,6 @@ csched_schedule( (unsigned char *)&d); } =20 - ret.migrated =3D 0; goto out; } tslice =3D prv->tslice; @@ -1955,7 +1953,6 @@ csched_schedule( } =20 snext =3D __runq_elem(runq->next); - ret.migrated =3D 0; =20 /* Tasklet work (which runs in idle ITEM context) overrides all else. = */ if ( tasklet_work_scheduled ) @@ -1981,7 +1978,7 @@ csched_schedule( if ( snext->pri > CSCHED_PRI_TS_OVER ) __runq_remove(snext); else - snext =3D csched_load_balance(prv, sched_cpu, snext, &ret.migrated= ); + snext =3D csched_load_balance(prv, sched_cpu, snext, &migrated); =20 /* * Update idlers mask if necessary. When we're idling, other CPUs @@ -2004,12 +2001,12 @@ out: /* * Return task to run next... */ - ret.time =3D (is_idle_item(snext->item) ? + item->next_time =3D (is_idle_item(snext->item) ? -1 : tslice); - ret.task =3D snext->item; + item->next_task =3D snext->item; + snext->item->migrated =3D migrated; =20 - CSCHED_ITEM_CHECK(ret.task); - return ret; + CSCHED_ITEM_CHECK(item->next_task); } =20 static void diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index d5cb8c0200..f1074be25d 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -3443,19 +3443,18 @@ runq_candidate(struct csched2_runqueue_data *rqd, * This function is in the critical path. It is designed to be simple and * fast for the common case. */ -static struct task_slice -csched2_schedule( - const struct scheduler *ops, s_time_t now, bool tasklet_work_scheduled) +static void csched2_schedule( + const struct scheduler *ops, struct sched_item *curritem, s_time_t now, + bool tasklet_work_scheduled) { const unsigned int cpu =3D smp_processor_id(); const unsigned int sched_cpu =3D sched_get_resource_cpu(cpu); struct csched2_runqueue_data *rqd; - struct sched_item *curritem =3D current->sched_item; struct csched2_item * const scurr =3D csched2_item(curritem); struct csched2_item *snext =3D NULL; unsigned int skipped_items =3D 0; - struct task_slice ret; bool tickled; + bool migrated =3D false; =20 SCHED_STAT_CRANK(schedule); CSCHED2_ITEM_CHECK(curritem); @@ -3540,8 +3539,6 @@ csched2_schedule( && item_runnable(curritem) ) __set_bit(__CSFLAG_delayed_runq_add, &scurr->flags); =20 - ret.migrated =3D 0; - /* Accounting for non-idle tasks */ if ( !is_idle_item(snext->item) ) { @@ -3591,7 +3588,7 @@ csched2_schedule( snext->credit +=3D CSCHED2_MIGRATE_COMPENSATION; sched_set_res(snext->item, per_cpu(sched_res, sched_cpu)); SCHED_STAT_CRANK(migrated); - ret.migrated =3D 1; + migrated =3D true; } } else @@ -3622,11 +3619,11 @@ csched2_schedule( /* * Return task to run next... */ - ret.time =3D csched2_runtime(ops, sched_cpu, snext, now); - ret.task =3D snext->item; + curritem->next_time =3D csched2_runtime(ops, sched_cpu, snext, now); + curritem->next_task =3D snext->item; + snext->item->migrated =3D migrated; =20 - CSCHED2_ITEM_CHECK(ret.task); - return ret; + CSCHED2_ITEM_CHECK(curritem->next_task); } =20 static void diff --git a/xen/common/sched_null.c b/xen/common/sched_null.c index 34ce7a05d3..1af396dcdb 100644 --- a/xen/common/sched_null.c +++ b/xen/common/sched_null.c @@ -703,16 +703,14 @@ static inline void null_item_check(struct sched_item = *item) * - the item assigned to the pCPU, if there's one and it can run; * - the idle item, otherwise. */ -static struct task_slice null_schedule(const struct scheduler *ops, - s_time_t now, - bool_t tasklet_work_scheduled) +static void null_schedule(const struct scheduler *ops, struct sched_item *= prev, + s_time_t now, bool tasklet_work_scheduled) { unsigned int bs; const unsigned int cpu =3D smp_processor_id(); const unsigned int sched_cpu =3D sched_get_resource_cpu(cpu); struct null_private *prv =3D null_priv(ops); struct null_item *wvc; - struct task_slice ret; =20 SCHED_STAT_CRANK(schedule); NULL_ITEM_CHECK(current->sched_item); @@ -740,19 +738,18 @@ static struct task_slice null_schedule(const struct s= cheduler *ops, if ( tasklet_work_scheduled ) { trace_var(TRC_SNULL_TASKLET, 1, 0, NULL); - ret.task =3D sched_idle_item(sched_cpu); + prev->next_task =3D sched_idle_item(sched_cpu); } else - ret.task =3D per_cpu(npc, sched_cpu).item; - ret.migrated =3D 0; - ret.time =3D -1; + prev->next_task =3D per_cpu(npc, sched_cpu).item; + prev->next_time =3D -1; =20 /* * We may be new in the cpupool, or just coming back online. In which * case, there may be items in the waitqueue that we can assign to us * and run. */ - if ( unlikely(ret.task =3D=3D NULL) ) + if ( unlikely(prev->next_task =3D=3D NULL) ) { spin_lock(&prv->waitq_lock); =20 @@ -778,7 +775,7 @@ static struct task_slice null_schedule(const struct sch= eduler *ops, { item_assign(prv, wvc->item, sched_cpu); list_del_init(&wvc->waitq_elem); - ret.task =3D wvc->item; + prev->next_task =3D wvc->item; goto unlock; } } @@ -787,11 +784,12 @@ static struct task_slice null_schedule(const struct s= cheduler *ops, spin_unlock(&prv->waitq_lock); } =20 - if ( unlikely(ret.task =3D=3D NULL || !item_runnable(ret.task)) ) - ret.task =3D sched_idle_item(sched_cpu); + if ( unlikely(prev->next_task =3D=3D NULL || !item_runnable(prev->next= _task)) ) + prev->next_task =3D sched_idle_item(sched_cpu); =20 - NULL_ITEM_CHECK(ret.task); - return ret; + NULL_ITEM_CHECK(prev->next_task); + + prev->next_task->migrated =3D false; } =20 static inline void dump_item(struct null_private *prv, struct null_item *n= vc) diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index 2366e33beb..c5e8b559f3 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -1062,16 +1062,16 @@ runq_pick(const struct scheduler *ops, const cpumas= k_t *mask) * schedule function for rt scheduler. * The lock is already grabbed in schedule.c, no need to lock here */ -static struct task_slice -rt_schedule(const struct scheduler *ops, s_time_t now, bool_t tasklet_work= _scheduled) +static void +rt_schedule(const struct scheduler *ops, struct sched_item *curritem, + s_time_t now, bool tasklet_work_scheduled) { const unsigned int cpu =3D smp_processor_id(); const unsigned int sched_cpu =3D sched_get_resource_cpu(cpu); struct rt_private *prv =3D rt_priv(ops); - struct rt_item *const scurr =3D rt_item(current->sched_item); + struct rt_item *const scurr =3D rt_item(curritem); struct rt_item *snext =3D NULL; - struct task_slice ret =3D { .migrated =3D 0 }; - struct sched_item *curritem =3D current->sched_item; + bool migrated =3D false; =20 /* TRACE */ { @@ -1119,7 +1119,7 @@ rt_schedule(const struct scheduler *ops, s_time_t now= , bool_t tasklet_work_sched __set_bit(__RTDS_delayed_runq_add, &scurr->flags); =20 snext->last_start =3D now; - ret.time =3D -1; /* if an idle item is picked */ + curritem->next_time =3D -1; /* if an idle item is picked */ if ( !is_idle_item(snext->item) ) { if ( snext !=3D scurr ) @@ -1130,13 +1130,13 @@ rt_schedule(const struct scheduler *ops, s_time_t n= ow, bool_t tasklet_work_sched if ( sched_item_cpu(snext->item) !=3D sched_cpu ) { sched_set_res(snext->item, per_cpu(sched_res, sched_cpu)); - ret.migrated =3D 1; + migrated =3D true; } - ret.time =3D snext->cur_budget; /* invoke the scheduler next time = */ + /* Invoke the scheduler next time. */ + curritem->next_time =3D snext->cur_budget; } - ret.task =3D snext->item; - - return ret; + curritem->next_task =3D snext->item; + snext->item->migrated =3D migrated; } =20 /* diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 9f9d6eb95b..b5fb48c553 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -1575,10 +1575,9 @@ static void schedule(void) s_time_t now; struct scheduler *sched; unsigned long *tasklet_work =3D &this_cpu(tasklet_work_to_do); - bool_t tasklet_work_scheduled =3D 0; + bool tasklet_work_scheduled =3D false; struct sched_resource *sd; spinlock_t *lock; - struct task_slice next_slice; int cpu =3D smp_processor_id(); =20 ASSERT_NOT_IN_ATOMIC(); @@ -1594,12 +1593,12 @@ static void schedule(void) set_bit(_TASKLET_scheduled, tasklet_work); /* fallthrough */ case TASKLET_enqueued|TASKLET_scheduled: - tasklet_work_scheduled =3D 1; + tasklet_work_scheduled =3D true; break; case TASKLET_scheduled: clear_bit(_TASKLET_scheduled, tasklet_work); case 0: - /*tasklet_work_scheduled =3D 0;*/ + /*tasklet_work_scheduled =3D false;*/ break; default: BUG(); @@ -1613,14 +1612,14 @@ static void schedule(void) =20 /* get policy-specific decision on scheduling... */ sched =3D this_cpu(scheduler); - next_slice =3D sched->do_schedule(sched, now, tasklet_work_scheduled); + sched->do_schedule(sched, prev, now, tasklet_work_scheduled); =20 - next =3D next_slice.task; + next =3D prev->next_task; =20 sd->curr =3D next; =20 - if ( next_slice.time >=3D 0 ) /* -ve means no limit */ - set_timer(&sd->s_timer, now + next_slice.time); + if ( prev->next_time >=3D 0 ) /* -ve means no limit */ + set_timer(&sd->s_timer, now + prev->next_time); =20 if ( unlikely(prev =3D=3D next) ) { @@ -1628,7 +1627,7 @@ static void schedule(void) TRACE_4D(TRC_SCHED_SWITCH_INFCONT, next->domain->domain_id, next->item_id, now - prev->state_entry_time, - next_slice.time); + prev->next_time); trace_continue_running(next->vcpu); return continue_running(prev->vcpu); } @@ -1640,7 +1639,7 @@ static void schedule(void) next->domain->domain_id, next->item_id, (next->vcpu->runstate.state =3D=3D RUNSTATE_runnable) ? (now - next->state_entry_time) : 0, - next_slice.time); + prev->next_time); =20 ASSERT(prev->vcpu->runstate.state =3D=3D RUNSTATE_running); =20 @@ -1670,7 +1669,7 @@ static void schedule(void) =20 stop_timer(&prev->vcpu->periodic_timer); =20 - if ( next_slice.migrated ) + if ( next->migrated ) vcpu_move_irqs(next->vcpu); =20 vcpu_periodic_timer_work(next->vcpu); diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index 2506538649..09544e05c0 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -180,12 +180,6 @@ static inline spinlock_t *pcpu_schedule_trylock(unsign= ed int cpu) return NULL; } =20 -struct task_slice { - struct sched_item *task; - s_time_t time; - bool_t migrated; -}; - struct scheduler { char *name; /* full name for this scheduler */ char *opt_name; /* option name for this scheduler */ @@ -228,8 +222,9 @@ struct scheduler { void (*context_saved) (const struct scheduler *, struct sched_item *); =20 - struct task_slice (*do_schedule) (const struct scheduler *, s_time_t, - bool_t tasklet_work_scheduled); + void (*do_schedule) (const struct scheduler *, + struct sched_item *, s_time_t, + bool tasklet_work_scheduled); =20 struct sched_resource * (*pick_resource) (const struct scheduler *, struct sched_item *); diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index cbd97f34c7..8bde790d27 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -281,6 +281,8 @@ struct sched_item { bool affinity_broken; /* Does soft affinity actually play a role (given hard affinity)? */ bool soft_aff_effective; + /* Item has been migrated to other cpu(s). */ + bool migrated; /* Bitmask of CPUs on which this VCPU may run. */ cpumask_var_t cpu_hard_affinity; /* Used to change affinity temporarily. */ @@ -289,6 +291,10 @@ struct sched_item { cpumask_var_t cpu_hard_affinity_saved; /* Bitmask of CPUs on which this VCPU prefers to run. */ cpumask_var_t cpu_soft_affinity; + + /* Next item to run. */ + struct sched_item *next_task; + s_time_t next_time; }; =20 #define for_each_sched_item(d, e) \ --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125915; cv=none; d=zoho.com; s=zohoarc; b=kzudgpVHsMbpROWHktqyzV91POwt9IAiEFa5KU2duI6z2sWO3XgvheF7A35ApvsUCisF43c08QZDsiOHCthPGomHbQln2bwSogMB1SS5Dbr+HE7UEecy7lyRYvs9jq6BDOeBIcICHBzZMmHxF3Aa0jTVGa37j6PxpOcgmf8wHOE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125915; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Rs9DNhroaE9f5K0nT/cN/gsSr122PproYhr7KZslQSM=; b=SxaUHA9pR0fV2pR4NJhQLas3onqs6eiino/sKhK+fxgxXlVh7UVeyWFwKY2GJ9GZdAe3AVuf6FpB1z2U/jsSmvIV6rj1zgLh/HxSTcRjgAw19zgMppqL2qFUbHuAiJUhfNjwHVQeyh2dTFGiJVWkoAtibRih/9pUo0f9ildTg1I= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125915955673.0775657299047; Sun, 5 May 2019 23:58:35 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYs-0002Vn-Mf; Mon, 06 May 2019 06:57:18 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYk-0002Ch-4R for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:10 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 26aa5e9b-6fcc-11e9-843c-bc764e045a96; Mon, 06 May 2019 06:57:03 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A51F3AF38; Mon, 6 May 2019 06:56:57 +0000 (UTC) X-Inumbo-ID: 26aa5e9b-6fcc-11e9-843c-bc764e045a96 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:32 +0200 Message-Id: <20190506065644.7415-34-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 33/45] xen/sched: add code to sync scheduling of all vcpus of a sched item X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , Dario Faggioli , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" When switching sched items synchronize all vcpus of the new item to be scheduled at the same time. A variable sched_granularity is added which holds the number of vcpus per schedule item. As tasklets require to schedule the idle item it is required to set the tasklet_work_scheduled parameter of do_schedule() to true if any cpu covered by the current schedule() call has any pending tasklet work. For joining other vcpus of the schedule item we need to add a new softirq SCHED_SLAVE_SOFTIRQ in order to have a way to initiate a context switch without calling the generic schedule() function selecting the vcpu to switch to, as we already know which vcpu we want to run. This has the other advantage not to loose any other concurrent SCHEDULE_SOFTIRQ events. Signed-off-by: Juergen Gross --- RFC V2: move syncing after context_switch() to schedule.c --- xen/arch/arm/domain.c | 2 +- xen/arch/x86/domain.c | 3 +- xen/common/schedule.c | 339 +++++++++++++++++++++++++++++++++--------= ---- xen/common/softirq.c | 6 +- xen/include/xen/sched-if.h | 1 + xen/include/xen/sched.h | 16 ++- xen/include/xen/softirq.h | 1 + 7 files changed, 269 insertions(+), 99 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 6dc633ed50..f18fb35ac2 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -311,7 +311,7 @@ static void schedule_tail(struct vcpu *prev) =20 local_irq_enable(); =20 - context_saved(prev); + sched_context_switched(prev, current); =20 if ( prev !=3D current ) update_runstate_area(current); diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 9eaa978ce5..1525ccd8e5 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -1714,7 +1714,6 @@ static void __context_switch(void) per_cpu(curr_vcpu, cpu) =3D n; } =20 - void context_switch(struct vcpu *prev, struct vcpu *next) { unsigned int cpu =3D smp_processor_id(); @@ -1792,7 +1791,7 @@ void context_switch(struct vcpu *prev, struct vcpu *n= ext) } } =20 - context_saved(prev); + sched_context_switched(prev, next); =20 if ( prev !=3D next ) { diff --git a/xen/common/schedule.c b/xen/common/schedule.c index b5fb48c553..9d65586cae 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -54,6 +54,10 @@ boolean_param("sched_smt_power_savings", sched_smt_power= _savings); * */ int sched_ratelimit_us =3D SCHED_DEFAULT_RATELIMIT_US; integer_param("sched_ratelimit_us", sched_ratelimit_us); + +/* Number of vcpus per struct sched_item. */ +static unsigned int sched_granularity =3D 1; + /* Various timer handlers. */ static void s_timer_fn(void *unused); static void vcpu_periodic_timer_fn(void *data); @@ -1564,134 +1568,291 @@ static void vcpu_periodic_timer_work(struct vcpu = *v) set_timer(&v->periodic_timer, periodic_next_event); } =20 -/* - * The main function - * - deschedule the current domain (scheduler independent). - * - pick a new domain (scheduler dependent). - */ -static void schedule(void) +static void sched_switch_items(struct sched_resource *sd, + struct sched_item *next, struct sched_item = *prev, + s_time_t now) { - struct sched_item *prev =3D current->sched_item, *next =3D NULL; - s_time_t now; - struct scheduler *sched; - unsigned long *tasklet_work =3D &this_cpu(tasklet_work_to_do); - bool tasklet_work_scheduled =3D false; - struct sched_resource *sd; - spinlock_t *lock; - int cpu =3D smp_processor_id(); + sd->curr =3D next; =20 - ASSERT_NOT_IN_ATOMIC(); + TRACE_3D(TRC_SCHED_SWITCH_INFPREV, prev->domain->domain_id, prev->item= _id, + now - prev->state_entry_time); + TRACE_4D(TRC_SCHED_SWITCH_INFNEXT, next->domain->domain_id, next->item= _id, + (next->vcpu->runstate.state =3D=3D RUNSTATE_runnable) ? + (now - next->state_entry_time) : 0, prev->next_time); =20 - SCHED_STAT_CRANK(sched_run); + ASSERT(prev->vcpu->runstate.state =3D=3D RUNSTATE_running); =20 - sd =3D this_cpu(sched_res); + TRACE_4D(TRC_SCHED_SWITCH, prev->domain->domain_id, prev->item_id, + next->domain->domain_id, next->item_id); =20 - /* Update tasklet scheduling status. */ - switch ( *tasklet_work ) + sched_item_runstate_change(prev, false, now); + prev->last_run_time =3D now; + + ASSERT(next->vcpu->runstate.state !=3D RUNSTATE_running); + sched_item_runstate_change(next, true, now); + + /* + * NB. Don't add any trace records from here until the actual context + * switch, else lost_records resume will not work properly. + */ + + ASSERT(!next->is_running); + next->vcpu->is_running =3D 1; + next->is_running =3D 1; +} + +static bool sched_tasklet_check(void) +{ + unsigned long *tasklet_work; + bool tasklet_work_scheduled =3D false; + const cpumask_t *mask =3D this_cpu(sched_res)->cpus; + int cpu; + + for_each_cpu ( cpu, mask ) { - case TASKLET_enqueued: - set_bit(_TASKLET_scheduled, tasklet_work); - /* fallthrough */ - case TASKLET_enqueued|TASKLET_scheduled: - tasklet_work_scheduled =3D true; - break; - case TASKLET_scheduled: - clear_bit(_TASKLET_scheduled, tasklet_work); - case 0: - /*tasklet_work_scheduled =3D false;*/ - break; - default: - BUG(); - } + tasklet_work =3D &per_cpu(tasklet_work_to_do, cpu); =20 - lock =3D pcpu_schedule_lock_irq(cpu); + switch ( *tasklet_work ) + { + case TASKLET_enqueued: + set_bit(_TASKLET_scheduled, tasklet_work); + /* fallthrough */ + case TASKLET_enqueued|TASKLET_scheduled: + tasklet_work_scheduled =3D true; + break; + case TASKLET_scheduled: + clear_bit(_TASKLET_scheduled, tasklet_work); + case 0: + /*tasklet_work_scheduled =3D false;*/ + break; + default: + BUG(); + } + } =20 - now =3D NOW(); + return tasklet_work_scheduled; +} =20 - stop_timer(&sd->s_timer); +static struct sched_item *do_schedule(struct sched_item *prev, s_time_t no= w) +{ + struct scheduler *sched =3D this_cpu(scheduler); + struct sched_resource *sd =3D this_cpu(sched_res); + struct sched_item *next; =20 /* get policy-specific decision on scheduling... */ - sched =3D this_cpu(scheduler); - sched->do_schedule(sched, prev, now, tasklet_work_scheduled); + sched->do_schedule(sched, prev, now, sched_tasklet_check()); =20 next =3D prev->next_task; =20 - sd->curr =3D next; - if ( prev->next_time >=3D 0 ) /* -ve means no limit */ set_timer(&sd->s_timer, now + prev->next_time); =20 - if ( unlikely(prev =3D=3D next) ) + if ( likely(prev !=3D next) ) + sched_switch_items(sd, next, prev, now); + + return next; +} + +static void context_saved(struct vcpu *prev) +{ + struct sched_item *item =3D prev->sched_item; + + item->is_running =3D 0; + item->state_entry_time =3D NOW(); + + /* Check for migration request /after/ clearing running flag. */ + smp_mb(); + + sched_context_saved(vcpu_scheduler(prev), item); + + sched_item_migrate_finish(item); +} + +/* + * Rendezvous on end of context switch. + * As no lock is protecting this rendezvous function we need to use atomic + * access functions on the counter. + * The counter will be 0 in case no rendezvous is needed. For the rendezvo= us + * case it is initialised to the number of cpus to rendezvous plus 1. Each + * member entering decrements the counter. The last one will decrement it = to + * 1 and perform the final needed action in that case (call of context_sav= ed() + * if vcpu was switched), and then set the counter to zero. The other memb= ers + * will wait until the counter becomes zero until they proceed. + */ +void sched_context_switched(struct vcpu *vprev, struct vcpu *vnext) +{ + struct sched_item *next =3D vnext->sched_item; + + /* Clear running flag /after/ writing context to memory. */ + smp_wmb(); + + vprev->is_running =3D 0; + + if ( atomic_read(&next->rendezvous_out_cnt) ) + { + int cnt =3D atomic_dec_return(&next->rendezvous_out_cnt); + + /* Call context_saved() before releasing other waiters. */ + if ( cnt =3D=3D 1 ) + { + if ( vprev !=3D vnext ) + context_saved(vprev); + atomic_set(&next->rendezvous_out_cnt, 0); + } + else + while ( atomic_read(&next->rendezvous_out_cnt) ) + cpu_relax(); + } + else if ( vprev !=3D vnext ) + context_saved(vprev); +} + +static void sched_context_switch(struct vcpu *vprev, struct vcpu *vnext, + s_time_t now) +{ + if ( unlikely(vprev =3D=3D vnext) ) { - pcpu_schedule_unlock_irq(lock, cpu); TRACE_4D(TRC_SCHED_SWITCH_INFCONT, - next->domain->domain_id, next->item_id, - now - prev->state_entry_time, - prev->next_time); - trace_continue_running(next->vcpu); - return continue_running(prev->vcpu); + vnext->domain->domain_id, vnext->sched_item->item_id, + now - vprev->runstate.state_entry_time, + vprev->sched_item->next_time); + sched_context_switched(vprev, vnext); + trace_continue_running(vnext); + return continue_running(vprev); } =20 - TRACE_3D(TRC_SCHED_SWITCH_INFPREV, - prev->domain->domain_id, prev->item_id, - now - prev->state_entry_time); - TRACE_4D(TRC_SCHED_SWITCH_INFNEXT, - next->domain->domain_id, next->item_id, - (next->vcpu->runstate.state =3D=3D RUNSTATE_runnable) ? - (now - next->state_entry_time) : 0, - prev->next_time); + SCHED_STAT_CRANK(sched_ctx); =20 - ASSERT(prev->vcpu->runstate.state =3D=3D RUNSTATE_running); + stop_timer(&vprev->periodic_timer); =20 - TRACE_4D(TRC_SCHED_SWITCH, - prev->domain->domain_id, prev->item_id, - next->domain->domain_id, next->item_id); + if ( vnext->sched_item->migrated ) + vcpu_move_irqs(vnext); =20 - sched_item_runstate_change(prev, false, now); - prev->last_run_time =3D now; + vcpu_periodic_timer_work(vnext); =20 - ASSERT(next->vcpu->runstate.state !=3D RUNSTATE_running); - sched_item_runstate_change(next, true, now); + context_switch(vprev, vnext); +} =20 - /* - * NB. Don't add any trace records from here until the actual context - * switch, else lost_records resume will not work properly. - */ +/* + * Rendezvous before taking a scheduling decision. + * Called with schedule lock held, so all accesses to the rendezvous count= er + * can be normal ones (no atomic accesses needed). + * The counter is initialized to the number of cpus to rendezvous initiall= y. + * Each cpu entering will decrement the counter. In case the counter becom= es + * zero do_schedule() is called and the rendezvous counter for leaving + * context_switch() is set. All other members will wait until the counter = is + * becoming zero, dropping the schedule lock in between. + */ +static struct sched_item *sched_wait_rendezvous_in(struct sched_item *prev, + spinlock_t *lock, int c= pu, + s_time_t now) +{ + struct sched_item *next; =20 - ASSERT(!next->is_running); - next->vcpu->is_running =3D 1; - next->is_running =3D 1; - next->state_entry_time =3D now; + if ( !--prev->rendezvous_in_cnt ) + { + next =3D do_schedule(prev, now); + atomic_set(&next->rendezvous_out_cnt, sched_granularity + 1); + return next; + } =20 - pcpu_schedule_unlock_irq(lock, cpu); + while ( prev->rendezvous_in_cnt ) + { + pcpu_schedule_unlock_irq(lock, cpu); + cpu_relax(); + pcpu_schedule_lock_irq(cpu); + } =20 - SCHED_STAT_CRANK(sched_ctx); + return prev->next_task; +} + +static void sched_slave(void) +{ + struct vcpu *vprev =3D current; + struct sched_item *prev =3D vprev->sched_item, *next; + s_time_t now; + spinlock_t *lock; + int cpu =3D smp_processor_id(); + + ASSERT_NOT_IN_ATOMIC(); + + lock =3D pcpu_schedule_lock_irq(cpu); + + now =3D NOW(); + + if ( !prev->rendezvous_in_cnt ) + { + pcpu_schedule_unlock_irq(lock, cpu); + return; + } =20 - stop_timer(&prev->vcpu->periodic_timer); + stop_timer(&this_cpu(sched_res)->s_timer); =20 - if ( next->migrated ) - vcpu_move_irqs(next->vcpu); + next =3D sched_wait_rendezvous_in(prev, lock, cpu, now); =20 - vcpu_periodic_timer_work(next->vcpu); + pcpu_schedule_unlock_irq(lock, cpu); =20 - context_switch(prev->vcpu, next->vcpu); + sched_context_switch(vprev, next->vcpu, now); } =20 -void context_saved(struct vcpu *prev) +/* + * The main function + * - deschedule the current domain (scheduler independent). + * - pick a new domain (scheduler dependent). + */ +static void schedule(void) { - /* Clear running flag /after/ writing context to memory. */ - smp_wmb(); + struct vcpu *vnext, *vprev =3D current; + struct sched_item *prev =3D vprev->sched_item, *next =3D NULL; + s_time_t now; + struct sched_resource *sd; + spinlock_t *lock; + int cpu =3D smp_processor_id(); =20 - prev->is_running =3D 0; - prev->sched_item->is_running =3D 0; - prev->sched_item->state_entry_time =3D NOW(); + ASSERT_NOT_IN_ATOMIC(); =20 - /* Check for migration request /after/ clearing running flag. */ - smp_mb(); + SCHED_STAT_CRANK(sched_run); =20 - sched_context_saved(vcpu_scheduler(prev), prev->sched_item); + sd =3D this_cpu(sched_res); + + lock =3D pcpu_schedule_lock_irq(cpu); + + if ( prev->rendezvous_in_cnt ) + { + /* + * We have a race: sched_slave() should be called, so raise a soft= irq + * in order to re-enter schedule() later and call sched_slave() no= w. + */ + pcpu_schedule_unlock_irq(lock, cpu); + + raise_softirq(SCHEDULE_SOFTIRQ); + return sched_slave(); + } + + now =3D NOW(); + + stop_timer(&sd->s_timer); + + if ( sched_granularity > 1 ) + { + cpumask_t mask; + + prev->rendezvous_in_cnt =3D sched_granularity; + cpumask_andnot(&mask, sd->cpus, cpumask_of(cpu)); + cpumask_raise_softirq(&mask, SCHED_SLAVE_SOFTIRQ); + next =3D sched_wait_rendezvous_in(prev, lock, cpu, now); + } + else + { + prev->rendezvous_in_cnt =3D 0; + next =3D do_schedule(prev, now); + atomic_set(&next->rendezvous_out_cnt, 0); + } + + pcpu_schedule_unlock_irq(lock, cpu); =20 - sched_item_migrate_finish(prev->sched_item); + vnext =3D next->vcpu; + sched_context_switch(vprev, vnext, now); } =20 /* The scheduler timer: force a run through the scheduler */ @@ -1733,6 +1894,7 @@ static int cpu_schedule_up(unsigned int cpu) if ( sd =3D=3D NULL ) return -ENOMEM; sd->processor =3D cpu; + sd->cpus =3D cpumask_of(cpu); per_cpu(sched_res, cpu) =3D sd; =20 per_cpu(scheduler, cpu) =3D &ops; @@ -1892,6 +2054,7 @@ void __init scheduler_init(void) int i; =20 open_softirq(SCHEDULE_SOFTIRQ, schedule); + open_softirq(SCHED_SLAVE_SOFTIRQ, sched_slave); =20 for ( i =3D 0; i < NUM_SCHEDULERS; i++) { diff --git a/xen/common/softirq.c b/xen/common/softirq.c index 83c3c09bd5..2d66193203 100644 --- a/xen/common/softirq.c +++ b/xen/common/softirq.c @@ -33,8 +33,8 @@ static void __do_softirq(unsigned long ignore_mask) for ( ; ; ) { /* - * Initialise @cpu on every iteration: SCHEDULE_SOFTIRQ may move - * us to another processor. + * Initialise @cpu on every iteration: SCHEDULE_SOFTIRQ or + * SCHED_SLAVE_SOFTIRQ may move us to another processor. */ cpu =3D smp_processor_id(); =20 @@ -55,7 +55,7 @@ void process_pending_softirqs(void) { ASSERT(!in_irq() && local_irq_is_enabled()); /* Do not enter scheduler as it can preempt the calling context. */ - __do_softirq(1ul<curr) diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 8bde790d27..5224f0aa70 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -295,6 +295,12 @@ struct sched_item { /* Next item to run. */ struct sched_item *next_task; s_time_t next_time; + + /* Number of vcpus not yet joined for context switch. */ + unsigned int rendezvous_in_cnt; + + /* Number of vcpus not yet finished with context switch. */ + atomic_t rendezvous_out_cnt; }; =20 #define for_each_sched_item(d, e) \ @@ -698,10 +704,10 @@ void sync_local_execstate(void); =20 /* * Called by the scheduler to switch to another VCPU. This function must - * call context_saved(@prev) when the local CPU is no longer running in - * @prev's context, and that context is saved to memory. Alternatively, if - * implementing lazy context switching, it suffices to ensure that invoking - * sync_vcpu_execstate() will switch and commit @prev's state. + * call sched_context_switched(@prev, @next) when the local CPU is no long= er + * running in @prev's context, and that context is saved to memory. + * Alternatively, if implementing lazy context switching, it suffices to e= nsure + * that invoking sync_vcpu_execstate() will switch and commit @prev's stat= e. */ void context_switch( struct vcpu *prev, @@ -713,7 +719,7 @@ void context_switch( * saved to memory. Alternatively, if implementing lazy context switching, * ensure that invoking sync_vcpu_execstate() will switch and commit @prev. */ -void context_saved(struct vcpu *prev); +void sched_context_switched(struct vcpu *prev, struct vcpu *vnext); =20 /* Called by the scheduler to continue running the current VCPU. */ void continue_running( diff --git a/xen/include/xen/softirq.h b/xen/include/xen/softirq.h index c327c9b6cd..d7273b389b 100644 --- a/xen/include/xen/softirq.h +++ b/xen/include/xen/softirq.h @@ -4,6 +4,7 @@ /* Low-latency softirqs come first in the following list. */ enum { TIMER_SOFTIRQ =3D 0, + SCHED_SLAVE_SOFTIRQ, SCHEDULE_SOFTIRQ, NEW_TLBFLUSH_CLOCK_PERIOD_SOFTIRQ, RCU_SOFTIRQ, --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125919; cv=none; d=zoho.com; s=zohoarc; b=mvD+BXO/ZwjtCfg4gsocLnCS+QQcEl1dFdGl+j/Ads/WeBEtuvX8+xLyVMSc6ZBm1h6f1prf/P4+IjWTYn1WI1+NH6PPbybxG2LZIm37oDUREPX2Wc7PmnVPhGa+s6qXDbU2Xibv/0r7vmJeqVzizGD86rwo6jNNdOl1sEEF9mM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125919; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=BIlhGTsRHigyAXAfgrXNFkbis61oT26q0MT8RRzDbIU=; b=JkCYll+U/ZaoDQ6A6Bji4YSpVaOZNY+agzIZxWP39hiore3LpK3LxpO4m6MN1xZUXUtajvwrLkupI9Cu/9f6XAQp2tAB5OGpLqETukqV/nIqHsW23sLk19MTvXDw7mLcj2kOA1tFB/wcimIVTiph5zoXGWBd6lHCvF7oCbrlUT4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125919942473.35111252017305; Sun, 5 May 2019 23:58:39 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYy-0002jH-1e; Mon, 06 May 2019 06:57:24 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYl-0002FF-Bb for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:11 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 26a2e41c-6fcc-11e9-8c8c-ef3362a04400; Mon, 06 May 2019 06:57:02 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 108B7AF3A; Mon, 6 May 2019 06:56:58 +0000 (UTC) X-Inumbo-ID: 26a2e41c-6fcc-11e9-8c8c-ef3362a04400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:33 +0200 Message-Id: <20190506065644.7415-35-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 34/45] xen/sched: introduce item_runnable_state() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Robert VanVossen , Tim Deegan , Julien Grall , Josh Whitehead , Meng Xu , Jan Beulich , Dario Faggioli MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Today the vcpu runstate of a new scheduled vcpu is always set to "running" even if at that time vcpu_runnable() is already returning false due to a race (e.g. with pausing the vcpu). With core scheduling this can no longer work as not all vcpus of a schedule item have to be "running" when being scheduled. So the vcpu's new runstate has to be selected at the same time as the runnability of the related schedule item is probed. For this purpose introduce a new helper item_runnable_state() which will save the new runstate of all tested vcpus in a new field of the vcpu struct. Signed-off-by: Juergen Gross --- RFC V2: new patch --- xen/common/domain.c | 1 + xen/common/sched_arinc653.c | 2 +- xen/common/sched_credit.c | 49 ++++++++++++++++++++++++-----------------= ---- xen/common/sched_credit2.c | 7 ++++--- xen/common/sched_null.c | 3 ++- xen/common/sched_rt.c | 8 +++++++- xen/common/schedule.c | 2 +- xen/include/xen/sched-if.h | 14 +++++++++++++ xen/include/xen/sched.h | 1 + 9 files changed, 57 insertions(+), 30 deletions(-) diff --git a/xen/common/domain.c b/xen/common/domain.c index 63ef64e4d4..97c0fdd797 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -151,6 +151,7 @@ struct vcpu *vcpu_create(struct domain *d, unsigned int= vcpu_id) if ( is_idle_domain(d) ) { v->runstate.state =3D RUNSTATE_running; + v->new_state =3D RUNSTATE_running; } else { diff --git a/xen/common/sched_arinc653.c b/xen/common/sched_arinc653.c index e98e98116b..72d7063f6a 100644 --- a/xen/common/sched_arinc653.c +++ b/xen/common/sched_arinc653.c @@ -557,7 +557,7 @@ a653sched_do_schedule( if ( !((new_task !=3D NULL) && (AITEM(new_task) !=3D NULL) && AITEM(new_task)->awake - && item_runnable(new_task)) ) + && item_runnable_state(new_task)) ) new_task =3D IDLETASK(cpu); BUG_ON(new_task =3D=3D NULL); =20 diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index 064f88ab23..804c675e25 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -1907,7 +1907,7 @@ static void csched_schedule( if ( !test_bit(CSCHED_FLAG_ITEM_YIELD, &scurr->flags) && !tasklet_work_scheduled && prv->ratelimit - && item_runnable(item) + && item_runnable_state(item) && !is_idle_item(item) && runtime < prv->ratelimit ) { @@ -1952,33 +1952,36 @@ static void csched_schedule( dec_nr_runnable(sched_cpu); } =20 - snext =3D __runq_elem(runq->next); - - /* Tasklet work (which runs in idle ITEM context) overrides all else. = */ - if ( tasklet_work_scheduled ) - { - TRACE_0D(TRC_CSCHED_SCHED_TASKLET); - snext =3D CSCHED_ITEM(sched_idle_item(sched_cpu)); - snext->pri =3D CSCHED_PRI_TS_BOOST; - } - /* * Clear YIELD flag before scheduling out */ clear_bit(CSCHED_FLAG_ITEM_YIELD, &scurr->flags); =20 - /* - * SMP Load balance: - * - * If the next highest priority local runnable ITEM has already eaten - * through its credits, look on other PCPUs to see if we have more - * urgent work... If not, csched_load_balance() will return snext, but - * already removed from the runq. - */ - if ( snext->pri > CSCHED_PRI_TS_OVER ) - __runq_remove(snext); - else - snext =3D csched_load_balance(prv, sched_cpu, snext, &migrated); + do { + snext =3D __runq_elem(runq->next); + + /* Tasklet work (which runs in idle ITEM context) overrides all el= se. */ + if ( tasklet_work_scheduled ) + { + TRACE_0D(TRC_CSCHED_SCHED_TASKLET); + snext =3D CSCHED_ITEM(sched_idle_item(sched_cpu)); + snext->pri =3D CSCHED_PRI_TS_BOOST; + } + + /* + * SMP Load balance: + * + * If the next highest priority local runnable ITEM has already ea= ten + * through its credits, look on other PCPUs to see if we have more + * urgent work... If not, csched_load_balance() will return snext,= but + * already removed from the runq. + */ + if ( snext->pri > CSCHED_PRI_TS_OVER ) + __runq_remove(snext); + else + snext =3D csched_load_balance(prv, sched_cpu, snext, &migrated= ); + + } while ( !item_runnable_state(snext->item) ); =20 /* * Update idlers mask if necessary. When we're idling, other CPUs diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index f1074be25d..f306821c6c 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -3288,7 +3288,7 @@ runq_candidate(struct csched2_runqueue_data *rqd, * In fact, it may be the case that scurr is about to spin, and there's * no point forcing it to do so until rate limiting expires. */ - if ( !yield && prv->ratelimit_us && item_runnable(scurr->item) && + if ( !yield && prv->ratelimit_us && item_runnable_state(scurr->item) && (now - scurr->item->state_entry_time) < MICROSECS(prv->ratelimit_= us) ) { if ( unlikely(tb_init_done) ) @@ -3342,7 +3342,7 @@ runq_candidate(struct csched2_runqueue_data *rqd, * * Of course, we also default to idle also if scurr is not runnable. */ - if ( item_runnable(scurr->item) && !soft_aff_preempt ) + if ( item_runnable_state(scurr->item) && !soft_aff_preempt ) snext =3D scurr; else snext =3D csched2_item(sched_idle_item(cpu)); @@ -3402,7 +3402,8 @@ runq_candidate(struct csched2_runqueue_data *rqd, * some budget, then choose it. */ if ( (yield || svc->credit > snext->credit) && - (!has_cap(svc) || item_grab_budget(svc)) ) + (!has_cap(svc) || item_grab_budget(svc)) && + item_runnable_state(svc->item) ) snext =3D svc; =20 /* In any case, if we got this far, break. */ diff --git a/xen/common/sched_null.c b/xen/common/sched_null.c index 1af396dcdb..1f59cbae75 100644 --- a/xen/common/sched_null.c +++ b/xen/common/sched_null.c @@ -784,7 +784,8 @@ static void null_schedule(const struct scheduler *ops, = struct sched_item *prev, spin_unlock(&prv->waitq_lock); } =20 - if ( unlikely(prev->next_task =3D=3D NULL || !item_runnable(prev->next= _task)) ) + if ( unlikely(prev->next_task =3D=3D NULL || + !item_runnable_state(prev->next_task)) ) prev->next_task =3D sched_idle_item(sched_cpu); =20 NULL_ITEM_CHECK(prev->next_task); diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index c5e8b559f3..3900e2159d 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -1101,12 +1101,18 @@ rt_schedule(const struct scheduler *ops, struct sch= ed_item *curritem, else { snext =3D runq_pick(ops, cpumask_of(sched_cpu)); + if ( snext =3D=3D NULL ) snext =3D rt_item(sched_idle_item(sched_cpu)); + else if ( !item_runnable_state(snext->item) ) + { + q_remove(snext); + snext =3D rt_item(sched_idle_item(sched_cpu)); + } =20 /* if scurr has higher priority and budget, still pick scurr */ if ( !is_idle_item(curritem) && - item_runnable(curritem) && + item_runnable_state(curritem) && scurr->cur_budget > 0 && ( is_idle_item(snext->item) || compare_item_priority(scurr, snext) > 0 ) ) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 9d65586cae..6ba6e70338 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -206,7 +206,7 @@ static inline void sched_item_runstate_change(struct sc= hed_item *item, struct vcpu *v =3D item->vcpu; =20 if ( running ) - vcpu_runstate_change(v, RUNSTATE_running, new_entry_time); + vcpu_runstate_change(v, v->new_state, new_entry_time); else vcpu_runstate_change(v, ((v->pause_flags & VPF_blocked) ? RUNSTATE_blocked : diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index 084b78d2b7..755b0f8f74 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -60,6 +60,20 @@ static inline bool item_runnable(const struct sched_item= *item) return vcpu_runnable(item->vcpu); } =20 +static inline bool item_runnable_state(const struct sched_item *item) +{ + struct vcpu *v; + bool runnable; + + v =3D item->vcpu; + runnable =3D vcpu_runnable(v); + + v->new_state =3D runnable ? RUNSTATE_running + : (v->pause_flags & VPF_blocked) + ? RUNSTATE_blocked : RUNSTATE_offline; + return runnable; +} + static inline void sched_set_res(struct sched_item *item, struct sched_resource *res) { diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 5224f0aa70..40d3def9f4 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -174,6 +174,7 @@ struct vcpu XEN_GUEST_HANDLE(vcpu_runstate_info_compat_t) compat; } runstate_guest; /* guest address */ #endif + int new_state; =20 /* Has the FPU been initialised? */ bool fpu_initialised; --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125920; cv=none; d=zoho.com; s=zohoarc; b=cSIwuYa4OEWeOcNvThF5/lrXThzhD6jeXQM/0oA8B3g3yakU2GHqgOo7TY0HfwrI9qvNSOiQ/t1C8oIEjvYoY6zl2o9BsCyUpGLNi7e1XHcAFG2PBQN+JvDB3Sb2WTl44QLHwFberfXEhY+0vXBEoaW2vt8zg6ZrATi9aQKeOKU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125920; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=csVN9hKJlc2tXMBImhvcZ+jnTkemKENvaZeMiQzqH/Q=; b=KmqgCTHRNFcysCJ05pK+hn2dMQDFqOFt495YhBJCDXnX4sO4/qgmgoJypLpdSYReJuBd3cbQJRR14GLnbQxqmRvPsukFR3Ip7alE8YKXBBKeBt5rbNqFw183NVUIpVqMS9ZQoK+ZMGohiYbHqIJZsXpWWBhrZa411KAIMXUjMl4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125920365418.7548606336288; Sun, 5 May 2019 23:58:40 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYv-0002eU-VA; Mon, 06 May 2019 06:57:21 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYl-0002Fa-L2 for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:11 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 26f3d5a4-6fcc-11e9-843c-bc764e045a96; Mon, 06 May 2019 06:57:03 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 5D908AC8C; Mon, 6 May 2019 06:56:58 +0000 (UTC) X-Inumbo-ID: 26f3d5a4-6fcc-11e9-843c-bc764e045a96 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:34 +0200 Message-Id: <20190506065644.7415-36-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 35/45] xen/sched: add support for multiple vcpus per sched item where missing X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Tim Deegan , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Dario Faggioli , Julien Grall , Jan Beulich MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" In several places there is support for multiple vcpus per sched item missing. Add that missing support (with the exception of initial allocation) and missing helpers for that. Signed-off-by: Juergen Gross --- RFC V2: fix vcpu_runstate_helper() --- xen/common/schedule.c | 26 ++++++++-------- xen/include/xen/sched-if.h | 74 ++++++++++++++++++++++++++++++++++++------= ---- 2 files changed, 73 insertions(+), 27 deletions(-) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 6ba6e70338..1134733314 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -180,8 +180,9 @@ static inline void vcpu_runstate_change( s_time_t delta; struct sched_item *item =3D v->sched_item; =20 - ASSERT(v->runstate.state !=3D new_state); ASSERT(spin_is_locked(per_cpu(sched_res, v->processor)->schedule_lock)= ); + if ( v->runstate.state =3D=3D new_state ) + return; =20 vcpu_urgent_count_update(v); =20 @@ -203,15 +204,16 @@ static inline void vcpu_runstate_change( static inline void sched_item_runstate_change(struct sched_item *item, bool running, s_time_t new_entry_time) { - struct vcpu *v =3D item->vcpu; + struct vcpu *v; =20 - if ( running ) - vcpu_runstate_change(v, v->new_state, new_entry_time); - else - vcpu_runstate_change(v, - ((v->pause_flags & VPF_blocked) ? RUNSTATE_blocked : - (vcpu_runnable(v) ? RUNSTATE_runnable : RUNSTATE_offline)), - new_entry_time); + for_each_sched_item_vcpu( item, v ) + if ( running ) + vcpu_runstate_change(v, v->new_state, new_entry_time); + else + vcpu_runstate_change(v, + ((v->pause_flags & VPF_blocked) ? RUNSTATE_blocked : + (vcpu_runnable(v) ? RUNSTATE_runnable : RUNSTATE_offline)= ), + new_entry_time); } =20 void vcpu_runstate_get(struct vcpu *v, struct vcpu_runstate_info *runstate) @@ -1580,7 +1582,7 @@ static void sched_switch_items(struct sched_resource = *sd, (next->vcpu->runstate.state =3D=3D RUNSTATE_runnable) ? (now - next->state_entry_time) : 0, prev->next_time); =20 - ASSERT(prev->vcpu->runstate.state =3D=3D RUNSTATE_running); + ASSERT(item_running(prev)); =20 TRACE_4D(TRC_SCHED_SWITCH, prev->domain->domain_id, prev->item_id, next->domain->domain_id, next->item_id); @@ -1588,7 +1590,7 @@ static void sched_switch_items(struct sched_resource = *sd, sched_item_runstate_change(prev, false, now); prev->last_run_time =3D now; =20 - ASSERT(next->vcpu->runstate.state !=3D RUNSTATE_running); + ASSERT(!item_running(next)); sched_item_runstate_change(next, true, now); =20 /* @@ -1703,7 +1705,7 @@ void sched_context_switched(struct vcpu *vprev, struc= t vcpu *vnext) while ( atomic_read(&next->rendezvous_out_cnt) ) cpu_relax(); } - else if ( vprev !=3D vnext ) + else if ( vprev !=3D vnext && sched_granularity =3D=3D 1 ) context_saved(vprev); } =20 diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index 755b0f8f74..88fbc06860 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -55,29 +55,55 @@ static inline bool is_idle_item(const struct sched_item= *item) return is_idle_vcpu(item->vcpu); } =20 +static inline unsigned int item_running(const struct sched_item *item) +{ + return item->runstate_cnt[RUNSTATE_running]; +} + static inline bool item_runnable(const struct sched_item *item) { - return vcpu_runnable(item->vcpu); + struct vcpu *v; + + for_each_sched_item_vcpu( item, v ) + if ( vcpu_runnable(v) ) + return true; + + return false; } =20 static inline bool item_runnable_state(const struct sched_item *item) { struct vcpu *v; - bool runnable; + bool runnable, ret =3D false; + + for_each_sched_item_vcpu( item, v ) + { + runnable =3D vcpu_runnable(v); + + v->new_state =3D runnable ? RUNSTATE_running + : (v->pause_flags & VPF_blocked) + ? RUNSTATE_blocked : RUNSTATE_offline; =20 - v =3D item->vcpu; - runnable =3D vcpu_runnable(v); + if ( runnable ) + ret =3D true; + } =20 - v->new_state =3D runnable ? RUNSTATE_running - : (v->pause_flags & VPF_blocked) - ? RUNSTATE_blocked : RUNSTATE_offline; - return runnable; + return ret; } =20 static inline void sched_set_res(struct sched_item *item, struct sched_resource *res) { - item->vcpu->processor =3D res->processor; + int cpu =3D cpumask_first(res->cpus); + struct vcpu *v; + + for_each_sched_item_vcpu( item, v ) + { + ASSERT(cpu < nr_cpu_ids); + v->processor =3D cpu; + cpu =3D cpumask_next(cpu, res->cpus); + } + item->res =3D res; } =20 @@ -89,25 +115,37 @@ static inline unsigned int sched_item_cpu(struct sched= _item *item) static inline void sched_set_pause_flags(struct sched_item *item, unsigned int bit) { - __set_bit(bit, &item->vcpu->pause_flags); + struct vcpu *v; + + for_each_sched_item_vcpu( item, v ) + __set_bit(bit, &v->pause_flags); } =20 static inline void sched_clear_pause_flags(struct sched_item *item, unsigned int bit) { - __clear_bit(bit, &item->vcpu->pause_flags); + struct vcpu *v; + + for_each_sched_item_vcpu( item, v ) + __clear_bit(bit, &v->pause_flags); } =20 static inline void sched_set_pause_flags_atomic(struct sched_item *item, unsigned int bit) { - set_bit(bit, &item->vcpu->pause_flags); + struct vcpu *v; + + for_each_sched_item_vcpu( item, v ) + set_bit(bit, &v->pause_flags); } =20 static inline void sched_clear_pause_flags_atomic(struct sched_item *item, unsigned int bit) { - clear_bit(bit, &item->vcpu->pause_flags); + struct vcpu *v; + + for_each_sched_item_vcpu( item, v ) + clear_bit(bit, &v->pause_flags); } =20 static inline struct sched_item *sched_idle_item(unsigned int cpu) @@ -468,12 +506,18 @@ static inline int sched_adjust_cpupool(const struct s= cheduler *s, =20 static inline void sched_item_pause_nosync(struct sched_item *item) { - vcpu_pause_nosync(item->vcpu); + struct vcpu *v; + + for_each_sched_item_vcpu( item, v ) + vcpu_pause_nosync(v); } =20 static inline void sched_item_unpause(struct sched_item *item) { - vcpu_unpause(item->vcpu); + struct vcpu *v; + + for_each_sched_item_vcpu( item, v ) + vcpu_unpause(v); } =20 #define REGISTER_SCHEDULER(x) static const struct scheduler *x##_entry \ --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125917; cv=none; d=zoho.com; s=zohoarc; b=Ome3E2JkV5UwingBS3BgbWv0UgrRDaCxksuX7fB0t4PRVExFGndv1v4yzoXr3uAARKSPxXI6es6mcrYEInRYJPi17pok4AH2Ss16sskWWGEU9m52LO7sYDWQkPCPBnynveDIPaeySxYXx+AE/KSjg4Z6UTvKcyI01nf2WbB8kSU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125917; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=7UBYupyfwfHPgZIfFj01l6K7oF+qdxyJcHYT2iRSpS0=; b=KYg0u5JrpSR4NyLzVm7jLIKG5yhuLFh7tqEuKjlPoxN9Nm5HvrsvRlZnN+/TY+3d/0+6jfwjP4st+khaTGAXbkC3vJg8G4CqoncX+1cAGCn4MTBVoSLgLG8XzpsQmm91xxkrujMg+AbelQq74e5Nmgqx8oZR/e8u4JcWcyz999k= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 155712591752699.71155201874194; Sun, 5 May 2019 23:58:37 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYv-0002c9-1C; Mon, 06 May 2019 06:57:21 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYl-0002FD-B7 for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:11 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 26ebd8d4-6fcc-11e9-9cee-1bf5b8f7eaa9; Mon, 06 May 2019 06:57:03 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 8B1B3AF3B; Mon, 6 May 2019 06:56:58 +0000 (UTC) X-Inumbo-ID: 26ebd8d4-6fcc-11e9-9cee-1bf5b8f7eaa9 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:35 +0200 Message-Id: <20190506065644.7415-37-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 36/45] x86: make loading of GDT at context switch more modular X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Andrew Cooper , Wei Liu , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" In preparation for core scheduling carve out the GDT related functionality (writing GDT related PTEs, loading default of full GDT) into sub-functions. Signed-off-by: Juergen Gross Acked-by: Jan Beulich --- RFC V2: split off non-refactoring part --- xen/arch/x86/domain.c | 57 +++++++++++++++++++++++++++++++----------------= ---- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 1525ccd8e5..72a365ff6a 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -1619,6 +1619,37 @@ static inline bool need_full_gdt(const struct domain= *d) return is_pv_domain(d) && !is_idle_domain(d); } =20 +static inline void write_full_gdt_ptes(seg_desc_t *gdt, struct vcpu *v) +{ + unsigned long mfn =3D virt_to_mfn(gdt); + l1_pgentry_t *pl1e =3D pv_gdt_ptes(v); + unsigned int i; + + for ( i =3D 0; i < NR_RESERVED_GDT_PAGES; i++ ) + l1e_write(pl1e + FIRST_RESERVED_GDT_PAGE + i, + l1e_from_pfn(mfn + i, __PAGE_HYPERVISOR_RW)); +} + +static inline void load_full_gdt(struct vcpu *v, unsigned int cpu) +{ + struct desc_ptr gdt_desc; + + gdt_desc.limit =3D LAST_RESERVED_GDT_BYTE; + gdt_desc.base =3D GDT_VIRT_START(v); + + lgdt(&gdt_desc); +} + +static inline void load_default_gdt(seg_desc_t *gdt, unsigned int cpu) +{ + struct desc_ptr gdt_desc; + + gdt_desc.limit =3D LAST_RESERVED_GDT_BYTE; + gdt_desc.base =3D (unsigned long)(gdt - FIRST_RESERVED_GDT_ENTRY); + + lgdt(&gdt_desc); +} + static void __context_switch(void) { struct cpu_user_regs *stack_regs =3D guest_cpu_user_regs(); @@ -1627,7 +1658,6 @@ static void __context_switch(void) struct vcpu *n =3D current; struct domain *pd =3D p->domain, *nd =3D n->domain; seg_desc_t *gdt; - struct desc_ptr gdt_desc; =20 ASSERT(p !=3D n); ASSERT(!vcpu_cpu_dirty(n)); @@ -1669,25 +1699,13 @@ static void __context_switch(void) =20 gdt =3D !is_pv_32bit_domain(nd) ? per_cpu(gdt_table, cpu) : per_cpu(compat_gdt_table, cpu); - if ( need_full_gdt(nd) ) - { - unsigned long mfn =3D virt_to_mfn(gdt); - l1_pgentry_t *pl1e =3D pv_gdt_ptes(n); - unsigned int i; =20 - for ( i =3D 0; i < NR_RESERVED_GDT_PAGES; i++ ) - l1e_write(pl1e + FIRST_RESERVED_GDT_PAGE + i, - l1e_from_pfn(mfn + i, __PAGE_HYPERVISOR_RW)); - } + if ( need_full_gdt(nd) ) + write_full_gdt_ptes(gdt, n); =20 if ( need_full_gdt(pd) && ((p->vcpu_id !=3D n->vcpu_id) || !need_full_gdt(nd)) ) - { - gdt_desc.limit =3D LAST_RESERVED_GDT_BYTE; - gdt_desc.base =3D (unsigned long)(gdt - FIRST_RESERVED_GDT_ENTRY); - - lgdt(&gdt_desc); - } + load_default_gdt(gdt, cpu); =20 write_ptbase(n); =20 @@ -1700,12 +1718,7 @@ static void __context_switch(void) =20 if ( need_full_gdt(nd) && ((p->vcpu_id !=3D n->vcpu_id) || !need_full_gdt(pd)) ) - { - gdt_desc.limit =3D LAST_RESERVED_GDT_BYTE; - gdt_desc.base =3D GDT_VIRT_START(n); - - lgdt(&gdt_desc); - } + load_full_gdt(n, cpu); =20 if ( pd !=3D nd ) cpumask_clear_cpu(cpu, pd->dirty_cpumask); --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125912; cv=none; d=zoho.com; s=zohoarc; b=GhCBho+GXlKvDIZojuC9PBTxr+1CSmNkINi5YQNuWKIzM9YBc1gNz7jfs5GtgvuEysaKMiszruim/Vczjszy2iOCqTNjKiLQSRqRMK7Ncs3al7dyacOLVrNxt3ubo++7M9089MJdXy41aXFFHys8MMgCfSq5z5Sb0I4D8+u7qz0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125912; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=gtoU8zI9xqHWpXpJPH7PE46rNx2p18fykc5WnTvARsM=; b=KV8DatP1riIcyuX7W6Fb/EFiAd0C7bVSYmu77wWWIgTAhqqTO4fMf/ZyL1Voo7PFMkBjg2rOg3FaHqMjw2llDk8I+8vaKnKDih+4tehjHGXiVuhXflydWKA3sMeuDv5UfV9O56+a0u+HSIu2fIUIlcGTypV+8SkRjtUVt6ibMaE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125912978505.7570127786255; Sun, 5 May 2019 23:58:32 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYt-0002XM-EA; Mon, 06 May 2019 06:57:19 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYk-0002Cl-5u for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:10 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 271b43fa-6fcc-11e9-843c-bc764e045a96; Mon, 06 May 2019 06:57:03 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id B9250AF3E; Mon, 6 May 2019 06:56:58 +0000 (UTC) X-Inumbo-ID: 271b43fa-6fcc-11e9-843c-bc764e045a96 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:36 +0200 Message-Id: <20190506065644.7415-38-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 37/45] x86: optimize loading of GDT at context switch X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Andrew Cooper , Wei Liu , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Instead of dynamically decide whether the previous vcpu was using full or default GDT just add a percpu variable for that purpose. This at once removes the need for testing vcpu_ids to differ twice. Cache the need_full_gdt(nd) value in a local variable. Signed-off-by: Juergen Gross Reviewed-by: Jan Beulich --- RFC V2: new patch (split from previous one) --- xen/arch/x86/domain.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 72a365ff6a..d04e704116 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -72,6 +72,8 @@ =20 DEFINE_PER_CPU(struct vcpu *, curr_vcpu); =20 +static DEFINE_PER_CPU(bool, full_gdt_loaded); + static void default_idle(void); void (*pm_idle) (void) __read_mostly =3D default_idle; void (*dead_idle) (void) __read_mostly =3D default_dead_idle; @@ -1638,6 +1640,8 @@ static inline void load_full_gdt(struct vcpu *v, unsi= gned int cpu) gdt_desc.base =3D GDT_VIRT_START(v); =20 lgdt(&gdt_desc); + + per_cpu(full_gdt_loaded, cpu) =3D true; } =20 static inline void load_default_gdt(seg_desc_t *gdt, unsigned int cpu) @@ -1648,6 +1652,8 @@ static inline void load_default_gdt(seg_desc_t *gdt, = unsigned int cpu) gdt_desc.base =3D (unsigned long)(gdt - FIRST_RESERVED_GDT_ENTRY); =20 lgdt(&gdt_desc); + + per_cpu(full_gdt_loaded, cpu) =3D false; } =20 static void __context_switch(void) @@ -1658,6 +1664,7 @@ static void __context_switch(void) struct vcpu *n =3D current; struct domain *pd =3D p->domain, *nd =3D n->domain; seg_desc_t *gdt; + bool need_full_gdt_n; =20 ASSERT(p !=3D n); ASSERT(!vcpu_cpu_dirty(n)); @@ -1700,11 +1707,13 @@ static void __context_switch(void) gdt =3D !is_pv_32bit_domain(nd) ? per_cpu(gdt_table, cpu) : per_cpu(compat_gdt_table, cpu); =20 - if ( need_full_gdt(nd) ) + need_full_gdt_n =3D need_full_gdt(nd); + + if ( need_full_gdt_n ) write_full_gdt_ptes(gdt, n); =20 - if ( need_full_gdt(pd) && - ((p->vcpu_id !=3D n->vcpu_id) || !need_full_gdt(nd)) ) + if ( per_cpu(full_gdt_loaded, cpu) && + ((p->vcpu_id !=3D n->vcpu_id) || !need_full_gdt_n) ) load_default_gdt(gdt, cpu); =20 write_ptbase(n); @@ -1716,8 +1725,7 @@ static void __context_switch(void) svm_load_segs(0, 0, 0, 0, 0, 0, 0); #endif =20 - if ( need_full_gdt(nd) && - ((p->vcpu_id !=3D n->vcpu_id) || !need_full_gdt(pd)) ) + if ( need_full_gdt_n && !per_cpu(full_gdt_loaded, cpu) ) load_full_gdt(n, cpu); =20 if ( pd !=3D nd ) --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125920; cv=none; d=zoho.com; s=zohoarc; b=MQqqD/TkHTMMLE68AqUindREKhex71CvnlPQcN17N80BjlFmQGI91dDbTv4BE1cz3fQneMPH6wyKEIcprXEf64oCFlxcbC7HEHx59uQuvN6yc2bVZqFWPZ+yoF41uQW16T0x/wD4Jxl6RvBBU8ajY9VBaz2y2DU4iQRAYxSIggs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125920; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=AiIL9W8Mb5zq0tdffpRzOK5urgx1QEw0irqHwbIuzW4=; b=CT/ZqlGGnCahB8ToyVa3X44R0NUqqTdxxVeo+kyjWEtmOUdZ6J/pHm+9ddxQXPddumN8XPcj5cakRVvQEvJ8I3emBghrMNQAR1BFGwQvNiyUBEdCbQW0LkbXVrxN8bNJfykZBEp7ZHx7qITTtXqToN/3A+HMS6cz/AKnO0FLT9o= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125920334762.884978625692; Sun, 5 May 2019 23:58:40 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYz-0002lx-1g; Mon, 06 May 2019 06:57:25 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYl-0002Fg-Iu for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:11 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 2712ad24-6fcc-11e9-bc56-4f907df96e70; Mon, 06 May 2019 06:57:03 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 1961DAF40; Mon, 6 May 2019 06:56:59 +0000 (UTC) X-Inumbo-ID: 2712ad24-6fcc-11e9-bc56-4f907df96e70 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:37 +0200 Message-Id: <20190506065644.7415-39-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 38/45] xen/sched: modify cpupool_domain_cpumask() to be an item mask X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Tim Deegan , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Dario Faggioli , Julien Grall , Jan Beulich MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" cpupool_domain_cpumask() is used by scheduling to select cpus or to iterate over cpus. In order to support scheduling items spanning multiple cpus let cpupool_domain_cpumask() return a cpumask with only one bit set per scheduling resource. Signed-off-by: Juergen Gross --- xen/common/cpupool.c | 30 +++++++++++++++++++++--------- xen/common/schedule.c | 5 +++-- xen/include/xen/sched-if.h | 5 ++++- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/xen/common/cpupool.c b/xen/common/cpupool.c index 31ac323e40..ba76045937 100644 --- a/xen/common/cpupool.c +++ b/xen/common/cpupool.c @@ -38,26 +38,35 @@ DEFINE_PER_CPU(struct cpupool *, cpupool); =20 #define cpupool_dprintk(x...) ((void)0) =20 +static void free_cpupool_struct(struct cpupool *c) +{ + if ( c ) + { + free_cpumask_var(c->res_valid); + free_cpumask_var(c->cpu_valid); + } + xfree(c); +} + static struct cpupool *alloc_cpupool_struct(void) { struct cpupool *c =3D xzalloc(struct cpupool); =20 - if ( !c || !zalloc_cpumask_var(&c->cpu_valid) ) + if ( !c ) + return NULL; + + zalloc_cpumask_var(&c->cpu_valid); + zalloc_cpumask_var(&c->res_valid); + + if ( !c->cpu_valid || !c->res_valid ) { - xfree(c); + free_cpupool_struct(c); c =3D NULL; } =20 return c; } =20 -static void free_cpupool_struct(struct cpupool *c) -{ - if ( c ) - free_cpumask_var(c->cpu_valid); - xfree(c); -} - /* * find a cpupool by it's id. to be called with cpupool lock held * if exact is not specified, the first cpupool with an id larger or equal= to @@ -271,6 +280,7 @@ static int cpupool_assign_cpu_locked(struct cpupool *c,= unsigned int cpu) cpupool_cpu_moving =3D NULL; } cpumask_set_cpu(cpu, c->cpu_valid); + cpumask_and(c->res_valid, c->cpu_valid, sched_res_mask); =20 rcu_read_lock(&domlist_read_lock); for_each_domain_in_cpupool(d, c) @@ -393,6 +403,7 @@ static int cpupool_unassign_cpu(struct cpupool *c, unsi= gned int cpu) atomic_inc(&c->refcnt); cpupool_cpu_moving =3D c; cpumask_clear_cpu(cpu, c->cpu_valid); + cpumask_and(c->res_valid, c->cpu_valid, sched_res_mask); spin_unlock(&cpupool_lock); =20 work_cpu =3D smp_processor_id(); @@ -509,6 +520,7 @@ static int cpupool_cpu_remove(unsigned int cpu) * allowed only for CPUs in pool0. */ cpumask_clear_cpu(cpu, cpupool0->cpu_valid); + cpumask_and(cpupool0->res_valid, cpupool0->cpu_valid, sched_res_ma= sk); ret =3D 0; } =20 diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 1134733314..2870e91cce 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -57,6 +57,7 @@ integer_param("sched_ratelimit_us", sched_ratelimit_us); =20 /* Number of vcpus per struct sched_item. */ static unsigned int sched_granularity =3D 1; +const cpumask_t *sched_res_mask =3D &cpumask_all; =20 /* Various timer handlers. */ static void s_timer_fn(void *unused); @@ -347,9 +348,9 @@ static unsigned int sched_select_initial_cpu(struct vcp= u *v) cpumask_clear(&cpus); for_each_node_mask ( node, d->node_affinity ) cpumask_or(&cpus, &cpus, &node_to_cpumask(node)); - cpumask_and(&cpus, &cpus, cpupool_domain_cpumask(d)); + cpumask_and(&cpus, &cpus, d->cpupool->cpu_valid); if ( cpumask_empty(&cpus) ) - cpumask_copy(&cpus, cpupool_domain_cpumask(d)); + cpumask_copy(&cpus, d->cpupool->cpu_valid); =20 if ( v->vcpu_id =3D=3D 0 ) return cpumask_first(&cpus); diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index 88fbc06860..b3921f3a41 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -22,6 +22,8 @@ extern cpumask_t cpupool_free_cpus; #define SCHED_DEFAULT_RATELIMIT_US 1000 extern int sched_ratelimit_us; =20 +/* Scheduling resource mask. */ +extern const cpumask_t *sched_res_mask; =20 /* * In order to allow a scheduler to remap the lock->cpu mapping, @@ -527,6 +529,7 @@ struct cpupool { int cpupool_id; cpumask_var_t cpu_valid; /* all cpus assigned to pool */ + cpumask_var_t res_valid; /* all scheduling resources of pool */ struct cpupool *next; unsigned int n_dom; struct scheduler *sched; @@ -543,7 +546,7 @@ static inline cpumask_t* cpupool_domain_cpumask(struct = domain *d) * be interested in calling this for the idle domain. */ ASSERT(d->cpupool !=3D NULL); - return d->cpupool->cpu_valid; + return d->cpupool->res_valid; } =20 /* --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125906; cv=none; d=zoho.com; s=zohoarc; b=L/mqmTgQVh5JZaiB2ojUwAw/qzsUCH8abTX6/rLExmFbRGqnknzY+BBgMyoXc5boPgh8QhEunM4MPeWWlY1EVrudZObJ9aGVJtEoCB9itL3+UfuAASICBbLsF2aNUJVOsS5WmoiskUo30+86DjSJk6oiGiMLL+a5Qy/c5SK/Cgw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125906; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=CxwjcQly1Umj7P8RYr4ZCmPFmtnnbeEHmURYh7eNyks=; b=oovjZZsYsO9KbuT2GRtCuIhfgGfgWY6FIRTzaMHjpZath115ifQ3kKWFCsjPyFmN9oh/G5OKCEpAU703YMCEVdYdNGYU1aRDLoPcz/zgGdvzC5sbkEcgBGmJ05xzjxSiS+amwUvI73+5I0ylno+bXVz6slnWaZUj4POIyfxIv3o= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 155712590623265.25734131858553; Sun, 5 May 2019 23:58:26 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYk-0002Db-FE; Mon, 06 May 2019 06:57:10 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYf-00022w-HW for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:05 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 2743af03-6fcc-11e9-843c-bc764e045a96; Mon, 06 May 2019 06:57:04 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 393F1AF3F; Mon, 6 May 2019 06:56:59 +0000 (UTC) X-Inumbo-ID: 2743af03-6fcc-11e9-843c-bc764e045a96 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:38 +0200 Message-Id: <20190506065644.7415-40-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 39/45] xen/sched: support allocating multiple vcpus into one sched item X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , George Dunlap , Dario Faggioli MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" With a scheduling granularity greater than 1 multiple vcpus share the same struct sched_item. Support that. Setting the initial processor must be done carefully: we can't use sched_set_res() as that relies on for_each_sched_item_vcpu() which in turn needs the vcpu already as a member of the domain's vcpu linked list, which isn't the case. Signed-off-by: Juergen Gross --- xen/common/schedule.c | 75 ++++++++++++++++++++++++++++++++++++++++++-----= ---- 1 file changed, 62 insertions(+), 13 deletions(-) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 2870e91cce..30ca9ef25e 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -275,10 +275,25 @@ static void sched_spin_unlock_double(spinlock_t *lock= 1, spinlock_t *lock2, spin_unlock_irqrestore(lock1, flags); } =20 -static void sched_free_item(struct sched_item *item) +static void sched_free_item(struct sched_item *item, struct vcpu *v) { struct sched_item *prev_item; struct domain *d =3D item->domain; + struct vcpu *vitem; + unsigned int cnt =3D 0; + + /* Don't count to be released vcpu, might be not in vcpu list yet. */ + for_each_sched_item_vcpu ( item, vitem ) + if ( vitem !=3D v ) + cnt++; + + v->sched_item =3D NULL; + + if ( cnt ) + return; + + if ( item->vcpu =3D=3D v ) + item->vcpu =3D v->next_in_list; =20 if ( d->sched_item_list =3D=3D item ) d->sched_item_list =3D item->next_in_list; @@ -294,8 +309,6 @@ static void sched_free_item(struct sched_item *item) } } =20 - item->vcpu->sched_item =3D NULL; - free_cpumask_var(item->cpu_hard_affinity); free_cpumask_var(item->cpu_hard_affinity_tmp); free_cpumask_var(item->cpu_hard_affinity_saved); @@ -304,17 +317,36 @@ static void sched_free_item(struct sched_item *item) xfree(item); } =20 +static void sched_item_add_vcpu(struct sched_item *item, struct vcpu *v) +{ + v->sched_item =3D item; + if ( !item->vcpu || item->vcpu->vcpu_id > v->vcpu_id ) + { + item->vcpu =3D v; + item->item_id =3D v->vcpu_id; + } +} + static struct sched_item *sched_alloc_item(struct vcpu *v) { struct sched_item *item, **prev_item; struct domain *d =3D v->domain; =20 + for_each_sched_item ( d, item ) + if ( item->vcpu->vcpu_id / sched_granularity =3D=3D + v->vcpu_id / sched_granularity ) + break; + + if ( item ) + { + sched_item_add_vcpu(item, v); + return item; + } + if ( (item =3D xzalloc(struct sched_item)) =3D=3D NULL ) return NULL; =20 - v->sched_item =3D item; - item->vcpu =3D v; - item->item_id =3D v->vcpu_id; + sched_item_add_vcpu(item, v); item->domain =3D d; =20 for ( prev_item =3D &d->sched_item_list; *prev_item; @@ -335,7 +367,7 @@ static struct sched_item *sched_alloc_item(struct vcpu = *v) return item; =20 fail: - sched_free_item(item); + sched_free_item(item, v); return NULL; } =20 @@ -377,8 +409,6 @@ int sched_init_vcpu(struct vcpu *v) else processor =3D sched_select_initial_cpu(v); =20 - sched_set_res(item, per_cpu(sched_res, processor)); - /* Initialise the per-vcpu timers. */ init_timer(&v->periodic_timer, vcpu_periodic_timer_fn, v, v->processor); @@ -387,10 +417,22 @@ int sched_init_vcpu(struct vcpu *v) init_timer(&v->poll_timer, poll_timer_fn, v, v->processor); =20 + /* If this is not the first vcpu of the item we are done. */ + if ( item->priv !=3D NULL ) + { + /* We can rely on previous vcpu to exist. */ + v->processor =3D cpumask_next(d->vcpu[v->vcpu_id - 1]->processor, + item->res->cpus); + return 0; + } + + /* The first vcpu of an item can be set via sched_set_res(). */ + sched_set_res(item, per_cpu(sched_res, processor)); + item->priv =3D sched_alloc_vdata(dom_scheduler(d), item, d->sched_priv= ); if ( item->priv =3D=3D NULL ) { - sched_free_item(item); + sched_free_item(item, v); return 1; } =20 @@ -544,9 +586,16 @@ void sched_destroy_vcpu(struct vcpu *v) kill_timer(&v->poll_timer); if ( test_and_clear_bool(v->is_urgent) ) atomic_dec(&per_cpu(sched_res, v->processor)->urgent_count); - sched_remove_item(vcpu_scheduler(v), item); - sched_free_vdata(vcpu_scheduler(v), item->priv); - sched_free_item(item); + /* + * Vcpus are being destroyed top-down. So being the first vcpu of an i= tem + * is the same as being the only one. + */ + if ( item->vcpu =3D=3D v ) + { + sched_remove_item(vcpu_scheduler(v), item); + sched_free_vdata(vcpu_scheduler(v), item->priv); + sched_free_item(item, v); + } } =20 int sched_init_domain(struct domain *d, int poolid) --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125913; cv=none; d=zoho.com; s=zohoarc; b=gFHwLtzbBBfCIRIudNjpclJXqtinhwkSMVIfMAOtQ2BzJKM5kHItkPA4mg1thdZ2AWjpiLHL57x50NEHkJaqZyt9oeXMj99hEUh3w7ACqPPzv/iQn+SaQQ++SlPMQg+Mnsx1nJTRqeLulmKyAjxuYXJ65LFX51W3RDG2PSHURmw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125913; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=nt69I/VtnVnUtkScJFnLMr0pprJqPeYUjl8Hh6c5EXY=; b=jsWM7nawVZo4EFAkVH/WgkuDZjruo9Uwi/uotui92an6BPl/a5w8MP8mCI686BqJj7a6rt/kXftrQQbGuwy0HX9QQ1iwzuzq3cW4opaS9smbX0pNXwDzEbUlfsub7Duh+HVuuTRS9yPr3+9AVAwF3GObhWNl29JPgLSzwnWM1z8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125913115995.1189141442142; Sun, 5 May 2019 23:58:33 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXZD-0003Qp-RD; Mon, 06 May 2019 06:57:39 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYw-0002gS-OA for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:22 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 2742ca42-6fcc-11e9-843c-bc764e045a96; Mon, 06 May 2019 06:57:04 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 8EF26ACAA; Mon, 6 May 2019 06:56:59 +0000 (UTC) X-Inumbo-ID: 2742ca42-6fcc-11e9-843c-bc764e045a96 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:39 +0200 Message-Id: <20190506065644.7415-41-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 40/45] xen/sched: add a scheduler_percpu_init() function X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , Dario Faggioli , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" For support of core scheduling the scheduler cpu callback for CPU_STARTING has to be moved into a dedicated function called by start_secondary() as it needs to run before spin_debug_enable() then due to potentially calling xfree(). Signed-off-by: Juergen Gross --- RFC V2: fix ARM build --- xen/arch/arm/smpboot.c | 2 ++ xen/arch/x86/smpboot.c | 2 ++ xen/common/schedule.c | 19 ++++++++++++------- xen/include/xen/sched.h | 1 + 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c index f756444362..9a6582f2a6 100644 --- a/xen/arch/arm/smpboot.c +++ b/xen/arch/arm/smpboot.c @@ -350,6 +350,8 @@ void start_secondary(unsigned long boot_phys_offset, =20 setup_cpu_sibling_map(cpuid); =20 + scheduler_percpu_init(cpuid); + /* Run local notifiers */ notify_cpu_starting(cpuid); /* diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index b7a0a4a419..1c4f628b97 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -383,6 +383,8 @@ void start_secondary(void *unused) =20 set_cpu_sibling_map(cpu); =20 + scheduler_percpu_init(cpu); + init_percpu_time(); =20 setup_secondary_APIC_clock(); diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 30ca9ef25e..8a8828e772 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -2018,6 +2018,15 @@ static void cpu_schedule_down(unsigned int cpu) per_cpu(sched_res, cpu) =3D NULL; } =20 +void scheduler_percpu_init(unsigned int cpu) +{ + struct scheduler *sched =3D per_cpu(scheduler, cpu); + struct sched_resource *sd =3D per_cpu(sched_res, cpu); + + if ( system_state !=3D SYS_STATE_resume ) + sched_init_pdata(sched, sd->sched_priv, cpu); +} + static int cpu_schedule_callback( struct notifier_block *nfb, unsigned long action, void *hcpu) { @@ -2036,8 +2045,8 @@ static int cpu_schedule_callback( * data can avoid implementing alloc_pdata. init_pdata may, however, be * necessary/useful in this case too (e.g., it can contain the "regist= er * the pCPU to the scheduler" part). alloc_pdata (if present) is called - * during CPU_UP_PREPARE. init_pdata (if present) is called during - * CPU_STARTING. + * during CPU_UP_PREPARE. init_pdata (if present) is called before + * CPU_STARTING in scheduler_percpu_init(). * * On the other hand, at teardown, we need to reverse what has been do= ne * during initialization, and then free the per-pCPU specific data. Th= is @@ -2060,10 +2069,6 @@ static int cpu_schedule_callback( */ switch ( action ) { - case CPU_STARTING: - if ( system_state !=3D SYS_STATE_resume ) - sched_init_pdata(sched, sd->sched_priv, cpu); - break; case CPU_UP_PREPARE: if ( system_state !=3D SYS_STATE_resume ) rc =3D cpu_schedule_up(cpu); @@ -2160,7 +2165,7 @@ void __init scheduler_init(void) this_cpu(sched_res)->curr =3D idle_vcpu[0]->sched_item; this_cpu(sched_res)->sched_priv =3D sched_alloc_pdata(&ops, 0); BUG_ON(IS_ERR(this_cpu(sched_res)->sched_priv)); - sched_init_pdata(&ops, this_cpu(sched_res)->sched_priv, 0); + scheduler_percpu_init(0); } =20 /* diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 40d3def9f4..b6a2fe28cc 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -678,6 +678,7 @@ void __domain_crash(struct domain *d); void noreturn asm_domain_crash_synchronous(unsigned long addr); =20 void scheduler_init(void); +void scheduler_percpu_init(unsigned int cpu); int sched_init_vcpu(struct vcpu *v); void sched_destroy_vcpu(struct vcpu *v); int sched_init_domain(struct domain *d, int poolid); --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125919; cv=none; d=zoho.com; s=zohoarc; b=k4jJH2qtkgD3lo+F+gK1VIjm1FArZjMhRIJeT4s9KD4y4pKCCriJ3Us6EQfyzVT4Q7fq5QjRT/wyc2gzKEhA6Q4yCsDNUmv3FKi23hCAfYU/ck1cOxG6OQ2hJ1AROht1I19FroqMVblRcfYaJKh2LhBt4J28DIrA0+lTBS5LVfw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125919; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=nfv6m5UoBokJlzWTisXcA1h4O9+pGiwiBrnTE5E3Mho=; b=BUfZmvHqM+vhDLwDz44CWt6qSuOU5d1IqG3L0s0SGKj4Eh1DX1rIGXbHHz7g3SSdReCldUWymC8/e2QNy5IP/+142XowqGBOizyBFwL8qdaFlt27zH+Dt4zVTDdfZUhuJUP5lwcU2ZRnxQqcQyPGOgM0ky+Z3tGOhItXLLt6AkY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125919042649.6456684662832; Sun, 5 May 2019 23:58:39 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYj-0002CA-QF; Mon, 06 May 2019 06:57:09 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYf-00022u-FF for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:05 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 2758fdee-6fcc-11e9-843c-bc764e045a96; Mon, 06 May 2019 06:57:04 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id AC0F8ABC7; Mon, 6 May 2019 06:56:59 +0000 (UTC) X-Inumbo-ID: 2758fdee-6fcc-11e9-843c-bc764e045a96 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:40 +0200 Message-Id: <20190506065644.7415-42-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 41/45] xen/sched: add a percpu resource index X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , George Dunlap , Dario Faggioli MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Add a percpu variable holding the index of the cpu in the current sched_resource structure. This index is used to get the correct vcpu of a sched_item on a specific cpu. For now this index will be zero for all cpus, but with core scheduling it will be possible to have higher values, too. Signed-off-by: Juergen Gross --- RFC V2: new patch (carved out from RFC V1 patch 49) --- xen/common/schedule.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 8a8828e772..0de199ccc9 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -68,6 +68,7 @@ static void poll_timer_fn(void *data); /* This is global for now so that private implementations can reach it */ DEFINE_PER_CPU(struct scheduler *, scheduler); DEFINE_PER_CPU(struct sched_resource *, sched_res); +static DEFINE_PER_CPU(unsigned int, sched_res_idx); =20 /* Scratch space for cpumasks. */ DEFINE_PER_CPU(cpumask_t, cpumask_scratch); @@ -78,6 +79,12 @@ extern const struct scheduler *__start_schedulers_array[= ], *__end_schedulers_arr =20 static struct scheduler __read_mostly ops; =20 +static inline struct vcpu *sched_item2vcpu_cpu(struct sched_item *item, + unsigned int cpu) +{ + return item->domain->vcpu[item->item_id + per_cpu(sched_res_idx, cpu)]; +} + static inline struct scheduler *dom_scheduler(const struct domain *d) { if ( likely(d->cpupool !=3D NULL) ) @@ -1844,7 +1851,7 @@ static void sched_slave(void) =20 pcpu_schedule_unlock_irq(lock, cpu); =20 - sched_context_switch(vprev, next->vcpu, now); + sched_context_switch(vprev, sched_item2vcpu_cpu(next, cpu), now); } =20 /* @@ -1903,7 +1910,7 @@ static void schedule(void) =20 pcpu_schedule_unlock_irq(lock, cpu); =20 - vnext =3D next->vcpu; + vnext =3D sched_item2vcpu_cpu(next, cpu); sched_context_switch(vprev, vnext, now); } =20 --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125916; cv=none; d=zoho.com; s=zohoarc; b=ER7PO55Vlp4K+BT8OAZEN5Dwfjy56dMYl0QM9msVilq9BGK86F01XrN4fCMnqhU2k6ks5GhEh465SdV5iT56a7arEzG1kRedNB3+1Nqgtx0nrZJ2YN7TCps0PDuvU6bG9hh+xOlDaPVQvrwsHzMf13KT9KqQYkNeE4bKGg52VyA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125916; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=sOgRtAjGcmzjDsQahAGCGK1gKhjq4qP7B5FpjptaSos=; b=NISj/86K26IpX+y8OckWRb0axt9nulbveyVSLShChZaAh0fgUFMvvcQbB2y8L7O4NjZMmyF1jT32cUAZ0t66P02XRELktVRw+Uczd79BVbyvGpJOlZJqM4YSIvKgoJ8YUGOWZAQ9tMO7ryb2qKktLR4CBkrcM3u4NLztb//rnBg= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125916031344.09799956953066; Sun, 5 May 2019 23:58:36 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXZ4-00030Z-Pt; Mon, 06 May 2019 06:57:30 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYm-0002Ia-Q5 for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:12 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 27512e46-6fcc-11e9-a316-8fe7f57547fe; Mon, 06 May 2019 06:57:04 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 0C55EAD03; Mon, 6 May 2019 06:57:00 +0000 (UTC) X-Inumbo-ID: 27512e46-6fcc-11e9-a316-8fe7f57547fe X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:41 +0200 Message-Id: <20190506065644.7415-43-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 42/45] xen/sched: add fall back to idle vcpu when scheduling item X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , Dario Faggioli , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" When scheduling an item with multiple vcpus there is no guarantee all vcpus are available (e.g. above maxvcpus or vcpu offline). Fall back to idle vcpu of the current cpu in that case. This requires to store the correct schedule_item pointer in the idle vcpu as long as it used as fallback vcpu. In order to modify the runstates of the correct vcpus when switching schedule items merge sched_item_runstate_change() into sched_switch_items() and loop over the affected physical cpus instead of the item's vcpus. This in turn requires an access function to the current variable of other cpus. Today context_saved() is called in case previous and next vcpus differ when doing a context switch. With an idle vcpu being capable to be a substitute for an offline vcpu this is problematic when switching to an idle scheduling item. An idle previous vcpu leaves us in doubt which schedule item was active previously, so save the previous item pointer in the per-schedule resource area and use its value being non-NULL as a hint whether context_saved() should be called. Signed-off-by: Juergen Gross --- RFC V2: new patch (Andrew Cooper) --- xen/arch/x86/domain.c | 21 ++++++ xen/common/schedule.c | 153 +++++++++++++++++++++++++++-----------= ---- xen/include/asm-arm/current.h | 1 + xen/include/asm-x86/current.h | 7 +- xen/include/asm-x86/smp.h | 3 + xen/include/xen/sched-if.h | 4 +- 6 files changed, 134 insertions(+), 55 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index d04e704116..f3dbca5dba 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -154,6 +154,24 @@ static void idle_loop(void) } } =20 +/* + * Idle loop for siblings of active schedule items. + * We don't do any standard idle work like tasklets, page scrubbing or + * livepatching. + * Use default_idle() in order to simulate v->is_urgent. + */ +static void guest_idle_loop(void) +{ + unsigned int cpu =3D smp_processor_id(); + + for ( ; ; ) + { + if ( !softirq_pending(cpu) ) + default_idle(); + do_softirq(); + } +} + void startup_cpu_idle_loop(void) { struct vcpu *v =3D current; @@ -167,6 +185,9 @@ void startup_cpu_idle_loop(void) =20 static void noreturn continue_idle_domain(struct vcpu *v) { + if ( !is_idle_item(v->sched_item) ) + reset_stack_and_jump(guest_idle_loop); + reset_stack_and_jump(idle_loop); } =20 diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 0de199ccc9..788ecc9e81 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -82,7 +82,18 @@ static struct scheduler __read_mostly ops; static inline struct vcpu *sched_item2vcpu_cpu(struct sched_item *item, unsigned int cpu) { - return item->domain->vcpu[item->item_id + per_cpu(sched_res_idx, cpu)]; + unsigned int idx =3D item->item_id + per_cpu(sched_res_idx, cpu); + const struct domain *d =3D item->domain; + struct vcpu *v; + + if ( idx < d->max_vcpus && d->vcpu[idx] ) + { + v =3D d->vcpu[idx]; + if ( v->new_state =3D=3D RUNSTATE_running ) + return v; + } + + return idle_vcpu[cpu]; } =20 static inline struct scheduler *dom_scheduler(const struct domain *d) @@ -196,8 +207,11 @@ static inline void vcpu_runstate_change( =20 trace_runstate_change(v, new_state); =20 - item->runstate_cnt[v->runstate.state]--; - item->runstate_cnt[new_state]++; + if ( !is_idle_vcpu(v) ) + { + item->runstate_cnt[v->runstate.state]--; + item->runstate_cnt[new_state]++; + } =20 delta =3D new_entry_time - v->runstate.state_entry_time; if ( delta > 0 ) @@ -209,21 +223,6 @@ static inline void vcpu_runstate_change( v->runstate.state =3D new_state; } =20 -static inline void sched_item_runstate_change(struct sched_item *item, - bool running, s_time_t new_entry_time) -{ - struct vcpu *v; - - for_each_sched_item_vcpu( item, v ) - if ( running ) - vcpu_runstate_change(v, v->new_state, new_entry_time); - else - vcpu_runstate_change(v, - ((v->pause_flags & VPF_blocked) ? RUNSTATE_blocked : - (vcpu_runnable(v) ? RUNSTATE_runnable : RUNSTATE_offline)= ), - new_entry_time); -} - void vcpu_runstate_get(struct vcpu *v, struct vcpu_runstate_info *runstate) { spinlock_t *lock =3D likely(v =3D=3D current) @@ -456,6 +455,7 @@ int sched_init_vcpu(struct vcpu *v) if ( is_idle_domain(d) ) { per_cpu(sched_res, v->processor)->curr =3D item; + per_cpu(sched_res, v->processor)->sched_item_idle =3D item; v->is_running =3D 1; item->is_running =3D 1; item->state_entry_time =3D NOW(); @@ -1631,33 +1631,67 @@ static void sched_switch_items(struct sched_resourc= e *sd, struct sched_item *next, struct sched_item = *prev, s_time_t now) { - sd->curr =3D next; - - TRACE_3D(TRC_SCHED_SWITCH_INFPREV, prev->domain->domain_id, prev->item= _id, - now - prev->state_entry_time); - TRACE_4D(TRC_SCHED_SWITCH_INFNEXT, next->domain->domain_id, next->item= _id, - (next->vcpu->runstate.state =3D=3D RUNSTATE_runnable) ? - (now - next->state_entry_time) : 0, prev->next_time); + int cpu; =20 ASSERT(item_running(prev)); =20 - TRACE_4D(TRC_SCHED_SWITCH, prev->domain->domain_id, prev->item_id, - next->domain->domain_id, next->item_id); + if ( prev !=3D next ) + { + sd->curr =3D next; + sd->prev =3D prev; =20 - sched_item_runstate_change(prev, false, now); - prev->last_run_time =3D now; + TRACE_3D(TRC_SCHED_SWITCH_INFPREV, prev->domain->domain_id, + prev->item_id, now - prev->state_entry_time); + TRACE_4D(TRC_SCHED_SWITCH_INFNEXT, next->domain->domain_id, + next->item_id, + (next->vcpu->runstate.state =3D=3D RUNSTATE_runnable) ? + (now - next->state_entry_time) : 0, prev->next_time); + TRACE_4D(TRC_SCHED_SWITCH, prev->domain->domain_id, prev->item_id, + next->domain->domain_id, next->item_id); =20 - ASSERT(!item_running(next)); - sched_item_runstate_change(next, true, now); + prev->last_run_time =3D now; =20 - /* - * NB. Don't add any trace records from here until the actual context - * switch, else lost_records resume will not work properly. - */ + ASSERT(!item_running(next)); + + /* + * NB. Don't add any trace records from here until the actual cont= ext + * switch, else lost_records resume will not work properly. + */ + + ASSERT(!next->is_running); + next->is_running =3D 1; =20 - ASSERT(!next->is_running); - next->vcpu->is_running =3D 1; - next->is_running =3D 1; + if ( is_idle_item(prev) ) + { + prev->runstate_cnt[RUNSTATE_running] =3D 0; + prev->runstate_cnt[RUNSTATE_runnable] =3D sched_granularity; + } + if ( is_idle_item(next) ) + { + next->runstate_cnt[RUNSTATE_running] =3D sched_granularity; + next->runstate_cnt[RUNSTATE_runnable] =3D 0; + } + } + + for_each_cpu( cpu, sd->cpus ) + { + struct vcpu *vprev =3D get_cpu_current(cpu); + struct vcpu *vnext =3D sched_item2vcpu_cpu(next, cpu); + + if ( vprev !=3D vnext || vprev->runstate.state !=3D vnext->new_sta= te ) + { + vcpu_runstate_change(vprev, + ((vprev->pause_flags & VPF_blocked) ? RUNSTATE_blocked : + (vcpu_runnable(vprev) ? RUNSTATE_runnable : RUNSTATE_offl= ine)), + now); + vcpu_runstate_change(vnext, vnext->new_state, now); + } + + vnext->is_running =3D 1; + + if ( is_idle_vcpu(vnext) ) + vnext->sched_item =3D next; + } } =20 static bool sched_tasklet_check(void) @@ -1706,25 +1740,25 @@ static struct sched_item *do_schedule(struct sched_= item *prev, s_time_t now) if ( prev->next_time >=3D 0 ) /* -ve means no limit */ set_timer(&sd->s_timer, now + prev->next_time); =20 - if ( likely(prev !=3D next) ) - sched_switch_items(sd, next, prev, now); + sched_switch_items(sd, next, prev, now); =20 return next; } =20 -static void context_saved(struct vcpu *prev) +static void context_saved(struct sched_item *item) { - struct sched_item *item =3D prev->sched_item; - item->is_running =3D 0; item->state_entry_time =3D NOW(); + this_cpu(sched_res)->prev =3D NULL; =20 /* Check for migration request /after/ clearing running flag. */ smp_mb(); =20 - sched_context_saved(vcpu_scheduler(prev), item); + sched_context_saved(vcpu_scheduler(item->vcpu), item); =20 - sched_item_migrate_finish(item); + /* Idle never migrates and idle vcpus might belong to other items. */ + if ( !is_idle_item(item) ) + sched_item_migrate_finish(item); } =20 /* @@ -1741,11 +1775,13 @@ static void context_saved(struct vcpu *prev) void sched_context_switched(struct vcpu *vprev, struct vcpu *vnext) { struct sched_item *next =3D vnext->sched_item; + struct sched_resource *sd =3D this_cpu(sched_res); =20 /* Clear running flag /after/ writing context to memory. */ smp_wmb(); =20 - vprev->is_running =3D 0; + if ( vprev !=3D vnext ) + vprev->is_running =3D 0; =20 if ( atomic_read(&next->rendezvous_out_cnt) ) { @@ -1754,20 +1790,23 @@ void sched_context_switched(struct vcpu *vprev, str= uct vcpu *vnext) /* Call context_saved() before releasing other waiters. */ if ( cnt =3D=3D 1 ) { - if ( vprev !=3D vnext ) - context_saved(vprev); + if ( sd->prev ) + context_saved(sd->prev); atomic_set(&next->rendezvous_out_cnt, 0); } else while ( atomic_read(&next->rendezvous_out_cnt) ) cpu_relax(); } - else if ( vprev !=3D vnext && sched_granularity =3D=3D 1 ) - context_saved(vprev); + else if ( sd->prev ) + context_saved(sd->prev); + + if ( is_idle_vcpu(vprev) && vprev !=3D vnext ) + vprev->sched_item =3D sd->sched_item_idle; } =20 static void sched_context_switch(struct vcpu *vprev, struct vcpu *vnext, - s_time_t now) + bool reset_idle_item, s_time_t now) { if ( unlikely(vprev =3D=3D vnext) ) { @@ -1776,6 +1815,10 @@ static void sched_context_switch(struct vcpu *vprev,= struct vcpu *vnext, now - vprev->runstate.state_entry_time, vprev->sched_item->next_time); sched_context_switched(vprev, vnext); + + if ( reset_idle_item ) + vnext->sched_item =3D this_cpu(sched_res)->sched_item_idle; + trace_continue_running(vnext); return continue_running(vprev); } @@ -1851,7 +1894,8 @@ static void sched_slave(void) =20 pcpu_schedule_unlock_irq(lock, cpu); =20 - sched_context_switch(vprev, sched_item2vcpu_cpu(next, cpu), now); + sched_context_switch(vprev, sched_item2vcpu_cpu(next, cpu), + is_idle_item(next) && !is_idle_item(prev), now); } =20 /* @@ -1911,7 +1955,8 @@ static void schedule(void) pcpu_schedule_unlock_irq(lock, cpu); =20 vnext =3D sched_item2vcpu_cpu(next, cpu); - sched_context_switch(vprev, vnext, now); + sched_context_switch(vprev, vnext, + !is_idle_item(prev) && is_idle_item(next), now); } =20 /* The scheduler timer: force a run through the scheduler */ @@ -1993,6 +2038,7 @@ static int cpu_schedule_up(unsigned int cpu) return -ENOMEM; =20 sd->curr =3D idle_vcpu[cpu]->sched_item; + sd->sched_item_idle =3D idle_vcpu[cpu]->sched_item; =20 /* * We don't want to risk calling xfree() on an sd->sched_priv @@ -2170,6 +2216,7 @@ void __init scheduler_init(void) if ( vcpu_create(idle_domain, 0) =3D=3D NULL ) BUG(); this_cpu(sched_res)->curr =3D idle_vcpu[0]->sched_item; + this_cpu(sched_res)->sched_item_idle =3D idle_vcpu[0]->sched_item; this_cpu(sched_res)->sched_priv =3D sched_alloc_pdata(&ops, 0); BUG_ON(IS_ERR(this_cpu(sched_res)->sched_priv)); scheduler_percpu_init(0); diff --git a/xen/include/asm-arm/current.h b/xen/include/asm-arm/current.h index c4af66fbb9..a7602eef8c 100644 --- a/xen/include/asm-arm/current.h +++ b/xen/include/asm-arm/current.h @@ -18,6 +18,7 @@ DECLARE_PER_CPU(struct vcpu *, curr_vcpu); =20 #define current (this_cpu(curr_vcpu)) #define set_current(vcpu) do { current =3D (vcpu); } while (0) +#define get_cpu_current(cpu) (per_cpu(curr_vcpu, cpu)) =20 /* Per-VCPU state that lives at the top of the stack */ struct cpu_info { diff --git a/xen/include/asm-x86/current.h b/xen/include/asm-x86/current.h index 5bd64b2271..cb5b6f1176 100644 --- a/xen/include/asm-x86/current.h +++ b/xen/include/asm-x86/current.h @@ -76,6 +76,11 @@ struct cpu_info { /* get_stack_bottom() must be 16-byte aligned */ }; =20 +static inline struct cpu_info *get_cpu_info_from_stack(unsigned long sp) +{ + return (struct cpu_info *)((sp | (STACK_SIZE - 1)) + 1) - 1; +} + static inline struct cpu_info *get_cpu_info(void) { #ifdef __clang__ @@ -86,7 +91,7 @@ static inline struct cpu_info *get_cpu_info(void) register unsigned long sp asm("rsp"); #endif =20 - return (struct cpu_info *)((sp | (STACK_SIZE - 1)) + 1) - 1; + return get_cpu_info_from_stack(sp); } =20 #define get_current() (get_cpu_info()->current_vcpu) diff --git a/xen/include/asm-x86/smp.h b/xen/include/asm-x86/smp.h index 9f533f9072..51a31ab00a 100644 --- a/xen/include/asm-x86/smp.h +++ b/xen/include/asm-x86/smp.h @@ -76,6 +76,9 @@ void set_nr_sockets(void); /* Representing HT and core siblings in each socket. */ extern cpumask_t **socket_cpumask; =20 +#define get_cpu_current(cpu) \ + (get_cpu_info_from_stack((unsigned long)stack_base[cpu])->current_vcpu) + #endif /* !__ASSEMBLY__ */ =20 #endif diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index b3921f3a41..8981d41629 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -39,6 +39,8 @@ struct sched_resource { spinlock_t *schedule_lock, _lock; struct sched_item *curr; /* current task = */ + struct sched_item *sched_item_idle; + struct sched_item *prev; /* previous task = */ void *sched_priv; struct timer s_timer; /* scheduling timer = */ atomic_t urgent_count; /* how many urgent vcpus = */ @@ -152,7 +154,7 @@ static inline void sched_clear_pause_flags_atomic(struc= t sched_item *item, =20 static inline struct sched_item *sched_idle_item(unsigned int cpu) { - return idle_vcpu[cpu]->sched_item; + return per_cpu(sched_res, cpu)->sched_item_idle; } =20 static inline unsigned int sched_get_resource_cpu(unsigned int cpu) --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125913; cv=none; d=zoho.com; s=zohoarc; b=okQN99mODa+xIPMNK3iL7TvYegZTYT5Kifkf9KDUdXGb0qLWLY+slNdqaEsF9G8W2zcXAz5Ch4jyVCvP3xQgWpezROvcbyy6HLX+90DdbXlCcA2WN/RvBTPeA3WUqcilABEr+cYBEgBDiyERUOEsLlWbJOZMosZBbc2b/jB0FE4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125913; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=YZIxMbAVoCtEoGI+SfTSZvac2sRhXAp/q/j73/h7aI0=; b=PFHrv/jzh2FpNj0coOwo/Jlc7gpeIugSZjo+LqkNI5eyNfx0FnMHXijdNwv6hEX/euZxmdEZTR4jccfIGrI/CbS24fE68EpAKz/E2bC1uvw8tsVSDPHAKYuZALmAjiJAZMohu6XPtCmhK1ZoaEUPDobgC9dXJOrb97CFjOerrh0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125913479854.4652365385314; Sun, 5 May 2019 23:58:33 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXZ9-0003De-Am; Mon, 06 May 2019 06:57:35 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYn-0002Kn-Tu for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:13 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 27acffe4-6fcc-11e9-843c-bc764e045a96; Mon, 06 May 2019 06:57:04 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 56C17AF41; Mon, 6 May 2019 06:57:00 +0000 (UTC) X-Inumbo-ID: 27acffe4-6fcc-11e9-843c-bc764e045a96 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:42 +0200 Message-Id: <20190506065644.7415-44-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 43/45] xen/sched: make vcpu_wake() and vcpu_sleep() core scheduling aware X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Tim Deegan , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Dario Faggioli , Julien Grall , Jan Beulich MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" vcpu_wake() and vcpu_sleep() need to be made core scheduling aware: they might need to switch a single vcpu of an already scheduled item between running and not running. Especially when vcpu_sleep() for a vcpu is being called by a vcpu of the same scheduling item special care must be taken in order to avoid a deadlock: the vcpu to be put asleep must be forced through a context switch without doing so for the calling vcpu. For this purpose add a vcpu flag handled in sched_slave() and in sched_wait_rendezvous_in() allowing a vcpu of the currently running item to switch state at a higher priority than a normal schedule event. Use the same mechanism when waking up a vcpu of a currently active item. While at it make vcpu_sleep_nosync_locked() static as it is used in schedule.c only. Signed-off-by: Juergen Gross --- RFC V2: add vcpu_sleep() handling and force_context_switch flag --- xen/common/schedule.c | 144 ++++++++++++++++++++++++++++++++++++++++-= ---- xen/include/xen/sched-if.h | 9 ++- xen/include/xen/sched.h | 2 + 3 files changed, 136 insertions(+), 19 deletions(-) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 788ecc9e81..49ed2b5900 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -79,21 +79,21 @@ extern const struct scheduler *__start_schedulers_array= [], *__end_schedulers_arr =20 static struct scheduler __read_mostly ops; =20 -static inline struct vcpu *sched_item2vcpu_cpu(struct sched_item *item, - unsigned int cpu) +static inline struct vcpu *item2vcpu_cpu(struct sched_item *item, + unsigned int cpu) { unsigned int idx =3D item->item_id + per_cpu(sched_res_idx, cpu); const struct domain *d =3D item->domain; - struct vcpu *v; =20 - if ( idx < d->max_vcpus && d->vcpu[idx] ) - { - v =3D d->vcpu[idx]; - if ( v->new_state =3D=3D RUNSTATE_running ) - return v; - } + return (idx < d->max_vcpus && d->vcpu[idx]) ? d->vcpu[idx] : NULL; +} =20 - return idle_vcpu[cpu]; +static inline struct vcpu *sched_item2vcpu_cpu(struct sched_item *item, + unsigned int cpu) +{ + struct vcpu *v =3D item2vcpu_cpu(item, cpu); + + return (v && v->new_state =3D=3D RUNSTATE_running) ? v : idle_vcpu[cpu= ]; } =20 static inline struct scheduler *dom_scheduler(const struct domain *d) @@ -644,8 +644,10 @@ void sched_destroy_domain(struct domain *d) } } =20 -void vcpu_sleep_nosync_locked(struct vcpu *v) +static void vcpu_sleep_nosync_locked(struct vcpu *v) { + struct sched_item *item =3D v->sched_item; + ASSERT(spin_is_locked(per_cpu(sched_res, v->processor)->schedule_lock)= ); =20 if ( likely(!vcpu_runnable(v)) ) @@ -653,7 +655,14 @@ void vcpu_sleep_nosync_locked(struct vcpu *v) if ( v->runstate.state =3D=3D RUNSTATE_runnable ) vcpu_runstate_change(v, RUNSTATE_offline, NOW()); =20 - sched_sleep(vcpu_scheduler(v), v->sched_item); + if ( likely(!item_runnable(item)) ) + sched_sleep(vcpu_scheduler(v), item); + else if ( item_running(item) > 1 && v->is_running && + !v->force_context_switch ) + { + v->force_context_switch =3D true; + cpu_raise_softirq(v->processor, SCHED_SLAVE_SOFTIRQ); + } } } =20 @@ -685,16 +694,22 @@ void vcpu_wake(struct vcpu *v) { unsigned long flags; spinlock_t *lock; + struct sched_item *item =3D v->sched_item; =20 TRACE_2D(TRC_SCHED_WAKE, v->domain->domain_id, v->vcpu_id); =20 - lock =3D item_schedule_lock_irqsave(v->sched_item, &flags); + lock =3D item_schedule_lock_irqsave(item, &flags); =20 if ( likely(vcpu_runnable(v)) ) { if ( v->runstate.state >=3D RUNSTATE_blocked ) vcpu_runstate_change(v, RUNSTATE_runnable, NOW()); - sched_wake(vcpu_scheduler(v), v->sched_item); + sched_wake(vcpu_scheduler(v), item); + if ( item->is_running && !v->is_running && !v->force_context_switc= h ) + { + v->force_context_switch =3D true; + cpu_raise_softirq(v->processor, SCHED_SLAVE_SOFTIRQ); + } } else if ( !(v->pause_flags & VPF_blocked) ) { @@ -702,7 +717,7 @@ void vcpu_wake(struct vcpu *v) vcpu_runstate_change(v, RUNSTATE_offline, NOW()); } =20 - item_schedule_unlock_irqrestore(lock, flags, v->sched_item); + item_schedule_unlock_irqrestore(lock, flags, item); } =20 void vcpu_unblock(struct vcpu *v) @@ -1835,6 +1850,61 @@ static void sched_context_switch(struct vcpu *vprev,= struct vcpu *vnext, context_switch(vprev, vnext); } =20 +/* + * Force a context switch of a single vcpu of an item. + * Might be called either if a vcpu of an already running item is woken up + * or if a vcpu of a running item is put asleep with other vcpus of the sa= me + * item still running. + */ +static struct vcpu *sched_force_context_switch(struct vcpu *vprev, + struct vcpu *v, + int cpu, s_time_t now) +{ + v->force_context_switch =3D false; + + if ( vcpu_runnable(v) =3D=3D v->is_running ) + return NULL; + + if ( vcpu_runnable(v) ) + { + if ( is_idle_vcpu(vprev) ) + { + vcpu_runstate_change(vprev, RUNSTATE_runnable, now); + vprev->sched_item =3D this_cpu(sched_res)->sched_item_idle; + } + vcpu_runstate_change(v, RUNSTATE_running, now); + } + else + { + /* Make sure not to switch last vcpu of an item away. */ + if ( item_running(v->sched_item) =3D=3D 1 ) + return NULL; + + vcpu_runstate_change(v, vcpu_runstate_blocked(v), now); + v =3D sched_item2vcpu_cpu(vprev->sched_item, cpu); + if ( v !=3D vprev ) + { + if ( is_idle_vcpu(vprev) ) + { + vcpu_runstate_change(vprev, RUNSTATE_runnable, now); + vprev->sched_item =3D this_cpu(sched_res)->sched_item_idle; + } + else + { + v->sched_item =3D vprev->sched_item; + vcpu_runstate_change(v, RUNSTATE_running, now); + } + } + } + + v->is_running =3D 1; + + /* Make sure not to loose another slave call. */ + raise_softirq(SCHED_SLAVE_SOFTIRQ); + + return v; +} + /* * Rendezvous before taking a scheduling decision. * Called with schedule lock held, so all accesses to the rendezvous count= er @@ -1850,6 +1920,7 @@ static struct sched_item *sched_wait_rendezvous_in(st= ruct sched_item *prev, s_time_t now) { struct sched_item *next; + struct vcpu *v; =20 if ( !--prev->rendezvous_in_cnt ) { @@ -1858,8 +1929,28 @@ static struct sched_item *sched_wait_rendezvous_in(s= truct sched_item *prev, return next; } =20 + v =3D item2vcpu_cpu(prev, cpu); while ( prev->rendezvous_in_cnt ) { + if ( v && v->force_context_switch ) + { + struct vcpu *vprev =3D current; + + v =3D sched_force_context_switch(vprev, v, cpu, now); + + if ( v ) + { + /* We'll come back another time, so adjust rendezvous_in_c= nt. */ + prev->rendezvous_in_cnt++; + + pcpu_schedule_unlock_irq(lock, cpu); + + sched_context_switch(vprev, v, false, now); + } + + v =3D item2vcpu_cpu(prev, cpu); + } + pcpu_schedule_unlock_irq(lock, cpu); cpu_relax(); pcpu_schedule_lock_irq(cpu); @@ -1870,10 +1961,11 @@ static struct sched_item *sched_wait_rendezvous_in(= struct sched_item *prev, =20 static void sched_slave(void) { - struct vcpu *vprev =3D current; + struct vcpu *v, *vprev =3D current; struct sched_item *prev =3D vprev->sched_item, *next; s_time_t now; spinlock_t *lock; + bool do_softirq =3D false; int cpu =3D smp_processor_id(); =20 ASSERT_NOT_IN_ATOMIC(); @@ -1882,9 +1974,29 @@ static void sched_slave(void) =20 now =3D NOW(); =20 + v =3D item2vcpu_cpu(prev, cpu); + if ( v && v->force_context_switch ) + { + v =3D sched_force_context_switch(vprev, v, cpu, now); + + if ( v ) + { + pcpu_schedule_unlock_irq(lock, cpu); + + sched_context_switch(vprev, v, false, now); + } + + do_softirq =3D true; + } + if ( !prev->rendezvous_in_cnt ) { pcpu_schedule_unlock_irq(lock, cpu); + + /* Check for failed forced context switch. */ + if ( do_softirq ) + raise_softirq(SCHEDULE_SOFTIRQ); + return; } =20 diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index 8981d41629..f16d81ab4a 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -75,6 +75,11 @@ static inline bool item_runnable(const struct sched_item= *item) return false; } =20 +static inline int vcpu_runstate_blocked(struct vcpu *v) +{ + return (v->pause_flags & VPF_blocked) ? RUNSTATE_blocked : RUNSTATE_of= fline; +} + static inline bool item_runnable_state(const struct sched_item *item) { struct vcpu *v; @@ -84,9 +89,7 @@ static inline bool item_runnable_state(const struct sched= _item *item) { runnable =3D vcpu_runnable(v); =20 - v->new_state =3D runnable ? RUNSTATE_running - : (v->pause_flags & VPF_blocked) - ? RUNSTATE_blocked : RUNSTATE_offline; + v->new_state =3D runnable ? RUNSTATE_running : vcpu_runstate_block= ed(v); =20 if ( runnable ) ret =3D true; diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index b6a2fe28cc..5629602de5 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -186,6 +186,8 @@ struct vcpu bool is_running; /* VCPU should wake fast (do not deep sleep the CPU). */ bool is_urgent; + /* VCPU must context_switch without scheduling item. */ + bool force_context_switch; =20 #ifdef VCPU_TRAP_LAST #define VCPU_TRAP_NONE 0 --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125917; cv=none; d=zoho.com; s=zohoarc; b=NaVsCOiWBc8aEU4mXqq0PnFNq7Olugk4u4GJtvEuCqB0r+d3TfmzVCxs2hdiOx+AyCXskNs+renDQLj7KxZrhCXM21B3mx/zqFgQtItl7JgR6NuN7BpGk51FBDsmWEPNz0BgBntt5ZH8eU9AilE10E+uZCs5Wwp4LWSGmFnhff8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125917; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=ZOatkKk4yP2++h4Gmw5NyHTcltOJ+UB764rd6X9U1+c=; b=KczVwDehy7mtaPre4NYXYdvT3Jb5WtwIsg9PhWQo1DXYluq6SdymMlmUxX7pn4cC5s79WqFeCg3yTI6xdCfb0oVMdm5Yx4ZA2vm+sOwwG6aVe1S/TLGoyW0yRC08xse6eG9RYORjiCCFpJWnDodcLCdRFcGqI4J3bs0xCPOBW50= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125917946282.80359578341483; Sun, 5 May 2019 23:58:37 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXZ0-0002pZ-BB; Mon, 06 May 2019 06:57:26 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYm-0002HI-74 for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:12 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 27acf987-6fcc-11e9-843c-bc764e045a96; Mon, 06 May 2019 06:57:04 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 77F9FAF42; Mon, 6 May 2019 06:57:00 +0000 (UTC) X-Inumbo-ID: 27acf987-6fcc-11e9-843c-bc764e045a96 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:43 +0200 Message-Id: <20190506065644.7415-45-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 44/45] xen/sched: carve out freeing sched_item memory into dedicated function X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , George Dunlap , Dario Faggioli MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" We'll need a way to free a sched_item structure without side effects in a later patch. Signed-off-by: Juergen Gross --- RFC V2: new patch, carved out from RFC V1 patch 49 --- xen/common/schedule.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 49ed2b5900..4336f2bdf8 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -281,25 +281,10 @@ static void sched_spin_unlock_double(spinlock_t *lock= 1, spinlock_t *lock2, spin_unlock_irqrestore(lock1, flags); } =20 -static void sched_free_item(struct sched_item *item, struct vcpu *v) +static void sched_free_item_mem(struct sched_item *item) { struct sched_item *prev_item; struct domain *d =3D item->domain; - struct vcpu *vitem; - unsigned int cnt =3D 0; - - /* Don't count to be released vcpu, might be not in vcpu list yet. */ - for_each_sched_item_vcpu ( item, vitem ) - if ( vitem !=3D v ) - cnt++; - - v->sched_item =3D NULL; - - if ( cnt ) - return; - - if ( item->vcpu =3D=3D v ) - item->vcpu =3D v->next_in_list; =20 if ( d->sched_item_list =3D=3D item ) d->sched_item_list =3D item->next_in_list; @@ -323,6 +308,25 @@ static void sched_free_item(struct sched_item *item, s= truct vcpu *v) xfree(item); } =20 +static void sched_free_item(struct sched_item *item, struct vcpu *v) +{ + struct vcpu *vitem; + unsigned int cnt =3D 0; + + /* Don't count to be released vcpu, might be not in vcpu list yet. */ + for_each_sched_item_vcpu ( item, vitem ) + if ( vitem !=3D v ) + cnt++; + + v->sched_item =3D NULL; + + if ( item->vcpu =3D=3D v ) + item->vcpu =3D v->next_in_list; + + if ( !cnt ) + sched_free_item_mem(item); +} + static void sched_item_add_vcpu(struct sched_item *item, struct vcpu *v) { v->sched_item =3D item; --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 16 11:14:51 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1557125914; cv=none; d=zoho.com; s=zohoarc; b=G5qLrmML49e9LhYQWfEdEgSd/cHUlMzY26/kdpcLEVkuRSC8RPYrlsXgQzOT0KECVtZmoThWu4ZxC2YZrEH3GvI0ECHzRJEtiJM8YGn2HkdnkXhcn5QoIFpqA/4tBWSWJIOEXf8oTwgf+5zxx9QVomu7O85vferVx7xjVEAYrzk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557125914; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Vx3MGA2hgAc3hs9/VU1PfMiyMUcmAhc3d3g90FZZjVs=; b=JDaKk0OMLcMIMhHeD8nj4qZdIjr/Bo40ZqAXOaAM0hJMx+mxNzWP8tnJTtya8x58aCSrgaRPWd0q9UG2lbQdxNrH/2y40rEntRKFsrO653b38KRzr98I+iEpZ/QclACHyF64tipBW5NyRXPgp9y0WxIHD7pchqPh8qHeWXYdREc= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1557125914220331.9972943813176; Sun, 5 May 2019 23:58:34 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXZA-0003Hl-BR; Mon, 06 May 2019 06:57:36 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hNXYo-0002LP-4T for xen-devel@lists.xenproject.org; Mon, 06 May 2019 06:57:14 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 28128da0-6fcc-11e9-843c-bc764e045a96; Mon, 06 May 2019 06:57:05 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id CF998AE3F; Mon, 6 May 2019 06:57:00 +0000 (UTC) X-Inumbo-ID: 28128da0-6fcc-11e9-843c-bc764e045a96 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 6 May 2019 08:56:44 +0200 Message-Id: <20190506065644.7415-46-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190506065644.7415-1-jgross@suse.com> References: <20190506065644.7415-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC V2 45/45] xen/sched: add scheduling granularity enum X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , Dario Faggioli , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Add a scheduling granularity enum ("thread", "core", "socket") for specification of the scheduling granularity. Initially it is set to "thread", this can be modified by the new boot parameter (x86 only) "sched_granularity". According to the selected granularity sched_granularity is set after all cpus are online. The sched items of the idle vcpus and the sched resources of the physical cpus need to be combined in case sched_granularity > 1, this happens before the init_pdata hook of the active scheduler is being called. A test is added for all sched resources holding the same number of cpus. For now panic if this is not the case. Signed-off-by: Juergen Gross --- RFC V2: - fixed freeing of sched_res when merging cpus - rename parameter to "sched-gran" (Jan Beulich) - rename parameter option from "thread" to "cpu" (Jan Beulich) --- xen/arch/x86/setup.c | 2 + xen/common/schedule.c | 155 +++++++++++++++++++++++++++++++++++++++++= ++-- xen/include/xen/sched-if.h | 4 +- xen/include/xen/sched.h | 1 + 4 files changed, 153 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 3440794275..83854eeef8 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1701,6 +1701,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) printk(XENLOG_INFO "Parked %u CPUs\n", num_parked); smp_cpus_done(); =20 + scheduler_smp_init(); + do_initcalls(); =20 if ( opt_watchdog )=20 diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 4336f2bdf8..3e68259411 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -55,9 +55,32 @@ boolean_param("sched_smt_power_savings", sched_smt_power= _savings); int sched_ratelimit_us =3D SCHED_DEFAULT_RATELIMIT_US; integer_param("sched_ratelimit_us", sched_ratelimit_us); =20 +static enum { + SCHED_GRAN_cpu, + SCHED_GRAN_core, + SCHED_GRAN_socket +} opt_sched_granularity =3D SCHED_GRAN_cpu; + +#ifdef CONFIG_X86 +static int __init sched_select_granularity(const char *str) +{ + if (strcmp("cpu", str) =3D=3D 0) + opt_sched_granularity =3D SCHED_GRAN_cpu; + else if (strcmp("core", str) =3D=3D 0) + opt_sched_granularity =3D SCHED_GRAN_core; + else if (strcmp("socket", str) =3D=3D 0) + opt_sched_granularity =3D SCHED_GRAN_socket; + else + return -EINVAL; + + return 0; +} +custom_param("sched-gran", sched_select_granularity); +#endif + /* Number of vcpus per struct sched_item. */ static unsigned int sched_granularity =3D 1; -const cpumask_t *sched_res_mask =3D &cpumask_all; +cpumask_var_t sched_res_mask; =20 /* Various timer handlers. */ static void s_timer_fn(void *unused); @@ -323,6 +346,8 @@ static void sched_free_item(struct sched_item *item, st= ruct vcpu *v) if ( item->vcpu =3D=3D v ) item->vcpu =3D v->next_in_list; =20 + item->runstate_cnt[v->runstate.state]--; + if ( !cnt ) sched_free_item_mem(item); } @@ -2113,8 +2138,14 @@ static int cpu_schedule_up(unsigned int cpu) sd =3D xzalloc(struct sched_resource); if ( sd =3D=3D NULL ) return -ENOMEM; + if ( !zalloc_cpumask_var(&sd->cpus) ) + { + xfree(sd); + return -ENOMEM; + } + sd->processor =3D cpu; - sd->cpus =3D cpumask_of(cpu); + cpumask_copy(sd->cpus, cpumask_of(cpu)); per_cpu(sched_res, cpu) =3D sd; =20 per_cpu(scheduler, cpu) =3D &ops; @@ -2170,30 +2201,92 @@ static int cpu_schedule_up(unsigned int cpu) return 0; } =20 +static void sched_free_sched_res(struct sched_resource *sd) +{ + kill_timer(&sd->s_timer); + free_cpumask_var(sd->cpus); + + xfree(sd); +} + static void cpu_schedule_down(unsigned int cpu) { struct sched_resource *sd =3D per_cpu(sched_res, cpu); struct scheduler *sched =3D per_cpu(scheduler, cpu); =20 + cpumask_clear_cpu(cpu, sd->cpus); + per_cpu(sched_res, cpu) =3D NULL; + + if ( cpumask_weight(sd->cpus) ) + return; + sched_free_pdata(sched, sd->sched_priv, cpu); sched_free_vdata(sched, idle_vcpu[cpu]->sched_item->priv); =20 idle_vcpu[cpu]->sched_item->priv =3D NULL; sd->sched_priv =3D NULL; + cpumask_clear_cpu(cpu, sched_res_mask); =20 - kill_timer(&sd->s_timer); - - xfree(per_cpu(sched_res, cpu)); - per_cpu(sched_res, cpu) =3D NULL; + sched_free_sched_res(sd); } =20 void scheduler_percpu_init(unsigned int cpu) { struct scheduler *sched =3D per_cpu(scheduler, cpu); struct sched_resource *sd =3D per_cpu(sched_res, cpu); + const cpumask_t *mask; + unsigned int master_cpu; + spinlock_t *lock; + struct sched_item *old_item, *master_item; + + if ( system_state =3D=3D SYS_STATE_resume ) + return; + + switch ( opt_sched_granularity ) + { + case SCHED_GRAN_cpu: + mask =3D cpumask_of(cpu); + break; + case SCHED_GRAN_core: + mask =3D per_cpu(cpu_sibling_mask, cpu); + break; + case SCHED_GRAN_socket: + mask =3D per_cpu(cpu_core_mask, cpu); + break; + default: + ASSERT_UNREACHABLE(); + return; + } =20 - if ( system_state !=3D SYS_STATE_resume ) + if ( cpu =3D=3D 0 || cpumask_weight(mask) =3D=3D 1 ) + { + cpumask_set_cpu(cpu, sched_res_mask); sched_init_pdata(sched, sd->sched_priv, cpu); + return; + } + + master_cpu =3D cpumask_first(mask); + master_item =3D idle_vcpu[master_cpu]->sched_item; + lock =3D pcpu_schedule_lock(master_cpu); + + /* Merge idle_vcpu item and sched_resource into master cpu. */ + old_item =3D idle_vcpu[cpu]->sched_item; + idle_vcpu[cpu]->sched_item =3D master_item; + per_cpu(sched_res, cpu) =3D per_cpu(sched_res, master_cpu); + per_cpu(sched_res_idx, cpu) =3D cpumask_weight(per_cpu(sched_res, cpu)= ->cpus); + cpumask_set_cpu(cpu, per_cpu(sched_res, cpu)->cpus); + master_item->runstate_cnt[RUNSTATE_running] +=3D + old_item->runstate_cnt[RUNSTATE_running]; + master_item->runstate_cnt[RUNSTATE_runnable] +=3D + old_item->runstate_cnt[RUNSTATE_runnable]; + + pcpu_schedule_unlock(lock, master_cpu); + + sched_free_pdata(sched, sd->sched_priv, cpu); + sched_free_vdata(sched, old_item->priv); + + sched_free_sched_res(sd); + sched_free_item_mem(old_item); } =20 static int cpu_schedule_callback( @@ -2273,6 +2366,51 @@ static struct notifier_block cpu_schedule_nfb =3D { .notifier_call =3D cpu_schedule_callback }; =20 +static unsigned int __init sched_check_granularity(void) +{ + unsigned int cpu; + unsigned int siblings, gran =3D 0; + + for_each_online_cpu( cpu ) + { + switch ( opt_sched_granularity ) + { + case SCHED_GRAN_cpu: + /* If granularity is "thread" we are fine already. */ + return 1; + case SCHED_GRAN_core: + siblings =3D cpumask_weight(per_cpu(cpu_sibling_mask, cpu)); + break; + case SCHED_GRAN_socket: + siblings =3D cpumask_weight(per_cpu(cpu_core_mask, cpu)); + break; + default: + ASSERT_UNREACHABLE(); + return 0; + } + + if ( gran =3D=3D 0 ) + gran =3D siblings; + else if ( gran !=3D siblings ) + return 0; + } + + return gran; +} + +/* Setup data for selected scheduler granularity. */ +void __init scheduler_smp_init(void) +{ + unsigned int gran; + + gran =3D sched_check_granularity(); + if ( gran =3D=3D 0 ) + panic("Illegal cpu configuration for scheduling granularity!\n" + "Please use thread scheduling.\n"); + + sched_granularity =3D gran; +} + /* Initialise the data structures. */ void __init scheduler_init(void) { @@ -2304,6 +2442,9 @@ void __init scheduler_init(void) printk("Using '%s' (%s)\n", ops.name, ops.opt_name); } =20 + if ( !zalloc_cpumask_var(&sched_res_mask) ) + BUG(); + if ( cpu_schedule_up(0) ) BUG(); register_cpu_notifier(&cpu_schedule_nfb); diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index f16d81ab4a..86525da77b 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -23,7 +23,7 @@ extern cpumask_t cpupool_free_cpus; extern int sched_ratelimit_us; =20 /* Scheduling resource mask. */ -extern const cpumask_t *sched_res_mask; +extern cpumask_var_t sched_res_mask; =20 /* * In order to allow a scheduler to remap the lock->cpu mapping, @@ -45,7 +45,7 @@ struct sched_resource { struct timer s_timer; /* scheduling timer = */ atomic_t urgent_count; /* how many urgent vcpus = */ unsigned processor; - const cpumask_t *cpus; /* cpus covered by this struct = */ + cpumask_var_t cpus; /* cpus covered by this struct = */ }; =20 #define curr_on_cpu(c) (per_cpu(sched_res, c)->curr) diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 5629602de5..0c37c2b55e 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -681,6 +681,7 @@ void noreturn asm_domain_crash_synchronous(unsigned lon= g addr); =20 void scheduler_init(void); void scheduler_percpu_init(unsigned int cpu); +void scheduler_smp_init(void); int sched_init_vcpu(struct vcpu *v); void sched_destroy_vcpu(struct vcpu *v); int sched_init_domain(struct domain *d, int poolid); --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel