From patchwork Fri Mar 29 15:09:31 2019 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: 10877327 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6FE221575 for ; Fri, 29 Mar 2019 15:12:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55ACE298CF for ; Fri, 29 Mar 2019 15:12:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 53406298E1; Fri, 29 Mar 2019 15:12:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C6DFB298D4 for ; Fri, 29 Mar 2019 15:12:35 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1h9t9k-0006Bm-Ql; Fri, 29 Mar 2019 15:10:56 +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 1h9t8q-0003xo-Ag for xen-devel@lists.xenproject.org; Fri, 29 Mar 2019 15:10:00 +0000 X-Inumbo-ID: b49f0558-5234-11e9-b1c8-7b85ac9b32ca Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id b49f0558-5234-11e9-b1c8-7b85ac9b32ca; Fri, 29 Mar 2019 15:09:53 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 18B6CB023; Fri, 29 Mar 2019 15:09:53 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Fri, 29 Mar 2019 16:09:31 +0100 Message-Id: <20190329150934.17694-47-jgross@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190329150934.17694-1-jgross@suse.com> References: <20190329150934.17694-1-jgross@suse.com> Subject: [Xen-devel] [PATCH RFC 46/49] 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_Pau_Monn=C3=A9?= MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 0728a9b505..3ae32449d7 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, setup_cpu_sibling_map(cpuid); + scheduler_percpu_init(cpu); + /* 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) set_cpu_sibling_map(cpu); + scheduler_percpu_init(cpu); + init_percpu_time(); setup_secondary_APIC_clock(); diff --git a/xen/common/schedule.c b/xen/common/schedule.c index a2140b3d7c..f43d00b59f 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -2029,6 +2029,15 @@ static void cpu_schedule_down(unsigned int cpu) per_cpu(sched_res, cpu) = NULL; } +void scheduler_percpu_init(unsigned int cpu) +{ + struct scheduler *sched = per_cpu(scheduler, cpu); + struct sched_resource *sd = per_cpu(sched_res, cpu); + + if ( system_state != SYS_STATE_resume ) + SCHED_OP(sched, init_pdata, sd->sched_priv, cpu); +} + static int cpu_schedule_callback( struct notifier_block *nfb, unsigned long action, void *hcpu) { @@ -2047,8 +2056,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 "register * 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 done * during initialization, and then free the per-pCPU specific data. This @@ -2071,10 +2080,6 @@ static int cpu_schedule_callback( */ switch ( action ) { - case CPU_STARTING: - if ( system_state != SYS_STATE_resume ) - SCHED_OP(sched, init_pdata, sd->sched_priv, cpu); - break; case CPU_UP_PREPARE: if ( system_state != SYS_STATE_resume ) rc = cpu_schedule_up(cpu); @@ -2171,7 +2176,7 @@ void __init scheduler_init(void) this_cpu(sched_res)->curr = idle_vcpu[0]->sched_item; this_cpu(sched_res)->sched_priv = SCHED_OP(&ops, alloc_pdata, 0); BUG_ON(IS_ERR(this_cpu(sched_res)->sched_priv)); - SCHED_OP(&ops, init_pdata, this_cpu(sched_res)->sched_priv, 0); + scheduler_percpu_init(0); } /* diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 314a453a60..51b8b6a44f 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -632,6 +632,7 @@ void __domain_crash(struct domain *d); void noreturn asm_domain_crash_synchronous(unsigned long addr); 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);