get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/2218148/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2218148,
    "url": "http://patchwork.ozlabs.org/api/patches/2218148/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20260331131622.30505-12-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-12-frederic@kernel.org>",
    "list_archive_url": "https://lore.kernel.org/linuxppc-dev/20260331131622.30505-12-frederic@kernel.org/",
    "date": "2026-03-31T13:16:19",
    "name": "[11/14] tick/sched: Consolidate idle time fetching APIs",
    "commit_ref": null,
    "pull_url": null,
    "state": "handled-elsewhere",
    "archived": false,
    "hash": "2739afe2436e716ecff4e446a5cf8622043c2ca0",
    "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-12-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/2218148/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2218148/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "\n <linuxppc-dev+bounces-19091-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=K7AeiwWS;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org\n (client-ip=112.213.38.117; helo=lists.ozlabs.org;\n envelope-from=linuxppc-dev+bounces-19091-incoming=patchwork.ozlabs.org@lists.ozlabs.org;\n receiver=patchwork.ozlabs.org)",
            "lists.ozlabs.org;\n arc=none smtp.remote-ip=172.105.4.254",
            "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=K7AeiwWS;\n\tdkim-atps=neutral",
            "lists.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org\n (client-ip=172.105.4.254; helo=tor.source.kernel.org;\n envelope-from=frederic@kernel.org; receiver=lists.ozlabs.org)"
        ],
        "Received": [
            "from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117])\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 4flTFP5Jjyz1y1q\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 01 Apr 2026 00:18:01 +1100 (AEDT)",
            "from boromir.ozlabs.org (localhost [127.0.0.1])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 4flTFK25Z5z2yl2;\n\tWed, 01 Apr 2026 00:17:57 +1100 (AEDT)",
            "from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254])\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 4flTFJ2dR1z2ybR\n\tfor <linuxppc-dev@lists.ozlabs.org>; Wed, 01 Apr 2026 00:17:56 +1100 (AEDT)",
            "from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58])\n\tby tor.source.kernel.org (Postfix) with ESMTP id 755D461119;\n\tTue, 31 Mar 2026 13:17:54 +0000 (UTC)",
            "by smtp.kernel.org (Postfix) with ESMTPSA id 4F24FC2BCB1;\n\tTue, 31 Mar 2026 13:17:47 +0000 (UTC)"
        ],
        "ARC-Seal": "i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1774963077;\n\tcv=none;\n b=QzIzNXKQlJiQiSIw5Lwa1ds4RyuX3T0uSN3rckLxJU9Sjl+G4sbjviw0QJGr0q9f2jqnDo6+L4qHObBs+9gTcri5SewRUKNn+nrS6NRs4KbrN/J+43TBGbiFwRH3KE4nH/tkccGRGMtLRRCdbRTC/Zn1Rrnzt4+BfMrSozF3oF3PR1O1HDdwnSkFwNhWXGO4A4rWJcQLk9Vo1afvadLZzKzzNyzIiViIKyZe5M8CXD1A27Fwa4GerA7txGa6iLCpRPj2riNG3t804CoUmLh8OHH0WxYmHK00IFagcGPuuzd5hhasia8vl4Ke/Z+krAe25pM57boV8zJKENi//PxpZQ==",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707;\n\tt=1774963077; c=relaxed/relaxed;\n\tbh=evDp0+wNGwi65GzOVUCrVKS2jJUSlYcqt3TDIZc0eIY=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=HHHsUVrJJaT+02Tl6IEPqEI4gMiYmx2TZYMp1J1UjkiaH1owubCiu/Vjn396gKmrd36MN71SHriotCV8CljlpuYf9oc+Ebwj3dDpy/zSExVuRC+GU4L20vc9PgCwha0055NgE4MeidGfRhSDb/qy5AdBzzbxFw6a+Fv4HY7hBc+QtXaURYVViqkMIqpf34YkA+qrA+jMgjCXRN/fpgFYqEq/5ctpswAjCShBS1tr8mFLMAWhENNKjH697cf9tN08LvNiGA+H2dAhj9Kgn7WJn32O0YdRHa3vcq03Tul3n/VpJIMATYYAC+lfEV6NP7i5jSe13JRYx8lyVigIx95DJA==",
        "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=K7AeiwWS; dkim-atps=neutral;\n spf=pass (client-ip=172.105.4.254; helo=tor.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=1774963074;\n\tbh=l4UXuPtarigCS8/9y+D4zvM6fzJUWSEh7U0vHQaQuhs=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=K7AeiwWShE7xc62Afgw7NwDYnh+ZgmePezlcZrhhBYuGYr1uAQThMppwIj2iv+eVC\n\t xgli87oaP2q84PRbUKRCTQB05BQiwbFcEj9RqjrBg5MK6wl+Q96JtNH0Z/7EIubhCf\n\t WWtkB9eKRqutDAYWQcAkhhWkeZyuLyrR5y9vBgCX4PFrW2ZiHUrdrr8eO45HFlo5ZV\n\t rDqMTg/pLaR4+9/ZQozUPVniXsadl7REgmynbEEJ9uNUBd8yY5w34XA++9ztKX1b4q\n\t /VkMTn9yDfG/vizNwxNkEX1uNe34WECIL2NHez5QPsSI7Pe9uTCJMvvn68Or6V7u9g\n\t AmIr/RlPBw7TQ==",
        "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 11/14] tick/sched: Consolidate idle time fetching APIs",
        "Date": "Tue, 31 Mar 2026 15:16:19 +0200",
        "Message-ID": "<20260331131622.30505-12-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": "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 4a259f2700a1..ebb9eee049e0 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@@ -517,12 +507,42 @@ static u64 get_cpu_sleep_time_us(int cpu, enum cpu_usage_stat idx,\n \t\t\tidle = cpustat[idx];\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@@ -570,7 +590,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@@ -1124,8 +1143,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@@ -1220,8 +1239,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@@ -1234,7 +1253,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": [
        "11/14"
    ]
}