From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Rafael J. Wysocki" Subject: Re: [PATCH v12 3/4] cpuidle: Export the next timer/tick expiration for a CPU Date: Tue, 26 Mar 2019 11:36:29 +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: Ulf Hansson 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 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. > 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? 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? 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,MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED 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 20D1BC43381 for ; Tue, 26 Mar 2019 10:36:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DDA7620857 for ; Tue, 26 Mar 2019 10:36:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553596602; bh=yn+zcbe5vHmzuxaaXc8U6ognhrxRs3M8GUNaTIFYqt4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=umaO0aax6+4e/f9bNskRuMn1dwI0RD8fo4lLbcbR2UlJFZkaMfh7/ypPreOZjP188 CTzvA1p6NM5lDz8j94sJj3XTZs1JiaY/lS0gf+uimAk9WlmO5FAY/gqAr96cAWy6v0 VxGG+eCdzETke85QJD/lAgXxtDzBsyBkmjqhPJOY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731324AbfCZKgl (ORCPT ); Tue, 26 Mar 2019 06:36:41 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:33801 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726171AbfCZKgl (ORCPT ); Tue, 26 Mar 2019 06:36:41 -0400 Received: by mail-ot1-f65.google.com with SMTP id k21so9590284otf.1; Tue, 26 Mar 2019 03:36:40 -0700 (PDT) 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=/8j1B6OwetF9lBqmH6rAe0V0MqvmwARcP8TsPhZtHqQ=; b=tUEQes7zzbIs06PwAD7QlfENw45jKFjbSRQPtKO4/jLaFNHNIYByoBP3kyiyZYN0OS F9tqPi8D7nCAnIK4w0z9VrykwLJZuYXImKmP2DajLpHK/R8NLYrRt7e/WTCkd/7645tm OoMzAaC1qkP1Lzzbc/i6IfUwGmRDLqImN2L2q2zr+30xGZjmBDbV/vj/+uIN/lSjThLE fEOx6uUQD4ibdhmdCAORLBwIHMl3SjLE1Mo6VHLS0756/vSS6d+iNen6i7o1i+W2sjgq cdk5m7ikTEB2FPsRGzfeldGT4C/KkjuPVBOYVO5SJAyOexcbY0H5OAm3gd1/dE83VkcY TRPQ== X-Gm-Message-State: APjAAAVGwpwbs1PIIdNMJxKsnGoAG8YZYJ2NUl5WNiR6X2EzIU6fFuY2 CzseIcOgfafLE6HlDvOO5mYN58p8s0Dz9TkK6rE= X-Google-Smtp-Source: APXvYqz9gqwmf/hj92we5sSVxPPQgaG3L1fYFdHikS27eQ71XBNB6iRel5FOTU8JxEQ617UPxb/yevGOr8mDdFikid4= X-Received: by 2002:a9d:738c:: with SMTP id j12mr20483042otk.119.1553596600485; Tue, 26 Mar 2019 03:36:40 -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: "Rafael J. Wysocki" Date: Tue, 26 Mar 2019 11:36:29 +0100 Message-ID: Subject: Re: [PATCH v12 3/4] cpuidle: Export the next timer/tick expiration for a CPU To: Ulf Hansson 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 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. > 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? 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? 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, MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED 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 0357AC43381 for ; Tue, 26 Mar 2019 10:37:03 +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 C5AF92084B for ; Tue, 26 Mar 2019 10:37:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="fWvoVIUu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C5AF92084B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.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=p18Qz+nkHe8kD1sAaojUXDGOya++YD6d7aNzRCCoNCU=; b=fWvoVIUuKvFGIa JT9aYeeDErvDHHjX/CFutLpM1tCPukwG20JNcQ6u+ephJmwaWvRZlSWMYd1ZoQtbv9Eq/KPrCwtZG TNMaRfjD1INot/86jDKtD7HaRCyysNXUt85ebanHh4HcawnWDCZdd9Ws7oFjFgdJDNFgr/YKUuuE5 IfNGm9mi23skQHwD1JDtxETQl7tKkW406Q+qs4eqH3hMl5TOwwPj3WTbwLpDbtCFTzfgWZgu2XwR7 4ytstkMyNRLamqp2w80ur28XiT5bHmigj1WJIl/1KJ/akCGTKCyHOmzuXJ8MwpIttyrOu/yjLRW1V NgxEaPpNbha3DiDFpcqA==; 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 1h8jRu-0006KG-CW; Tue, 26 Mar 2019 10:36:54 +0000 Received: from mail-ot1-f65.google.com ([209.85.210.65]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h8jRp-0006Io-W2 for linux-arm-kernel@lists.infradead.org; Tue, 26 Mar 2019 10:36:51 +0000 Received: by mail-ot1-f65.google.com with SMTP id t8so5670383otp.7 for ; Tue, 26 Mar 2019 03:36:45 -0700 (PDT) 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=/8j1B6OwetF9lBqmH6rAe0V0MqvmwARcP8TsPhZtHqQ=; b=ZfiXoSjwgxTemFPsNRZknYeh1N07LjpEjjKal/rEKjaDVDmiX3J/iKyfoHV5BgQYDn JP2fZCNi+oDUCoDqVYpv2I6X//63vX6NkrUd/tFbpjscGI8n3/Lamh2mrQetOO2ldmFg x05gdXas0yNaROWx+7LgdJHYorS5RuIDxFW8Frxesn8uG2ErQ4VXGYUfelQueg6REE12 ZFThgkmAxnyFoa5BzmMDfMyNfolR8xr7YYwbdTmPpmkzr5dyV+T6Cxxarb6YZ4IQit3o cPI9MHa38o4NKXB+p17a/7/OmZSazJ/22FfNJOoyg4OJauV7LsFgyY75ONulWAq6QJwp sp2g== X-Gm-Message-State: APjAAAV6PFvr8syUICyabDCECp3DHUlNIFZV5HjdFbZ0boqD+XS7VM14 v/8OYueHA8wdH0ScHenm36T2DEdUESpc4JyWaVQ= X-Google-Smtp-Source: APXvYqz9gqwmf/hj92we5sSVxPPQgaG3L1fYFdHikS27eQ71XBNB6iRel5FOTU8JxEQ617UPxb/yevGOr8mDdFikid4= X-Received: by 2002:a9d:738c:: with SMTP id j12mr20483042otk.119.1553596600485; Tue, 26 Mar 2019 03:36:40 -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: "Rafael J. Wysocki" Date: Tue, 26 Mar 2019 11:36:29 +0100 Message-ID: Subject: Re: [PATCH v12 3/4] cpuidle: Export the next timer/tick expiration for a CPU To: Ulf Hansson X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190326_033650_025969_49711A9A X-CRM114-Status: GOOD ( 16.44 ) 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 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. > 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? 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? _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel