.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * x86 APERF/MPERF KHz calculation for |
---|
3 | 4 | * /sys/.../cpufreq/scaling_cur_freq |
---|
4 | 5 | * |
---|
5 | 6 | * Copyright (C) 2017 Intel Corp. |
---|
6 | 7 | * Author: Len Brown <len.brown@intel.com> |
---|
7 | | - * |
---|
8 | | - * This file is licensed under GPLv2. |
---|
9 | 8 | */ |
---|
10 | 9 | |
---|
11 | 10 | #include <linux/delay.h> |
---|
12 | 11 | #include <linux/ktime.h> |
---|
13 | 12 | #include <linux/math64.h> |
---|
14 | 13 | #include <linux/percpu.h> |
---|
| 14 | +#include <linux/cpufreq.h> |
---|
15 | 15 | #include <linux/smp.h> |
---|
| 16 | +#include <linux/sched/isolation.h> |
---|
16 | 17 | |
---|
17 | 18 | #include "cpu.h" |
---|
18 | 19 | |
---|
.. | .. |
---|
82 | 83 | if (!cpu_khz) |
---|
83 | 84 | return 0; |
---|
84 | 85 | |
---|
85 | | - if (!static_cpu_has(X86_FEATURE_APERFMPERF)) |
---|
| 86 | + if (!boot_cpu_has(X86_FEATURE_APERFMPERF)) |
---|
| 87 | + return 0; |
---|
| 88 | + |
---|
| 89 | + if (!housekeeping_cpu(cpu, HK_FLAG_MISC)) |
---|
86 | 90 | return 0; |
---|
87 | 91 | |
---|
88 | 92 | aperfmperf_snapshot_cpu(cpu, ktime_get(), true); |
---|
.. | .. |
---|
98 | 102 | if (!cpu_khz) |
---|
99 | 103 | return; |
---|
100 | 104 | |
---|
101 | | - if (!static_cpu_has(X86_FEATURE_APERFMPERF)) |
---|
| 105 | + if (!boot_cpu_has(X86_FEATURE_APERFMPERF)) |
---|
102 | 106 | return; |
---|
103 | 107 | |
---|
104 | | - for_each_online_cpu(cpu) |
---|
| 108 | + for_each_online_cpu(cpu) { |
---|
| 109 | + if (!housekeeping_cpu(cpu, HK_FLAG_MISC)) |
---|
| 110 | + continue; |
---|
105 | 111 | if (!aperfmperf_snapshot_cpu(cpu, now, false)) |
---|
106 | 112 | wait = true; |
---|
| 113 | + } |
---|
107 | 114 | |
---|
108 | 115 | if (wait) |
---|
109 | 116 | msleep(APERFMPERF_REFRESH_DELAY_MS); |
---|
.. | .. |
---|
114 | 121 | if (!cpu_khz) |
---|
115 | 122 | return 0; |
---|
116 | 123 | |
---|
117 | | - if (!static_cpu_has(X86_FEATURE_APERFMPERF)) |
---|
| 124 | + if (!boot_cpu_has(X86_FEATURE_APERFMPERF)) |
---|
| 125 | + return 0; |
---|
| 126 | + |
---|
| 127 | + if (!housekeeping_cpu(cpu, HK_FLAG_MISC)) |
---|
118 | 128 | return 0; |
---|
119 | 129 | |
---|
120 | 130 | if (aperfmperf_snapshot_cpu(cpu, ktime_get(), true)) |
---|