[RFC PATCH 12/08] sched/fair: Record the cpu that updated the stats last

K Prateek Nayak posted 8 patches 9 months, 1 week ago
[RFC PATCH 12/08] sched/fair: Record the cpu that updated the stats last
Posted by K Prateek Nayak 9 months ago
Record which CPU updated the stats last. This will be used to invalidate
the stats in the following commits.

Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com>
---
 kernel/sched/fair.c  | 5 +++--
 kernel/sched/sched.h | 1 +
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 6c486e194a9d..2a34d73d824b 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -10279,9 +10279,9 @@ static inline void cache_sd_stats(struct lb_env *env, struct sg_lb_stats *sd_sta
 {
 	struct sched_domain_shared *sd_share = env->sd->shared;
 	struct sg_lb_stats_prop *lb_prop;
-	int cpu, retry_limit = 3;
 	u64 time, lock;
 	long version;
+	int cpu;
 
 	if (!sd_share)
 		return;
@@ -10319,7 +10319,7 @@ static inline void cache_sd_stats(struct lb_env *env, struct sg_lb_stats *sd_sta
 		 * Version is up for grabs! Try again. If the CPU grabs
 		 * the lock next time around lock = version = 0 and this
 		 * is skipped. If it cannot grab the version, lock != 0
-		 * and we return from here thus ensuring on a single
+		 * and we return from here thus ensuring only a single
 		 * retry.
 		 */
 		if (!lock) {
@@ -10330,6 +10330,7 @@ static inline void cache_sd_stats(struct lb_env *env, struct sg_lb_stats *sd_sta
 	}
 
 	lb_prop->sg_stats = *sd_stats;
+	lb_prop->update_cpu = cpu;
 
 	/*
 	 * Pairs against readers checking the version
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 64f7e013fd59..adf4fa2ed031 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -2197,6 +2197,7 @@ struct sg_lb_stats_prop {
 	 */
 	atomic_long_t		version;
 	struct sg_lb_stats	sg_stats;	/* Cached sched_group stats */
+	int			update_cpu;	/* CPU that updated the stats */
 };
 
 static inline struct cpumask *sched_group_span(struct sched_group *sg)
-- 
2.43.0