Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3972362pxb; Tue, 10 Nov 2020 05:05:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJztuxhsE/BMpBIhojMjKJ23TY+i8z+GQIvgzyFcFLlzkJOrkvHQtJ4WKoHPyU2wc4uwiQvJ X-Received: by 2002:a17:906:26c7:: with SMTP id u7mr19756597ejc.494.1605013526991; Tue, 10 Nov 2020 05:05:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605013526; cv=none; d=google.com; s=arc-20160816; b=UTc/LXkEDsfnt9CDt0C4Jhcp2UJJtzivrhFOophm4mZxJvdfh2Fzjv+plV8sTr/pR0 zIs4LobiH+Fz8gZHuRc93+F9zJhMSQeeF0Jqa10klqeuXCa5qOa3i60mZNhjQz44ei48 D/v4t1vNUiGdo1sW7o/71TSOmePsS7issURooWU9ARgE/SkL1zMRVLqbUPI+NevcAtLY rWNRmPlNvETl87joT0AGbYydWrvvMIvWd4mbC4vsmHmn2qTPhOb43D/3R65cY8a1Nh7C s4FgehKQLdUyxIDUtcfgKJiE+p0qNHBov8qDmvzB++RChZje/AMx7jKstQCRTjx5I6pf rmZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=nQJTAdZ1adBsQ8C+kbyZpy76IwyPcxh02MnCTX/G32M=; b=dzf5ku5BxO9LiSjULuH6gzx1x9vF33j8neu30ASj2BkdgiXrrak9gFda4rcdNxTi3P 5oxnuEfUxdh4NB0aUUpJ3ZWQENGlwL8eDqodfd9EZUSVXpppp95xoLiq1Mk0rnOI3Eoy KD9KWj3feYwYmnvdRpBhT2PCfYvVVnRWheJC66ASpJkmVYTpZfuquUzj3P+mrruVvwuF +0K1LzOX+GarS0krfM23QOhAh4covGfaLFLluAngf/WkVKKhRzBUkpJ8pttGNC3bb6C0 fpcOpPJHOzFWKIGLFCOhfhPvW77TLxOsKdrgGKdyqhYsmoPk+mE/Mz49ceYqoZaFvq3d t3PA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o1si8602758eja.87.2020.11.10.05.04.56; Tue, 10 Nov 2020 05:05:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730473AbgKJM74 (ORCPT + 99 others); Tue, 10 Nov 2020 07:59:56 -0500 Received: from mail-ot1-f68.google.com ([209.85.210.68]:36187 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726462AbgKJM7z (ORCPT ); Tue, 10 Nov 2020 07:59:55 -0500 Received: by mail-ot1-f68.google.com with SMTP id n89so1169714otn.3; Tue, 10 Nov 2020 04:59:55 -0800 (PST) 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=nQJTAdZ1adBsQ8C+kbyZpy76IwyPcxh02MnCTX/G32M=; b=eUoq5h7WdKBQY9bZOt/rWgaNknaR+NAds5bAB+mEB9Uy9h1FjgXPZsjTiaBaoW7NIf vkFkmo9iL0D4vrSe0RQv2rR0NZWR2ipUADo5O9b5giv5bL+pmLLqnw05J9SHbx7NuqHu T98RymeYRVrYTIrzOHF3A4ulcKbrUt8zqgTg46aELBanYiASoP2yG8oizQQ28lVC517I wuaFuOkreXFNCfu0cWWzqzImRCRD1hMq5FlzJlZIibj00lZEmgrdVUYvO1OjviJuk/7J ma0knsaVLYwzlwuKLNYnAXP7XSiMkylJdp+MiXLRYrQVhuTZx/aNC0c8ZHsyMDJniZ9B WpwA== X-Gm-Message-State: AOAM530K9HoCRyKTErOlrPKu52kio8mE3M2qAogWXqpzL5FuOhA90Z+9 kKUfRk6s9z99bUHeo0s/Og+4oE/1XYHos12Zw28TBzqW X-Received: by 2002:a9d:16f:: with SMTP id 102mr14776795otu.206.1605013195114; Tue, 10 Nov 2020 04:59:55 -0800 (PST) MIME-Version: 1.0 References: <0e0fb542b6f6b26944cb2cf356041348aeac95f6.1605006378.git.viresh.kumar@linaro.org> In-Reply-To: <0e0fb542b6f6b26944cb2cf356041348aeac95f6.1605006378.git.viresh.kumar@linaro.org> From: "Rafael J. Wysocki" Date: Tue, 10 Nov 2020 13:59:42 +0100 Message-ID: Subject: Re: [PATCH] cpufreq: stats: Switch to ktime and msec instead of jiffies and usertime To: Viresh Kumar Cc: Rafael Wysocki , Jonathan Corbet , Linux PM , Vincent Guittot , Thomas Renninger , Shuah Khan , "open list:DOCUMENTATION" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 10, 2020 at 12:07 PM Viresh Kumar wrote: > > The cpufreq and thermal core, both provide sysfs statistics to help > userspace learn about the behavior of frequencies and cooling states. > > This is how they look: > > /sys/devices/system/cpu/cpufreq/policy0/stats/time_in_state:208000 11 > /sys/devices/system/cpu/cpufreq/policy0/stats/time_in_state:432000 147 > /sys/devices/system/cpu/cpufreq/policy0/stats/time_in_state:729000 1600 > /sys/devices/system/cpu/cpufreq/policy0/stats/time_in_state:960000 879 > /sys/devices/system/cpu/cpufreq/policy0/stats/time_in_state:1200000 399 > > /sys/class/thermal/cooling_device0/stats/time_in_state_ms:state0 4097 > /sys/class/thermal/cooling_device0/stats/time_in_state_ms:state1 8932 > /sys/class/thermal/cooling_device0/stats/time_in_state_ms:state2 15868 > /sys/class/thermal/cooling_device0/stats/time_in_state_ms:state3 1384 > /sys/class/thermal/cooling_device0/stats/time_in_state_ms:state4 103 > > Here, state0 of thermal corresponds to the highest frequency of the CPU, > i.e. 1200000 and state4 to the lowest one. > > While both of these try to show similar kind of data (which can still be > very much different from each other), the values looked different (by a > factor of 10, i.e. thermal's time_in_state is almost 10 times that of > cpufreq time_in_state). > > This comes from the fact that cpufreq core displays the time in usertime > units (10 ms). > > It would be better if both the frameworks displayed times in the same > unit as the users may need to correlate between them and different > scales just make it awkward. And the choice of thermal core for that > (msec) seems to be a better choice as it is easier to read. > > The thermal core also does the stats calculations using ktime, which is > much more accurate as compared to jiffies used by cpufreq core. > > This patch updates the cpufreq core to use ktime for the internal > calculations and changes the units of time_in_state to msec. Well, this may confuse user space using the stats today. > > The results look like this after this commit: > > /sys/devices/system/cpu/cpufreq/policy0/stats/time_in_state:208000 13 > /sys/devices/system/cpu/cpufreq/policy0/stats/time_in_state:432000 790 > /sys/devices/system/cpu/cpufreq/policy0/stats/time_in_state:729000 12492 > /sys/devices/system/cpu/cpufreq/policy0/stats/time_in_state:960000 13259 > /sys/devices/system/cpu/cpufreq/policy0/stats/time_in_state:1200000 3830 > > /sys/class/thermal/cooling_device0/stats/time_in_state_ms:state0 3888 > /sys/class/thermal/cooling_device0/stats/time_in_state_ms:state1 13432 > /sys/class/thermal/cooling_device0/stats/time_in_state_ms:state2 12336 > /sys/class/thermal/cooling_device0/stats/time_in_state_ms:state3 740 > /sys/class/thermal/cooling_device0/stats/time_in_state_ms:state4 0 > > FWIW, tools/power/cpupower/ does consume the time_in_state values from > the sysfs files but it is independent of the unit of the time and didn't > require an update. But whoever uses cpupower may be confused.