Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 58919e83 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

cpufreq / sched: Pass flags to cpufreq_update_util()



It is useful to know the reason why cpufreq_update_util() has just
been called and that can be passed as flags to cpufreq_update_util()
and to the ->func() callback in struct update_util_data.  However,
doing that in addition to passing the util and max arguments they
already take would be clumsy, so avoid it.

Instead, use the observation that the schedutil governor is part
of the scheduler proper, so it can access scheduler data directly.
This allows the util and max arguments of cpufreq_update_util()
and the ->func() callback in struct update_util_data to be replaced
with a flags one, but schedutil has to be modified to follow.

Thus make the schedutil governor obtain the CFS utilization
information from the scheduler and use the "RT" and "DL" flags
instead of the special utilization value of ULONG_MAX to track
updates from the RT and DL sched classes.  Make it non-modular
too to avoid having to export scheduler variables to modules at
large.

Next, update all of the other users of cpufreq_update_util()
and the ->func() callback in struct update_util_data accordingly.

Suggested-by: default avatarPeter Zijlstra <peterz@infradead.org>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
parent 694d0d0b
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -194,7 +194,7 @@ config CPU_FREQ_GOV_CONSERVATIVE
	  If in doubt, say N.

config CPU_FREQ_GOV_SCHEDUTIL
	tristate "'schedutil' cpufreq policy governor"
	bool "'schedutil' cpufreq policy governor"
	depends on CPU_FREQ && SMP
	select CPU_FREQ_GOV_ATTR_SET
	select IRQ_WORK
@@ -208,9 +208,6 @@ config CPU_FREQ_GOV_SCHEDUTIL
	  frequency tipping point is at utilization/capacity equal to 80% in
	  both cases.

	  To compile this driver as a module, choose M here: the module will
	  be called cpufreq_schedutil.

	  If in doubt, say N.

comment "CPU frequency scaling drivers"
+1 −1
Original line number Diff line number Diff line
@@ -260,7 +260,7 @@ static void dbs_irq_work(struct irq_work *irq_work)
}

static void dbs_update_util_handler(struct update_util_data *data, u64 time,
				    unsigned long util, unsigned long max)
				    unsigned int flags)
{
	struct cpu_dbs_info *cdbs = container_of(data, struct cpu_dbs_info, update_util);
	struct policy_dbs_info *policy_dbs = cdbs->policy_dbs;
+1 −1
Original line number Diff line number Diff line
@@ -1329,7 +1329,7 @@ static inline void intel_pstate_adjust_busy_pstate(struct cpudata *cpu)
}

static void intel_pstate_update_util(struct update_util_data *data, u64 time,
				     unsigned long util, unsigned long max)
				     unsigned int flags)
{
	struct cpudata *cpu = container_of(data, struct cpudata, update_util);
	u64 delta_ns = time - cpu->sample.time;
+8 −4
Original line number Diff line number Diff line
@@ -3469,15 +3469,19 @@ static inline unsigned long rlimit_max(unsigned int limit)
	return task_rlimit_max(current, limit);
}

#define SCHED_CPUFREQ_RT	(1U << 0)
#define SCHED_CPUFREQ_DL	(1U << 1)

#define SCHED_CPUFREQ_RT_DL	(SCHED_CPUFREQ_RT | SCHED_CPUFREQ_DL)

#ifdef CONFIG_CPU_FREQ
struct update_util_data {
	void (*func)(struct update_util_data *data,
		     u64 time, unsigned long util, unsigned long max);
       void (*func)(struct update_util_data *data, u64 time, unsigned int flags);
};

void cpufreq_add_update_util_hook(int cpu, struct update_util_data *data,
                       void (*func)(struct update_util_data *data, u64 time,
				     unsigned long util, unsigned long max));
				    unsigned int flags));
void cpufreq_remove_update_util_hook(int cpu);
#endif /* CONFIG_CPU_FREQ */

+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ DEFINE_PER_CPU(struct update_util_data *, cpufreq_update_util_data);
 */
void cpufreq_add_update_util_hook(int cpu, struct update_util_data *data,
			void (*func)(struct update_util_data *data, u64 time,
				     unsigned long util, unsigned long max))
				     unsigned int flags))
{
	if (WARN_ON(!data || !func))
		return;
Loading