From patchwork Thu Jun 15 12:11:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 776282 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wpMp334Gpz9s2P for ; Thu, 15 Jun 2017 22:12:43 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="FviUssps"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3wpMp31lHVzDqLV for ; Thu, 15 Jun 2017 22:12:43 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="FviUssps"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mail-pf0-x243.google.com (mail-pf0-x243.google.com [IPv6:2607:f8b0:400e:c00::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3wpMmX2vDzzDqL8 for ; Thu, 15 Jun 2017 22:11:24 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="FviUssps"; dkim-atps=neutral Received: by mail-pf0-x243.google.com with SMTP id w12so1544363pfk.0 for ; Thu, 15 Jun 2017 05:11:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-transfer-encoding; bh=rKxYlS5//4XLG9m+qQoZv6QtL97WgYhiy93HTAdfglk=; b=FviUssps2tk+9NFxKCP4cwVmdjY+JoNdn1wCXc7texlsOE6yiF9dNvKsY8Hgx7xscM tlQmfgpQWZnv8be6i1rZOvSs8RBi7zQ5aYrlaSbwCmPfyeu2ed4cHs/F6ElFC9w38CdH Dk8eR5ZFM+Upt2g6XBKRn3t4nVG5YV/uW/2RF8sORlinHCIVMnxjqtYhIiaSQ5nDvgxN JyAvpsL12hjt4Yrz1VGTSWQ5w+wZWzsm6USYnTF7zpTDNxdpruN7TRjb3m7C1B0EzFlW mFRytZmG1iP1dXyzNJfL2SXU4ef2PI9JO3HNQEVeJywqoDnZ3lzA1KHetvBhWASiuGtj ibBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=rKxYlS5//4XLG9m+qQoZv6QtL97WgYhiy93HTAdfglk=; b=a4sHfoQvU1tz9xnGBUL8Ph1lwWsKK24l0Xu/L2rDG3Z/8RDGf7SCKbEqF02CN2zcKS SltptH6UfpEWDe2WjQyzyVLvQAygT0UTW9DI3JUxhTMVDIAfJ1PgT7ceuRpjBfk39gdV DenJvg3JJRyAzf7Tt+qkx6nJygDo0NhCGWMJ5rDXGTZMBmrVPPXfTp7/VqwI22pAA/gG dRLcteP/hLiaqoj5RIda5Zuc6MJGX2Gl/VKmoYMVP6qMGCegXCHenOardAi9tkZtjFE1 /N/lqoJ5UKjs1h4nKVb2CMtvxEe1KRutfILN4q9tACpYHAfzwqpJRidzjTLCTKzMtsqJ asQw== X-Gm-Message-State: AKS2vOy/IrFwfhWM4mrFz92bU1qkdL8LZfppRy5CDFirbou66J9cczRq UOCeNfOZH96SKSf2 X-Received: by 10.98.200.66 with SMTP id z63mr4888110pff.136.1497528681381; Thu, 15 Jun 2017 05:11:21 -0700 (PDT) Received: from roar.ozlabs.ibm.com ([210.185.119.63]) by smtp.gmail.com with ESMTPSA id s131sm541pgs.6.2017.06.15.05.11.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Jun 2017 05:11:20 -0700 (PDT) Date: Thu, 15 Jun 2017 22:11:08 +1000 From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH 07/13] powerpc/64s: idle avoid SRR usage in idle sleep/wake paths Message-ID: <20170615221108.3f9abd33@roar.ozlabs.ibm.com> In-Reply-To: <20170613130557.26315-8-npiggin@gmail.com> References: <20170613130557.26315-1-npiggin@gmail.com> <20170613130557.26315-8-npiggin@gmail.com> Organization: IBM X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Gautham R . Shenoy" Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Tue, 13 Jun 2017 23:05:51 +1000 Nicholas Piggin wrote: > Idle code now always runs at the 0xc... effective address whether > in real or virtual mode. This means rfid can be ditched, along > with a lot of SRR manipulations. > > In the wakeup path, carry SRR1 around in r12. Use mtmsrd to change > MSR states as required. > > This also balances the return prediction for the idle call, by > doing blr rather than rfid to return to the idle caller. > > On POWER9, 2-process context switch on different cores, with snooze > disabled, increases performance by 2%. This patch has a few stupid bugs in the kvm_start_guest path. It needs the following incremental patch. - mtspr dst/src wrong - Did not pass SRR1 in r3 to kvm_start_guest - Didn't take into account the return back to pnv_wakeup_loss, so r1 was getting lost. This would cause crashes when starting KVM guests with -smp cores=2,threads=8 I've also tested HMI wakeup by adjusting SRR1 in the simulator, but can't do an HMI injection on real hardware when it is in nap state AFAIK. Thanks, Nick --- arch/powerpc/kernel/idle_book3s.S | 10 +++++++--- arch/powerpc/kvm/book3s_hv_rmhandlers.S | 6 ++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/kernel/idle_book3s.S b/arch/powerpc/kernel/idle_book3s.S index 6305d4d7a268..ebe80b5d5ce4 100644 --- a/arch/powerpc/kernel/idle_book3s.S +++ b/arch/powerpc/kernel/idle_book3s.S @@ -402,16 +402,16 @@ BEGIN_FTR_SECTION BEGIN_FTR_SECTION_NESTED(70) bl power9_dd1_recover_paca END_FTR_SECTION_NESTED_IFSET(CPU_FTR_POWER9_DD1, 70) - ld r1,PACAR1(r13) bl pnv_restore_hyp_resource_arch300 FTR_SECTION_ELSE - ld r1,PACAR1(r13) bl pnv_restore_hyp_resource_arch207 ALT_FTR_SECTION_END_IFSET(CPU_FTR_ARCH_300) li r0,PNV_THREAD_RUNNING stb r0,PACA_THREAD_IDLE_STATE(r13) /* Clear thread state */ + mr r3,r12 + #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE li r0,KVM_HWTHREAD_IN_KERNEL stb r0,HSTATE_HWTHREAD_STATE(r13) @@ -425,7 +425,6 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_ARCH_300) #endif /* Return SRR1 from power7_nap() */ - mr r3,r12 blt cr3,pnv_wakeup_noloss b pnv_wakeup_loss @@ -499,6 +498,7 @@ pnv_restore_hyp_resource_arch207: * r4 - PACA_THREAD_IDLE_STATE */ pnv_wakeup_tb_loss: + ld r1,PACAR1(r13) /* * Before entering any idle state, the NVGPRs are saved in the stack. * If there was a state loss, or PACA_NAPSTATELOST was set, then the @@ -789,9 +789,11 @@ fastsleep_workaround_at_exit: /* * R3 here contains the value that will be returned to the caller * of power7_nap. + * R12 contains SRR1 for CHECK_HMI_INTERRUPT. */ .global pnv_wakeup_loss pnv_wakeup_loss: + ld r1,PACAR1(r13) BEGIN_FTR_SECTION CHECK_HMI_INTERRUPT END_FTR_SECTION_IFSET(CPU_FTR_HVMODE) @@ -809,11 +811,13 @@ END_FTR_SECTION_IFSET(CPU_FTR_HVMODE) /* * R3 here contains the value that will be returned to the caller * of power7_nap. + * R12 contains SRR1 for CHECK_HMI_INTERRUPT. */ pnv_wakeup_noloss: lbz r0,PACA_NAPSTATELOST(r13) cmpwi r0,0 bne pnv_wakeup_loss + ld r1,PACAR1(r13) BEGIN_FTR_SECTION CHECK_HMI_INTERRUPT END_FTR_SECTION_IFSET(CPU_FTR_HVMODE) diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S index eb5b78b6bacf..ecb69c4ee943 100644 --- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S +++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S @@ -342,7 +342,7 @@ kvm_start_guest: * Could avoid this and pass it through in r3. For now, * code expects it to be in SRR1. */ - mtspr r3,SPRN_SRR1 + mtspr SPRN_SRR1,r3 ld r2,PACATOC(r13) @@ -462,13 +462,15 @@ kvm_no_guest: /* * We jump to pnv_wakeup_loss, which will return to the caller * of power7_nap in the powernv cpu offline loop. The value we - * put in r3 becomes the return value for power7_nap. + * put in r3 becomes the return value for power7_nap. pnv_wakeup_loss + * requires SRR1 in r12. */ li r3, LPCR_PECE0 mfspr r4, SPRN_LPCR rlwimi r4, r3, 0, LPCR_PECE0 | LPCR_PECE1 mtspr SPRN_LPCR, r4 li r3, 0 + mfspr r12,SPRN_SRR1 b pnv_wakeup_loss 53: HMT_LOW