From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ulf Hansson Subject: Re: [PATCH v12 3/4] cpuidle: Export the next timer/tick expiration for a CPU Date: Tue, 26 Mar 2019 12:29:52 +0100 Message-ID: References: <20190227195836.24739-1-ulf.hansson@linaro.org> <20190227195836.24739-4-ulf.hansson@linaro.org> <2942111.nn8VVVUCAL@aspire.rjw.lan> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: "Rafael J. Wysocki" Cc: "Rafael J. Wysocki" , Linux PM , Frederic Weisbecker , Thomas Gleixner , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , "Raju P . L . S . S . S . N" , Stephen Boyd , Tony Lindgren , Kevin Hilman , Lina Iyer , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , Linux ARM , linux-arm-msm Linux List-Id: linux-arm-msm@vger.kernel.org On Tue, 26 Mar 2019 at 11:36, Rafael J. Wysocki wrote: > > On Mon, Mar 25, 2019 at 3:24 PM Ulf Hansson wrote: > > > > On Mon, 25 Mar 2019 at 13:21, Rafael J. Wysocki wrote: > > > > > > On Wednesday, February 27, 2019 8:58:35 PM CET Ulf Hansson wrote: > > > > To be able to predict the sleep duration for a CPU that is entering idle, > > > > knowing when the next timer/tick is going to expire, is extremely useful. > > > > Both the teo and the menu cpuidle governors already makes use of this > > > > information, while selecting an idle state. > > > > > > [cut] > > > > > > > > + > > > > if (cpuidle_state_is_coupled(drv, index)) > > > > return cpuidle_enter_state_coupled(dev, drv, index); > > > > return cpuidle_enter_state(dev, drv, index); > > > > > > Also I would clear next_hrtimer here to avoid dragging stale values > > > around. > > > > Right, I can do that. > > > > However, at least in my case it would be an unnecessary update of the > > variable, as I am never in a path where the value can be "stale". > > It easily can AFAICS. After all, cpu_power_down_ok() need not run on > the same CPU that is setting next_hrtimer here. That's correct. > > > Even if one theoretically could use a stale value, it's seems likely to not > > be an issue, don't you think? > > That would be because of the locking in the ->enter() callback I > suppose? But is it actually universally guaranteed that setting > next_hrtimer will never be reordered with acquiring the lock? In the PSCI case and for those CPUs that shares the same genpd governor (even hierarchically), then yes. Unfortunate, I haven't been able to explore this in that great detail for other legacy ARM32 platforms, so maybe it's just better to play safe, as you suggest and avoid a stale value. > > Also, there is some overhead to be avoided if cpu_power_down_ok() > checked the next_hrtimer of the other CPUs against 0 explicitly, isn't > it? In regards to overhead and when using genpd for CPUs, there are a couple of things I have in mind that we could try to improve. Yes, checking for next_hrtimer against 0 could be one thing to consider. Kind regards Uffe From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CEBFC43381 for ; Tue, 26 Mar 2019 11:30:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D76A82075D for ; Tue, 26 Mar 2019 11:30:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="AaJl87bM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730587AbfCZLaa (ORCPT ); Tue, 26 Mar 2019 07:30:30 -0400 Received: from mail-vs1-f68.google.com ([209.85.217.68]:41703 "EHLO mail-vs1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726285AbfCZLaa (ORCPT ); Tue, 26 Mar 2019 07:30:30 -0400 Received: by mail-vs1-f68.google.com with SMTP id g187so7378725vsc.8 for ; Tue, 26 Mar 2019 04:30:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HhUEgjNRNgTc30sxj0UUXn4H7N0bkT21t+Udf71BA04=; b=AaJl87bMvta5uABhGN6Un/EJU/GM+ATpLcVkmuSPTnS/8nXXX6wrFEl77GD1aXI4qG N/ZWmHikT7WZ3zZaYzz8B01f8Ro+maK4ZdVdcqiK4v+dxdIMiRa1aXUv6/redzk3Z8z2 qGzS9jDAfCq13z164+zsaMRMHEDZ2PZ3Kx4OPJQSRK0TSbWN+nysFTg218RZvfaRWST8 7OK7qybQHNdrxWXLsg+oP9aIteaLcx+aZmqFffACv7yQA7t1V1nyqrESu9wt6iqAFHb4 enCqS1WoaL220pcDsHmkG47EWbVV0z3eVDu9hO/RU+JqKGEIuu0M2tZCeA0r+LgZgmZK ztqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HhUEgjNRNgTc30sxj0UUXn4H7N0bkT21t+Udf71BA04=; b=H37aR5eMHIfSu/JDrQskQVbZsqFvyMBK06Be6n0iB/d3LoWbWWTza/5RFu3J2OUMLW BLnyXJ2ys8T5C6LGRpyNjwN0xL7JvHx6/1tz5YWGmn+pWCbuN0MQDzvxByfmX+6v3Mch +edd017DVqhss0cDokZLuc9xOsWg9lblFLnpkp1sQiZS05O5zN/JAb3afKwp7lFno2RP D0eJU8e2wluAthNuQP6nU1YCCSLueXLH3EgFcMXth0sv4AX0ZUDr0ggSds95q2Ck8uLe 47/XfoTIzPsHJDlwrpQLUkHthaZ/ee+mcPa6kmSF9BFXiUZtMx1FKABGJC+nCK3zQ8WA cW+Q== X-Gm-Message-State: APjAAAXmbFiRFQDfdHepp1sUfOwaAE3ANaDL0WcHQbhzQIFTv4ZH4KUU yJL8lz07ddl9NWVhECjSabn+b1D7biPnMeymMsDn0Q== X-Google-Smtp-Source: APXvYqwwDYUHIA9yNpb8J5UoF6dHpB1rEn3Q5o8GTEVqL+HFoLizxVH/6Mvi76JCz5GgPiWpLpTvQfJBG379++DFK/k= X-Received: by 2002:a67:ec03:: with SMTP id d3mr10878596vso.165.1553599829328; Tue, 26 Mar 2019 04:30:29 -0700 (PDT) MIME-Version: 1.0 References: <20190227195836.24739-1-ulf.hansson@linaro.org> <20190227195836.24739-4-ulf.hansson@linaro.org> <2942111.nn8VVVUCAL@aspire.rjw.lan> In-Reply-To: From: Ulf Hansson Date: Tue, 26 Mar 2019 12:29:52 +0100 Message-ID: Subject: Re: [PATCH v12 3/4] cpuidle: Export the next timer/tick expiration for a CPU To: "Rafael J. Wysocki" Cc: "Rafael J. Wysocki" , Linux PM , Frederic Weisbecker , Thomas Gleixner , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , Daniel Lezcano , "Raju P . L . S . S . S . N" , Stephen Boyd , Tony Lindgren , Kevin Hilman , Lina Iyer , Viresh Kumar , Vincent Guittot , Geert Uytterhoeven , Linux ARM , linux-arm-msm , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 26 Mar 2019 at 11:36, Rafael J. Wysocki wrote: > > On Mon, Mar 25, 2019 at 3:24 PM Ulf Hansson wrote: > > > > On Mon, 25 Mar 2019 at 13:21, Rafael J. Wysocki wrote: > > > > > > On Wednesday, February 27, 2019 8:58:35 PM CET Ulf Hansson wrote: > > > > To be able to predict the sleep duration for a CPU that is entering idle, > > > > knowing when the next timer/tick is going to expire, is extremely useful. > > > > Both the teo and the menu cpuidle governors already makes use of this > > > > information, while selecting an idle state. > > > > > > [cut] > > > > > > > > + > > > > if (cpuidle_state_is_coupled(drv, index)) > > > > return cpuidle_enter_state_coupled(dev, drv, index); > > > > return cpuidle_enter_state(dev, drv, index); > > > > > > Also I would clear next_hrtimer here to avoid dragging stale values > > > around. > > > > Right, I can do that. > > > > However, at least in my case it would be an unnecessary update of the > > variable, as I am never in a path where the value can be "stale". > > It easily can AFAICS. After all, cpu_power_down_ok() need not run on > the same CPU that is setting next_hrtimer here. That's correct. > > > Even if one theoretically could use a stale value, it's seems likely to not > > be an issue, don't you think? > > That would be because of the locking in the ->enter() callback I > suppose? But is it actually universally guaranteed that setting > next_hrtimer will never be reordered with acquiring the lock? In the PSCI case and for those CPUs that shares the same genpd governor (even hierarchically), then yes. Unfortunate, I haven't been able to explore this in that great detail for other legacy ARM32 platforms, so maybe it's just better to play safe, as you suggest and avoid a stale value. > > Also, there is some overhead to be avoided if cpu_power_down_ok() > checked the next_hrtimer of the other CPUs against 0 explicitly, isn't > it? In regards to overhead and when using genpd for CPUs, there are a couple of things I have in mind that we could try to improve. Yes, checking for next_hrtimer against 0 could be one thing to consider. Kind regards Uffe From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78984C43381 for ; Tue, 26 Mar 2019 11:30:40 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 44AD42070B for ; Tue, 26 Mar 2019 11:30:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="T8DvLcTl"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="AaJl87bM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 44AD42070B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uS10VInoG55R4BodnfZIr+mJwyT6w9nu8DslFEHSQqo=; b=T8DvLcTlKNIqQ6 16kV8yhswyFVQHhMT0q32rpV9arG3/uJ60H+lEi3foLoiH6mdveH6i/PY6NJZOvu65B9lvlA7hCk6 hefIry5TPJ/nYvtnLZ058a6XOHITQVfbLOjxMHBDYmV54e3DfNID9frwIA4tJ5lhSq8DuNty45/n9 EjLuBXK0oPvgB1LCbUNP4Use74DFrWMrqWcCGNZ1a47MOPPbEwtKhvwCLst8kX9ullNSYuzR60lpx F0dP2B2z6z3MiAkP7emsZPEsTRRBcIpuVwruDt4f0o5nXyMTjCXYj12u7OeTSmHai95ABr+iHZFVu JwgGmavYsgpxaEWMvIow==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h8kHq-0001ZI-DU; Tue, 26 Mar 2019 11:30:34 +0000 Received: from mail-vs1-xe41.google.com ([2607:f8b0:4864:20::e41]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h8kHn-0001Yc-5Q for linux-arm-kernel@lists.infradead.org; Tue, 26 Mar 2019 11:30:32 +0000 Received: by mail-vs1-xe41.google.com with SMTP id w13so7396591vsc.4 for ; Tue, 26 Mar 2019 04:30:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HhUEgjNRNgTc30sxj0UUXn4H7N0bkT21t+Udf71BA04=; b=AaJl87bMvta5uABhGN6Un/EJU/GM+ATpLcVkmuSPTnS/8nXXX6wrFEl77GD1aXI4qG N/ZWmHikT7WZ3zZaYzz8B01f8Ro+maK4ZdVdcqiK4v+dxdIMiRa1aXUv6/redzk3Z8z2 qGzS9jDAfCq13z164+zsaMRMHEDZ2PZ3Kx4OPJQSRK0TSbWN+nysFTg218RZvfaRWST8 7OK7qybQHNdrxWXLsg+oP9aIteaLcx+aZmqFffACv7yQA7t1V1nyqrESu9wt6iqAFHb4 enCqS1WoaL220pcDsHmkG47EWbVV0z3eVDu9hO/RU+JqKGEIuu0M2tZCeA0r+LgZgmZK ztqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HhUEgjNRNgTc30sxj0UUXn4H7N0bkT21t+Udf71BA04=; b=N8UcK2sTXiwkbF/iE9p3s10ncrHUfYufybMtOKOgmsrilKtCldCshIskypU6DzutHU VzUH6GSAYiOwYXC9RitEDiJtWakteLzRDRLe8bT0YqAMp+y82yI/jYJWTy8VSMz7d6+R F3p9bpmOG+QmS+T0m13Qy2CPLW30pcF08yjY3pz0Rj367/G4H0h8Do8X4HMaN0srtkwb lZ0ZOTVYiAkb9QBrKjC3xsinn3cpOsjDseObJctpihDvyQF6bqdq6OvsnDpQtRjLGSRH zNUtfXPNqSp4s9BWuDm9mOe6dxwY55R+dSQTsGeot9xO+k9RsUdwewfHCdSnp0f1HPJQ MirQ== X-Gm-Message-State: APjAAAUQz3vHvASaAD0+IHyEpot2lf8WbDWSxqp5vaTayQA0x0Jh16TL 2AR1bzEqdTIEVC+5+CCAws8thyBWPehBENwITRoASQ== X-Google-Smtp-Source: APXvYqwwDYUHIA9yNpb8J5UoF6dHpB1rEn3Q5o8GTEVqL+HFoLizxVH/6Mvi76JCz5GgPiWpLpTvQfJBG379++DFK/k= X-Received: by 2002:a67:ec03:: with SMTP id d3mr10878596vso.165.1553599829328; Tue, 26 Mar 2019 04:30:29 -0700 (PDT) MIME-Version: 1.0 References: <20190227195836.24739-1-ulf.hansson@linaro.org> <20190227195836.24739-4-ulf.hansson@linaro.org> <2942111.nn8VVVUCAL@aspire.rjw.lan> In-Reply-To: From: Ulf Hansson Date: Tue, 26 Mar 2019 12:29:52 +0100 Message-ID: Subject: Re: [PATCH v12 3/4] cpuidle: Export the next timer/tick expiration for a CPU To: "Rafael J. Wysocki" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190326_043031_212845_EF1CC37D X-CRM114-Status: GOOD ( 21.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Lorenzo Pieralisi , Vincent Guittot , Geert Uytterhoeven , Linux PM , Stephen Boyd , Frederic Weisbecker , linux-arm-msm , Daniel Lezcano , "Rafael J. Wysocki" , Kevin Hilman , Lina Iyer , Linux Kernel Mailing List , Tony Lindgren , Viresh Kumar , Sudeep Holla , Thomas Gleixner , "Raju P . L . S . S . S . N" , Linux ARM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 26 Mar 2019 at 11:36, Rafael J. Wysocki wrote: > > On Mon, Mar 25, 2019 at 3:24 PM Ulf Hansson wrote: > > > > On Mon, 25 Mar 2019 at 13:21, Rafael J. Wysocki wrote: > > > > > > On Wednesday, February 27, 2019 8:58:35 PM CET Ulf Hansson wrote: > > > > To be able to predict the sleep duration for a CPU that is entering idle, > > > > knowing when the next timer/tick is going to expire, is extremely useful. > > > > Both the teo and the menu cpuidle governors already makes use of this > > > > information, while selecting an idle state. > > > > > > [cut] > > > > > > > > + > > > > if (cpuidle_state_is_coupled(drv, index)) > > > > return cpuidle_enter_state_coupled(dev, drv, index); > > > > return cpuidle_enter_state(dev, drv, index); > > > > > > Also I would clear next_hrtimer here to avoid dragging stale values > > > around. > > > > Right, I can do that. > > > > However, at least in my case it would be an unnecessary update of the > > variable, as I am never in a path where the value can be "stale". > > It easily can AFAICS. After all, cpu_power_down_ok() need not run on > the same CPU that is setting next_hrtimer here. That's correct. > > > Even if one theoretically could use a stale value, it's seems likely to not > > be an issue, don't you think? > > That would be because of the locking in the ->enter() callback I > suppose? But is it actually universally guaranteed that setting > next_hrtimer will never be reordered with acquiring the lock? In the PSCI case and for those CPUs that shares the same genpd governor (even hierarchically), then yes. Unfortunate, I haven't been able to explore this in that great detail for other legacy ARM32 platforms, so maybe it's just better to play safe, as you suggest and avoid a stale value. > > Also, there is some overhead to be avoided if cpu_power_down_ok() > checked the next_hrtimer of the other CPUs against 0 explicitly, isn't > it? In regards to overhead and when using genpd for CPUs, there are a couple of things I have in mind that we could try to improve. Yes, checking for next_hrtimer against 0 could be one thing to consider. Kind regards Uffe _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel