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: 10731257 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1C1EC13AD for ; Fri, 14 Dec 2018 14:22:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DBCE2D532 for ; Fri, 14 Dec 2018 14:22:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F8D02D543; Fri, 14 Dec 2018 14:22:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E9122D532 for ; Fri, 14 Dec 2018 14:22:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729809AbeLNOWh (ORCPT ); Fri, 14 Dec 2018 09:22:37 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:46405 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730097AbeLNOWh (ORCPT ); Fri, 14 Dec 2018 09:22:37 -0500 Received: by mail-wr1-f67.google.com with SMTP id l9so5572959wrt.13 for ; Fri, 14 Dec 2018 06:22:35 -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=6OfNe/T/LeZU07HVnofeGpoR29hMVsSl1YI+aCAy6w0=; b=GXYRqnWNI7vCR7WIkhtAlTiJnJFzKbxGqxfzF1jWgeWIJ7miEYmjlthXu388qROCkg VoqOvfR7yvjkYutWfHMbINbJ7yhXjPUQ2KzJkcjaEsj/eEBBUIqt5GDjZ4nAgtWY7dJT Y8SRr+PBjuvOfB2lq7d/Cq1F03nweV9JXc6eo= 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=psEmOTIuoeHZWzvMU9/lgAUf0OI1Ixj8pUsFZ27A3mTtiFbyddQdhuKRRnlIzy5q5c T2cwAEN49Sj5JUU9NYR4H/lRBBg5cvCf6OXYeXbmGm4aR8RBLkb4s8UpCjvIRKZNb6Uj IIad8k/MvDqo+NzgJCPFkNRs9B4UsSNn4PNN1xoFWjrjsZpdqS3Ut12Fj68qRnKEasIL GhfL2GV19s5lDAsfWEZ8D979F95JHjsI/9ktpsmFdps9saEw2Sb51IMLQ7xHgyMWn09J AU9R1rOgKOWjV73ry+3bFR5QIjGepqNq3B3Diz/H3B48djkMUxQn9RBfWMV80o3PIQcD MMjQ== X-Gm-Message-State: AA+aEWarmxIW6cZ1Df6XtyUZzwwBWlNgBNrPILMmJHtQMftzXoMxl05P mfyLX5VpZlQCc9RebRMm8fVRtBh1ujvopQ== X-Google-Smtp-Source: AFSGD/XKteD3Sq7Lp26IbQh1V7OPDOYMZKq3B0o6ZnuXiDJTEY5+s2OBuGHSRN7FsX9P/dnapjxY1g== 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 Cc: ulf.hansson@linaro.org, Vincent Guittot 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> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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);