From patchwork Wed Jun 14 13:02:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 775781 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 3wnn650qvZz9s65 for ; Wed, 14 Jun 2017 23:09:33 +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="tDDg+3vA"; 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 3wnn646xzCzDqNS for ; Wed, 14 Jun 2017 23:09:32 +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="tDDg+3vA"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mail-pf0-x244.google.com (mail-pf0-x244.google.com [IPv6:2607:f8b0:400e:c00::244]) (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 3wnmyw1fNrzDqLb for ; Wed, 14 Jun 2017 23:03:20 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="tDDg+3vA"; dkim-atps=neutral Received: by mail-pf0-x244.google.com with SMTP id y7so26689462pfd.3 for ; Wed, 14 Jun 2017 06:03: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=l4pTXO+hHfoNNPmPAibf7Uuyb8BbVnZ0Z8sHxEcl2e8=; b=tDDg+3vAtIGqtPKBv4MbZp4i11u3eAuRrP1ifSDPMYp5d/94QtE4Fk4hRpchPJBESZ /RCGFzS2vHzDzZ2SXjvKWrvAXCWMo8m9p2S2vDKSPpPWKLytoQK8pQ8cyBOM56AaQbxR KbhH4D3BIlTxvfzCDL2+g7pul3owYS7imY2whGTYlW5tuyX7ZK4K/RLPHkCkTLYaa2F3 puryJ8SWXBVGBVv3NXrvFMLFy64n521Nx05oGejA2HEBlP4g1k4aAKrHN0HoJ2554iBh ex5nCLEKYCHaMEWRmS7Kb3qupOdXHE6JmrebpT1V+PFZg8IAJ/tXNVOommQ40UQAyV8X YjSA== 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=l4pTXO+hHfoNNPmPAibf7Uuyb8BbVnZ0Z8sHxEcl2e8=; b=YIwL/8rbPmbCQ2wrom7gnk8lHRdo3tWKrOmBBp1RiSI+cm0VbSPBqxoJJwkrzsE+fy vZYAZ0ThieLPsSASBAWBCFDQNXx3PzkIz9C2szjDk6MD5N3NK+31AavgXVDFcIKZqVfl JcawyzOpohDLZttTMaZ0c7yToYcMoWbnGwIx6l0YvNzHJ9caDSaUvJyYlxv5L4lMGCFT zy3EJcPQkT4dvKkKDrQHvBiVkhi+CbtOFRkTupyN/D4ABdSecDY8DeEG8UiDAa7gk66g hFBORUOaz9SqOMQQTMcvNcXhBwKfToWw5eS0UMGEHTKZr03mJ9UVszQVv7XANe8D6MPV hD3A== X-Gm-Message-State: AKS2vOwDJfm7HPnSzYxcJvGT7hsoFx3WUPKSJPsdtuQjYCdlUBhuqaGh 510w28CzbfItR0MC X-Received: by 10.101.83.138 with SMTP id x10mr485909pgq.205.1497445397865; Wed, 14 Jun 2017 06:03:17 -0700 (PDT) Received: from roar.au.ibm.com ([210.185.119.63]) by smtp.gmail.com with ESMTPSA id 15sm2215497pfj.59.2017.06.14.06.03.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Jun 2017 06:03:16 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 3/3] cpuidle: powerpc: no memory barrier after break from idle Date: Wed, 14 Jun 2017 23:02:41 +1000 Message-Id: <20170614130241.19865-4-npiggin@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170614130241.19865-1-npiggin@gmail.com> References: <20170614130241.19865-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" , linux-pm@vger.kernel.org, Daniel Lezcano , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" A memory barrier is not required after the task wakes up, only if we clear the polling flag before waking. The case where we have work to do is the important one, so optimise for it. Reviewed-by: Vaidyanathan Srinivasan Signed-off-by: Nicholas Piggin --- drivers/cpuidle/cpuidle-powernv.c | 11 +++++++++-- drivers/cpuidle/cpuidle-pseries.c | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c index abf2ffcd4a0a..722b81b03593 100644 --- a/drivers/cpuidle/cpuidle-powernv.c +++ b/drivers/cpuidle/cpuidle-powernv.c @@ -59,14 +59,21 @@ static int snooze_loop(struct cpuidle_device *dev, ppc64_runlatch_off(); HMT_very_low(); while (!need_resched()) { - if (likely(snooze_timeout_en) && get_tb() > snooze_exit_time) + if (likely(snooze_timeout_en) && get_tb() > snooze_exit_time) { + /* + * Task has not woken up but we are exiting the polling + * loop anyway. Require a barrier after polling is + * cleared to order subsequent test of need_resched(). + */ + clear_thread_flag(TIF_POLLING_NRFLAG); + smp_mb(); break; + } } HMT_medium(); ppc64_runlatch_on(); clear_thread_flag(TIF_POLLING_NRFLAG); - smp_mb(); return index; } diff --git a/drivers/cpuidle/cpuidle-pseries.c b/drivers/cpuidle/cpuidle-pseries.c index a404f352d284..e9b3853d93ea 100644 --- a/drivers/cpuidle/cpuidle-pseries.c +++ b/drivers/cpuidle/cpuidle-pseries.c @@ -71,13 +71,20 @@ static int snooze_loop(struct cpuidle_device *dev, while (!need_resched()) { HMT_low(); HMT_very_low(); - if (snooze_timeout_en && get_tb() > snooze_exit_time) + if (likely(snooze_timeout_en) && get_tb() > snooze_exit_time) { + /* + * Task has not woken up but we are exiting the polling + * loop anyway. Require a barrier after polling is + * cleared to order subsequent test of need_resched(). + */ + clear_thread_flag(TIF_POLLING_NRFLAG); + smp_mb(); break; + } } HMT_medium(); clear_thread_flag(TIF_POLLING_NRFLAG); - smp_mb(); idle_loop_epilog(in_purr);