From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from e8.ny.us.ibm.com (e8.ny.us.ibm.com [32.97.182.138]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id BD2F81A0063 for ; Mon, 27 Oct 2014 16:32:36 +1100 (AEDT) Received: from /spool/local by e8.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 27 Oct 2014 01:32:34 -0400 Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id E0B7438C803D for ; Mon, 27 Oct 2014 01:32:31 -0400 (EDT) Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id s9R5WVf62228706 for ; Mon, 27 Oct 2014 05:32:31 GMT Received: from d01av03.pok.ibm.com (localhost [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s9R5WVTj013096 for ; Mon, 27 Oct 2014 01:32:31 -0400 Message-ID: <544DD8EC.6050403@linux.vnet.ibm.com> Date: Mon, 27 Oct 2014 11:02:28 +0530 From: Preeti U Murthy MIME-Version: 1.0 To: kernelfans@gmail.com, linuxppc-dev@lists.ozlabs.org, kvm-ppc@vger.kernel.org Subject: Re: [RFC 06/11] powerpc: kvm: introduce online in paca to indicate whether cpu is needed by host References: <1413487800-7162-1-git-send-email-kernelfans@gmail.com> <1413487800-7162-7-git-send-email-kernelfans@gmail.com> In-Reply-To: <1413487800-7162-7-git-send-email-kernelfans@gmail.com> Content-Type: text/plain; charset=UTF-8 Cc: Paul Mackerras , Alexander Graf List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Hi Liu, On 10/17/2014 12:59 AM, kernelfans@gmail.com wrote: > Nowadays, powerKVM runs with secondary hwthread offline. Although > we can make all secondary hwthread online later, we still preserve > this behavior for dedicated KVM env. Achieve this by setting > paca->online as false. > > Signed-off-by: Liu Ping Fan > --- > arch/powerpc/include/asm/paca.h | 3 +++ > arch/powerpc/kernel/asm-offsets.c | 3 +++ > arch/powerpc/kernel/smp.c | 3 +++ > arch/powerpc/kvm/book3s_hv_rmhandlers.S | 12 ++++++++++++ > 4 files changed, 21 insertions(+) > > diff --git a/arch/powerpc/include/asm/paca.h b/arch/powerpc/include/asm/paca.h > index a5139ea..67c2500 100644 > --- a/arch/powerpc/include/asm/paca.h > +++ b/arch/powerpc/include/asm/paca.h > @@ -84,6 +84,9 @@ struct paca_struct { > u8 cpu_start; /* At startup, processor spins until */ > /* this becomes non-zero. */ > u8 kexec_state; /* set when kexec down has irqs off */ > +#ifdef CONFIG_KVMPPC_ENABLE_SECONDARY > + u8 online; > +#endif > #ifdef CONFIG_PPC_STD_MMU_64 > struct slb_shadow *slb_shadow_ptr; > struct dtl_entry *dispatch_log; > diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c > index 9d7dede..0faa8fe 100644 > --- a/arch/powerpc/kernel/asm-offsets.c > +++ b/arch/powerpc/kernel/asm-offsets.c > @@ -182,6 +182,9 @@ int main(void) > DEFINE(PACATOC, offsetof(struct paca_struct, kernel_toc)); > DEFINE(PACAKBASE, offsetof(struct paca_struct, kernelbase)); > DEFINE(PACAKMSR, offsetof(struct paca_struct, kernel_msr)); > +#ifdef CONFIG_KVMPPC_ENABLE_SECONDARY > + DEFINE(PACAONLINE, offsetof(struct paca_struct, online)); > +#endif > DEFINE(PACASOFTIRQEN, offsetof(struct paca_struct, soft_enabled)); > DEFINE(PACAIRQHAPPENED, offsetof(struct paca_struct, irq_happened)); > DEFINE(PACACONTEXTID, offsetof(struct paca_struct, context.id)); > diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c > index a0738af..4c3843e 100644 > --- a/arch/powerpc/kernel/smp.c > +++ b/arch/powerpc/kernel/smp.c > @@ -736,6 +736,9 @@ void start_secondary(void *unused) > > cpu_startup_entry(CPUHP_ONLINE); > > +#ifdef CONFIG_KVMPPC_ENABLE_SECONDARY > + get_paca()->online = true; > +#endif > BUG(); > } > > diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S > index f0c4db7..d5594b0 100644 > --- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S > +++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S > @@ -322,6 +322,13 @@ kvm_no_guest: > li r0, KVM_HWTHREAD_IN_NAP > stb r0, HSTATE_HWTHREAD_STATE(r13) > kvm_do_nap: > +#ifdef PPCKVM_ENABLE_SECONDARY > + /* check the cpu is needed by host or not */ > + ld r2, PACAONLINE(r13) > + ld r3, 0 > + cmp r2, r3 > + bne kvm_secondary_exit_trampoline > +#endif > /* Clear the runlatch bit before napping */ > mfspr r2, SPRN_CTRLF > clrrdi r2, r2, 1 > @@ -340,6 +347,11 @@ kvm_do_nap: > nap > b . > > +#ifdef PPCKVM_ENABLE_SECONDARY > +kvm_secondary_exit_trampoline: > + b . Uh? When we have no vcpu to run, we loop here instead of doing a nap? What are we achieving? If I understand the intention of the patch well, we are looking to provide a knob whereby the host can indicate if it needs the secondaries at all. Today the host does boot with all threads online. There are some init scripts which take the secondaries down. So today the host does not have a say in preventing this, compile time or runtime. So lets see how we can switch between the two behaviors if we don't have the init script, which looks like a saner thing to do. We should set the paca->online flag to false by default. If KVM_PPC_ENABLE_SECONDARY is configured, we need to set this flag to true. So at compile time, we resolve the flag. While booting, we look at the flag and decide whether to get the secondaries online. So we get the current behavior if we have not configured KVM_PPC_ENABLE_SECONDARY. Will this achieve the purpose of this patch? Regards Preeti U Murthy