From patchwork Mon May 22 05:53:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 765255 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.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 3wWSX574D8z9ryT for ; Mon, 22 May 2017 15:53:57 +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="N1Cl/wAN"; 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 3wWSX55qGyzDqbk for ; Mon, 22 May 2017 15:53:57 +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="N1Cl/wAN"; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@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 3wWSWN43qczDqY7 for ; Mon, 22 May 2017 15:53:20 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="N1Cl/wAN"; dkim-atps=neutral Received: by mail-pf0-x243.google.com with SMTP id f27so17590638pfe.0 for ; Sun, 21 May 2017 22:53:20 -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=BI+8sSC/4uDPtADi+wEZrjT8MQ9jGhUGbRVcFFD873o=; b=N1Cl/wANHG3YQYee/8Mo1wKK1/1k2ZxTNjRrzISeUdbbWgzr8pOUUTPLl6mhCj3sfw 4jKvxUmT8M8l7YDtmAtH2SaHMYZpe8aszHTzhrntykauK59PR/AVQJZcU2B+AqD60BBP N2HcXWcnG0/SYIwbFWN02RXh/ZLLupasXuar/ROjZuuUtczyfNbnFwwHFwITeT8SWKb8 PAc3BZ3dS5F9q5Pv9KnKz2hS9zEf+1AEvv8xTaKT7BYxpzXwdsaFMWhmv0kyPlY+M7J+ 407MYvuaPj+Ur7/gQnT/NxrAfKw1QqbW1r4Z03gHUkuoO+wBlGQS8YK5QDPc9gqLKaGU i+HA== 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=BI+8sSC/4uDPtADi+wEZrjT8MQ9jGhUGbRVcFFD873o=; b=pgCR996FzKG/TdvMPefBNjW/E1BJ9kKzp21BKYjdq+OH/bACOGsm9IxhvPzgITipSb Yh3EjSXBvlJNpQeS8kEOS7tQgFW6570fnVxL6BzzX03cpafbK0Ju9k52FSCYah5XfbW7 FQP2UArDz1Hq+W04wjJJhxL5fPxhBMvgIXSKZgPVQkmwIkRJLqyCZlF89jnhAYwQ2+op UdsHYe11qHOCE52pZmyK8cT2CgknpQ6TpkkUyLXPtSgpUUP2BsCkB10H1xesOBnlcJE3 JWk/ShQa58ik5m/gmIfN8PmNMdXm+Uxv/LtTc+56NNbkpfR5ZTWaQbfF02iUqEIzOWqS FsLg== X-Gm-Message-State: AODbwcAqIwyns3B/haSutNa7eZpnqrQ7fBiaBgwcfd4tM0gEVYzmOgcX RI0GyUO1Sm3yqQ== X-Received: by 10.84.216.30 with SMTP id m30mr26960118pli.161.1495432398933; Sun, 21 May 2017 22:53:18 -0700 (PDT) Received: from roar.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id m24sm26449632pfi.129.2017.05.21.22.53.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 May 2017 22:53:18 -0700 (PDT) From: Nicholas Piggin To: skiboot@lists.ozlabs.org Date: Mon, 22 May 2017 15:53:02 +1000 Message-Id: <20170522055303.2025-4-npiggin@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170522055303.2025-1-npiggin@gmail.com> References: <20170522055303.2025-1-npiggin@gmail.com> Subject: [Skiboot] [PATCH 3/4] Convert important polling loops to spin at lowest SMT priority X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" The pattern of calling cpu_relax() inside a polling loop does not suit the powerpc SMT priority instructions. Prefrred is to set a low priority then spin until break condition is reached, then restore priority. Signed-off-by: Nicholas Piggin --- core/hmi.c | 4 +++- core/lock.c | 5 ++++- core/timer.c | 5 ++++- hw/lpc-uart.c | 10 +++++++--- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/core/hmi.c b/core/hmi.c index e55a85b2..06d83476 100644 --- a/core/hmi.c +++ b/core/hmi.c @@ -599,6 +599,7 @@ static void wait_for_subcore_threads(void) { uint64_t timeout = 0; + smt_lowest(); while (!(*(this_cpu()->core_hmi_state_ptr) & HMI_STATE_CLEANUP_DONE)) { /* * We use a fixed number of TIMEOUT_LOOPS rather @@ -616,8 +617,9 @@ static void wait_for_subcore_threads(void) prlog(PR_DEBUG, "HMI: TB pre-recovery timeout\n"); break; } - cpu_relax(); + barrier(); } + smt_medium(); } /* diff --git a/core/lock.c b/core/lock.c index e82048bf..0868f2ba 100644 --- a/core/lock.c +++ b/core/lock.c @@ -93,7 +93,10 @@ void lock(struct lock *l) for (;;) { if (try_lock(l)) break; - cpu_relax(); + smt_lowest(); + while (l->lock_val) + barrier(); + smt_medium(); } } diff --git a/core/timer.c b/core/timer.c index 75489963..4b5925fe 100644 --- a/core/timer.c +++ b/core/timer.c @@ -45,7 +45,10 @@ static void __sync_timer(struct timer *t) while (t->running) { unlock(&timer_lock); - cpu_relax(); + smt_lowest(); + while (t->running) + barrier(); + smt_medium(); /* Should we call the pollers here ? */ lock(&timer_lock); } diff --git a/hw/lpc-uart.c b/hw/lpc-uart.c index 6e349ef9..912bffa5 100644 --- a/hw/lpc-uart.c +++ b/hw/lpc-uart.c @@ -115,10 +115,14 @@ static void uart_check_tx_room(void) static void uart_wait_tx_room(void) { - while(!tx_room) { + while (!tx_room) { uart_check_tx_room(); - if (!tx_room) - cpu_relax(); + if (!tx_room) { + smt_lowest(); + while (!tx_room) + barrier(); + smt_medium(); + } } }