Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.2/patches/2235048/?format=api
{ "id": 2235048, "url": "http://patchwork.ozlabs.org/api/1.2/patches/2235048/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20260508131647.43868-13-frederic@kernel.org/", "project": { "id": 2, "url": "http://patchwork.ozlabs.org/api/1.2/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": "<20260508131647.43868-13-frederic@kernel.org>", "list_archive_url": "https://lore.kernel.org/linuxppc-dev/20260508131647.43868-13-frederic@kernel.org/", "date": "2026-05-08T13:16:44", "name": "[12/15] tick/sched: Consolidate idle time fetching APIs", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "f900c8a3383957012308d2587a365d1db6b9e5e2", "submitter": { "id": 79411, "url": "http://patchwork.ozlabs.org/api/1.2/people/79411/?format=api", "name": "Frederic Weisbecker", "email": "frederic@kernel.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20260508131647.43868-13-frederic@kernel.org/mbox/", "series": [ { "id": 503389, "url": "http://patchwork.ozlabs.org/api/1.2/series/503389/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=503389", "date": "2026-05-08T13:16:32", "name": "tick/sched: Refactor idle cputime accounting", "version": 4, "mbox": "http://patchwork.ozlabs.org/series/503389/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2235048/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2235048/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "\n <linuxppc-dev+bounces-20622-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=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=SyrFWjpJ;\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-20622-incoming=patchwork.ozlabs.org@lists.ozlabs.org;\n receiver=patchwork.ozlabs.org)", "lists.ozlabs.org;\n arc=none smtp.remote-ip=172.234.252.31", "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=SyrFWjpJ;\n\tdkim-atps=neutral", "lists.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org\n (client-ip=172.234.252.31; 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 4gBqSp0CxVz1yJq\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 08 May 2026 23:18:50 +1000 (AEST)", "from boromir.ozlabs.org (localhost [127.0.0.1])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 4gBqSn6S4qz3bpd;\n\tFri, 08 May 2026 23:18:49 +1000 (AEST)", "from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31])\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 4gBqSn0Yvjz30Wd\n\tfor <linuxppc-dev@lists.ozlabs.org>; Fri, 08 May 2026 23:18:49 +1000 (AEST)", "from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58])\n\tby sea.source.kernel.org (Postfix) with ESMTP id 818534414F;\n\tFri, 8 May 2026 13:18:47 +0000 (UTC)", "by smtp.kernel.org (Postfix) with ESMTPSA id 5E0E6C2BCB0;\n\tFri, 8 May 2026 13:18:39 +0000 (UTC)" ], "ARC-Seal": "i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1778246329;\n\tcv=none;\n b=daikdRcmG2tthnZy+iYtyg7YIPmKgmSqg6piSJpDiCbzv1hMSPiOWFFmh8vsiM7uOzOK2FS6vwlg/AP2OP3HvxLxXsLTf7abDMSQ/aAuAFeW0/eiz3kIWYJSc2QQXAWlnMOGbB1H197i64AgXTJx6EscRGy9PwWs9W//oJEn+pw+owZk1VrcwCKoxRrVyKR5mSthBpqnerUJ1W0JsKMNN5PzwTORRjXeXco0XOzSW7FWtcyh+pGZwoD9ZrQd8U8QynlKm96iNoLoJqIvx+8fDky0LZdlrf5WWOEPetwHUYtHGoOkJxWYbNGWzlB4ZxYMfeOObz1FEKQsOBpnWTvKCw==", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707;\n\tt=1778246329; c=relaxed/relaxed;\n\tbh=Iy8gADhS0fGBKs1ulfcGOOP7XjbvGDNtpblMwCCmhRo=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=hDga3YVLEA5lnYXLWOuKk7HVWn+Y9S3P7xRsPek5ApUIe4V7tODZ2EepBXMfy/+Meg2dP61cwC3uCXsAlk1ACwN0HtZJZ5u9KE7dh7KjOe77INjd2E2bJbpqeju2g5O+QNfvIVfMGh6fXBeqxl8n32ypnnqPtPX0NnnC+ZJXQiAoCQ2gJsnzJvD2UXgwyBrZf01yircqjcI957qRKPJDtZZvJEyJkQCgKIzI8gIzYFDQiNUE6ZZaKSXIi9v1taMucDh9jLC5xsszxrTv4M5ACzK7bBB6q5yXskY/yhr+6HXDjQrnduBQKaMVEttahfj4P9kw3jwG1rqDK+ujg/vS7Q==", "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=SyrFWjpJ; dkim-atps=neutral;\n spf=pass (client-ip=172.234.252.31; helo=sea.source.kernel.org;\n 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=1778246327;\n\tbh=rN3T9sUkaKTavz4WR9YKK7d+NSorY6dTBaBlF1BDCwU=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=SyrFWjpJxwXZcG2oaMGjTmOFyjrHK3yEmr+gTglJhCNIphIfJHYgkuPUijPu5P1Vz\n\t 3HCaFqTAEVbuUBRo00nJvG6Db3NBRO2y/qW9gzlKXoeZWP+01XrVSJ1Yr4f57qMU67\n\t 50kmrwDWARlQdClh/E40mmC34cYowDsrkMBsLVqPBNAbO4+KXEhacTFGv9LKZRZD/y\n\t 4Qkp6IhBA2XCavXqf85QoaKiG83OcJywokwUwLuGA90aTaqgSfemKD1w63aTFIAQmA\n\t cP+l5K1N7ye9ue2zdcIcUmCval3FvbhX/tYWPnNNCxUsu45ecTpWVu+0/RdqNebatb\n\t WC+di16AEZfqw==", "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>, Boqun 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>, Ingo Molnar <mingo@kernel.org>,\n\tIngo Molnar <mingo@redhat.com>, Jan 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>, Michael 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>, Sashiko@lists.ozlabs.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>, linux-pm@vger.kernel.org,\n\tlinux-s390@vger.kernel.org, linuxppc-dev@lists.ozlabs.org", "Subject": "[PATCH 12/15] tick/sched: Consolidate idle time fetching APIs", "Date": "Fri, 8 May 2026 15:16:44 +0200", "Message-ID": "<20260508131647.43868-13-frederic@kernel.org>", "X-Mailer": "git-send-email 2.53.0", "In-Reply-To": "<20260508131647.43868-1-frederic@kernel.org>", "References": "<20260508131647.43868-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.6 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": "Fetching the idle cputime is available through a variety of accessors\nall over the place depending on the different accounting flavours and\nneeds:\n\n- idle vtime generic accounting can be accessed by kcpustat_field(),\n kcpustat_cpu_fetch(), get_idle/iowait_time() and\n get_cpu_idle/iowait_time_us()\n\n- dynticks-idle accounting can only be accessed by get_idle/iowait_time()\n or get_cpu_idle/iowait_time_us()\n\n- CONFIG_NO_HZ_COMMON=n idle accounting can be accessed by kcpustat_field()\n kcpustat_cpu_fetch(), or get_idle/iowait_time() but not by\n get_cpu_idle/iowait_time_us()\n\nMoreover get_idle/iowait_time() relies on get_cpu_idle/iowait_time_us()\nwith a non-sensical conversion to microseconds and back to nanoseconds\non the way.\n\nStart consolidating the APIs with removing get_idle/iowait_time() and\nmake kcpustat_field() and kcpustat_cpu_fetch() work for all cases.\n\nSigned-off-by: Frederic Weisbecker <frederic@kernel.org>\nTested-by: Shrikanth Hegde <sshegde@linux.ibm.com>\n---\n fs/proc/stat.c | 40 +++---------------------\n fs/proc/uptime.c | 8 ++---\n include/linux/kernel_stat.h | 34 ++++++++++++++++++---\n kernel/sched/cputime.c | 61 ++++++++++++++++++++++++-------------\n 4 files changed, 76 insertions(+), 67 deletions(-)", "diff": "diff --git a/fs/proc/stat.c b/fs/proc/stat.c\nindex 8b444e862319..c00468a83f64 100644\n--- a/fs/proc/stat.c\n+++ b/fs/proc/stat.c\n@@ -22,38 +22,6 @@\n #define arch_irq_stat() 0\n #endif\n \n-u64 get_idle_time(struct kernel_cpustat *kcs, int cpu)\n-{\n-\tu64 idle, idle_usecs = -1ULL;\n-\n-\tif (cpu_online(cpu))\n-\t\tidle_usecs = get_cpu_idle_time_us(cpu, NULL);\n-\n-\tif (idle_usecs == -1ULL)\n-\t\t/* !NO_HZ or cpu offline so we can rely on cpustat.idle */\n-\t\tidle = kcs->cpustat[CPUTIME_IDLE];\n-\telse\n-\t\tidle = idle_usecs * NSEC_PER_USEC;\n-\n-\treturn idle;\n-}\n-\n-static u64 get_iowait_time(struct kernel_cpustat *kcs, int cpu)\n-{\n-\tu64 iowait, iowait_usecs = -1ULL;\n-\n-\tif (cpu_online(cpu))\n-\t\tiowait_usecs = get_cpu_iowait_time_us(cpu, NULL);\n-\n-\tif (iowait_usecs == -1ULL)\n-\t\t/* !NO_HZ or cpu offline so we can rely on cpustat.iowait */\n-\t\tiowait = kcs->cpustat[CPUTIME_IOWAIT];\n-\telse\n-\t\tiowait = iowait_usecs * NSEC_PER_USEC;\n-\n-\treturn iowait;\n-}\n-\n static void show_irq_gap(struct seq_file *p, unsigned int gap)\n {\n \tstatic const char zeros[] = \" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\";\n@@ -105,8 +73,8 @@ static int show_stat(struct seq_file *p, void *v)\n \t\tuser\t\t+= cpustat[CPUTIME_USER];\n \t\tnice\t\t+= cpustat[CPUTIME_NICE];\n \t\tsystem\t\t+= cpustat[CPUTIME_SYSTEM];\n-\t\tidle\t\t+= get_idle_time(&kcpustat, i);\n-\t\tiowait\t\t+= get_iowait_time(&kcpustat, i);\n+\t\tidle\t\t+= cpustat[CPUTIME_IDLE];\n+\t\tiowait\t\t+= cpustat[CPUTIME_IOWAIT];\n \t\tirq\t\t+= cpustat[CPUTIME_IRQ];\n \t\tsoftirq\t\t+= cpustat[CPUTIME_SOFTIRQ];\n \t\tsteal\t\t+= cpustat[CPUTIME_STEAL];\n@@ -146,8 +114,8 @@ static int show_stat(struct seq_file *p, void *v)\n \t\tuser\t\t= cpustat[CPUTIME_USER];\n \t\tnice\t\t= cpustat[CPUTIME_NICE];\n \t\tsystem\t\t= cpustat[CPUTIME_SYSTEM];\n-\t\tidle\t\t= get_idle_time(&kcpustat, i);\n-\t\tiowait\t\t= get_iowait_time(&kcpustat, i);\n+\t\tidle\t\t= cpustat[CPUTIME_IDLE];\n+\t\tiowait\t\t= cpustat[CPUTIME_IOWAIT];\n \t\tirq\t\t= cpustat[CPUTIME_IRQ];\n \t\tsoftirq\t\t= cpustat[CPUTIME_SOFTIRQ];\n \t\tsteal\t\t= cpustat[CPUTIME_STEAL];\ndiff --git a/fs/proc/uptime.c b/fs/proc/uptime.c\nindex b5343d209381..433aa947cd57 100644\n--- a/fs/proc/uptime.c\n+++ b/fs/proc/uptime.c\n@@ -18,12 +18,8 @@ static int uptime_proc_show(struct seq_file *m, void *v)\n \tint i;\n \n \tidle_nsec = 0;\n-\tfor_each_possible_cpu(i) {\n-\t\tstruct kernel_cpustat kcs;\n-\n-\t\tkcpustat_cpu_fetch(&kcs, i);\n-\t\tidle_nsec += get_idle_time(&kcs, i);\n-\t}\n+\tfor_each_possible_cpu(i)\n+\t\tidle_nsec += kcpustat_field(CPUTIME_IDLE, i);\n \n \tktime_get_boottime_ts64(&uptime);\n \ttimens_add_boottime(&uptime);\ndiff --git a/include/linux/kernel_stat.h b/include/linux/kernel_stat.h\nindex 9343353ac7a3..3680519d7b2c 100644\n--- a/include/linux/kernel_stat.h\n+++ b/include/linux/kernel_stat.h\n@@ -110,32 +110,59 @@ extern void kcpustat_dyntick_start(u64 now);\n extern void kcpustat_dyntick_stop(u64 now);\n extern void kcpustat_irq_enter(u64 now);\n extern void kcpustat_irq_exit(u64 now);\n+extern u64 kcpustat_field_idle(int cpu);\n+extern u64 kcpustat_field_iowait(int cpu);\n \n static inline bool kcpustat_idle_dyntick(void)\n {\n \treturn __this_cpu_read(kernel_cpustat.idle_dyntick);\n }\n #else\n+static inline u64 kcpustat_field_idle(int cpu)\n+{\n+\treturn kcpustat_cpu(cpu).cpustat[CPUTIME_IDLE];\n+}\n+static inline u64 kcpustat_field_iowait(int cpu)\n+{\n+\treturn kcpustat_cpu(cpu).cpustat[CPUTIME_IOWAIT];\n+}\n+\n static inline bool kcpustat_idle_dyntick(void)\n {\n \treturn false;\n }\n #endif /* CONFIG_NO_HZ_COMMON */\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+{\n+\tif (usage == CPUTIME_IDLE)\n+\t\treturn kcpustat_field_idle(cpu);\n+\tif (usage == CPUTIME_IOWAIT)\n+\t\treturn kcpustat_field_iowait(cpu);\n+\treturn kcpustat_cpu(cpu).cpustat[usage];\n+}\n+\n+static inline void kcpustat_cpu_fetch_default(struct kernel_cpustat *dst, int cpu)\n+{\n+\t*dst = kcpustat_cpu(cpu);\n+\tdst->cpustat[CPUTIME_IDLE] = kcpustat_field_idle(cpu);\n+\tdst->cpustat[CPUTIME_IOWAIT] = kcpustat_field_iowait(cpu);\n+}\n+\n #ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN\n extern u64 kcpustat_field(enum cpu_usage_stat usage, int cpu);\n extern void kcpustat_cpu_fetch(struct kernel_cpustat *dst, int cpu);\n #else\n static inline u64 kcpustat_field(enum cpu_usage_stat usage, int cpu)\n {\n-\treturn kcpustat_cpu(cpu).cpustat[usage];\n+\treturn kcpustat_field_default(usage, cpu);\n }\n \n static inline void kcpustat_cpu_fetch(struct kernel_cpustat *dst, int cpu)\n {\n-\t*dst = kcpustat_cpu(cpu);\n+\tkcpustat_cpu_fetch_default(dst, cpu);\n }\n-\n #endif /* !CONFIG_VIRT_CPU_ACCOUNTING_GEN */\n \n extern void account_user_time(struct task_struct *, u64);\n@@ -145,7 +172,6 @@ extern void account_system_index_time(struct task_struct *, u64,\n \t\t\t\t enum cpu_usage_stat);\n extern void account_steal_time(u64);\n extern void account_idle_time(u64);\n-extern u64 get_idle_time(struct kernel_cpustat *kcs, int cpu);\n \n #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE\n static inline void account_process_tick(struct task_struct *tsk, int user)\ndiff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c\nindex 4c00163b74b9..c91fd67f93ea 100644\n--- a/kernel/sched/cputime.c\n+++ b/kernel/sched/cputime.c\n@@ -490,24 +490,14 @@ void kcpustat_irq_exit(u64 now)\n \t\tkcpustat_idle_start(kc, now);\n }\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+static u64 kcpustat_field_dyntick(int cpu, enum cpu_usage_stat idx,\n+\t\t\t\t bool compute_delta, u64 now)\n {\n \tstruct kernel_cpustat *kc = &kcpustat_cpu(cpu);\n \tu64 *cpustat = kc->cpustat;\n \tunsigned int seq;\n-\tktime_t now;\n \tu64 idle;\n \n-\tnow = ktime_get();\n-\tif (last_update_time)\n-\t\t*last_update_time = ktime_to_us(now);\n-\n-\tif (vtime_generic_enabled_cpu(cpu)) {\n-\t\tidle = kcpustat_field(idx, cpu);\n-\t\tgoto to_us;\n-\t}\n-\n \tdo {\n \t\tseq = read_seqcount_begin(&kc->idle_sleeptime_seq);\n \n@@ -516,12 +506,42 @@ static u64 get_cpu_sleep_time_us(int cpu, enum cpu_usage_stat idx,\n \t\t\tidle += (now - kc->idle_entrytime);\n \t} while (read_seqcount_retry(&kc->idle_sleeptime_seq, seq));\n \n-to_us:\n-\tdo_div(idle, NSEC_PER_USEC);\n-\n \treturn idle;\n }\n \n+u64 kcpustat_field_idle(int cpu)\n+{\n+\treturn kcpustat_field_dyntick(cpu, CPUTIME_IDLE,\n+\t\t\t\t !nr_iowait_cpu(cpu), ktime_get());\n+}\n+EXPORT_SYMBOL_GPL(kcpustat_field_idle);\n+\n+u64 kcpustat_field_iowait(int cpu)\n+{\n+\treturn kcpustat_field_dyntick(cpu, CPUTIME_IOWAIT,\n+\t\t\t\t nr_iowait_cpu(cpu), ktime_get());\n+}\n+EXPORT_SYMBOL_GPL(kcpustat_field_iowait);\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+{\n+\tktime_t now = ktime_get();\n+\tu64 res;\n+\n+\tif (vtime_generic_enabled_cpu(cpu))\n+\t\tres = kcpustat_field(idx, cpu);\n+\telse\n+\t\tres = kcpustat_field_dyntick(cpu, idx, compute_delta, now);\n+\n+\tdo_div(res, NSEC_PER_USEC);\n+\n+\tif (last_update_time)\n+\t\t*last_update_time = ktime_to_us(now);\n+\n+\treturn res;\n+}\n+\n /**\n * get_cpu_idle_time_us - get the total idle time of a CPU\n * @cpu: CPU number to query\n@@ -569,7 +589,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-\n #endif /* CONFIG_NO_HZ_COMMON */\n \n /*\n@@ -1123,8 +1142,8 @@ u64 kcpustat_field(enum cpu_usage_stat usage, int cpu)\n \tstruct rq *rq;\n \tint err;\n \n-\tif (!vtime_accounting_enabled_cpu(cpu))\n-\t\treturn val;\n+\tif (!vtime_generic_enabled_cpu(cpu))\n+\t\treturn kcpustat_field_default(usage, cpu);\n \n \trq = cpu_rq(cpu);\n \n@@ -1219,8 +1238,8 @@ void kcpustat_cpu_fetch(struct kernel_cpustat *dst, int cpu)\n \tstruct rq *rq;\n \tint err;\n \n-\tif (!vtime_accounting_enabled_cpu(cpu)) {\n-\t\t*dst = *src;\n+\tif (!vtime_generic_enabled_cpu(cpu)) {\n+\t\tkcpustat_cpu_fetch_default(dst, cpu);\n \t\treturn;\n \t}\n \n@@ -1233,7 +1252,7 @@ void kcpustat_cpu_fetch(struct kernel_cpustat *dst, int cpu)\n \t\tcurr = rcu_dereference(rq->curr);\n \t\tif (WARN_ON_ONCE(!curr)) {\n \t\t\trcu_read_unlock();\n-\t\t\t*dst = *src;\n+\t\t\tkcpustat_cpu_fetch_default(dst, cpu);\n \t\t\treturn;\n \t\t}\n \n", "prefixes": [ "12/15" ] }