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: 9786281 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E9D6360384 for ; Wed, 14 Jun 2017 13:04:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC7E328650 for ; Wed, 14 Jun 2017 13:04:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC3E028676; Wed, 14 Jun 2017 13:04:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C9EC28650 for ; Wed, 14 Jun 2017 13:04:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752084AbdFNNDK (ORCPT ); Wed, 14 Jun 2017 09:03:10 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:36637 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752476AbdFNNDH (ORCPT ); Wed, 14 Jun 2017 09:03:07 -0400 Received: by mail-pf0-f196.google.com with SMTP id y7so26688914pfd.3; Wed, 14 Jun 2017 06:03:07 -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=II4tMR+8pZUopWRjoTuIKVdse2F5H0Nx6SX0ibT44SpATLfUTLRpt8Z8l5gid9XJGm 8fTX7tSDDRnc0upsKnjl1h9XNb7vFDbGQ8lYk/Czj6un9i3YSp06PQzBZ1pADLcQ4vLT H6/cMg8tMgP9RrTP6QmFNby4NVDQwOonpsnV6bT9fQ3wgplpza4hYBPF055ApR5IMAbV F+uAQmcJSMj0QpO1/TB3Fgd0amkJZ8FEgPWaeDX4OyCX5NXINsojnpI1UlvLBcxwt9m8 +VUh5XfCTYnxbAu3aBcrlfMtPvRANE6mtDbRWFEAVnJ5xFA080s2CnkpWp3/S9uFwFrE aUlg== X-Gm-Message-State: AKS2vOyCnV3hjmGPjjlBoBLUlPEyZ5P7G+RVqM00X8OwPWJ982sE2DkS IIycBGoRENKkjg== 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 Cc: Nicholas Piggin , Michael Ellerman , Vaidyanathan Srinivasan , "Gautham R . Shenoy" , "Rafael J . Wysocki" , Daniel Lezcano , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.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> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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()) {