From patchwork Tue Mar 14 09:23:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 738599 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 3vj8lF5wZ0z9s0g for ; Tue, 14 Mar 2017 20:36:57 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="tuJjDZMK"; 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 3vj8lF4pswzDqnv for ; Tue, 14 Mar 2017 20:36:57 +1100 (AEDT) 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="tuJjDZMK"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mail-pg0-x241.google.com (mail-pg0-x241.google.com [IPv6:2607:f8b0:400e:c05::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 3vj8St707MzDqXy for ; Tue, 14 Mar 2017 20:24:30 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="tuJjDZMK"; dkim-atps=neutral Received: by mail-pg0-x241.google.com with SMTP id 77so23198951pgc.0 for ; Tue, 14 Mar 2017 02:24:30 -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=21PVuRwCluk9UUljSRXOwp4Q4db86yJ/QZ7+7F+BdaE=; b=tuJjDZMKiOjUsUN9m3Mp9p/rpCR8GMmxFXvgXN1h4WD3mbqsHjMhsU5BvLQJA8TM2R 9fV0tfM8h2krIW+1dcxJCrIQqMpzc7w7TcUZLPU1t1pV7PrKkaqcoZl4TjtwrSnv1wGw E7RmOKdHE7fZlFCry4gTFfFxZIFoohg2ddAM+QIKUBHNxWMeZV3UtnZiycv6OhxQFOJW VBFqeLLC0RdS8gSg8gCafX7vhXUS45dMdmOYWZPnal0KmO1YjVY1EwLLGiyKgq8FDvJj RsfqMdSmLN73Y+0HaakOd1I35qYOQ4PvsVaa5m6mFg5i2oV/LXkUHiSe1XRFz8lQay41 sfDQ== 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=21PVuRwCluk9UUljSRXOwp4Q4db86yJ/QZ7+7F+BdaE=; b=K6eG0Mz11P4IUyNTR5ilxlCqAhT1pyHQrvoFibNxIbi3FSzGbv3lh7kcpuQzsscEO2 rPTQWBqZE9cIFphaQwqfa4y0DHy1+L7QjgXLKm5cbwHoStn8e+EcA7zLFKIpyrVLCPoz BWZFJdRcc4QKkW2bae68JUNQnxNZ1djG0yyeBTeiOdwAORUpPErONNYAS6pk90ynkfN1 0f1eCaxN9IcesmLp9K1TCdMDWHSVDYO6qlxLDjs/y+q1x10fW7kdcm0skCfUgtqX1/0Z KYYfqGO/B6vQ9qZn/PuO+cQMyuhXO4eWU2MuNqlcsnPVf5H+zePOtvAp1Yg3digGtSmn e8qg== X-Gm-Message-State: AMke39mjNZcrxi6e30urqPAgt7gmFPFAihQ9fFHdrpSgRDy87TjGYEd/xX22i3l2Biuwdw== X-Received: by 10.84.135.34 with SMTP id 31mr53512745pli.50.1489483469379; Tue, 14 Mar 2017 02:24:29 -0700 (PDT) Received: from roar.au.ibm.com ([203.221.48.234]) by smtp.gmail.com with ESMTPSA id s21sm37262882pfs.87.2017.03.14.02.24.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Mar 2017 02:24:28 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 7/8] powerpc/64s: idle do not hold reservation longer than required Date: Tue, 14 Mar 2017 19:23:48 +1000 Message-Id: <20170314092349.10981-8-npiggin@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170314092349.10981-1-npiggin@gmail.com> References: <20170314092349.10981-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: Gautham R Shenoy , 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. Signed-off-by: Nicholas Piggin Reviewed-by: Gautham R. Shenoy --- 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 1c91dc35c559..3cb75907c5c5 100644 --- a/arch/powerpc/kernel/idle_book3s.S +++ b/arch/powerpc/kernel/idle_book3s.S @@ -488,12 +488,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. @@ -501,7 +501,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 @@ -513,11 +520,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