.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Activity LED trigger |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2017 Willy Tarreau <w@1wt.eu> |
---|
5 | 6 | * Partially based on Atsushi Nemoto's ledtrig-heartbeat.c. |
---|
6 | | - * |
---|
7 | | - * This program is free software; you can redistribute it and/or modify |
---|
8 | | - * it under the terms of the GNU General Public License version 2 as |
---|
9 | | - * published by the Free Software Foundation. |
---|
10 | 7 | */ |
---|
11 | 8 | |
---|
12 | 9 | #include <linux/init.h> |
---|
.. | .. |
---|
60 | 57 | curr_used = 0; |
---|
61 | 58 | |
---|
62 | 59 | for_each_possible_cpu(i) { |
---|
63 | | - curr_used += kcpustat_cpu(i).cpustat[CPUTIME_USER] |
---|
64 | | - + kcpustat_cpu(i).cpustat[CPUTIME_NICE] |
---|
65 | | - + kcpustat_cpu(i).cpustat[CPUTIME_SYSTEM] |
---|
66 | | - + kcpustat_cpu(i).cpustat[CPUTIME_SOFTIRQ] |
---|
67 | | - + kcpustat_cpu(i).cpustat[CPUTIME_IRQ]; |
---|
| 60 | + struct kernel_cpustat kcpustat; |
---|
| 61 | + |
---|
| 62 | + kcpustat_cpu_fetch(&kcpustat, i); |
---|
| 63 | + |
---|
| 64 | + curr_used += kcpustat.cpustat[CPUTIME_USER] |
---|
| 65 | + + kcpustat.cpustat[CPUTIME_NICE] |
---|
| 66 | + + kcpustat.cpustat[CPUTIME_SYSTEM] |
---|
| 67 | + + kcpustat.cpustat[CPUTIME_SOFTIRQ] |
---|
| 68 | + + kcpustat.cpustat[CPUTIME_IRQ]; |
---|
68 | 69 | cpus++; |
---|
69 | 70 | } |
---|
70 | 71 | |
---|
.. | .. |
---|
73 | 74 | * down to 16us, ensuring we won't overflow 32-bit computations below |
---|
74 | 75 | * even up to 3k CPUs, while keeping divides cheap on smaller systems. |
---|
75 | 76 | */ |
---|
76 | | - curr_boot = ktime_get_boot_ns() * cpus; |
---|
| 77 | + curr_boot = ktime_get_boottime_ns() * cpus; |
---|
77 | 78 | diff_boot = (curr_boot - activity_data->last_boot) >> 16; |
---|
78 | 79 | diff_used = (curr_used - activity_data->last_used) >> 16; |
---|
79 | 80 | activity_data->last_boot = curr_boot; |
---|