From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dario Faggioli Subject: [PATCH 2/3] xen: sched: add wakeup flags to the scheduler interface Date: Thu, 11 Feb 2016 12:38:53 +0100 Message-ID: <20160211113853.20959.36796.stgit@Solace.station> References: <20160211113321.20959.53804.stgit@Solace.station> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aTpaM-0005vd-DG for xen-devel@lists.xenproject.org; Thu, 11 Feb 2016 11:38:58 +0000 Received: by mail-wm0-f65.google.com with SMTP id g62so10140135wme.2 for ; Thu, 11 Feb 2016 03:38:56 -0800 (PST) In-Reply-To: <20160211113321.20959.53804.stgit@Solace.station> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: George Dunlap , Josh Whitehead , Meng Xu , Robert VanVossen List-Id: xen-devel@lists.xenproject.org For making it possible to pass to the specific scheduler code information about the nature of the wakeup, and let it act accordingly, if necessary. For now, this will only be useful to Credit1, that needs to differentiate between 'regular' wakeups (happening, for instance, because an I/O event), and wakeups "artificially induced" for migrating a vCPU to another pCPU. In this patch, only the WF_wakeup flag is introduced, and used everything. In fact, instead of changing the prototype of vcpu_wake(), the _vcpu_wake() helper is introduced. This can change, in case, at some point, the majority of wakeup paths will end up wanting to pass a flag. Signed-off-by: Dario Faggioli --- Cc: George Dunlap Cc: Josh Whitehead Cc: Robert VanVossen Cc: Meng Xu --- xen/common/sched_arinc653.c | 2 +- xen/common/sched_credit.c | 2 +- xen/common/sched_credit2.c | 2 +- xen/common/sched_rt.c | 2 +- xen/common/schedule.c | 9 +++++++-- xen/include/xen/sched-if.h | 3 ++- xen/include/xen/sched.h | 7 +++++++ 7 files changed, 20 insertions(+), 7 deletions(-) diff --git a/xen/common/sched_arinc653.c b/xen/common/sched_arinc653.c index 0606988..b8ea596 100644 --- a/xen/common/sched_arinc653.c +++ b/xen/common/sched_arinc653.c @@ -537,7 +537,7 @@ a653sched_vcpu_sleep(const struct scheduler *ops, struct vcpu *vc) * @param vc Pointer to the VCPU structure for the current domain */ static void -a653sched_vcpu_wake(const struct scheduler *ops, struct vcpu *vc) +a653sched_vcpu_wake(const struct scheduler *ops, struct vcpu *vc, unsigned wf) { if ( AVCPU(vc) != NULL ) AVCPU(vc)->awake = 1; diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index 5708701..f728ddd 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -983,7 +983,7 @@ csched_vcpu_sleep(const struct scheduler *ops, struct vcpu *vc) } static void -csched_vcpu_wake(const struct scheduler *ops, struct vcpu *vc) +csched_vcpu_wake(const struct scheduler *ops, struct vcpu *vc, unsigned wf) { struct csched_vcpu * const svc = CSCHED_VCPU(vc); const unsigned int cpu = vc->processor; diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index 78220a7..a8ba61d 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -940,7 +940,7 @@ csched2_vcpu_sleep(const struct scheduler *ops, struct vcpu *vc) } static void -csched2_vcpu_wake(const struct scheduler *ops, struct vcpu *vc) +csched2_vcpu_wake(const struct scheduler *ops, struct vcpu *vc, unsigned wf) { struct csched2_vcpu * const svc = CSCHED2_VCPU(vc); s_time_t now = 0; diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index 2e5430f..4ee1fce 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -1022,7 +1022,7 @@ out: * TODO: what if these two vcpus belongs to the same domain? */ static void -rt_vcpu_wake(const struct scheduler *ops, struct vcpu *vc) +rt_vcpu_wake(const struct scheduler *ops, struct vcpu *vc, unsigned wf) { struct rt_vcpu * const svc = rt_vcpu(vc); s_time_t now = NOW(); diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 7306d71..ea74c96 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -406,7 +406,7 @@ void vcpu_sleep_sync(struct vcpu *v) sync_vcpu_execstate(v); } -void vcpu_wake(struct vcpu *v) +static void _vcpu_wake(struct vcpu *v, unsigned wake_flags) { unsigned long flags; spinlock_t *lock = vcpu_schedule_lock_irqsave(v, &flags); @@ -415,7 +415,7 @@ void vcpu_wake(struct vcpu *v) { if ( v->runstate.state >= RUNSTATE_blocked ) vcpu_runstate_change(v, RUNSTATE_runnable, NOW()); - SCHED_OP(VCPU2OP(v), wake, v); + SCHED_OP(VCPU2OP(v), wake, v, wake_flags); } else if ( !(v->pause_flags & VPF_blocked) ) { @@ -428,6 +428,11 @@ void vcpu_wake(struct vcpu *v) TRACE_2D(TRC_SCHED_WAKE, v->domain->domain_id, v->vcpu_id); } +void vcpu_wake(struct vcpu *v) +{ + return _vcpu_wake(v, WF_wakeup); +} + void vcpu_unblock(struct vcpu *v) { if ( !test_and_clear_bit(_VPF_blocked, &v->pause_flags) ) diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index 66dc9c8..ea1cd4a 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -144,7 +144,8 @@ struct scheduler { void (*remove_vcpu) (const struct scheduler *, struct vcpu *); void (*sleep) (const struct scheduler *, struct vcpu *); - void (*wake) (const struct scheduler *, struct vcpu *); + void (*wake) (const struct scheduler *, struct vcpu *, + unsigned int); void (*yield) (const struct scheduler *, struct vcpu *); void (*context_saved) (const struct scheduler *, struct vcpu *); diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index b47a3fe..9fdcfff 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -758,6 +758,13 @@ static inline struct domain *next_domain_in_cpupool( #define _VPF_in_reset 7 #define VPF_in_reset (1UL<<_VPF_in_reset) +/* + * VCPU wake up flags. + */ +/* 'Default' wakeup. */ +#define _WF_wakeup 0 +#define WF_wakeup (1U<<_WF_wakeup) + static inline int vcpu_runnable(struct vcpu *v) { return !(v->pause_flags |