aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include/linux/kernel_stat.h
diff options
context:
space:
mode:
authorFrederic Weisbecker <frederic@kernel.org>2019-11-21 03:44:26 +0100
committerIngo Molnar <mingo@kernel.org>2019-11-21 07:33:24 +0100
commit74722bb223d0f236303b60c9509ff924a9713780 (patch)
tree8e29d87890a00e4377b0296f712c1e52ab1f0d7d /include/linux/kernel_stat.h
parentsched/cputime: Support other fields on kcpustat_field() (diff)
downloadwireguard-linux-74722bb223d0f236303b60c9509ff924a9713780.tar.xz
wireguard-linux-74722bb223d0f236303b60c9509ff924a9713780.zip
sched/vtime: Bring up complete kcpustat accessor
Many callsites want to fetch the values of system, user, user_nice, guest or guest_nice kcpustat fields altogether or at least a pair of these. In that case calling kcpustat_field() for each requested field brings unecessary overhead when we could fetch all of them in a row. So provide kcpustat_cpu_fetch() that fetches the whole kcpustat array in a vtime safe way under the same RCU and seqcount block. Signed-off-by: Frederic Weisbecker <frederic@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Wanpeng Li <wanpengli@tencent.com> Cc: Yauheni Kaliuta <yauheni.kaliuta@redhat.com> Link: https://lkml.kernel.org/r/20191121024430.19938-3-frederic@kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'include/linux/kernel_stat.h')
-rw-r--r--include/linux/kernel_stat.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/include/linux/kernel_stat.h b/include/linux/kernel_stat.h
index 79781196eb25..89f0745c096d 100644
--- a/include/linux/kernel_stat.h
+++ b/include/linux/kernel_stat.h
@@ -81,12 +81,19 @@ static inline unsigned int kstat_cpu_irqs_sum(unsigned int cpu)
#ifdef CONFIG_VIRT_CPU_ACCOUNTING_GEN
extern u64 kcpustat_field(struct kernel_cpustat *kcpustat,
enum cpu_usage_stat usage, int cpu);
+extern void kcpustat_cpu_fetch(struct kernel_cpustat *dst, int cpu);
#else
static inline u64 kcpustat_field(struct kernel_cpustat *kcpustat,
enum cpu_usage_stat usage, int cpu)
{
return kcpustat->cpustat[usage];
}
+
+static inline void kcpustat_cpu_fetch(struct kernel_cpustat *dst, int cpu)
+{
+ *dst = kcpustat_cpu(cpu);
+}
+
#endif
extern void account_user_time(struct task_struct *, u64);