Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2218149/?format=api
{ "id": 2218149, "url": "http://patchwork.ozlabs.org/api/patches/2218149/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20260331131622.30505-13-frederic@kernel.org/", "project": { "id": 2, "url": "http://patchwork.ozlabs.org/api/projects/2/?format=api", "name": "Linux PPC development", "link_name": "linuxppc-dev", "list_id": "linuxppc-dev.lists.ozlabs.org", "list_email": "linuxppc-dev@lists.ozlabs.org", "web_url": "https://github.com/linuxppc/wiki/wiki", "scm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git", "webscm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/", "list_archive_url": "https://lore.kernel.org/linuxppc-dev/", "list_archive_url_format": "https://lore.kernel.org/linuxppc-dev/{}/", "commit_url_format": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id={}" }, "msgid": "<20260331131622.30505-13-frederic@kernel.org>", "list_archive_url": "https://lore.kernel.org/linuxppc-dev/20260331131622.30505-13-frederic@kernel.org/", "date": "2026-03-31T13:16:20", "name": "[12/14] sched/cputime: Provide get_cpu_[idle|iowait]_time_us() off-case", "commit_ref": null, "pull_url": null, "state": "handled-elsewhere", "archived": false, "hash": "ab21c1efa445800c9f634cf844bd0730c3a0d412", "submitter": { "id": 79411, "url": "http://patchwork.ozlabs.org/api/people/79411/?format=api", "name": "Frederic Weisbecker", "email": "frederic@kernel.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20260331131622.30505-13-frederic@kernel.org/mbox/", "series": [ { "id": 498198, "url": "http://patchwork.ozlabs.org/api/series/498198/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=498198", "date": "2026-03-31T13:16:08", "name": "tick/sched: Refactor idle cputime accounting", "version": 3, "mbox": "http://patchwork.ozlabs.org/series/498198/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2218149/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2218149/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "\n <linuxppc-dev+bounces-19092-incoming=patchwork.ozlabs.org@lists.ozlabs.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "linuxppc-dev@lists.ozlabs.org" ], "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=NQ8bprRL;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org\n (client-ip=2404:9400:21b9:f100::1; helo=lists.ozlabs.org;\n envelope-from=linuxppc-dev+bounces-19092-incoming=patchwork.ozlabs.org@lists.ozlabs.org;\n receiver=patchwork.ozlabs.org)", "lists.ozlabs.org;\n arc=none smtp.remote-ip=\"2600:3c0a:e001:78e:0:1991:8:25\"", "lists.ozlabs.org;\n dmarc=pass (p=quarantine dis=none) header.from=kernel.org", "lists.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=NQ8bprRL;\n\tdkim-atps=neutral", "lists.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org\n (client-ip=2600:3c0a:e001:78e:0:1991:8:25; helo=sea.source.kernel.org;\n envelope-from=frederic@kernel.org; receiver=lists.ozlabs.org)" ], "Received": [ "from lists.ozlabs.org (lists.ozlabs.org\n [IPv6:2404:9400:21b9:f100::1])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4flTFY3PyPz1y1q\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 01 Apr 2026 00:18:09 +1100 (AEDT)", "from boromir.ozlabs.org (localhost [127.0.0.1])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 4flTFS55DTz2ymg;\n\tWed, 01 Apr 2026 00:18:04 +1100 (AEDT)", "from sea.source.kernel.org (sea.source.kernel.org\n [IPv6:2600:3c0a:e001:78e:0:1991:8:25])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 4flTFR5XRbz2ybR\n\tfor <linuxppc-dev@lists.ozlabs.org>; Wed, 01 Apr 2026 00:18:03 +1100 (AEDT)", "from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58])\n\tby sea.source.kernel.org (Postfix) with ESMTP id 9E83743ED2;\n\tTue, 31 Mar 2026 13:18:01 +0000 (UTC)", "by smtp.kernel.org (Postfix) with ESMTPSA id 9007DC2BCB4;\n\tTue, 31 Mar 2026 13:17:54 +0000 (UTC)" ], "ARC-Seal": "i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1774963084;\n\tcv=none;\n b=ZBuflIoxI9J9ZoCheGCEmwUnescg3yYdh1eies2OTDmdZaVUxdnYVZEYt3CQONQ3h2h6o5NRyLUNSKL5wsno2jHmOSJGN/mvBuXux1PwRkNZ+QUnh9jYcj9WIHKcSrGG8E0BhhuUVGj0NGvxwBXzGs6krEqdEsW1CbR867pr0dQEwylN1x2gxYW94VzlLU/31HyvrUHhSN3dp1i8FLtSzMUlXaORfboPR7SwfXKbHvwCxlCO3l7ZJ5rytHzSTVJW3nETh2pYuimbTjSWwgWFTMg0NbLTvZXRgUDJg6tkeD6VxvTyKVQlrXWt97aK2y5g21GxhG3StYYK1slzFdz9kw==", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707;\n\tt=1774963084; c=relaxed/relaxed;\n\tbh=5bVq1dkSIoN8lEDck0lC1EGqT4gwGGkdLeUpNPGVHNY=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=BQSfyAmNVKh4FnQPU6pZaxu5SdsNVz9uXv7Iv4D8ItX57GyMDOmmxqq1fhKoow+Ctu1Htv1Pi71Vp4bjzfYEMAHprKdu2qgrWdk9qOT9dTH9WwVCT4CqMCCFjERLcQgxoVVk815XAcyzlB3Yx53Xd9WrJ3mzXZA3Ivi4e7fB9Dp/H/UExF2PsGbXjC2hc7UYcDYTo7NxavD6raxVNLTyJLh7aKnE4ESbwsk6qcTE42CGieJBIsvspl0azng+nDsLpekc0epEcL2Kps6N5LP2GYCHrsEeVH7r7H7p7emLiz6xYvUCmmJWx58oJo6u7S6tAkR70KOZEgKf7W0ywoTlAA==", "ARC-Authentication-Results": "i=1; lists.ozlabs.org;\n dmarc=pass (p=quarantine dis=none) header.from=kernel.org;\n dkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=NQ8bprRL; dkim-atps=neutral;\n spf=pass (client-ip=2600:3c0a:e001:78e:0:1991:8:25;\n helo=sea.source.kernel.org; envelope-from=frederic@kernel.org;\n receiver=lists.ozlabs.org) smtp.mailfrom=kernel.org", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1774963081;\n\tbh=6XEEW8WwCjaro5TSsa+MlYr1uj+SUPgh5dpCfyCU+rQ=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=NQ8bprRLqMwo/foMLh5eabFQjJhQgi5Hbd4PdmZnuFEA2wIQZmCJD/AtQNN1Lpx0b\n\t 06SMhRLJFER9dP93aD+nZpi4B2xPNqNlQolI2KMKJFDEy/hCaV+k/KoXxQe3Ai9BQY\n\t ET1EFxl7Zbwn963tlqLhhTNxRcoPJqxThT/TfFRtggrfwzc/XcoExYe6+B/N3ehKj0\n\t IBw43IHDUKF6ztSihzA/xAbsMcHNLQKOISpZQdEu/5JinMj2mazGGmTWNg55gphkHe\n\t xiZ6eQ8FSxB7opJFrah3Pg77/09PffUFYTPy7dGbNlNZks0vJ26xp2KLkweWj9c1iq\n\t l3lYhjQyl4nhg==", "From": "Frederic Weisbecker <frederic@kernel.org>", "To": "LKML <linux-kernel@vger.kernel.org>", "Cc": "Frederic Weisbecker <frederic@kernel.org>,\n\t\"Christophe Leroy (CS GROUP)\" <chleroy@kernel.org>,\n\t\"Rafael J. Wysocki\" <rafael@kernel.org>,\n\tAlexander Gordeev <agordeev@linux.ibm.com>,\n\tAnna-Maria Behnsen <anna-maria@linutronix.de>,\n\tBen Segall <bsegall@google.com>,\n\tBoqun Feng <boqun.feng@gmail.com>,\n\tChristian Borntraeger <borntraeger@linux.ibm.com>,\n\tDietmar Eggemann <dietmar.eggemann@arm.com>,\n\tHeiko Carstens <hca@linux.ibm.com>,\n\tIngo Molnar <mingo@redhat.com>,\n\tJan Kiszka <jan.kiszka@siemens.com>,\n\tJoel Fernandes <joelagnelf@nvidia.com>,\n\tJuri Lelli <juri.lelli@redhat.com>,\n\tKieran Bingham <kbingham@kernel.org>,\n\tMadhavan Srinivasan <maddy@linux.ibm.com>,\n\tMel Gorman <mgorman@suse.de>,\n\tMichael Ellerman <mpe@ellerman.id.au>,\n\tNeeraj Upadhyay <neeraj.upadhyay@kernel.org>,\n\tNicholas Piggin <npiggin@gmail.com>,\n\t\"Paul E . McKenney\" <paulmck@kernel.org>,\n\tPeter Zijlstra <peterz@infradead.org>,\n\tShrikanth Hegde <sshegde@linux.ibm.com>,\n\tSteven Rostedt <rostedt@goodmis.org>,\n\tSven Schnelle <svens@linux.ibm.com>,\n\tThomas Gleixner <tglx@linutronix.de>,\n\tUladzislau Rezki <urezki@gmail.com>,\n\tValentin Schneider <vschneid@redhat.com>,\n\tVasily Gorbik <gor@linux.ibm.com>,\n\tVincent Guittot <vincent.guittot@linaro.org>,\n\tViresh Kumar <viresh.kumar@linaro.org>,\n\tXin Zhao <jackzxcui1989@163.com>,\n\tlinux-pm@vger.kernel.org,\n\tlinux-s390@vger.kernel.org,\n\tlinuxppc-dev@lists.ozlabs.org", "Subject": "[PATCH 12/14] sched/cputime: Provide get_cpu_[idle|iowait]_time_us()\n off-case", "Date": "Tue, 31 Mar 2026 15:16:20 +0200", "Message-ID": "<20260331131622.30505-13-frederic@kernel.org>", "X-Mailer": "git-send-email 2.53.0", "In-Reply-To": "<20260331131622.30505-1-frederic@kernel.org>", "References": "<20260331131622.30505-1-frederic@kernel.org>", "X-Mailing-List": "linuxppc-dev@lists.ozlabs.org", "List-Id": "<linuxppc-dev.lists.ozlabs.org>", "List-Help": "<mailto:linuxppc-dev+help@lists.ozlabs.org>", "List-Owner": "<mailto:linuxppc-dev+owner@lists.ozlabs.org>", "List-Post": "<mailto:linuxppc-dev@lists.ozlabs.org>", "List-Archive": "<https://lore.kernel.org/linuxppc-dev/>,\n <https://lists.ozlabs.org/pipermail/linuxppc-dev/>", "List-Subscribe": "<mailto:linuxppc-dev+subscribe@lists.ozlabs.org>,\n <mailto:linuxppc-dev+subscribe-digest@lists.ozlabs.org>,\n <mailto:linuxppc-dev+subscribe-nomail@lists.ozlabs.org>", "List-Unsubscribe": "<mailto:linuxppc-dev+unsubscribe@lists.ozlabs.org>", "Precedence": "list", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-Spam-Status": "No, score=-0.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED,\n\tDKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS\n\tautolearn=disabled version=4.0.1 OzLabs 8", "X-Spam-Checker-Version": "SpamAssassin 4.0.1 (2024-03-25) on lists.ozlabs.org" }, "content": "The last reason why get_cpu_idle/iowait_time_us() may return -1 now is\nif the config doesn't support nohz.\n\nThe ad-hoc replacement solution by cpufreq is to compute jiffies minus\nthe whole busy cputime. Although the intention should provide a coherent\nlow resolution estimation of the idle and iowait time, the\nimplementation is buggy because jiffies don't start at 0.\n\nJust provide instead a real get_cpu_[idle|iowait]_time_us() offcase.\n\nSigned-off-by: Frederic Weisbecker <frederic@kernel.org>\nTested-by: Shrikanth Hegde <sshegde@linux.ibm.com>\n---\n drivers/cpufreq/cpufreq.c | 29 +----------------------------\n include/linux/kernel_stat.h | 3 +++\n include/linux/tick.h | 4 ----\n kernel/sched/cputime.c | 12 +++++++++---\n 4 files changed, 13 insertions(+), 35 deletions(-)", "diff": "diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c\nindex 277884d91913..1adffb8ccefd 100644\n--- a/drivers/cpufreq/cpufreq.c\n+++ b/drivers/cpufreq/cpufreq.c\n@@ -130,38 +130,11 @@ struct kobject *get_governor_parent_kobj(struct cpufreq_policy *policy)\n }\n EXPORT_SYMBOL_GPL(get_governor_parent_kobj);\n \n-static inline u64 get_cpu_idle_time_jiffy(unsigned int cpu, u64 *wall)\n-{\n-\tstruct kernel_cpustat kcpustat;\n-\tu64 cur_wall_time;\n-\tu64 idle_time;\n-\tu64 busy_time;\n-\n-\tcur_wall_time = jiffies64_to_nsecs(get_jiffies_64());\n-\n-\tkcpustat_cpu_fetch(&kcpustat, cpu);\n-\n-\tbusy_time = kcpustat.cpustat[CPUTIME_USER];\n-\tbusy_time += kcpustat.cpustat[CPUTIME_SYSTEM];\n-\tbusy_time += kcpustat.cpustat[CPUTIME_IRQ];\n-\tbusy_time += kcpustat.cpustat[CPUTIME_SOFTIRQ];\n-\tbusy_time += kcpustat.cpustat[CPUTIME_STEAL];\n-\tbusy_time += kcpustat.cpustat[CPUTIME_NICE];\n-\n-\tidle_time = cur_wall_time - busy_time;\n-\tif (wall)\n-\t\t*wall = div_u64(cur_wall_time, NSEC_PER_USEC);\n-\n-\treturn div_u64(idle_time, NSEC_PER_USEC);\n-}\n-\n u64 get_cpu_idle_time(unsigned int cpu, u64 *wall, int io_busy)\n {\n \tu64 idle_time = get_cpu_idle_time_us(cpu, io_busy ? wall : NULL);\n \n-\tif (idle_time == -1ULL)\n-\t\treturn get_cpu_idle_time_jiffy(cpu, wall);\n-\telse if (!io_busy)\n+\tif (!io_busy)\n \t\tidle_time += get_cpu_iowait_time_us(cpu, wall);\n \n \treturn idle_time;\ndiff --git a/include/linux/kernel_stat.h b/include/linux/kernel_stat.h\nindex 3680519d7b2c..512104b0ff49 100644\n--- a/include/linux/kernel_stat.h\n+++ b/include/linux/kernel_stat.h\n@@ -133,6 +133,9 @@ static inline bool kcpustat_idle_dyntick(void)\n }\n #endif /* CONFIG_NO_HZ_COMMON */\n \n+extern u64 get_cpu_idle_time_us(int cpu, u64 *last_update_time);\n+extern u64 get_cpu_iowait_time_us(int cpu, u64 *last_update_time);\n+\n /* Fetch cputime values when vtime is disabled on a CPU */\n static inline u64 kcpustat_field_default(enum cpu_usage_stat usage, int cpu)\n {\ndiff --git a/include/linux/tick.h b/include/linux/tick.h\nindex 738007d6f577..1cf4651f09ad 100644\n--- a/include/linux/tick.h\n+++ b/include/linux/tick.h\n@@ -139,8 +139,6 @@ extern bool tick_nohz_idle_got_tick(void);\n extern ktime_t tick_nohz_get_next_hrtimer(void);\n extern ktime_t tick_nohz_get_sleep_length(ktime_t *delta_next);\n extern unsigned long tick_nohz_get_idle_calls_cpu(int cpu);\n-extern u64 get_cpu_idle_time_us(int cpu, u64 *last_update_time);\n-extern u64 get_cpu_iowait_time_us(int cpu, u64 *last_update_time);\n #else /* !CONFIG_NO_HZ_COMMON */\n #define tick_nohz_enabled (0)\n static inline bool tick_nohz_is_active(void) { return false; }\n@@ -162,8 +160,6 @@ static inline ktime_t tick_nohz_get_sleep_length(ktime_t *delta_next)\n \t*delta_next = TICK_NSEC;\n \treturn *delta_next;\n }\n-static inline u64 get_cpu_idle_time_us(int cpu, u64 *unused) { return -1; }\n-static inline u64 get_cpu_iowait_time_us(int cpu, u64 *unused) { return -1; }\n #endif /* !CONFIG_NO_HZ_COMMON */\n \n /*\ndiff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c\nindex ebb9eee049e0..137e6b099fa9 100644\n--- a/kernel/sched/cputime.c\n+++ b/kernel/sched/cputime.c\n@@ -523,6 +523,13 @@ u64 kcpustat_field_iowait(int cpu)\n \t\t\t\t nr_iowait_cpu(cpu), ktime_get());\n }\n EXPORT_SYMBOL_GPL(kcpustat_field_iowait);\n+#else\n+static u64 kcpustat_field_dyntick(int cpu, enum cpu_usage_stat idx,\n+\t\t\t\t bool compute_delta, ktime_t now)\n+{\n+\treturn kcpustat_cpu(cpu).cpustat[idx];\n+}\n+#endif /* CONFIG_NO_HZ_COMMON */\n \n static u64 get_cpu_sleep_time_us(int cpu, enum cpu_usage_stat idx,\n \t\t\t\t bool compute_delta, u64 *last_update_time)\n@@ -558,7 +565,7 @@ static u64 get_cpu_sleep_time_us(int cpu, enum cpu_usage_stat idx,\n * This time is measured via accounting rather than sampling,\n * and is as accurate as ktime_get() is.\n *\n- * Return: -1 if generic vtime is enabled, else total idle time of the @cpu\n+ * Return: total idle time of the @cpu\n */\n u64 get_cpu_idle_time_us(int cpu, u64 *last_update_time)\n {\n@@ -582,7 +589,7 @@ EXPORT_SYMBOL_GPL(get_cpu_idle_time_us);\n * This time is measured via accounting rather than sampling,\n * and is as accurate as ktime_get() is.\n *\n- * Return: -1 if generic vtime is enabled, else total iowait time of @cpu\n+ * Return: total iowait time of @cpu\n */\n u64 get_cpu_iowait_time_us(int cpu, u64 *last_update_time)\n {\n@@ -590,7 +597,6 @@ u64 get_cpu_iowait_time_us(int cpu, u64 *last_update_time)\n \t\t\t\t nr_iowait_cpu(cpu), last_update_time);\n }\n EXPORT_SYMBOL_GPL(get_cpu_iowait_time_us);\n-#endif /* CONFIG_NO_HZ_COMMON */\n \n /*\n * Use precise platform statistics if available:\n", "prefixes": [ "12/14" ] }