From patchwork Tue Dec 18 14:55:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 154147 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3805553ljp; Tue, 18 Dec 2018 06:55:42 -0800 (PST) X-Google-Smtp-Source: AFSGD/VZ4Ds7Oam+Ms2cMsmIW4xuZO9B+/vQ6AVPcMdBAAm7ypblmvCmfmD8CFXiWVp9uhV8f6xt X-Received: by 2002:a62:3a04:: with SMTP id h4mr16761192pfa.119.1545144942215; Tue, 18 Dec 2018 06:55:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545144942; cv=none; d=google.com; s=arc-20160816; b=IrHyj3UtvHWN7GT1Tcc0uU401q0RNlFCAc6T2WW7V+4O+qftTfITIvIp2ajSnvM9Ys dCPVpxXesFTnkBJs6YymKBwOvAPrroiZG5Sx1mGrw3+hRijkLetwqc1Lq4q1foxXx27P H0xiK5tmbYpi6pFAGbTB3KWLzESj1liRxAJTTEIApdbVtQ4l1tI63FWcuhmvF0zz/CaB nkes406ATzXrCOnQ+hY/NM62uNob27VF3lgI//QI9YnYha7NCQCBpURxbeahOipqvqXJ xjvMQqFBxnsrJxgwrX2OWt1Udfh1oWNDHeW7oSuKndfFysxo+syI9X+X/8HKYDRMp3cn 56Ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=gUwbwmeADuEc2X4Ia538ZUBklszWDge9MdrlOIVIBqg=; b=ASbXiqeYTE8Ssh+0xWGNpuTNxuTtIpxG1mr3XoS/HZM5s35ZZJTgKHTgMsSRHpPuAR lJIsopWAytIYw2DCUbHOLSh7hjZgzp3tfw5D5F8ieqiwpPUNL89gIsQGjf6RnTPHVtfm X3m07667AqWzUnpvDgdpovgnZQyKnRtsA/xCfjqTX3fycpabpa6fNg9rFI0RPPayS6ng t7h9SRbbe2DlOXHG+KA3eIyHVsGjdsJMOtI7cl4tHK+Cjift/1oQgioWutPWJDuykYOz HB9p0YOhTJfsxLsRrzaLfcUna8MSL9iQ/R+/FeP5jaq2W9HZ0aa4Psj5MxdTuWE0H7Hg Ltmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YpMcJy+o; 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 b19si14641632pfm.100.2018.12.18.06.55.41; Tue, 18 Dec 2018 06:55:42 -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=YpMcJy+o; 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 S1726802AbeLROzk (ORCPT + 31 others); Tue, 18 Dec 2018 09:55:40 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:43990 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726766AbeLROzh (ORCPT ); Tue, 18 Dec 2018 09:55:37 -0500 Received: by mail-wr1-f67.google.com with SMTP id r10so16188876wrs.10 for ; Tue, 18 Dec 2018 06:55:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gUwbwmeADuEc2X4Ia538ZUBklszWDge9MdrlOIVIBqg=; b=YpMcJy+oov1I6Sv6Xa3HOejixQCR0FjNZ6zfWc7eRx7Y7qeUibf3JeP+h6MhGzGrUe gxnsBy8U9VN0BFhJl9S4R1nHxIaRNBeHqmfqPnMwQLbqsYcxUkS9Cmb+F/fLq36EjRCF nrmRCqAMrzG9W9zj8uClaRVMDh9YpyCl6MHSg= 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:in-reply-to :references; bh=gUwbwmeADuEc2X4Ia538ZUBklszWDge9MdrlOIVIBqg=; b=WMFVDgxey8QKEW1kernhmDuk2suputArHKRqbiouDeygQm/AELQtu5OrnmlbzL7i7b VrHKYjgR2yK9V26qB4AeNPw6SGF/tsIub0dyfGQrav7SwZ1Xvw4UxYAM0V4ziB5WNlOs rXfbsTMIBuMKO8nYrtRuqRiNc3Yrkm7j7AZrgFz17rmUZZwSpvPK7l+kJMXPWYtrSQxr zbahxC5IIczPaoxzA6ystB5OyJg/qinCClpIjhT+ElX7T4zs7vMHRNsx4A/0oVaaLc7I kPjyhd3AclEUqR7doTSdVMoytzPZyabsTIAvXaCgOJXiIrQAcp6bhlp9loCY5GvTuVvr +awQ== X-Gm-Message-State: AA+aEWanmM/bUCuboWZI9b2RotpzvgoC+ijJq0BlfITJrS0kh7Be7Jep 2xeRRq2rs/WYcL6jLEh1O6Sh9Q== X-Received: by 2002:a5d:4a0c:: with SMTP id m12mr14781326wrq.38.1545144935389; Tue, 18 Dec 2018 06:55:35 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:f:6020:85e9:25c5:6cbd:73e9]) by smtp.gmail.com with ESMTPSA id n20sm1579956wmi.11.2018.12.18.06.55.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Dec 2018 06:55:34 -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 Cc: ulf.hansson@linaro.org, Vincent Guittot Subject: [PATCH 3/3] PM/runtime:Replace jiffies based accounting with ktime based accounting Date: Tue, 18 Dec 2018 15:55:23 +0100 Message-Id: <1545144923-31546-4-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1545144923-31546-1-git-send-email-vincent.guittot@linaro.org> References: <1545144923-31546-1-git-send-email-vincent.guittot@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 | 10 +++++----- drivers/base/power/sysfs.c | 11 ++++++++--- include/linux/pm.h | 6 +++--- 3 files changed, 16 insertions(+), 11 deletions(-) -- 2.7.4 diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 6461469..5c18e28 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -66,8 +66,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; @@ -77,9 +77,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) @@ -1517,7 +1517,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 0bd9de1..3d2cbf9 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -633,9 +633,9 @@ struct dev_pm_info { int runtime_error; int autosuspend_delay; u64 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);