From patchwork Wed Apr 19 13:05:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 752281 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 3w7NJQ1q5vz9ryk for ; Wed, 19 Apr 2017 23:34:14 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="BNQTH2rD"; 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 3w7NJQ0lXpzDqW9 for ; Wed, 19 Apr 2017 23:34:14 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="BNQTH2rD"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mail-io0-x241.google.com (mail-io0-x241.google.com [IPv6:2607:f8b0:4001:c06::241]) (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 3w7MhJ2mhHzDqmF for ; Wed, 19 Apr 2017 23:06:24 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="BNQTH2rD"; dkim-atps=neutral Received: by mail-io0-x241.google.com with SMTP id h41so3501784ioi.1 for ; Wed, 19 Apr 2017 06:06:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RK04VhcXMCFp5+8oxSLQjynthCtxGQLaunm2zXf1Sdc=; b=BNQTH2rDLbIGIxzZbwL1PyZ83meOg01PraGhr72M5G9qbLKKLrvZc3iMM122vWR74c TSV+4WUCWrytCVwG+u16dzIYQV0M9CenbdcRrLuBpXBYPgSk/JbKpQifbLG5XcZjxNyF PI9t7NiiFGtrr0I6i7wFd4A4N6eVveoSrtXh7Np3vTFRAQFwzKgUgzwaB66I2NiNQmy4 Qr2CfimFhTc60PxXxL2hMwG16MMOR4LE1AtG6Tp3PqBRvMUGfj+4cB6IzAHGOY5Yzd7l 3ZF2g0XJc+nimyeQ2Ny5hkAnsdxBjGFRv0+0JbHbsZITJWC5I7gNafCeWKrzU+PJEFEe caCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RK04VhcXMCFp5+8oxSLQjynthCtxGQLaunm2zXf1Sdc=; b=joaGXejtB83KeJ7jF4Z4jGiZJjGAfN0ejm4YK2MsLWEj1eSanNnzRIKIP5/8jRllb/ TL1UxPoZPCmHpFLy6Oc6csHd89Z7SZSBoiB6mDgL9w/y4Mfk28ovC5OPugzinMYYqE3U Z/UEDC4dEm9pVhZOmWhzynHJqpxZpkrqu+xJa+ON6GYfPSvLqdEKTHF0kql35vqAAEGM ct+z8T6Qw52hhO0RVv+l/lShGnQEt29NLiXppPC7DIEgwOv22oqn26bW1tzCI+dwc7K4 UMvBH/9xzpgQzunbwOkWKoBIiXy+9gVCCY3HUUnDsh7y6Tq/DfgLE7eKADbetGbd47Ba ZM/Q== X-Gm-Message-State: AN3rC/7GjNyTMTGsfQoRCaf/1GSAypglPfq67AHCO1zrQJa0oEzLtMW+ mDc+k3ecRgfd1A== X-Received: by 10.98.43.13 with SMTP id r13mr3053780pfr.32.1492607182415; Wed, 19 Apr 2017 06:06:22 -0700 (PDT) Received: from roar.au.ibm.com (14-202-189-126.tpgi.com.au. [14.202.189.126]) by smtp.gmail.com with ESMTPSA id i15sm4728860pfj.51.2017.04.19.06.06.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Apr 2017 06:06:21 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 7/9] powerpc/64s: idle do not hold reservation longer than required Date: Wed, 19 Apr 2017 23:05:49 +1000 Message-Id: <20170419130551.32378-8-npiggin@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170419130551.32378-1-npiggin@gmail.com> References: <20170419130551.32378-1-npiggin@gmail.com> 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: Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" When taking the core idle state lock, grab it immediately like a regular lock, rather than adding more tests in there. Holding the lock keeps it stable, so there is no need to do it whole holding the reservation. Reviewed-by: Gautham R. Shenoy Signed-off-by: Nicholas Piggin --- arch/powerpc/kernel/idle_book3s.S | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/kernel/idle_book3s.S b/arch/powerpc/kernel/idle_book3s.S index 13b7044c1541..db60e051fb1c 100644 --- a/arch/powerpc/kernel/idle_book3s.S +++ b/arch/powerpc/kernel/idle_book3s.S @@ -569,12 +569,12 @@ BEGIN_FTR_SECTION CHECK_HMI_INTERRUPT END_FTR_SECTION_IFSET(CPU_FTR_HVMODE) - lbz r7,PACA_THREAD_MASK(r13) ld r14,PACA_CORE_IDLE_STATE_PTR(r13) -lwarx_loop2: - lwarx r15,0,r14 - andis. r9,r15,PNV_CORE_IDLE_LOCK_BIT@h + lbz r7,PACA_THREAD_MASK(r13) + /* + * Take the core lock to synchronize against other threads. + * * Lock bit is set in one of the 2 cases- * a. In the sleep/winkle enter path, the last thread is executing * fastsleep workaround code. @@ -582,7 +582,14 @@ lwarx_loop2: * workaround undo code or resyncing timebase or restoring context * In either case loop until the lock bit is cleared. */ +1: + lwarx r15,0,r14 + andis. r9,r15,PNV_CORE_IDLE_LOCK_BIT@h bnel- core_idle_lock_held + oris r15,r15,PNV_CORE_IDLE_LOCK_BIT@h + stwcx. r15,0,r14 + bne- 1b + isync andi. r9,r15,PNV_CORE_IDLE_THREAD_BITS cmpwi cr2,r9,0 @@ -594,11 +601,6 @@ lwarx_loop2: * cr4 - gt or eq if waking up from complete hypervisor state loss. */ - oris r15,r15,PNV_CORE_IDLE_LOCK_BIT@h - stwcx. r15,0,r14 - bne- lwarx_loop2 - isync - BEGIN_FTR_SECTION lbz r4,PACA_SUBCORE_SIBLING_MASK(r13) and r4,r4,r15