lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <379d23e5-79a5-9d90-0fb6-125d9be85e99@arm.com>
Date:   Fri, 1 Nov 2019 13:17:27 +0100
From:   Dietmar Eggemann <dietmar.eggemann@....com>
To:     Thara Gopinath <thara.gopinath@...aro.org>, mingo@...hat.com,
        peterz@...radead.org, ionela.voinescu@....com,
        vincent.guittot@...aro.org, rui.zhang@...el.com,
        edubezval@...il.com, qperret@...gle.com
Cc:     linux-kernel@...r.kernel.org, amit.kachhap@...il.com,
        javi.merino@...nel.org, daniel.lezcano@...aro.org
Subject: Re: [Patch v4 2/6] sched: Add infrastructure to store and update
 instantaneous thermal pressure

On 22.10.19 22:34, Thara Gopinath wrote:

[...]

> +/**
> + * trigger_thermal_pressure_average: Trigger the thermal pressure accumulate
> + *				     and average algorithm
> + */
> +void trigger_thermal_pressure_average(struct rq *rq)
> +{
> +	update_thermal_load_avg(rq_clock_task(rq), rq,
> +				per_cpu(delta_capacity, cpu_of(rq)));
> +}

Why not call update_thermal_load_avg() directly in fair.c? We do this for all
the other update_foo_load_avg() functions (foo eq. irq, rt_rq, dl_rq ...)

You don't have to pass 'u64 now', so you can hide it plus the 
sched_thermal_decay_coeff add-on within update_thermal_load_avg().
(Similar to update_irq_load_avg()).

You could even hide 'u64 capacity' in it.

So we save one function layer (trigger_thermal_pressure_average()), thermal becomes
more aligned with the other PELT users when it comes to call-sites and we have less
code for this feature.

Something like this (only for 'u64 now' and only compile tested on arm64:

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index be3e802a2dc5..ac3ec3a04469 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -7576,7 +7576,7 @@ static void update_blocked_averages(int cpu)
 
        update_blocked_load_status(rq, !done);
 
-       trigger_thermal_pressure_average(rq);
+       update_thermal_load_avg(rq, per_cpu(delta_capacity, cpu_of(rq)));
        rq_unlock_irqrestore(rq, &rf);
 }
 
@@ -9938,7 +9938,7 @@ static void task_tick_fair(struct rq *rq, struct task_struct *curr, int queued)
        update_misfit_status(curr, rq);
        update_overutilized_status(task_rq(curr));
 
-       trigger_thermal_pressure_average(rq);
+       update_thermal_load_avg(rq, per_cpu(delta_capacity, cpu_of(rq)));
 }
 
 /*
diff --git a/kernel/sched/pelt.c b/kernel/sched/pelt.c
index 38210691c615..7dd0d7e43854 100644
--- a/kernel/sched/pelt.c
+++ b/kernel/sched/pelt.c
@@ -353,8 +353,12 @@ int update_dl_rq_load_avg(u64 now, struct rq *rq, int running)
        return 0;
 }
 
-int update_thermal_load_avg(u64 now, struct rq *rq, u64 capacity)
+extern int sched_thermal_decay_coeff;
+
+int update_thermal_load_avg(struct rq *rq, u64 capacity)
 {
+       u64 now = rq_clock_task(rq) >> sched_thermal_decay_coeff;
+
        if (___update_load_sum(now, &rq->avg_thermal,
                               capacity,
                               capacity,
diff --git a/kernel/sched/pelt.h b/kernel/sched/pelt.h
index c74226de716e..91483c957b6c 100644
--- a/kernel/sched/pelt.h
+++ b/kernel/sched/pelt.h
@@ -6,7 +6,7 @@ int __update_load_avg_se(u64 now, struct cfs_rq *cfs_rq, struct sched_entity *se
 int __update_load_avg_cfs_rq(u64 now, struct cfs_rq *cfs_rq);
 int update_rt_rq_load_avg(u64 now, struct rq *rq, int running);
 int update_dl_rq_load_avg(u64 now, struct rq *rq, int running);
-int update_thermal_load_avg(u64 now, struct rq *rq, u64 capacity);
+int update_thermal_load_avg(struct rq *rq, u64 capacity);
 
 #ifdef CONFIG_HAVE_SCHED_AVG_IRQ
 int update_irq_load_avg(struct rq *rq, u64 running);
diff --git a/kernel/sched/thermal.c b/kernel/sched/thermal.c
index 0da31e12a5ff..7b8c4e35c28d 100644
--- a/kernel/sched/thermal.c
+++ b/kernel/sched/thermal.c
@@ -21,7 +21,7 @@
  *     3                       256
  *     4                       512
  */
-static int sched_thermal_decay_coeff;
+int sched_thermal_decay_coeff;
 
 static int __init setup_sched_thermal_decay_coeff(char *str)
 {
@@ -32,7 +32,7 @@ static int __init setup_sched_thermal_decay_coeff(char *str)
 }
 __setup("sched_thermal_decay_coeff=", setup_sched_thermal_decay_coeff);
 
-static DEFINE_PER_CPU(unsigned long, delta_capacity);
+DEFINE_PER_CPU(unsigned long, delta_capacity);
 
 /**
  * update_thermal_pressure: Update thermal pressure
@@ -55,14 +55,3 @@ void update_thermal_pressure(int cpu, u64 capped_freq_ratio)
 
        per_cpu(delta_capacity, cpu) = delta;
 }
-
-/**
- * trigger_thermal_pressure_average: Trigger the thermal pressure accumulate
- *                                  and average algorithm
- */
-void trigger_thermal_pressure_average(struct rq *rq)
-{
-       update_thermal_load_avg(rq_clock_task(rq) >>
-                               sched_thermal_decay_coeff, rq,
-                               per_cpu(delta_capacity, cpu_of(rq)));
-}
diff --git a/kernel/sched/thermal.h b/kernel/sched/thermal.h
index 26e5b07e9c29..a6ee973db41b 100644
--- a/kernel/sched/thermal.h
+++ b/kernel/sched/thermal.h
@@ -2,12 +2,4 @@
 /*
  * Scheduler thermal interaction internal methods.
  */
-
-#ifdef CONFIG_SMP
-void trigger_thermal_pressure_average(struct rq *rq);
-
-#else
-static inline void trigger_thermal_pressure_average(struct rq *rq)
-{
-}
-#endif
+DECLARE_PER_CPU(unsigned long , delta_capacity);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ