Received: by 2002:ac0:8c8e:0:0:0:0:0 with SMTP id r14csp435702ima; Wed, 6 Feb 2019 02:36:00 -0800 (PST) X-Google-Smtp-Source: AHgI3IY5TVRribTd5W/S8DHHGvJ3hd2MR4iZFyoJy+w39Ilhifxidw0BEzkLQ4KW+wz/rlHd/yjx X-Received: by 2002:a63:e247:: with SMTP id y7mr8616197pgj.84.1549449360809; Wed, 06 Feb 2019 02:36:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549449360; cv=none; d=google.com; s=arc-20160816; b=TZuuCgTP1mYBA8j6zHGwSk71tbuZyiU7N2uEqA3MqWdp1Xo+EZQz/En+y4UQYVHqvm lFDM2LL1LdT+4gGXK1WlCjTq/7d5hIQ7S4OJ80iPFk/RqkBqUuHDkzePaqoPK8wHbfUB xyHTV9g07EimCo0keDxtMmecyEIAovSHk1671JVx1QpRYjjSP/B49MjCvMnvNp8O3jDO bt0dCEJZJb5fRDoaDJVR+78hFF3q1kYERisW1rStFKekFyY+yQGF20ZuIgGcv+wwem4W L9VC/SAYkZrAVTxhzo+qKltjYF186CIWvzVmx0DmA3vvxTXMYZVASx7hVD2DExICqeFd oQnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=vjw+ETnDLgs8Omog7Xjwcd/gFDdJAAxWX/I5RufC6IQ=; b=SUINTcuUAoLGHVr0omxRQ7v4Z6EBfc8rJ1BXAjwJ68qIQogamas3tEP8K+VVqqjBBH 4IiMU1S1oI31whaJxSJHk/ilWzFldNKdMeTXJIeNSPjQN8jRbkNTacbXdpbD2/piDPXU vfFuUzBwNOZ95TRKbbtIZKxiiCCMGUP4k3G72IwtcCngUYE/tFxnUhlKVVL2VWwlvEU9 lhX9JLirEGFOMoSmTo94Lqg6KgzArEAtbVuwqnyDYkPMovvaF1CrutVYAoo08SmuDugF 8KCWZrIfPZq8uFxrRYXUUHbNpuF/gYPmB+KranLVx+oHtpb9jCwsZ2yubwXXYsw47Wmt hbbA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c32si5887383plj.38.2019.02.06.02.35.45; Wed, 06 Feb 2019 02:36:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729597AbfBFKfS (ORCPT + 99 others); Wed, 6 Feb 2019 05:35:18 -0500 Received: from cloudserver094114.home.pl ([79.96.170.134]:58418 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728416AbfBFKfR (ORCPT ); Wed, 6 Feb 2019 05:35:17 -0500 Received: from 79.184.254.36.ipv4.supernova.orange.pl (79.184.254.36) (HELO aspire.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.183) id d97ed51e97c75656; Wed, 6 Feb 2019 11:35:15 +0100 From: "Rafael J. Wysocki" To: Ladislav Michl Cc: "Rafael J. Wysocki" , Linux PM , Linux Kernel Mailing List , Linux ARM , Linux OMAP Mailing List , Ulf Hansson , Biju Das , Geert Uytterhoeven , Linux-Renesas , Vincent Guittot Subject: Re: [PATCH] PM/runtime: Optimize pm_runtime_autosuspend_expiration() Date: Wed, 06 Feb 2019 11:34:03 +0100 Message-ID: <4091828.IqCJ3qcF9B@aspire.rjw.lan> In-Reply-To: <20190130214017.GA5038@lenoch> References: <20190130214017.GA5038@lenoch> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wednesday, January 30, 2019 10:40:17 PM CET Ladislav Michl wrote: > pm_runtime_autosuspend_expiration calls ktime_get_mono_fast_ns > even when its returned value may be unused. Therefore get > current time later and remove gotos while there. > > Signed-off-by: Ladislav Michl > Acked-by: Tony Lindgren > Acked-by: Vincent Guittot > --- > This patch is based on top of bleeding-edge branch, where > "[PATCH v2 ] PM-runtime: fix deadlock with ktime" is sitting. > I expect v3 of that patch, which should not harm this one. > It is meant to replace "PM/runtime: Do not needlessly call ktime_get" > sent earlier. > > drivers/base/power/runtime.c | 19 ++++++++----------- > 1 file changed, 8 insertions(+), 11 deletions(-) > > diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c > index 65e2b5f48e0c..7bbe28faca8d 100644 > --- a/drivers/base/power/runtime.c > +++ b/drivers/base/power/runtime.c > @@ -145,24 +145,21 @@ static void pm_runtime_cancel_pending(struct device *dev) > u64 pm_runtime_autosuspend_expiration(struct device *dev) > { > int autosuspend_delay; > - u64 last_busy, expires = 0; > - u64 now = ktime_get_mono_fast_ns(); > + u64 expires; > > if (!dev->power.use_autosuspend) > - goto out; > + return 0; > > autosuspend_delay = READ_ONCE(dev->power.autosuspend_delay); > if (autosuspend_delay < 0) > - goto out; > - > - last_busy = READ_ONCE(dev->power.last_busy); > + return 0; > > - expires = last_busy + (u64)autosuspend_delay * NSEC_PER_MSEC; > - if (expires <= now) > - expires = 0; /* Already expired. */ > + expires = READ_ONCE(dev->power.last_busy); > + expires += (u64)autosuspend_delay * NSEC_PER_MSEC; > + if (expires > ktime_get_mono_fast_ns()) > + return expires; /* Expires in the future */ > > - out: > - return expires; > + return 0; > } > EXPORT_SYMBOL_GPL(pm_runtime_autosuspend_expiration); > > Applied, thanks!