From patchwork Wed Jun 14 13:02:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 775777 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wnn2B2clSz9s65 for ; Wed, 14 Jun 2017 23:06:10 +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="oYH0HVh0"; 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 3wnn2B1Gm0zDqMH for ; Wed, 14 Jun 2017 23:06:10 +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="oYH0HVh0"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mail-pf0-x241.google.com (mail-pf0-x241.google.com [IPv6:2607:f8b0:400e:c00::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 3wnmyj2LK0zDqLt for ; Wed, 14 Jun 2017 23:03:09 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="oYH0HVh0"; dkim-atps=neutral Received: by mail-pf0-x241.google.com with SMTP id w12so16683847pfk.0 for ; Wed, 14 Jun 2017 06:03:09 -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=qrfP4+0TGh+me+ihHpeM5ALKkLhrAKrOVg4qGNoeF2c=; b=oYH0HVh0upkVR9mtcPDwFSD2OgOPYpQELIG3OyjTxtMdjbWB1jZvyc3QFc90wf2vrb SnsLEiCWiLHtXyGaZmxE4K4kadGh3HH2zxiI9bq0Kq1GQipKz4FibjemKOGy+jPaGMcx xLouKh3VL2TCswsxtHpDVy2y6dZDjcUSWLUoZzA9E5aNBxATF+yXk8izLbHO1vIqNFE5 Z54ZtQH9bWgIK3MsSG8gtl+zq+fFu0fdFQe2MFFJ30G60ro2Tyv2EQIY/k3SUP0O0pSd MVJamL4IXmp0IKMEwTtmb+IMxsYUXZxSP9JRu4SXZmfOKm3vsz4XZzu4gy72xh0xB6YI Ruow== 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=qrfP4+0TGh+me+ihHpeM5ALKkLhrAKrOVg4qGNoeF2c=; b=N1fMvxcq9Xr++ShxpGhD++7qNNU4qHn9r8j9LTalTfmVX9JA7lcyNsJRX831fRMMjG X2dg/Bso6VFDIMKtbbZaQbaUi3oK/WncOui/v4nhzZHOd5MSDjc7psfjYJdEbM5gmsOT 0FNCYM1y7iOMreBft5FoMMTzj7WvnEpifh6lkRHiX4W2FNOpJElyUrQuX2IrZ8izmyMW MHWPDSNZMZWHY1+eCDccO1rV1fWIkVbpfQJCGdh6d4MSnyCmUywEhWhQQgLWn0atGBvF XG3baZsoY20hinwovot0aPZlEmSjcdRSOA6BA/iJWTunpf3muS5Gp7wdcEVy0zf5jXp/ T0PA== X-Gm-Message-State: AKS2vOy9C+lx8RhY7ZDISTzI83UktGZLGbPd80e+h16VBx0+Cq6X3nYZ rSzzzDL4I6c2fEbf X-Received: by 10.99.115.79 with SMTP id d15mr519636pgn.140.1497445387200; Wed, 14 Jun 2017 06:03:07 -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.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Jun 2017 06:03:06 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 1/3] cpuidle: powerpc: cpuidle set polling before enabling irqs Date: Wed, 14 Jun 2017 23:02:39 +1000 Message-Id: <20170614130241.19865-2-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" local_irq_enable can cause interrupts to be taken which could take significant amount of processing time. The idle process should set its polling flag before this, so another process that wakes it during this time will not have to send an IPI. Expand the TIF_POLLING_NRFLAG coverage to as large as possible. Reviewed-by: Gautham R. Shenoy Signed-off-by: Nicholas Piggin --- drivers/cpuidle/cpuidle-powernv.c | 4 +++- drivers/cpuidle/cpuidle-pseries.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c index 45eaf06462ae..77bc50ad9f57 100644 --- a/drivers/cpuidle/cpuidle-powernv.c +++ b/drivers/cpuidle/cpuidle-powernv.c @@ -51,9 +51,10 @@ static int snooze_loop(struct cpuidle_device *dev, { u64 snooze_exit_time; - local_irq_enable(); set_thread_flag(TIF_POLLING_NRFLAG); + local_irq_enable(); + snooze_exit_time = get_tb() + snooze_timeout; ppc64_runlatch_off(); HMT_very_low(); @@ -66,6 +67,7 @@ static int snooze_loop(struct cpuidle_device *dev, 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 166ccd711ec9..7b12bb2ea70f 100644 --- a/drivers/cpuidle/cpuidle-pseries.c +++ b/drivers/cpuidle/cpuidle-pseries.c @@ -62,9 +62,10 @@ static int snooze_loop(struct cpuidle_device *dev, unsigned long in_purr; u64 snooze_exit_time; + set_thread_flag(TIF_POLLING_NRFLAG); + idle_loop_prolog(&in_purr); local_irq_enable(); - set_thread_flag(TIF_POLLING_NRFLAG); snooze_exit_time = get_tb() + snooze_timeout; while (!need_resched()) {