From patchwork Thu Dec 20 14:17:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 154338 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp6238700ljp; Thu, 20 Dec 2018 06:17:14 -0800 (PST) X-Google-Smtp-Source: AFSGD/XzlkXOtcFFfASJ8ygqt9dZqvprXolZFWPjtF0eFEJVzTUV7YLux7KdgaLsg/xWUh7bbD+F X-Received: by 2002:aa7:868f:: with SMTP id d15mr24155797pfo.225.1545315434621; Thu, 20 Dec 2018 06:17:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545315434; cv=none; d=google.com; s=arc-20160816; b=F9IwjXL1sopE8NaTkSxvjIJHSPIkzCia7NNByxG98ufDAMphSPKozV565MShMJZuSs Cz2/0SfaawcSf8QC9iPdojC10WNYKp0uRL+kAo6K+w1ECWQPi7ZvQVl0ApTo13uFAWL1 q5HRnWZK8FbXKebImMdLDgxjF7d8Sp6eL0ghz5Ldij/SRcMoFbgah9D2F89uqVW02c4s jo/4OFagyh9ZoeJWuhnfUGDJ2LfDlZEY4jUELLzCHr6dQ3oqhQvu+J/Tm7ti8mdTRmY+ r8Aq0xs+Q19x8QtTV90He57k5KqVN/TvGBqYYRE1HLl81HUVYKcWv+8VPII1O9G5/u+C 861w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:message-id:date:subject:to:from:delivered-to; bh=NyM3K8uh/pUoGlE2EussyPqXEIJ17a+ZErdwR0Nz5ec=; b=j0umjy/JyN7tSrBqR6uKH6OiXkeaEUurZ21NNoWXDqXPwZTvlfm36YytOCIx+jUlhm 6D/hKOii9mTE6Rxq+Z5j1Vndulp0GQ/TAwWIc4jAhUthy/uqkpm5aU+4b0iaMMNMkh+a TkC25RtH0Zb2JrWuCTfwm+CFT8ubyHvHyWu9fXO8GI1EQlm77H4YZY94VQ8RS80kKtsB s1BuzPObzx2u6CGQuzfdfMvD0HvuTO7ATzJBd0USQUtL/Y8rW/gXT9xjw4pJmF2TB3q3 Erp2h+5zgYswDeo4mUqWsKhkkjr8EMTB6jpWAuswRKEVDPtus1W1OnXg1PgS4Bkz8ned V2yg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id 26si19191209pgu.190.2018.12.20.06.17.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Dec 2018 06:17:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D5B266F3CA; Thu, 20 Dec 2018 14:17:12 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by gabe.freedesktop.org (Postfix) with ESMTPS id C17846F3C9 for ; Thu, 20 Dec 2018 14:17:10 +0000 (UTC) Received: by mail-wm1-x344.google.com with SMTP id c126so2371772wmh.0 for ; Thu, 20 Dec 2018 06:17:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Knn4iUcnejv9TyDbBm0a94Rk0LLVciIk4+jKF5JXBmY=; b=GtAAlEwjj8TEjKtS2zu6bA03pjD0nEkZ9Dm1YvcF/GJ2HrE26AdQkzh/orlVOQpPRw arjIKovMBjMdL3faQusERQ1ffay5NnRBRasUvOQIn+pl/M20IuKOeAG3798/n3O1yc7b Sa+QS/3P/zgI0gq2Dfv9X3tp9UTqVfV8a6cj9rc+H7PNUriBBRp13vB2a21SaDDCAdKO zpm1B6bDdAcAHVokhAbDghf2SWZ1Y118yFNLTWIDptgztMDD0jpogJ7vE2CuxytFnlqV teh8cPTSSSVyPnfs8M6PhLRk3LrT6TVlFvV25y08R2eozt/vUkqgeIXDT2WP2pveALDt XouA== X-Gm-Message-State: AA+aEWZ0SZCO4lcCrTdRLbEFzKSNxdxUFar6uhHIuHx19j1XsXhqkJxr emzRLWKKZmBS7waPqo0hsaN7SQ== X-Received: by 2002:a1c:9806:: with SMTP id a6mr2824292wme.114.1545315429397; Thu, 20 Dec 2018 06:17:09 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:f:6020:f9b3:37c1:b11a:64ce]) by smtp.gmail.com with ESMTPSA id m132sm4616849wmd.15.2018.12.20.06.17.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Dec 2018 06:17:08 -0800 (PST) From: Vincent Guittot To: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, rjw@rjwysocki.net, thara.gopinath@linaro.org, jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, airlied@linux.ie, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH v4 3/3] PM/runtime:Replace jiffies based accounting with ktime based accounting Date: Thu, 20 Dec 2018 15:17:06 +0100 Message-Id: <1545315426-14545-1-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ulf.hansson@linaro.org, Vincent Guittot MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Thara Gopinath This patch replaces jiffies based accounting for runtime_active_time and runtime_suspended_time with ktime base accounting. This makes the runtime debug counters inline with genpd and other pm subsytems which uses ktime based accounting. Signed-off-by: Thara Gopinath [move from ktime to raw nsec] Signed-off-by: Vincent Guittot --- drivers/base/power/runtime.c | 17 +++++++++-------- drivers/base/power/sysfs.c | 11 ++++++++--- include/linux/pm.h | 6 +++--- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index e695544..f700524 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -64,8 +64,8 @@ static int rpm_suspend(struct device *dev, int rpmflags); */ void update_pm_runtime_accounting(struct device *dev) { - unsigned long now = jiffies; - unsigned long delta; + u64 now = ktime_to_ns(ktime_get()); + u64 delta; delta = now - dev->power.accounting_timestamp; @@ -75,9 +75,9 @@ void update_pm_runtime_accounting(struct device *dev) return; if (dev->power.runtime_status == RPM_SUSPENDED) - dev->power.suspended_jiffies += delta; + dev->power.suspended_time += delta; else - dev->power.active_jiffies += delta; + dev->power.active_time += delta; } static void __update_runtime_status(struct device *dev, enum rpm_status status) @@ -88,17 +88,18 @@ static void __update_runtime_status(struct device *dev, enum rpm_status status) u64 pm_runtime_suspended_time(struct device *dev) { - unsigned long flags, time; + u64 time; + unsigned long flags; spin_lock_irqsave(&dev->power.lock, flags); update_pm_runtime_accounting(dev); - time = dev->power.suspended_jiffies; + time = dev->power.suspended_time; spin_unlock_irqrestore(&dev->power.lock, flags); - return jiffies_to_nsecs(time); + return time; } EXPORT_SYMBOL_GPL(pm_runtime_suspended_time); @@ -1503,7 +1504,7 @@ void pm_runtime_init(struct device *dev) dev->power.request_pending = false; dev->power.request = RPM_REQ_NONE; dev->power.deferred_resume = false; - dev->power.accounting_timestamp = jiffies; + dev->power.accounting_timestamp = ktime_to_ns(ktime_get()); INIT_WORK(&dev->power.work, pm_runtime_work); dev->power.timer_expires = 0; diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c index d713738..96c8a22 100644 --- a/drivers/base/power/sysfs.c +++ b/drivers/base/power/sysfs.c @@ -125,9 +125,12 @@ static ssize_t runtime_active_time_show(struct device *dev, struct device_attribute *attr, char *buf) { int ret; + u64 tmp; spin_lock_irq(&dev->power.lock); update_pm_runtime_accounting(dev); - ret = sprintf(buf, "%i\n", jiffies_to_msecs(dev->power.active_jiffies)); + tmp = dev->power.active_time; + do_div(tmp, NSEC_PER_MSEC); + ret = sprintf(buf, "%llu\n", tmp); spin_unlock_irq(&dev->power.lock); return ret; } @@ -138,10 +141,12 @@ static ssize_t runtime_suspended_time_show(struct device *dev, struct device_attribute *attr, char *buf) { int ret; + u64 tmp; spin_lock_irq(&dev->power.lock); update_pm_runtime_accounting(dev); - ret = sprintf(buf, "%i\n", - jiffies_to_msecs(dev->power.suspended_jiffies)); + tmp = dev->power.suspended_time; + do_div(tmp, NSEC_PER_MSEC); + ret = sprintf(buf, "%llu\n", tmp); spin_unlock_irq(&dev->power.lock); return ret; } diff --git a/include/linux/pm.h b/include/linux/pm.h index e723b78..e5a34e2 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -632,9 +632,9 @@ struct dev_pm_info { int runtime_error; int autosuspend_delay; unsigned long last_busy; - unsigned long active_jiffies; - unsigned long suspended_jiffies; - unsigned long accounting_timestamp; + u64 active_time; + u64 suspended_time; + u64 accounting_timestamp; #endif struct pm_subsys_data *subsys_data; /* Owned by the subsystem. */ void (*set_latency_tolerance)(struct device *, s32);