From: Dario Faggioli Subject: [PATCH 2/7] xen: sched_rt: implement the .free_pdata hook Date: Mon, 16 Mar 2015 18:04:58 +0100 Message-ID: <20150316170458.10279.60102.stgit@Solace.station> References: <20150316165642.10279.86684.stgit@Solace.station> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20150316165642.10279.86684.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 Cc: George Dunlap , Keir Fraser , Meng Xu , Jan Beulich List-Id: xen-devel@lists.xenproject.org which is called by cpu_schedule_down(), and is necessary for resetting the spinlock pointers in schedule_data from the RTDS global runqueue lock, back to the default _lock fields in the struct. Not doing so causes Xen to explode, e.g., when removing pCPUs from an RTDS cpupool and assigning them to another one. Signed-off-by: Dario Faggioli Cc: George Dunlap Cc: Meng Xu Cc: Jan Beulich Cc: Keir Fraser --- xen/common/sched_rt.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/xen/common/sched_rt.c b/xen/common/sched_rt.c index 055a50f..3e37e62 100644 --- a/xen/common/sched_rt.c +++ b/xen/common/sched_rt.c @@ -444,6 +444,23 @@ rt_alloc_pdata(const struct scheduler *ops, int cpu) return (void *)1; } +static void +rt_free_pdata(const struct scheduler *ops, void *pcpu, int cpu) +{ + struct rt_private *prv = rt_priv(ops); + struct schedule_data *sd = &per_cpu(schedule_data, cpu); + unsigned long flags; + + spin_lock_irqsave(&prv->lock, flags); + + /* Move spinlock back to the default lock */ + ASSERT(sd->schedule_lock == &prv->lock); + ASSERT(!spin_is_locked(&sd->_lock)); + sd->schedule_lock = &sd->_lock; + + spin_unlock_irqrestore(&prv->lock, flags); +} + static void * rt_alloc_domdata(const struct scheduler *ops, struct domain *dom) { @@ -1090,6 +1107,7 @@ const struct scheduler sched_rtds_def = { .init = rt_init, .deinit = rt_deinit, .alloc_pdata = rt_alloc_pdata, + .free_pdata = rt_free_pdata, .alloc_domdata = rt_alloc_domdata, .free_domdata = rt_free_domdata, .init_domain = rt_dom_init,