Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1837388ybt; Mon, 15 Jun 2020 10:38:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmpexgOT1PzKN87bxDzKhn8D0DkxHIvaOblOsvlUWR/qbSgFw2+qki75oS+eGWeu8t7+8T X-Received: by 2002:a17:906:17c8:: with SMTP id u8mr14304228eje.129.1592242698424; Mon, 15 Jun 2020 10:38:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592242698; cv=none; d=google.com; s=arc-20160816; b=MLZs0HQ2ubGZhDEtk2xBARuDKaYtTLkC9V4KeEyuPFNJj3Ro1HPKwfijP12xy2uRb4 lh2brof+evxQkSsWOe6gr6hY/i4e6I+vLvzV/Wz+5vOVE3b5gbR1b+Wos/9Aom4auOBl YZUNUK4MJYDzk6QeZFJNrUt41to/+CRkTp1sTdX55gehYtT5+rw8L+ojbovKtCHXcbFX W/Yh1KdNrjpbJ7PhsFZy6CtWAKGCzxVBrOLCv2zZPOzRG1Gb73qxi+bP2zrwyglIb9oa h0QNaZgQ1DXARqSv6sUXY7n+q3QO7cZtCczUBFYykwGZUx+LAoOW2KG8OTrCxusQ4kpv clEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=D68q+IzCoBLmQnVcnbKpB1IWycL5CepJ5yJ9/Kh8hWI=; b=XHigH1jsZlac+QXpPJfjL+7co6R9yY6mQq8QutUgZVvIPtAXpF9DVP+zMQpePatUL8 IK8Nz/AE/6tXYctNkb/bWAtGIb31FVmfXmEpczaJqaIr8zyGUT131z3xsAaaEmk9dYTr 0VPAiQL0Zg+IMA0ABegONUAxEsTD8s8YRHV7R02XX+F1t+lMVM+/t6JHTue20HvER2YR hQqY1eZS4/Cjyf566o/gWFwwO5uBwWFUxhYZlDbIddyYipGW8JxjouqzAJZx0YmaY1K+ IydxJL+3ZUDev82OKQ/AzWLhe/r5JcPB7CN4l3FJoVl5wAm/a2WVxnks9NeBCOdbJHN4 vIkA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l17si3100639ejf.494.2020.06.15.10.37.56; Mon, 15 Jun 2020 10:38:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731222AbgFORfU (ORCPT + 99 others); Mon, 15 Jun 2020 13:35:20 -0400 Received: from mga07.intel.com ([134.134.136.100]:60144 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729847AbgFORfS (ORCPT ); Mon, 15 Jun 2020 13:35:18 -0400 IronPort-SDR: YwrT5Lkv5HZDZsACtBnspln9ds2k3+nKIKngwPmAg5bR7NfA9dw6hD+YURDvD7KXcbNhvWd2zj GMR7msC99AmQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2020 10:35:18 -0700 IronPort-SDR: 51+mZbATzb7maRcHc1mjVbVrxDqDO6M2cv45SsM7b+oxHngCDcFSqacinDVTDXr7OPEcmXRB/a d40MxvSKq9pQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,515,1583222400"; d="scan'208";a="298594064" Received: from chenyu-office.sh.intel.com ([10.239.158.173]) by fmsmga004.fm.intel.com with ESMTP; 15 Jun 2020 10:35:16 -0700 From: Chen Yu To: "Rafael J. Wysocki" , Peter Zijlstra Cc: Daniel Lezcano , Ingo Molnar , Len Brown , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Chen Yu Subject: [PATCH][RFC] PM / s2idle: Clear _TIF_POLLING_NRFLAG before suspend to idle Date: Tue, 16 Jun 2020 01:36:11 +0800 Message-Id: <20200615173611.15349-1-yu.c.chen@intel.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Suspend to idle was found to not work on Goldmont CPU recently. And the issue was triggered due to: 1. On Goldmont the CPU in idle can only be woken up via IPIs, not POLL mode: Commit 08e237fa56a1 ("x86/cpu: Add workaround for MONITOR instruction erratum on Goldmont based CPUs") 2. When the CPU is entering suspend to idle process, the _TIF_POLLING_NRFLAG is kept on. 3. Commit b2a02fc43a1f ("smp: Optimize send_call_function_single_ipi()") makes use of _TIF_POLLING_NRFLAG to avoid sending IPIs to idle CPUs. 4. As a result, some IPIs related functions might not work well during suspend to idle on Goldmont. For example, one suspected victim: tick_unfreeze() -> timekeeping_resume() -> hrtimers_resume() -> clock_was_set() -> on_each_cpu() might wait forever, because the IPIs will not be sent to the CPUs which are sleeping with _TIF_POLLING_NRFLAG set, and Goldmont CPU could not be woken up by only setting _TIF_NEED_RESCHED on the monitor address. I don't find a way in Ubuntu to update the firmware of Goldmont and check if the issue was gone, a fix patch would do no harm. Clear the _TIF_POLLING_NRFLAG flag before entering suspend to idle, and let the driver's enter_s2idle() to decide whether to set _TIF_POLLING_NRFLAG or not. So that to avoid the scenario described above and keep the context consistent with before. Fixes: b2a02fc43a1f ("smp: Optimize send_call_function_single_ipi()") Reported-by: kbuild test robot Cc: Peter Zijlstra (Intel) Signed-off-by: Chen Yu --- drivers/cpuidle/cpuidle.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index c149d9e20dfd..d17dad362d34 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -186,8 +187,10 @@ int cpuidle_enter_s2idle(struct cpuidle_driver *drv, struct cpuidle_device *dev) * be frozen safely. */ index = find_deepest_state(drv, dev, U64_MAX, 0, true); - if (index > 0) + if (index > 0) { + __current_clr_polling(); enter_s2idle_proper(drv, dev, index); + } return index; } -- 2.17.1