From patchwork Fri Dec 14 14:22:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Guittot X-Patchwork-Id: 153857 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2130351ljp; Fri, 14 Dec 2018 06:22:48 -0800 (PST) X-Google-Smtp-Source: AFSGD/W58fPGwkka7s1+M2uts3Nr037gYsK8NbDl8gVBLp3zzguRNNJXSEWBC7YAqq13MKNUnAjI X-Received: by 2002:a63:77ce:: with SMTP id s197mr2866627pgc.89.1544797368382; Fri, 14 Dec 2018 06:22:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544797368; cv=none; d=google.com; s=arc-20160816; b=ttCwQA2G1nqN/+uV73n+Ue3twTL/zyJU2V9QAhlKamhT7RaBv5N6FTCuo6hGB1sk7s IM6QTHU1h+9ygt7yh6EC9yybnDVgu9l7xBnANONetHlEmLDL1NZFBZVvB2RJJ/ZpnNzy Gxj5kxAjGai/EviGYQFclsfVTZFZKajBPIS/E186NWMlV5DIMTYU4F9JCHrQ5oHX44+q UamW6+gEJ6587bKwOQlk35cuZHgWGhaGKxSP9yCLL9v06IDNrodYS/Eek2lYhQuxzCxC Q1EYLyAu0URYRe/wV2bVzVC9BQmqmDfa2LPTIBqQUl7gyq3JhrJMPzZ5MvWrjL6r9VtT SZYA== 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:references:in-reply-to:message-id:date:subject :to:from:delivered-to; bh=Z32D3c/2dQnglY9N1vjMPPbkt8LyFgudi3aYyzLLhKg=; b=y09RGG7eE+B17X8kVybVa3tXxH5A4qNhC/5RodCUxm++4Eo5AEhzuUOut/+cee3zJV KnLw36FVf9UlED7Hw42B+16E6IjoRRrVCKpZVsUYBPpqQAiegMADT53KZ/Mbrym3WHsy VnHDNBHKAO69fu+NWW5MgxLpfkk7otjp4lsyJ8PVPHNRqlEIibYTvHbupy9peqkDK0IJ uIR6j00joRX+XghAayTQj2N9WE8IRYJQ+BjmZc0vmv1Fg9dw+XDcPVPR4UrKmzRopo3i DM2VCvWsDrAhzz3phEcoPTGT1N6vgRlEnWKHf7J3IkQ5GwxlriRVJ/XR+sdXjGz/Tkjt ifWw== 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 a16si3957654plm.365.2018.12.14.06.22.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Dec 2018 06:22:48 -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 23FCE6F528; Fri, 14 Dec 2018 14:22:47 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6ACC76F523 for ; Fri, 14 Dec 2018 14:22:35 +0000 (UTC) Received: by mail-wr1-x442.google.com with SMTP id 96so5616382wrb.2 for ; Fri, 14 Dec 2018 06:22:35 -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:in-reply-to :references; bh=6OfNe/T/LeZU07HVnofeGpoR29hMVsSl1YI+aCAy6w0=; b=br6Rz5N71BAg3JNtryyT4ruqTVyKGhONmOu/+hSyudb612GqHt+z3Wokxupa9+jM/o t8hIW2VACc8CThoIL3V7FwbiOqjMhX2NtmNC/1Z7V1zkdRKrsAgk1ZsnUhUmsWmsnNy+ 80hNODpVCJ+RUIT/VC2COtrqaYZqv5eoRl4TWBSahZYCNaabX4RO25OiAp8T6PHrnqn7 RDBw+1yLiNCzZbtJdf5vZswLrZRyP2xStLkMOfkuQB7grPOatsQpcIc6RrshxDXdQ4ks 4UGmxSihMalpPEKR5dPEka+yYgTnOsyGvasCZ9ceun6QnrvYq4RTcO7jzHUOCkA3KTdC sQOA== X-Gm-Message-State: AA+aEWbHQvGi0OHic/Sl1MEYUdOfkKDTkybiFAUtlgtBlNuuzJtvsZdX +8WZC0eBlkZLt151OCQyM2zXWQ== X-Received: by 2002:a05:6000:104b:: with SMTP id c11mr2828130wrx.303.1544797353861; Fri, 14 Dec 2018 06:22:33 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:f:6020:ed2e:a6ad:f6ef:ff8e]) by smtp.gmail.com with ESMTPSA id m4sm25793829wmi.3.2018.12.14.06.22.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Dec 2018 06:22:32 -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 v2 2/3] PM/runtime:Replace jiffies based accouting with ktime based accounting Date: Fri, 14 Dec 2018 15:22:26 +0100 Message-Id: <1544797347-20601-3-git-send-email-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1544797347-20601-1-git-send-email-vincent.guittot@linaro.org> References: <1544797347-20601-1-git-send-email-vincent.guittot@linaro.org> 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 accoutning 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(-) diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index 7062469..89655e2 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) @@ -1491,7 +1491,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);