[Devel] [PATCH RH9 15/33] vzstat,sched: Track sched_lat_ve
Andrey Zhadchenko
andrey.zhadchenko at virtuozzo.com
Thu Sep 23 22:08:18 MSK 2021
From: Kirill Tkhai <ktkhai at virtuozzo.com>
FIXME: This patch must be rewritten via sched_entity::statistics::wait_max.
Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
(cherry picked from vz8 commit c0fb61430afceb6564a1b0792d51835b70eab9e1)
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
---
include/linux/ve.h | 3 +++
kernel/sched/fair.c | 11 +++++++++++
kernel/ve/ve.c | 10 ++++++++++
3 files changed, 24 insertions(+)
diff --git a/include/linux/ve.h b/include/linux/ve.h
index c8dd71c..a0b2b46 100644
--- a/include/linux/ve.h
+++ b/include/linux/ve.h
@@ -14,6 +14,7 @@
#include <linux/ve_proto.h>
#include <linux/cgroup.h>
#include <linux/kmapset.h>
+#include <linux/vzstat.h>
struct nsproxy;
struct veip_struct;
@@ -51,6 +52,8 @@ struct ve_struct {
atomic_t netns_avail_nr;
int netns_max_nr;
+
+ struct kstat_lat_pcpu_struct sched_lat_ve;
};
extern int nr_ve;
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 44c4520..0dbfd01 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -21,6 +21,8 @@
* Copyright (C) 2007 Red Hat, Inc., Peter Zijlstra
*/
#include "sched.h"
+#include <linux/ve.h>
+#include <linux/vzstat.h>
/*
* Targeted preemption latency for CPU-bound tasks:
@@ -848,6 +850,14 @@ static void update_curr_fair(struct rq *rq)
__schedstat_set(se->statistics.wait_start, wait_start);
}
+static inline void update_sched_lat(struct task_struct *t, u64 delta)
+{
+#ifdef CONFIG_VE
+ KSTAT_LAT_PCPU_ADD(&kstat_glob.sched_lat, delta);
+ KSTAT_LAT_PCPU_ADD(&t->task_ve->sched_lat_ve, delta);
+#endif
+}
+
static inline void
update_stats_wait_end(struct cfs_rq *cfs_rq, struct sched_entity *se)
{
@@ -880,6 +890,7 @@ static void update_curr_fair(struct rq *rq)
return;
}
trace_sched_stat_wait(p, delta);
+ update_sched_lat(p, delta);
}
__schedstat_set(se->statistics.wait_max,
diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index 1cce1a5..751f43f 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -27,6 +27,8 @@
static struct kmem_cache *ve_cachep;
+static DEFINE_PER_CPU(struct kstat_lat_pcpu_snap_struct, ve0_lat_stats);
+
struct ve_struct ve0 = {
.ve_name = "0",
.start_jiffies = INITIAL_JIFFIES,
@@ -40,6 +42,7 @@ struct ve_struct ve0 = {
.features = -1,
.netns_avail_nr = ATOMIC_INIT(INT_MAX),
.netns_max_nr = INT_MAX,
+ .sched_lat_ve.cur = &ve0_lat_stats,
};
EXPORT_SYMBOL(ve0);
@@ -328,6 +331,10 @@ static struct cgroup_subsys_state *ve_create(struct cgroup_subsys_state *parent_
if (!ve)
goto err_ve;
+ ve->sched_lat_ve.cur = alloc_percpu(struct kstat_lat_pcpu_snap_struct);
+ if (!ve->sched_lat_ve.cur)
+ goto err_lat;
+
ve->features = VE_FEATURES_DEF;
atomic_set(&ve->netns_avail_nr, NETNS_MAX_NR_DEFAULT);
@@ -338,6 +345,8 @@ static struct cgroup_subsys_state *ve_create(struct cgroup_subsys_state *parent_
kmapset_init_key(&ve->sysfs_perms_key);
return &ve->css;
+err_lat:
+ kmem_cache_free(ve_cachep, ve);
err_ve:
return ERR_PTR(err);
}
@@ -377,6 +386,7 @@ static void ve_destroy(struct cgroup_subsys_state *css)
struct ve_struct *ve = css_to_ve(css);
kmapset_unlink(&ve->sysfs_perms_key, &sysfs_ve_perms_set);
+ free_percpu(ve->sched_lat_ve.cur);
kmem_cache_free(ve_cachep, ve);
}
--
1.8.3.1
More information about the Devel
mailing list