From nobody Fri Mar 29 09:50:12 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=1568021693; cv=none; d=zoho.com; s=zohoarc; b=J87p3+1CyTNTUpJJRR1DHvAIPY4kWNcK9znJPI0Zwt1uDhBL1uMutNDyGuqUQouKSjTWjDTfiEw2+Mxl/Fq6gFa+VGfk6yn/xh4o0oESZC5tiRY8eOtfxxDj1bwcMlLbW5O0EZLieYFX8CJUpR/UuW3pIbojs8Etq2nHkqNqeGc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568021693; 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=f1QTX/v3OSN6RMpRV606jPjQozpdk1iSO2iy/9j9QZQ=; b=ENUHCFRHySqDkuhrHP99URaXwhFlWCtboudwpmb/+SrNlFiR1iEHqInZeIuZBFHn7yNloYP1wX6v6s0uEpXr2Vi7dUuyFu3iZgJ8WZ/XPGGYlDJw0td6QOFvTcUkivCRy1wEXZZoMR9WDw41m4TYdq3QKjcNMWoKIE15WAq3fAE= 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 1568021693318824.6840044985425; Mon, 9 Sep 2019 02:34:53 -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 1i7G3N-0006W8-91; Mon, 09 Sep 2019 09:33:45 +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 1i7G3M-0006Vy-FM for xen-devel@lists.xenproject.org; Mon, 09 Sep 2019 09:33:44 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id e96cb970-d2e4-11e9-ac09-12813bfff9fa; Mon, 09 Sep 2019 09:33:42 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id D39BDB65E; Mon, 9 Sep 2019 09:33:41 +0000 (UTC) X-Inumbo-ID: e96cb970-d2e4-11e9-ac09-12813bfff9fa X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 9 Sep 2019 11:33:36 +0200 Message-Id: <20190909093339.7134-2-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190909093339.7134-1-jgross@suse.com> References: <20190909093339.7134-1-jgross@suse.com> Subject: [Xen-devel] [PATCH v3 1/4] xen/sched: populate cpupool0 only after all cpus are up 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 , 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" Simplify cpupool initialization by populating cpupool0 with cpus only after all cpus are up. This avoids having to call the cpu notifier directly for cpu 0. With that in place there is no need to create cpupool0 earlier, so do that just before assigning the cpus. Initialize free cpus with all online cpus at that time in order to be able to add the cpu notifier late, too. Signed-off-by: Juergen Gross Reviewed-by: Dario Faggioli --- V1: new patch --- xen/common/cpupool.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/xen/common/cpupool.c b/xen/common/cpupool.c index f90e496eda..caea5bd8b3 100644 --- a/xen/common/cpupool.c +++ b/xen/common/cpupool.c @@ -762,18 +762,28 @@ static struct notifier_block cpu_nfb =3D { .notifier_call =3D cpu_callback }; =20 -static int __init cpupool_presmp_init(void) +static int __init cpupool_init(void) { + unsigned int cpu; int err; - void *cpu =3D (void *)(long)smp_processor_id(); + cpupool0 =3D cpupool_create(0, 0, &err); BUG_ON(cpupool0 =3D=3D NULL); cpupool_put(cpupool0); - cpu_callback(&cpu_nfb, CPU_ONLINE, cpu); register_cpu_notifier(&cpu_nfb); + + spin_lock(&cpupool_lock); + + cpumask_copy(&cpupool_free_cpus, &cpu_online_map); + + for_each_cpu ( cpu, &cpupool_free_cpus ) + cpupool_assign_cpu_locked(cpupool0, cpu); + + spin_unlock(&cpupool_lock); + return 0; } -presmp_initcall(cpupool_presmp_init); +__initcall(cpupool_init); =20 /* * Local variables: --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri Mar 29 09:50:12 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=1568021718; cv=none; d=zoho.com; s=zohoarc; b=DQvqWVFrzxA800oWmD9MJ6UIrQDYTWYcIudAusv5vxIRnTZThrsaf0VyN2v/L/jATa6yXyTLEWFSfEOfMWOO7pK4O5tRwn3ByVHH0vdNAEw2Sm6d3iY9/PS1nwumk0A2FGXDvTOl4M4Yq1tRyjIfzrEXdpjpyWbJr00YmP9slds= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568021718; 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=v03WBlxujzjSMO/f+Wi7UR2ta2/EujjAJBg/0jp7AA0=; b=UPXsvCcU2e5KsXDKrQsfHX7DtI1cfRVhqho9upX7Ek1rLcVoAEf+DiKXro6MGyTZB5zlaDBSspB5UgjZP8vCMR5sHYVWdb0I4YbOs5c8LAUEe+e+86wDXw4aVAXYyc73obVaQg5Osc53aj4q1cj7MN3JC6uSktB/Kv9ojZ6L14Q= 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 1568021718218265.70336599184327; Mon, 9 Sep 2019 02:35:18 -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 1i7G3c-0006cY-Nr; Mon, 09 Sep 2019 09:34:00 +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 1i7G3b-0006bs-Bx for xen-devel@lists.xenproject.org; Mon, 09 Sep 2019 09:33:59 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id ea6b5b7e-d2e4-11e9-ac09-12813bfff9fa; Mon, 09 Sep 2019 09:33:44 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 4FE2EB660; Mon, 9 Sep 2019 09:33:43 +0000 (UTC) X-Inumbo-ID: ea6b5b7e-d2e4-11e9-ac09-12813bfff9fa X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 9 Sep 2019 11:33:37 +0200 Message-Id: <20190909093339.7134-3-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190909093339.7134-1-jgross@suse.com> References: <20190909093339.7134-1-jgross@suse.com> Subject: [Xen-devel] [PATCH v3 2/4] xen/sched: remove cpu from pool0 before removing it 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" Today a cpu which is removed from the system is taken directly from Pool0 to the offline state. This will conflict with the new idle scheduler, so remove it from Pool0 first. Additionally accept removing a free cpu instead of requiring it to be in Pool0. For the resume failed case we need to call the scheduler code for that situation after the cpupool handling, so move the scheduler code into a function and call it from cpupool_cpu_remove_forced() and remove the CPU_RESUME_FAILED case from cpu_schedule_callback(). Note that we are calling now schedule_cpu_switch() in stop_machine context so we need to switch from spinlock_irq to spinlock_irqsave. Signed-off-by: Juergen Gross --- V2: rename cpupool_unassign_cpu_[epi|pro]logue() (Dario Faggioli) --- xen/common/cpupool.c | 176 +++++++++++++++++++++++++++--------------= ---- xen/common/schedule.c | 27 ++++--- xen/include/xen/sched-if.h | 2 + 3 files changed, 128 insertions(+), 77 deletions(-) diff --git a/xen/common/cpupool.c b/xen/common/cpupool.c index caea5bd8b3..15e7004df4 100644 --- a/xen/common/cpupool.c +++ b/xen/common/cpupool.c @@ -282,22 +282,14 @@ static int cpupool_assign_cpu_locked(struct cpupool *= c, unsigned int cpu) return 0; } =20 -static long cpupool_unassign_cpu_helper(void *info) +static int cpupool_unassign_cpu_finish(struct cpupool *c) { int cpu =3D cpupool_moving_cpu; - struct cpupool *c =3D info; struct domain *d; - long ret; - - cpupool_dprintk("cpupool_unassign_cpu(pool=3D%d,cpu=3D%d)\n", - cpupool_cpu_moving->cpupool_id, cpu); + int ret; =20 - spin_lock(&cpupool_lock); if ( c !=3D cpupool_cpu_moving ) - { - ret =3D -EADDRNOTAVAIL; - goto out; - } + return -EADDRNOTAVAIL; =20 /* * We need this for scanning the domain list, both in @@ -332,39 +324,19 @@ static long cpupool_unassign_cpu_helper(void *info) domain_update_node_affinity(d); } rcu_read_unlock(&domlist_read_lock); -out: - spin_unlock(&cpupool_lock); - cpupool_dprintk("cpupool_unassign_cpu ret=3D%ld\n", ret); + return ret; } =20 -/* - * unassign a specific cpu from a cpupool - * we must be sure not to run on the cpu to be unassigned! to achieve this - * the main functionality is performed via continue_hypercall_on_cpu on a - * specific cpu. - * if the cpu to be removed is the last one of the cpupool no active domain - * must be bound to the cpupool. dying domains are moved to cpupool0 as th= ey - * might be zombies. - * possible failures: - * - last cpu and still active domains in cpupool - * - cpu just being unplugged - */ -static int cpupool_unassign_cpu(struct cpupool *c, unsigned int cpu) +static int cpupool_unassign_cpu_start(struct cpupool *c, unsigned int cpu) { - int work_cpu; int ret; struct domain *d; =20 - cpupool_dprintk("cpupool_unassign_cpu(pool=3D%d,cpu=3D%d)\n", - c->cpupool_id, cpu); - spin_lock(&cpupool_lock); ret =3D -EADDRNOTAVAIL; if ( (cpupool_moving_cpu !=3D -1) && (cpu !=3D cpupool_moving_cpu) ) goto out; - if ( cpumask_test_cpu(cpu, &cpupool_locked_cpus) ) - goto out; =20 ret =3D 0; if ( !cpumask_test_cpu(cpu, c->cpu_valid) && (cpu !=3D cpupool_moving_= cpu) ) @@ -376,7 +348,7 @@ static int cpupool_unassign_cpu(struct cpupool *c, unsi= gned int cpu) rcu_read_lock(&domlist_read_lock); for_each_domain_in_cpupool(d, c) { - if ( !d->is_dying ) + if ( !d->is_dying && system_state =3D=3D SYS_STATE_active ) { ret =3D -EBUSY; break; @@ -393,7 +365,57 @@ static int cpupool_unassign_cpu(struct cpupool *c, uns= igned int cpu) atomic_inc(&c->refcnt); cpupool_cpu_moving =3D c; cpumask_clear_cpu(cpu, c->cpu_valid); + +out: + spin_unlock(&cpupool_lock); + + return ret; +} + +static long cpupool_unassign_cpu_helper(void *info) +{ + struct cpupool *c =3D info; + long ret; + + cpupool_dprintk("cpupool_unassign_cpu(pool=3D%d,cpu=3D%d)\n", + cpupool_cpu_moving->cpupool_id, cpupool_moving_cpu); + spin_lock(&cpupool_lock); + + ret =3D cpupool_unassign_cpu_finish(c); + spin_unlock(&cpupool_lock); + cpupool_dprintk("cpupool_unassign_cpu ret=3D%ld\n", ret); + + return ret; +} + +/* + * unassign a specific cpu from a cpupool + * we must be sure not to run on the cpu to be unassigned! to achieve this + * the main functionality is performed via continue_hypercall_on_cpu on a + * specific cpu. + * if the cpu to be removed is the last one of the cpupool no active domain + * must be bound to the cpupool. dying domains are moved to cpupool0 as th= ey + * might be zombies. + * possible failures: + * - last cpu and still active domains in cpupool + * - cpu just being unplugged + */ +static int cpupool_unassign_cpu(struct cpupool *c, unsigned int cpu) +{ + int work_cpu; + int ret; + + cpupool_dprintk("cpupool_unassign_cpu(pool=3D%d,cpu=3D%d)\n", + c->cpupool_id, cpu); + + ret =3D cpupool_unassign_cpu_start(c, cpu); + if ( ret ) + { + cpupool_dprintk("cpupool_unassign_cpu(pool=3D%d,cpu=3D%d) ret %d\n= ", + c->cpupool_id, cpu, ret); + return ret; + } =20 work_cpu =3D smp_processor_id(); if ( work_cpu =3D=3D cpu ) @@ -403,12 +425,6 @@ static int cpupool_unassign_cpu(struct cpupool *c, uns= igned int cpu) work_cpu =3D cpumask_next(cpu, cpupool0->cpu_valid); } return continue_hypercall_on_cpu(work_cpu, cpupool_unassign_cpu_helper= , c); - -out: - spin_unlock(&cpupool_lock); - cpupool_dprintk("cpupool_unassign_cpu(pool=3D%d,cpu=3D%d) ret %d\n", - c->cpupool_id, cpu, ret); - return ret; } =20 /* @@ -492,30 +508,54 @@ static int cpupool_cpu_add(unsigned int cpu) } =20 /* - * Called to remove a CPU from a pool. The CPU is locked, to forbid removi= ng - * it from pool0. In fact, if we want to hot-unplug a CPU, it must belong = to - * pool0, or we fail. + * This function is called in stop_machine context, so we can be sure no + * non-idle vcpu is active on the system. */ -static int cpupool_cpu_remove(unsigned int cpu) +static void cpupool_cpu_remove(unsigned int cpu) { - int ret =3D -ENODEV; + int ret; =20 - spin_lock(&cpupool_lock); + ASSERT(is_idle_vcpu(current)); =20 - if ( cpumask_test_cpu(cpu, cpupool0->cpu_valid) ) + if ( !cpumask_test_cpu(cpu, &cpupool_free_cpus) ) { - /* - * If we are not suspending, we are hot-unplugging cpu, and that is - * allowed only for CPUs in pool0. - */ - cpumask_clear_cpu(cpu, cpupool0->cpu_valid); - ret =3D 0; + ret =3D cpupool_unassign_cpu_finish(cpupool0); + BUG_ON(ret); } +} =20 - if ( !ret ) +/* + * Called before a CPU is being removed from the system. + * Removing a CPU is allowed for free CPUs or CPUs in Pool-0 (those are mo= ved + * to free cpus actually before removing them). + * The CPU is locked, to forbid adding it again to another cpupool. + */ +static int cpupool_cpu_remove_prologue(unsigned int cpu) +{ + int ret =3D 0; + + spin_lock(&cpupool_lock); + + if ( cpumask_test_cpu(cpu, &cpupool_locked_cpus) ) + ret =3D -EBUSY; + else cpumask_set_cpu(cpu, &cpupool_locked_cpus); + spin_unlock(&cpupool_lock); =20 + if ( ret ) + return ret; + + if ( cpumask_test_cpu(cpu, cpupool0->cpu_valid) ) + { + /* Cpupool0 is populated only after all cpus are up. */ + ASSERT(system_state =3D=3D SYS_STATE_active); + + ret =3D cpupool_unassign_cpu_start(cpupool0, cpu); + } + else if ( !cpumask_test_cpu(cpu, &cpupool_free_cpus) ) + ret =3D -ENODEV; + return ret; } =20 @@ -523,13 +563,13 @@ static int cpupool_cpu_remove(unsigned int cpu) * Called during resume for all cpus which didn't come up again. The cpu m= ust * be removed from the cpupool it is assigned to. In case a cpupool will be * left without cpu we move all domains of that cpupool to cpupool0. + * As we are called with all domains still frozen there is no need to take= the + * cpupool lock here. */ static void cpupool_cpu_remove_forced(unsigned int cpu) { struct cpupool **c; - struct domain *d; - - spin_lock(&cpupool_lock); + int ret; =20 if ( cpumask_test_cpu(cpu, &cpupool_free_cpus) ) cpumask_clear_cpu(cpu, &cpupool_free_cpus); @@ -539,19 +579,13 @@ static void cpupool_cpu_remove_forced(unsigned int cp= u) { if ( cpumask_test_cpu(cpu, (*c)->cpu_valid) ) { - cpumask_clear_cpu(cpu, (*c)->cpu_valid); - if ( cpumask_weight((*c)->cpu_valid) =3D=3D 0 ) - { - if ( *c =3D=3D cpupool0 ) - panic("No cpu left in cpupool0\n"); - for_each_domain_in_cpupool(d, *c) - cpupool_move_domain_locked(d, cpupool0); - } + ret =3D cpupool_unassign_cpu(*c, cpu); + BUG_ON(ret); } } } =20 - spin_unlock(&cpupool_lock); + sched_rm_cpu(cpu); } =20 /* @@ -619,7 +653,8 @@ int cpupool_do_sysctl(struct xen_sysctl_cpupool_op *op) if ( cpu >=3D nr_cpu_ids ) goto addcpu_out; ret =3D -ENODEV; - if ( !cpumask_test_cpu(cpu, &cpupool_free_cpus) ) + if ( !cpumask_test_cpu(cpu, &cpupool_free_cpus) || + cpumask_test_cpu(cpu, &cpupool_locked_cpus) ) goto addcpu_out; c =3D cpupool_find_by_id(op->cpupool_id); ret =3D -ENOENT; @@ -746,7 +781,12 @@ static int cpu_callback( case CPU_DOWN_PREPARE: /* Suspend/Resume don't change assignments of cpus to cpupools. */ if ( system_state <=3D SYS_STATE_active ) - rc =3D cpupool_cpu_remove(cpu); + rc =3D cpupool_cpu_remove_prologue(cpu); + break; + case CPU_DYING: + /* Suspend/Resume don't change assignments of cpus to cpupools. */ + if ( system_state <=3D SYS_STATE_active ) + cpupool_cpu_remove(cpu); break; case CPU_RESUME_FAILED: cpupool_cpu_remove_forced(cpu); diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 7b71581756..93164c64f6 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -1654,6 +1654,20 @@ static void cpu_schedule_down(unsigned int cpu) kill_timer(&sd->s_timer); } =20 +void sched_rm_cpu(unsigned int cpu) +{ + int rc; + struct schedule_data *sd =3D &per_cpu(schedule_data, cpu); + struct scheduler *sched =3D per_cpu(scheduler, cpu); + + rcu_read_lock(&domlist_read_lock); + rc =3D cpu_disable_scheduler(cpu); + BUG_ON(rc); + rcu_read_unlock(&domlist_read_lock); + sched_deinit_pdata(sched, sd->sched_priv, cpu); + cpu_schedule_down(cpu); +} + static int cpu_schedule_callback( struct notifier_block *nfb, unsigned long action, void *hcpu) { @@ -1709,16 +1723,10 @@ static int cpu_schedule_callback( rc =3D cpu_disable_scheduler_check(cpu); rcu_read_unlock(&domlist_read_lock); break; - case CPU_RESUME_FAILED: case CPU_DEAD: if ( system_state =3D=3D SYS_STATE_suspend ) break; - rcu_read_lock(&domlist_read_lock); - rc =3D cpu_disable_scheduler(cpu); - BUG_ON(rc); - rcu_read_unlock(&domlist_read_lock); - sched_deinit_pdata(sched, sd->sched_priv, cpu); - cpu_schedule_down(cpu); + sched_rm_cpu(cpu); break; case CPU_UP_CANCELED: if ( system_state !=3D SYS_STATE_resume ) @@ -1841,6 +1849,7 @@ int schedule_cpu_switch(unsigned int cpu, struct cpup= ool *c) struct cpupool *old_pool =3D per_cpu(cpupool, cpu); struct schedule_data *sd =3D &per_cpu(schedule_data, cpu); spinlock_t *old_lock, *new_lock; + unsigned long flags; =20 /* * pCPUs only move from a valid cpupool to free (i.e., out of any pool= ), @@ -1895,7 +1904,7 @@ int schedule_cpu_switch(unsigned int cpu, struct cpup= ool *c) * that the lock itself changed, and retry acquiring the new one (which * will be the correct, remapped one, at that point). */ - old_lock =3D pcpu_schedule_lock_irq(cpu); + old_lock =3D pcpu_schedule_lock_irqsave(cpu, &flags); =20 vpriv_old =3D idle->sched_priv; ppriv_old =3D sd->sched_priv; @@ -1913,7 +1922,7 @@ int schedule_cpu_switch(unsigned int cpu, struct cpup= ool *c) sd->schedule_lock =3D new_lock; =20 /* _Not_ pcpu_schedule_unlock(): schedule_lock may have changed! */ - spin_unlock_irq(old_lock); + spin_unlock_irqrestore(old_lock, flags); =20 sched_do_tick_resume(new_ops, cpu); =20 diff --git a/xen/include/xen/sched-if.h b/xen/include/xen/sched-if.h index d82ead586a..dc255b064b 100644 --- a/xen/include/xen/sched-if.h +++ b/xen/include/xen/sched-if.h @@ -437,4 +437,6 @@ affinity_balance_cpumask(const struct vcpu *v, int step= , cpumask_t *mask) cpumask_copy(mask, v->cpu_hard_affinity); } =20 +void sched_rm_cpu(unsigned int cpu); + #endif /* __XEN_SCHED_IF_H__ */ --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri Mar 29 09:50:12 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=1568021694; cv=none; d=zoho.com; s=zohoarc; b=NwDbn5SslVzk8Fpz9mvjRsB/XP0GYadAwfFzetvW/6bUxrXIbmNlwXtNAGdYD0tfJ2hreSncSO+RtI7MAaWF52eMt2sAZaBVr9NZEzDLhQdDFv/ak0/ptJq/Lbvwqje+FCZfVBVL9KVX3T84Ydaibdz3wIobXn+nzHruuVhEEJ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568021694; 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=/1dZMEhjmoqJhISf1SjaTWS6oA4L6k+6nqPMkVU8RSk=; b=S210iuaB9CE6Pj1eURXOWdkOLd8oGJOwnJE4qqu397ZNVM17J3mPDpY2dcU1TKXh7tr+CTvRW7YfWOVoe07twXBxUd0f1VopRI96sc7xhueheXo9Zn9RofQnhE4ebrBOPMmJyoE9BbRSMixOJ9rDNheBNdlC0IYR5abhQIz32ak= 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 1568021694820862.2193625557551; Mon, 9 Sep 2019 02:34:54 -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 1i7G3N-0006WE-Im; Mon, 09 Sep 2019 09:33:45 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i7G3M-0006Vz-GY for xen-devel@lists.xenproject.org; Mon, 09 Sep 2019 09:33:44 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e9a30caa-d2e4-11e9-978d-bc764e2007e4; Mon, 09 Sep 2019 09:33:43 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 4BA7BB658; Mon, 9 Sep 2019 09:33:42 +0000 (UTC) X-Inumbo-ID: e9a30caa-d2e4-11e9-978d-bc764e2007e4 X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 9 Sep 2019 11:33:38 +0200 Message-Id: <20190909093339.7134-4-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190909093339.7134-1-jgross@suse.com> References: <20190909093339.7134-1-jgross@suse.com> Subject: [Xen-devel] [PATCH v3 3/4] xen/sched: add minimalistic idle scheduler for free cpus 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" Instead of having a full blown scheduler running for the free cpus add a very minimalistic scheduler for that purpose only ever scheduling the related idle vcpu. This has the big advantage of not needing any per-cpu, per-domain or per-scheduling unit data for free cpus and in turn simplifying moving cpus to and from cpupools a lot. Right now, CPUs that are not in any pool, still belong to Pool-0's scheduler. This forces us to make, within the scheduler, extra effort to avoid actually running vCPUs on those. In the case of Credit1, this also cause issue to weights (re)distribution, as the number of CPUs available to the scheduler is wrong. This is described in the changelog of commit e7191920261d ("xen: credit2: never consider CPUs outside of our cpupool"). This new scheduler will just use a common lock for all free cpus. As this new scheduler is not user selectable don't register it as an official scheduler, but just include it in schedule.c. Signed-off-by: Juergen Gross Acked-by: Dario Faggioli --- V3: - use ZERO_BLOCK_PTR instead of (void *)1 (Jan Beulich, Andrew Cooper) --- xen/common/sched_credit.c | 9 --- xen/common/sched_null.c | 7 --- xen/common/schedule.c | 153 +++++++++++++++++++++++-------------------= ---- 3 files changed, 75 insertions(+), 94 deletions(-) diff --git a/xen/common/sched_credit.c b/xen/common/sched_credit.c index 81dee5e472..70fe718127 100644 --- a/xen/common/sched_credit.c +++ b/xen/common/sched_credit.c @@ -617,15 +617,6 @@ csched_init_pdata(const struct scheduler *ops, void *p= data, int cpu) { unsigned long flags; struct csched_private *prv =3D CSCHED_PRIV(ops); - struct schedule_data *sd =3D &per_cpu(schedule_data, cpu); - - /* - * This is called either during during boot, resume or hotplug, in - * case Credit1 is the scheduler chosen at boot. In such cases, the - * scheduler lock for cpu is already pointing to the default per-cpu - * spinlock, as Credit1 needs it, so there is no remapping to be done. - */ - ASSERT(sd->schedule_lock =3D=3D &sd->_lock && !spin_is_locked(&sd->_lo= ck)); =20 spin_lock_irqsave(&prv->lock, flags); init_pdata(prv, pdata, cpu); diff --git a/xen/common/sched_null.c b/xen/common/sched_null.c index 26c6f0f129..6782ecda5c 100644 --- a/xen/common/sched_null.c +++ b/xen/common/sched_null.c @@ -167,17 +167,10 @@ static void init_pdata(struct null_private *prv, unsi= gned 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); =20 /* alloc_pdata is not implemented, so we want this to be NULL. */ ASSERT(!pdata); =20 - /* - * The scheduler lock points already to the default per-cpu spinlock, - * so there is no remapping to be done. - */ - ASSERT(sd->schedule_lock =3D=3D &sd->_lock && !spin_is_locked(&sd->_lo= ck)); - init_pdata(prv, cpu); } =20 diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 93164c64f6..fdeec10c3b 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); + +/* Common lock for free cpus. */ +static DEFINE_SPINLOCK(sched_free_cpu_lock); + /* Various timer handlers. */ static void s_timer_fn(void *unused); static void vcpu_periodic_timer_fn(void *data); @@ -73,6 +77,58 @@ extern const struct scheduler *__start_schedulers_array[= ], *__end_schedulers_arr =20 static struct scheduler __read_mostly ops; =20 +static spinlock_t * +sched_idle_switch_sched(struct scheduler *new_ops, unsigned int cpu, + void *pdata, void *vdata) +{ + idle_vcpu[cpu]->sched_priv =3D NULL; + + return &sched_free_cpu_lock; +} + +static int +sched_idle_cpu_pick(const struct scheduler *ops, struct vcpu *v) +{ + return v->processor; +} + +static void * +sched_idle_alloc_vdata(const struct scheduler *ops, struct vcpu *v, + void *dd) +{ + /* Any non-NULL pointer is fine here. */ + return ZERO_BLOCK_PTR; +} + +static void +sched_idle_free_vdata(const struct scheduler *ops, void *priv) +{ +} + +static struct task_slice sched_idle_schedule( + const struct scheduler *ops, s_time_t now, + bool tasklet_work_scheduled) +{ + const unsigned int cpu =3D smp_processor_id(); + struct task_slice ret =3D { .time =3D -1 }; + + ret.task =3D idle_vcpu[cpu]; + return ret; +} + +static struct scheduler sched_idle_ops =3D { + .name =3D "Idle Scheduler", + .opt_name =3D "idle", + .sched_data =3D NULL, + + .pick_cpu =3D sched_idle_cpu_pick, + .do_schedule =3D sched_idle_schedule, + + .alloc_vdata =3D sched_idle_alloc_vdata, + .free_vdata =3D sched_idle_free_vdata, + .switch_sched =3D sched_idle_switch_sched, +}; + static inline struct scheduler *dom_scheduler(const struct domain *d) { if ( likely(d->cpupool !=3D NULL) ) @@ -1587,12 +1643,10 @@ static void poll_timer_fn(void *data) static int cpu_schedule_up(unsigned int cpu) { struct schedule_data *sd =3D &per_cpu(schedule_data, cpu); - void *sched_priv; =20 - per_cpu(scheduler, cpu) =3D &ops; + per_cpu(scheduler, cpu) =3D &sched_idle_ops; spin_lock_init(&sd->_lock); - sd->schedule_lock =3D &sd->_lock; - sd->curr =3D idle_vcpu[cpu]; + sd->schedule_lock =3D &sched_free_cpu_lock; init_timer(&sd->s_timer, s_timer_fn, NULL, cpu); atomic_set(&sd->urgent_count, 0); =20 @@ -1602,40 +1656,19 @@ static int cpu_schedule_up(unsigned int cpu) =20 if ( idle_vcpu[cpu] =3D=3D NULL ) vcpu_create(idle_vcpu[0]->domain, cpu, cpu); - else - { - struct vcpu *idle =3D idle_vcpu[cpu]; - - /* - * During (ACPI?) suspend the idle vCPU for this pCPU is not freed, - * while its scheduler specific data (what is pointed by sched_pri= v) - * is. Also, at this stage of the resume path, we attach the pCPU - * to the default scheduler, no matter in what cpupool it was befo= re - * suspend. To avoid inconsistency, let's allocate default schedul= er - * data for the idle vCPU here. If the pCPU was in a different pool - * 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); =20 - idle->sched_priv =3D sched_alloc_vdata(&ops, idle, - idle->domain->sched_priv); - if ( idle->sched_priv =3D=3D NULL ) - return -ENOMEM; - } if ( idle_vcpu[cpu] =3D=3D NULL ) return -ENOMEM; =20 /* - * We don't want to risk calling xfree() on an sd->sched_priv - * (e.g., inside free_pdata, from cpu_schedule_down() called - * during CPU_UP_CANCELLED) that contains an IS_ERR value. + * No need to allocate any scheduler data, as cpus coming online are + * free initially and the idle scheduler doesn't need any data areas + * allocated. */ - sched_priv =3D sched_alloc_pdata(&ops, cpu); - if ( IS_ERR(sched_priv) ) - return PTR_ERR(sched_priv); =20 - sd->sched_priv =3D sched_priv; + sd->curr =3D idle_vcpu[cpu]; + + sd->sched_priv =3D NULL; =20 return 0; } @@ -1643,13 +1676,6 @@ static int cpu_schedule_up(unsigned int cpu) 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); - - sched_free_pdata(sched, sd->sched_priv, cpu); - sched_free_vdata(sched, idle_vcpu[cpu]->sched_priv); - - idle_vcpu[cpu]->sched_priv =3D NULL; - sd->sched_priv =3D NULL; =20 kill_timer(&sd->s_timer); } @@ -1657,14 +1683,11 @@ static void cpu_schedule_down(unsigned int cpu) void sched_rm_cpu(unsigned int cpu) { int rc; - struct schedule_data *sd =3D &per_cpu(schedule_data, cpu); - struct scheduler *sched =3D per_cpu(scheduler, cpu); =20 rcu_read_lock(&domlist_read_lock); rc =3D cpu_disable_scheduler(cpu); BUG_ON(rc); rcu_read_unlock(&domlist_read_lock); - sched_deinit_pdata(sched, sd->sched_priv, cpu); cpu_schedule_down(cpu); } =20 @@ -1672,8 +1695,6 @@ static int cpu_schedule_callback( struct notifier_block *nfb, unsigned long action, void *hcpu) { 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); int rc =3D 0; =20 /* @@ -1681,39 +1702,25 @@ static int cpu_schedule_callback( * allocating and initializing the per-pCPU scheduler specific data, * as well as "registering" this pCPU to the scheduler (which may * involve modifying some scheduler wide data structures). - * This happens by calling the alloc_pdata and init_pdata hooks, in - * this order. A scheduler that does not need to allocate any per-pCPU - * 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. + * As new pCPUs always start as "free" cpus with the minimal idle + * scheduler being in charge, we don't need any of that. * * 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 - * happens by calling the deinit_pdata and free_pdata hooks, in this + * during initialization, and then free the per-pCPU specific data. A + * pCPU brought down is not forced through "free" cpus, so here we nee= d to + * use the appropriate hooks. + * + * This happens by calling the deinit_pdata and free_pdata hooks, in t= his * 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 d= one * on scheduler wide data structure during init_pdata). Both deinit_pd= ata * and free_pdata are called during CPU_DEAD. * - * If someting goes wrong during bringup, we go to CPU_UP_CANCELLED - * *before* having called init_pdata. In this case, as there is no - * initialization needing undoing, only free_pdata should be called. - * This means it is possible to call free_pdata just after alloc_pdata, - * without a init_pdata/deinit_pdata "cycle" in between the two. - * - * So, in summary, the usage pattern should look either - * - alloc_pdata-->init_pdata-->deinit_pdata-->free_pdata, or - * - alloc_pdata-->free_pdata. + * If someting goes wrong during bringup, we go to CPU_UP_CANCELLED. */ 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); @@ -1824,9 +1831,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).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(schedule_data).curr =3D idle_vcpu[0]; } =20 /* @@ -1834,18 +1839,14 @@ void __init scheduler_init(void) * cpupool, or subject it to the scheduler of a new cpupool. * * For the pCPUs that are removed from their cpupool, their scheduler beco= mes - * &ops (the default scheduler, selected at boot, which also services the - * default cpupool). However, as these pCPUs are not really part of any po= ol, - * there won't be any scheduling event on them, not even from the default - * scheduler. Basically, they will just sit idle until they are explicitly - * added back to a cpupool. + * &sched_idle_ops (the idle scheduler). */ int schedule_cpu_switch(unsigned int cpu, struct cpupool *c) { struct vcpu *idle; 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; + struct scheduler *new_ops =3D (c =3D=3D NULL) ? &sched_idle_ops : c->s= ched; struct cpupool *old_pool =3D per_cpu(cpupool, cpu); struct schedule_data *sd =3D &per_cpu(schedule_data, cpu); spinlock_t *old_lock, *new_lock; @@ -1865,9 +1866,6 @@ int schedule_cpu_switch(unsigned int cpu, struct cpup= ool *c) ASSERT((c =3D=3D NULL && !cpumask_test_cpu(cpu, old_pool->cpu_valid)) = || (c !=3D NULL && !cpumask_test_cpu(cpu, c->cpu_valid))); =20 - if ( old_ops =3D=3D new_ops ) - goto out; - /* * To setup the cpu for the new scheduler we need: * - a valid instance of per-CPU scheduler specific data, as it is @@ -1931,7 +1929,6 @@ int schedule_cpu_switch(unsigned int cpu, struct cpup= ool *c) sched_free_vdata(old_ops, vpriv_old); sched_free_pdata(old_ops, ppriv_old, cpu); =20 - out: per_cpu(cpupool, cpu) =3D c; /* When a cpu is added to a pool, trigger it to go pick up some work */ if ( c !=3D NULL ) --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Fri Mar 29 09:50:12 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=1568021692; cv=none; d=zoho.com; s=zohoarc; b=JxFsZ6VJAzmpbdIaNv/FgsQkIAt6FwXUgt3gnU0+ZaI0tnlQxTeA5Gfio93t5WZZRiwlE6DjShS4ypJqrQdQD+hX234MOCBbemQYwBCRzyndDpWS6jgYjpRVkVIQKY+K9+7r9eq0AEPJOD8+oTAudumbscUuH9m0orN/X8iTiSo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568021692; 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=vzFSEPwrKM2XLFlpGbfNRVQ0bagFiuV91nZVzX1xfrU=; b=OabuRJcDR3bpnoX42xcmsiL4jnVwoeb/b+Wr9WDYVeP7FxMhLoXfd6tN5x7PZ/f+GNUPCD7lWY6oAwPlhfERRNORF5OiCOz81aIwxEBsgIMF854brSgg72k8R3rGszDy0yV/rYOu7Z43PMSnPyrAwGF9O5otAchMwivMJ6NebUE= 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 1568021692613806.1180904345804; Mon, 9 Sep 2019 02:34:52 -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 1i7G3S-0006Wv-S7; Mon, 09 Sep 2019 09:33:50 +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 1i7G3R-0006WS-CA for xen-devel@lists.xenproject.org; Mon, 09 Sep 2019 09:33:49 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id e9b6a148-d2e4-11e9-ac09-12813bfff9fa; Mon, 09 Sep 2019 09:33:43 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 67521B65F; Mon, 9 Sep 2019 09:33:42 +0000 (UTC) X-Inumbo-ID: e9b6a148-d2e4-11e9-ac09-12813bfff9fa X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Mon, 9 Sep 2019 11:33:39 +0200 Message-Id: <20190909093339.7134-5-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190909093339.7134-1-jgross@suse.com> References: <20190909093339.7134-1-jgross@suse.com> Subject: [Xen-devel] [PATCH v3 4/4] xen/sched: switch to debugtrace in cpupool handling 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 , 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" Instead of having a cpupool_dprintk() define just use debugtrace. Signed-off-by: Juergen Gross Acked-by: Dario Faggioli --- xen/common/cpupool.c | 48 +++++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/xen/common/cpupool.c b/xen/common/cpupool.c index 15e7004df4..179521e2dd 100644 --- a/xen/common/cpupool.c +++ b/xen/common/cpupool.c @@ -36,8 +36,6 @@ static DEFINE_SPINLOCK(cpupool_lock); =20 DEFINE_PER_CPU(struct cpupool *, cpupool); =20 -#define cpupool_dprintk(x...) ((void)0) - static struct cpupool *alloc_cpupool_struct(void) { struct cpupool *c =3D xzalloc(struct cpupool); @@ -133,7 +131,7 @@ static struct cpupool *cpupool_create( /* One reference for caller, one reference for cpupool_destroy(). */ atomic_set(&c->refcnt, 2); =20 - cpupool_dprintk("cpupool_create(pool=3D%d,sched=3D%u)\n", poolid, sche= d_id); + debugtrace_printk("cpupool_create(pool=3D%d,sched=3D%u)\n", poolid, sc= hed_id); =20 spin_lock(&cpupool_lock); =20 @@ -175,8 +173,8 @@ static struct cpupool *cpupool_create( =20 spin_unlock(&cpupool_lock); =20 - cpupool_dprintk("Created cpupool %d with scheduler %s (%s)\n", - c->cpupool_id, c->sched->name, c->sched->opt_name); + debugtrace_printk("Created cpupool %d with scheduler %s (%s)\n", + c->cpupool_id, c->sched->name, c->sched->opt_name); =20 *perr =3D 0; return c; @@ -212,7 +210,7 @@ static int cpupool_destroy(struct cpupool *c) =20 cpupool_put(c); =20 - cpupool_dprintk("cpupool_destroy(pool=3D%d)\n", c->cpupool_id); + debugtrace_printk("cpupool_destroy(pool=3D%d)\n", c->cpupool_id); return 0; } =20 @@ -377,14 +375,14 @@ static long cpupool_unassign_cpu_helper(void *info) struct cpupool *c =3D info; long ret; =20 - cpupool_dprintk("cpupool_unassign_cpu(pool=3D%d,cpu=3D%d)\n", - cpupool_cpu_moving->cpupool_id, cpupool_moving_cpu); + debugtrace_printk("cpupool_unassign_cpu(pool=3D%d,cpu=3D%d)\n", + cpupool_cpu_moving->cpupool_id, cpupool_moving_cpu); spin_lock(&cpupool_lock); =20 ret =3D cpupool_unassign_cpu_finish(c); =20 spin_unlock(&cpupool_lock); - cpupool_dprintk("cpupool_unassign_cpu ret=3D%ld\n", ret); + debugtrace_printk("cpupool_unassign_cpu ret=3D%ld\n", ret); =20 return ret; } @@ -406,14 +404,14 @@ static int cpupool_unassign_cpu(struct cpupool *c, un= signed int cpu) int work_cpu; int ret; =20 - cpupool_dprintk("cpupool_unassign_cpu(pool=3D%d,cpu=3D%d)\n", - c->cpupool_id, cpu); + debugtrace_printk("cpupool_unassign_cpu(pool=3D%d,cpu=3D%d)\n", + c->cpupool_id, cpu); =20 ret =3D cpupool_unassign_cpu_start(c, cpu); if ( ret ) { - cpupool_dprintk("cpupool_unassign_cpu(pool=3D%d,cpu=3D%d) ret %d\n= ", - c->cpupool_id, cpu, ret); + debugtrace_printk("cpupool_unassign_cpu(pool=3D%d,cpu=3D%d) ret %d= \n", + c->cpupool_id, cpu, ret); return ret; } =20 @@ -455,8 +453,8 @@ int cpupool_add_domain(struct domain *d, int poolid) rc =3D 0; } spin_unlock(&cpupool_lock); - cpupool_dprintk("cpupool_add_domain(dom=3D%d,pool=3D%d) n_dom %d rc %d= \n", - d->domain_id, poolid, n_dom, rc); + debugtrace_printk("cpupool_add_domain(dom=3D%d,pool=3D%d) n_dom %d rc = %d\n", + d->domain_id, poolid, n_dom, rc); return rc; } =20 @@ -476,8 +474,8 @@ void cpupool_rm_domain(struct domain *d) n_dom =3D d->cpupool->n_dom; d->cpupool =3D NULL; spin_unlock(&cpupool_lock); - cpupool_dprintk("cpupool_rm_domain(dom=3D%d,pool=3D%d) n_dom %d\n", - d->domain_id, cpupool_id, n_dom); + debugtrace_printk("cpupool_rm_domain(dom=3D%d,pool=3D%d) n_dom %d\n", + d->domain_id, cpupool_id, n_dom); return; } =20 @@ -644,8 +642,8 @@ int cpupool_do_sysctl(struct xen_sysctl_cpupool_op *op) unsigned cpu; =20 cpu =3D op->cpu; - cpupool_dprintk("cpupool_assign_cpu(pool=3D%d,cpu=3D%d)\n", - op->cpupool_id, cpu); + debugtrace_printk("cpupool_assign_cpu(pool=3D%d,cpu=3D%d)\n", + op->cpupool_id, cpu); spin_lock(&cpupool_lock); if ( cpu =3D=3D XEN_SYSCTL_CPUPOOL_PAR_ANY ) cpu =3D cpumask_first(&cpupool_free_cpus); @@ -663,8 +661,8 @@ int cpupool_do_sysctl(struct xen_sysctl_cpupool_op *op) ret =3D cpupool_assign_cpu_locked(c, cpu); addcpu_out: spin_unlock(&cpupool_lock); - cpupool_dprintk("cpupool_assign_cpu(pool=3D%d,cpu=3D%d) ret %d\n", - op->cpupool_id, cpu, ret); + debugtrace_printk("cpupool_assign_cpu(pool=3D%d,cpu=3D%d) ret %d\n= ", + op->cpupool_id, cpu, ret); } break; =20 @@ -703,8 +701,8 @@ int cpupool_do_sysctl(struct xen_sysctl_cpupool_op *op) rcu_unlock_domain(d); break; } - cpupool_dprintk("cpupool move_domain(dom=3D%d)->pool=3D%d\n", - d->domain_id, op->cpupool_id); + debugtrace_printk("cpupool move_domain(dom=3D%d)->pool=3D%d\n", + d->domain_id, op->cpupool_id); ret =3D -ENOENT; spin_lock(&cpupool_lock); =20 @@ -713,8 +711,8 @@ int cpupool_do_sysctl(struct xen_sysctl_cpupool_op *op) ret =3D cpupool_move_domain_locked(d, c); =20 spin_unlock(&cpupool_lock); - cpupool_dprintk("cpupool move_domain(dom=3D%d)->pool=3D%d ret %d\n= ", - d->domain_id, op->cpupool_id, ret); + debugtrace_printk("cpupool move_domain(dom=3D%d)->pool=3D%d ret %d= \n", + d->domain_id, op->cpupool_id, ret); rcu_unlock_domain(d); } break; --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel