Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2259982imu; Thu, 10 Jan 2019 10:58:24 -0800 (PST) X-Google-Smtp-Source: ALg8bN53NeCOHpKcusU/4NK6ILLTj89jtk8EHEOvusdv0P2usLqUq5P2J2ZWHAqj4UhN94sfOz/Y X-Received: by 2002:a17:902:680f:: with SMTP id h15mr11326649plk.40.1547146704628; Thu, 10 Jan 2019 10:58:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547146704; cv=none; d=google.com; s=arc-20160816; b=U1EjYDBKnwpWdAVDedVt9gWytaoPUZIePIssckfmwLzAq0LPVvUw3Ztk/mr+Mg/lGS IIZZJUq/emVwo2mSKKYrsIDd5eIA6Ub+lV/Ll8bzAkVdHFJMKyEwoa853aQ5YRyBQ3BZ UKcuyhh2RLke3z4jMGOFblF7SmSo08jdv5qPNEOUh/MHwVyPJ9BSRW6ZQSJ3U7RLFI6O kcp8e1SSxqVjzHsOf1obrd9h3dAuREkyPWUtOkfxDn1Ei23iXhoS1VGaodhplSYqMpKj yKYb+8s6dZw/65+dKdTLBtqU9hU/IqlkzcfCLalNJqt4hkeyqKGqdSn5Ux6zz4xy34Rg oY/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=7BgF4kh9Xmlpw50K9SbfmwVdmpzqbAle3GfrvnRfGmk=; b=QuNGgDqr9BChqMsl+HufU4FxstwZCPogq1jEhIh+aTBR6NC4COKBp9vnEzcdYu6vAZ +hZNVp7aUEY/N/+GgguPsJVdv8Km/qST2exO2EURNItKMasENPKIq9YBG2aNE+m5cOso kMTQ3oK+ssUW+8Z37MvYyuFT3lYnb7EiND73a5CZCnfYNbS3AXITmA6N7fCkgpUsoffy sHKTsHbhU8IW2ooX/xR5jomRzYQ8V5ao+OngYfdNn7bJC5cNyU2WSDOVRMkSrnEhOqyb NMrsKSXAlxSAhffpWAnChk1Mr/oGjoMv4xPB2ZHm3DFMncpEvbRbPM8KRyZ4VdR66bfl 0bpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SyFN34cb; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l186si18197809pge.205.2019.01.10.10.58.09; Thu, 10 Jan 2019 10:58:24 -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; dkim=pass header.i=@linaro.org header.s=google header.b=SyFN34cb; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729216AbfAJS4c (ORCPT + 99 others); Thu, 10 Jan 2019 13:56:32 -0500 Received: from mail-io1-f67.google.com ([209.85.166.67]:46897 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728331AbfAJS4c (ORCPT ); Thu, 10 Jan 2019 13:56:32 -0500 Received: by mail-io1-f67.google.com with SMTP id v10so9766695ios.13 for ; Thu, 10 Jan 2019 10:56:31 -0800 (PST) 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=7BgF4kh9Xmlpw50K9SbfmwVdmpzqbAle3GfrvnRfGmk=; b=SyFN34cb6X7nCgBYzsAzXOb9UUWhX+NfdDJaApUeY6oM0bWGvd2oAhEfM9LwF34glr +4GvkzgsPgfa2jenE6CcTmKmCeASazCXEvWf8L9Hj8JRtISD6JrrM0WNb2B7+hROCg/D yQEX7hQmhZkDylS2lChIBGRE2u+M+Q3+58T8E= 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=7BgF4kh9Xmlpw50K9SbfmwVdmpzqbAle3GfrvnRfGmk=; b=RBJbt+QUJg4B9M9lt+OMUdD9pU2ozKRypvRgtmUH21PAcEVMC6fDsdrSAnID8ATL+U Khe0WCWtrENEipmrRDmlPNTtNZgT0iccO3G23QJNjnI44Qa5hm6N429N0x/T2BLWKmRu TrWrYpHI1cZYJILlIt2Ac2xO2D98SiWvJ5Dc5dNZlly3fgRhQxIJwFqfxixyEZ3yUET4 p/7IAbCMG+ceBO/en1nJxD+8xn6Fy4CIUZru5JqAdUuTrS3TsiHeK4q8t4nlxWKizwwS 3Gxc1NOEpQYLENT/nqwvuc1P7cOuth1xWWyjZApfufc4MYSMtYhHJqbHdpM8U62bWTnv ri2w== X-Gm-Message-State: AJcUukdZSC1718e5LqoALQieeOyOMNnes6OKAz2au3+Vz+7mto/nZZGr ShoJvi1jjt7S+XgA6yAGpjWgJzYOcKWuZ73rfpa3vEeGYroNnQ== X-Received: by 2002:a6b:6b02:: with SMTP id g2mr7195717ioc.18.1547146590880; Thu, 10 Jan 2019 10:56:30 -0800 (PST) MIME-Version: 1.0 References: <20190110095125.GA4491@lenoch> In-Reply-To: <20190110095125.GA4491@lenoch> From: Vincent Guittot Date: Thu, 10 Jan 2019 19:56:19 +0100 Message-ID: Subject: Re: [PATCH] PM/runtime: Do not needlessly call ktime_get To: Ladislav Michl Cc: "Rafael J. Wysocki" , Linux PM , Linux Kernel Mailing List , Linux ARM , Linux OMAP Mailing List , "Rafael J. Wysocki" , Ulf Hansson , Tony Lindgren 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 Thu, 10 Jan 2019 at 10:51, Ladislav Michl wrote: > > pm_runtime_autosuspend_expiration calls ktime_get 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: Vincent Guittot > --- > NOTE: Depends on Vincent's "[PATCH v2] PM/runtime: Fix autosuspend_delay > on 32bits arch"! > > 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 457be03b744d..836b1b8784eb 100644 > --- a/drivers/base/power/runtime.c > +++ b/drivers/base/power/runtime.c > @@ -129,24 +129,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_to_ns(ktime_get()); > + 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_to_ns(ktime_get())) > + return expires; /* Expires in the future */ > > - out: > - return expires; > + return 0; > } > EXPORT_SYMBOL_GPL(pm_runtime_autosuspend_expiration); > > -- > 2.20.1 >