From patchwork Tue Feb 11 12:15:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 11375331 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F3078921 for ; Tue, 11 Feb 2020 12:16:58 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CDE182082F for ; Tue, 11 Feb 2020 12:16:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CDE182082F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j1US2-0005we-6k; Tue, 11 Feb 2020 12:15:38 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j1US1-0005wZ-Cv for xen-devel@lists.xenproject.org; Tue, 11 Feb 2020 12:15:37 +0000 X-Inumbo-ID: 34de9588-4cc8-11ea-a96e-bc764e2007e4 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 34de9588-4cc8-11ea-a96e-bc764e2007e4; Tue, 11 Feb 2020 12:15:35 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id CAA34BBB2; Tue, 11 Feb 2020 12:15:34 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Tue, 11 Feb 2020 13:15:30 +0100 Message-Id: <20200211121530.11665-1-jgross@suse.com> X-Mailer: git-send-email 2.16.4 Subject: [Xen-devel] [PATCH v2] xen/sched: remove sched_init_pdata() 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 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" sched_init_pdata() is used nowhere, it can be removed. Same applies to the .init_pdata hook of the per-scheduler interface. The last caller has been removed with commit f855dd962523b6cb47a92037bdd28b1485141abe ("sched: add minimalistic idle scheduler for free cpus"). With the idle scheduler introduction the switch_sched hook became the only place where new cpus get added to a normal scheduler, so the init_pdata functionality is performed inside that hook. Adjust some comments as well to reflect reality. While at it correct a typo in a comment next to a modified comment. Signed-off-by: Juergen Gross Reviewed-by: Dario Faggioli --- xen/common/sched/core.c | 9 ++++----- xen/common/sched/credit.c | 12 ------------ xen/common/sched/credit2.c | 21 --------------------- xen/common/sched/null.c | 10 ---------- xen/common/sched/private.h | 8 -------- xen/common/sched/rt.c | 31 ------------------------------- 6 files changed, 4 insertions(+), 87 deletions(-) diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c index d4e8944e0e..2e43f8029f 100644 --- a/xen/common/sched/core.c +++ b/xen/common/sched/core.c @@ -2775,10 +2775,10 @@ static int cpu_schedule_callback( * order. If no per-pCPU memory was allocated, there is no need to * provide an implementation of free_pdata. deinit_pdata may, however, * be necessary/useful in this case too (e.g., it can undo something done - * on scheduler wide data structure during init_pdata). Both deinit_pdata + * on scheduler wide data structure during switch_sched). Both deinit_pdata * and free_pdata are called during CPU_DEAD. * - * If someting goes wrong during bringup, we go to CPU_UP_CANCELLED. + * If something goes wrong during bringup, we go to CPU_UP_CANCELLED. */ switch ( action ) { @@ -2968,9 +2968,8 @@ int schedule_cpu_add(unsigned int cpu, struct cpupool *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_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. + * initialize it yet, as 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 idle * 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. diff --git a/xen/common/sched/credit.c b/xen/common/sched/credit.c index 05946eea6e..93d89da278 100644 --- a/xen/common/sched/credit.c +++ b/xen/common/sched/credit.c @@ -614,17 +614,6 @@ init_pdata(struct csched_private *prv, struct csched_pcpu *spc, int cpu) spc->nr_runnable = 0; } -static void -csched_init_pdata(const struct scheduler *ops, void *pdata, int cpu) -{ - unsigned long flags; - struct csched_private *prv = CSCHED_PRIV(ops); - - spin_lock_irqsave(&prv->lock, flags); - init_pdata(prv, pdata, cpu); - spin_unlock_irqrestore(&prv->lock, flags); -} - /* Change the scheduler of cpu to us (Credit). */ static spinlock_t * csched_switch_sched(struct scheduler *new_ops, unsigned int cpu, @@ -2273,7 +2262,6 @@ static const struct scheduler sched_credit_def = { .alloc_udata = csched_alloc_udata, .free_udata = csched_free_udata, .alloc_pdata = csched_alloc_pdata, - .init_pdata = csched_init_pdata, .deinit_pdata = csched_deinit_pdata, .free_pdata = csched_free_pdata, .switch_sched = csched_switch_sched, diff --git a/xen/common/sched/credit2.c b/xen/common/sched/credit2.c index f2752f27e2..7d104f15d0 100644 --- a/xen/common/sched/credit2.c +++ b/xen/common/sched/credit2.c @@ -3816,26 +3816,6 @@ init_pdata(struct csched2_private *prv, struct csched2_pcpu *spc, return spc->runq_id; } -static void -csched2_init_pdata(const struct scheduler *ops, void *pdata, int cpu) -{ - struct csched2_private *prv = csched2_priv(ops); - spinlock_t *old_lock; - unsigned long flags; - unsigned rqi; - - write_lock_irqsave(&prv->lock, flags); - old_lock = pcpu_schedule_lock(cpu); - - rqi = init_pdata(prv, pdata, cpu); - /* Move the scheduler lock to the new runq lock. */ - get_sched_res(cpu)->schedule_lock = &prv->rqd[rqi].lock; - - /* _Not_ pcpu_schedule_unlock(): schedule_lock may have changed! */ - spin_unlock(old_lock); - write_unlock_irqrestore(&prv->lock, flags); -} - /* Change the scheduler of cpu to us (Credit2). */ static spinlock_t * csched2_switch_sched(struct scheduler *new_ops, unsigned int cpu, @@ -4083,7 +4063,6 @@ static const struct scheduler sched_credit2_def = { .alloc_udata = csched2_alloc_udata, .free_udata = csched2_free_udata, .alloc_pdata = csched2_alloc_pdata, - .init_pdata = csched2_init_pdata, .deinit_pdata = csched2_deinit_pdata, .free_pdata = csched2_free_pdata, .switch_sched = csched2_switch_sched, diff --git a/xen/common/sched/null.c b/xen/common/sched/null.c index 8c3101649d..82d5d1baab 100644 --- a/xen/common/sched/null.c +++ b/xen/common/sched/null.c @@ -166,15 +166,6 @@ static void init_pdata(struct null_private *prv, struct null_pcpu *npc, npc->unit = NULL; } -static void null_init_pdata(const struct scheduler *ops, void *pdata, int cpu) -{ - struct null_private *prv = null_priv(ops); - - ASSERT(pdata); - - init_pdata(prv, pdata, cpu); -} - static void null_deinit_pdata(const struct scheduler *ops, void *pcpu, int cpu) { struct null_private *prv = null_priv(ops); @@ -1042,7 +1033,6 @@ static const struct scheduler sched_null_def = { .deinit = null_deinit, .alloc_pdata = null_alloc_pdata, .free_pdata = null_free_pdata, - .init_pdata = null_init_pdata, .switch_sched = null_switch_sched, .deinit_pdata = null_deinit_pdata, diff --git a/xen/common/sched/private.h b/xen/common/sched/private.h index 2a94179baa..367811a12f 100644 --- a/xen/common/sched/private.h +++ b/xen/common/sched/private.h @@ -306,7 +306,6 @@ struct scheduler { struct sched_unit *, void *); void (*free_pdata) (const struct scheduler *, void *, int); void * (*alloc_pdata) (const struct scheduler *, int); - void (*init_pdata) (const struct scheduler *, void *, int); void (*deinit_pdata) (const struct scheduler *, void *, int); /* Returns ERR_PTR(-err) for error, NULL for 'nothing needed'. */ @@ -408,13 +407,6 @@ static inline void sched_free_pdata(const struct scheduler *s, void *data, s->free_pdata(s, data, cpu); } -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 *data, int cpu) { diff --git a/xen/common/sched/rt.c b/xen/common/sched/rt.c index 66585ed50a..c24cd2ac32 100644 --- a/xen/common/sched/rt.c +++ b/xen/common/sched/rt.c @@ -713,36 +713,6 @@ rt_deinit(struct scheduler *ops) xfree(prv); } -/* - * Point per_cpu spinlock to the global system lock; - * All cpu have same global system lock - */ -static void -rt_init_pdata(const struct scheduler *ops, void *pdata, int cpu) -{ - struct rt_private *prv = rt_priv(ops); - spinlock_t *old_lock; - unsigned long flags; - - old_lock = pcpu_schedule_lock_irqsave(cpu, &flags); - - /* - * TIMER_STATUS_invalid means we are the first cpu that sees the timer - * allocated but not initialized, and so it's up to us to initialize it. - */ - if ( prv->repl_timer.status == TIMER_STATUS_invalid ) - { - init_timer(&prv->repl_timer, repl_timer_handler, (void *)ops, cpu); - dprintk(XENLOG_DEBUG, "RTDS: timer initialized on cpu %u\n", cpu); - } - - /* Move the scheduler lock to our global runqueue lock. */ - get_sched_res(cpu)->schedule_lock = &prv->lock; - - /* _Not_ pcpu_schedule_unlock(): per_cpu().schedule_lock changed! */ - spin_unlock_irqrestore(old_lock, flags); -} - /* Change the scheduler of cpu to us (RTDS). */ static spinlock_t * rt_switch_sched(struct scheduler *new_ops, unsigned int cpu, @@ -1568,7 +1538,6 @@ static const struct scheduler sched_rtds_def = { .dump_settings = rt_dump, .init = rt_init, .deinit = rt_deinit, - .init_pdata = rt_init_pdata, .switch_sched = rt_switch_sched, .deinit_pdata = rt_deinit_pdata, .alloc_domdata = rt_alloc_domdata,