Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1910136pxb; Thu, 16 Sep 2021 19:58:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0FE89B5GPZ9IzpiJPYOn7JXWxDczP9KdX973Nq2/0BUGarfH3jIW6e87PbpyFWO7+5nSu X-Received: by 2002:a05:6402:42d4:: with SMTP id i20mr10063971edc.348.1631847516066; Thu, 16 Sep 2021 19:58:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631847516; cv=none; d=google.com; s=arc-20160816; b=bAcTXmIivcdfD94V5MzGnVJBCz8u6vRwxtVofNKoSykHhmZda0XbtqjUN3cwZHIZMK lmJwsRFgMd5jiE3odwkoz8Fj1Zg3hhk43SjxuGD0dpWy9AXaJYwSvnm9q4D2j25kYZgt uXeiXuMzZKMTqysH4EsDyqXVqyizxa4Q/3dqFNQo58u3RFEK6PfrYgegNEYfk/UzGHuY Iobntw8zWdMiQBcBndh0DbNHlUkPbnMF4tT8+x1hYDgLaJFC86pXjsbJ44ClIUzD976B 4SjUM9fMC531xwutoVfrgUiaUCUJ0WcKaRTk304hulNHA6d2+WQNNLkaohaLlh6Eij3k pksg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=z+6yrHyHlGto5Z0X93rg7x/RNc5ckEinBY0c/ym4myA=; b=moiRBu9EQ5yzBLIdD9ytsZq8bpQbzUIFV+u2fkxP8L/1FYNrpRj8efR8IGZZ5iLe0Q BQvPVbWqVaNvZS7r7+EbrSw8qrShZmZJMdNajB4N10yg1WkayUDQJzkmX2HO3jkdpEuH dB72CVX1pe1fh7F99llUd8k/XFlxBP+TaW/OLpViNUFZdHoKP+jrlIEmoUJC+xiONmxr duKk+ASZ13Hl5mCrZh6fOG0eSUt+wPI6n9tgtsnLVpjdEoAfOqwTC1e1ss5rdVx4ovoO XMWC6iD55+0LGM6bUhM/7DHbpfLTK+iHpmgRatx8jnCtcxdAkXl2eCvMP5DAe1RhD9kb M+Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cY2zTE+M; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id eo22si5327018ejc.690.2021.09.16.19.58.11; Thu, 16 Sep 2021 19:58:36 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cY2zTE+M; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351819AbhIPRXc (ORCPT + 99 others); Thu, 16 Sep 2021 13:23:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:41022 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351290AbhIPRPY (ORCPT ); Thu, 16 Sep 2021 13:15:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8AD7B61B7F; Thu, 16 Sep 2021 16:39:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631810385; bh=VMxKDaM3SrW+qUbRpV5JvN7HFM5PZKPdR0iiyeMpvyE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cY2zTE+Mgq7TgYMp76x7LfnoGM+98DU8GhpXOh/mpMoAnTs4oz+0blPri2taK/PKL 71vqeMiZ2oQaBJhWbuDOMtxUAOWnFmqZ3H0Gi2GiLXYHbSewvpS+JsooUu/KBuM858 wUO+KMjt/xwDQmOmom2eTKSxlYdVRWKP5BHx8W54= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Enrico Joedecke , "Gautham R. Shenoy" , Michael Ellerman , Sasha Levin Subject: [PATCH 5.14 094/432] cpuidle: pseries: Fixup CEDE0 latency only for POWER10 onwards Date: Thu, 16 Sep 2021 17:57:23 +0200 Message-Id: <20210916155813.968979874@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155810.813340753@linuxfoundation.org> References: <20210916155810.813340753@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gautham R. Shenoy [ Upstream commit 50741b70b0cbbafbd9199f5180e66c0c53783a4a ] Commit d947fb4c965c ("cpuidle: pseries: Fixup exit latency for CEDE(0)") sets the exit latency of CEDE(0) based on the latency values of the Extended CEDE states advertised by the platform On POWER9 LPARs, the firmwares advertise a very low value of 2us for CEDE1 exit latency on a Dedicated LPAR. The latency advertized by the PHYP hypervisor corresponds to the latency required to wakeup from the underlying hardware idle state. However the wakeup latency from the LPAR perspective should include 1. The time taken to transition the CPU from the Hypervisor into the LPAR post wakeup from platform idle state 2. Time taken to send the IPI from the source CPU (waker) to the idle target CPU (wakee). 1. can be measured via timer idle test, where we queue a timer, say for 1ms, and enter the CEDE state. When the timer fires, in the timer handler we compute how much extra timer over the expected 1ms have we consumed. On a a POWER9 LPAR the numbers are CEDE latency measured using a timer (numbers in ns) N Min Median Avg 90%ile 99%ile Max Stddev 400 2601 5677 5668.74 5917 6413 9299 455.01 1. and 2. combined can be determined by an IPI latency test where we send an IPI to an idle CPU and in the handler compute the time difference between when the IPI was sent and when the handler ran. We see the following numbers on POWER9 LPAR. CEDE latency measured using an IPI (numbers in ns) N Min Median Avg 90%ile 99%ile Max Stddev 400 711 7564 7369.43 8559 9514 9698 1200.01 Suppose, we consider the 99th percentile latency value measured using the IPI to be the wakeup latency, the value would be 9.5us This is in the ballpark of the default value of 10us. Hence, use the exit latency of CEDE(0) based on the latency values advertized by platform only from POWER10 onwards. The values advertized on POWER10 platforms is more realistic and informed by the latency measurements. For earlier platforms stick to the default value of 10us. The fix was suggested by Michael Ellerman. Fixes: d947fb4c965c ("cpuidle: pseries: Fixup exit latency for CEDE(0)") Reported-by: Enrico Joedecke Signed-off-by: Gautham R. Shenoy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/1626676399-15975-2-git-send-email-ego@linux.vnet.ibm.com Signed-off-by: Sasha Levin --- drivers/cpuidle/cpuidle-pseries.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/cpuidle/cpuidle-pseries.c b/drivers/cpuidle/cpuidle-pseries.c index a2b5c6f60cf0..e592280d8acf 100644 --- a/drivers/cpuidle/cpuidle-pseries.c +++ b/drivers/cpuidle/cpuidle-pseries.c @@ -419,7 +419,21 @@ static int pseries_idle_probe(void) cpuidle_state_table = shared_states; max_idle_state = ARRAY_SIZE(shared_states); } else { - fixup_cede0_latency(); + /* + * Use firmware provided latency values + * starting with POWER10 platforms. In the + * case that we are running on a POWER10 + * platform but in an earlier compat mode, we + * can still use the firmware provided values. + * + * However, on platforms prior to POWER10, we + * cannot rely on the accuracy of the firmware + * provided latency values. On such platforms, + * go with the conservative default estimate + * of 10us. + */ + if (cpu_has_feature(CPU_FTR_ARCH_31) || pvr_version_is(PVR_POWER10)) + fixup_cede0_latency(); cpuidle_state_table = dedicated_states; max_idle_state = NR_DEDICATED_STATES; } -- 2.30.2