linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V3 0/5] cpufreq: Record stats with fast-switching
@ 2020-10-05  7:56 Viresh Kumar
  2020-10-05  7:56 ` [PATCH V3 1/5] cpufreq: stats: Defer stats update to cpufreq_stats_record_transition() Viresh Kumar
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Viresh Kumar @ 2020-10-05  7:56 UTC (permalink / raw)
  To: Rafael Wysocki, Ben Segall, Dietmar Eggemann, Ingo Molnar,
	Juri Lelli, Mel Gorman, Peter Zijlstra, Steven Rostedt,
	Vincent Guittot, Viresh Kumar
  Cc: linux-pm, Lukasz Luba, cristian.marussi, sudeep.holla, linux-kernel

Hi,

We disabled recording cpufreq stats when fast switching was introduced
to the cpufreq core as the cpufreq stats required to take a spinlock and
that can't be allowed (for performance reasons) on scheduler's hot path.

Here is an attempt to get rid of the lock and bring back the support.

V2->V3:
- Use READ/WRITE_ONCE() for reset-time as well.
- Use unlikely for few conditionals in the hot path.
- Better changelogs.
- Rebase changes.

V1-V2:
- Use READ_ONCE/WRITE_ONCE instead of atomic in the first patch.

--
Viresh

Viresh Kumar (5):
  cpufreq: stats: Defer stats update to
    cpufreq_stats_record_transition()
  cpufreq: stats: Remove locking
  cpufreq: stats: Mark few conditionals with unlikely()
  cpufreq: stats: Enable stats for fast-switch as well
  cpufreq: Move traces and update to policy->cur to cpufreq core

 drivers/cpufreq/cpufreq.c        | 11 ++++
 drivers/cpufreq/cpufreq_stats.c  | 89 ++++++++++++++++++++------------
 kernel/sched/cpufreq_schedutil.c | 12 +----
 3 files changed, 69 insertions(+), 43 deletions(-)

-- 
2.25.0.rc1.19.g042ed3e048af


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH V3 1/5] cpufreq: stats: Defer stats update to cpufreq_stats_record_transition()
  2020-10-05  7:56 [PATCH V3 0/5] cpufreq: Record stats with fast-switching Viresh Kumar
@ 2020-10-05  7:56 ` Viresh Kumar
  2020-10-05  7:56 ` [PATCH V3 2/5] cpufreq: stats: Remove locking Viresh Kumar
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Viresh Kumar @ 2020-10-05  7:56 UTC (permalink / raw)
  To: Rafael Wysocki, Viresh Kumar
  Cc: linux-pm, Vincent Guittot, Lukasz Luba, cristian.marussi,
	sudeep.holla, linux-kernel

In order to prepare for lock-less stats update, add support to defer any
updates to it until cpufreq_stats_record_transition() is called.

The stats were updated from two places earlier:

- show_time_in_state(): This can be easily deferred, all we need is to
  calculate the delta duration again in this routine to show the current
  state's time-in-state.

- store_reset(): This is a bit tricky as we need to clear the stats
  here and avoid races with simultaneous call to
  cpufreq_stats_record_transition().

  This patch fixes it by deferring the reset of the stats (within the
  code) to the next call to cpufreq_stats_record_transition(), but since
  we need to keep showing the right stats until that time, we capture
  the reset time and account for the time since last time reset was
  called until the time cpufreq_stats_record_transition() update the
  stats.

  Userspace will continue seeing the stats correctly, everything will be
  0 after the stats are reset, apart from the time-in-state of the
  current state, until the time a frequency switch happens.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/cpufreq_stats.c | 75 ++++++++++++++++++++++++---------
 1 file changed, 56 insertions(+), 19 deletions(-)

diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index 94d959a8e954..498d962ba224 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -22,17 +22,22 @@ struct cpufreq_stats {
 	spinlock_t lock;
 	unsigned int *freq_table;
 	unsigned int *trans_table;
+
+	/* Deferred reset */
+	unsigned int reset_pending;
+	unsigned long long reset_time;
 };
 
-static void cpufreq_stats_update(struct cpufreq_stats *stats)
+static void cpufreq_stats_update(struct cpufreq_stats *stats,
+				 unsigned long long time)
 {
 	unsigned long long cur_time = get_jiffies_64();
 
-	stats->time_in_state[stats->last_index] += cur_time - stats->last_time;
+	stats->time_in_state[stats->last_index] += cur_time - time;
 	stats->last_time = cur_time;
 }
 
-static void cpufreq_stats_clear_table(struct cpufreq_stats *stats)
+static void cpufreq_stats_reset_table(struct cpufreq_stats *stats)
 {
 	unsigned int count = stats->max_state;
 
@@ -41,42 +46,67 @@ static void cpufreq_stats_clear_table(struct cpufreq_stats *stats)
 	memset(stats->trans_table, 0, count * count * sizeof(int));
 	stats->last_time = get_jiffies_64();
 	stats->total_trans = 0;
+
+	/* Adjust for the time elapsed since reset was requested */
+	WRITE_ONCE(stats->reset_pending, 0);
+	cpufreq_stats_update(stats, READ_ONCE(stats->reset_time));
 	spin_unlock(&stats->lock);
 }
 
 static ssize_t show_total_trans(struct cpufreq_policy *policy, char *buf)
 {
-	return sprintf(buf, "%d\n", policy->stats->total_trans);
+	struct cpufreq_stats *stats = policy->stats;
+
+	if (READ_ONCE(stats->reset_pending))
+		return sprintf(buf, "%d\n", 0);
+	else
+		return sprintf(buf, "%d\n", stats->total_trans);
 }
 cpufreq_freq_attr_ro(total_trans);
 
 static ssize_t show_time_in_state(struct cpufreq_policy *policy, char *buf)
 {
 	struct cpufreq_stats *stats = policy->stats;
+	bool pending = READ_ONCE(stats->reset_pending);
+	unsigned long long time;
 	ssize_t len = 0;
 	int i;
 
 	if (policy->fast_switch_enabled)
 		return 0;
 
-	spin_lock(&stats->lock);
-	cpufreq_stats_update(stats);
-	spin_unlock(&stats->lock);
-
 	for (i = 0; i < stats->state_num; i++) {
+		if (pending) {
+			if (i == stats->last_index)
+				time = get_jiffies_64() - READ_ONCE(stats->reset_time);
+			else
+				time = 0;
+		} else {
+			time = stats->time_in_state[i];
+			if (i == stats->last_index)
+				time += get_jiffies_64() - stats->last_time;
+		}
+
 		len += sprintf(buf + len, "%u %llu\n", stats->freq_table[i],
-			(unsigned long long)
-			jiffies_64_to_clock_t(stats->time_in_state[i]));
+			       jiffies_64_to_clock_t(time));
 	}
 	return len;
 }
 cpufreq_freq_attr_ro(time_in_state);
 
+/* We don't care what is written to the attribute */
 static ssize_t store_reset(struct cpufreq_policy *policy, const char *buf,
 			   size_t count)
 {
-	/* We don't care what is written to the attribute. */
-	cpufreq_stats_clear_table(policy->stats);
+	struct cpufreq_stats *stats = policy->stats;
+
+	/*
+	 * Defer resetting of stats to cpufreq_stats_record_transition() to
+	 * avoid races.
+	 */
+	WRITE_ONCE(stats->reset_time, get_jiffies_64());
+	WRITE_ONCE(stats->reset_pending, 1);
+
 	return count;
 }
 cpufreq_freq_attr_wo(reset);
@@ -84,8 +114,9 @@ cpufreq_freq_attr_wo(reset);
 static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf)
 {
 	struct cpufreq_stats *stats = policy->stats;
+	bool pending = READ_ONCE(stats->reset_pending);
 	ssize_t len = 0;
-	int i, j;
+	int i, j, count;
 
 	if (policy->fast_switch_enabled)
 		return 0;
@@ -113,8 +144,13 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf)
 		for (j = 0; j < stats->state_num; j++) {
 			if (len >= PAGE_SIZE)
 				break;
-			len += scnprintf(buf + len, PAGE_SIZE - len, "%9u ",
-					stats->trans_table[i*stats->max_state+j]);
+
+			if (pending)
+				count = 0;
+			else
+				count = stats->trans_table[i * stats->max_state + j];
+
+			len += scnprintf(buf + len, PAGE_SIZE - len, "%9u ", count);
 		}
 		if (len >= PAGE_SIZE)
 			break;
@@ -228,10 +264,11 @@ void cpufreq_stats_record_transition(struct cpufreq_policy *policy,
 	struct cpufreq_stats *stats = policy->stats;
 	int old_index, new_index;
 
-	if (!stats) {
-		pr_debug("%s: No stats found\n", __func__);
+	if (!stats)
 		return;
-	}
+
+	if (unlikely(READ_ONCE(stats->reset_pending)))
+		cpufreq_stats_reset_table(stats);
 
 	old_index = stats->last_index;
 	new_index = freq_table_get_index(stats, new_freq);
@@ -241,7 +278,7 @@ void cpufreq_stats_record_transition(struct cpufreq_policy *policy,
 		return;
 
 	spin_lock(&stats->lock);
-	cpufreq_stats_update(stats);
+	cpufreq_stats_update(stats, stats->last_time);
 
 	stats->last_index = new_index;
 	stats->trans_table[old_index * stats->max_state + new_index]++;
-- 
2.25.0.rc1.19.g042ed3e048af


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH V3 2/5] cpufreq: stats: Remove locking
  2020-10-05  7:56 [PATCH V3 0/5] cpufreq: Record stats with fast-switching Viresh Kumar
  2020-10-05  7:56 ` [PATCH V3 1/5] cpufreq: stats: Defer stats update to cpufreq_stats_record_transition() Viresh Kumar
@ 2020-10-05  7:56 ` Viresh Kumar
  2020-10-05  7:56 ` [PATCH V3 3/5] cpufreq: stats: Mark few conditionals with unlikely() Viresh Kumar
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Viresh Kumar @ 2020-10-05  7:56 UTC (permalink / raw)
  To: Rafael Wysocki, Viresh Kumar
  Cc: linux-pm, Vincent Guittot, Lukasz Luba, cristian.marussi,
	sudeep.holla, linux-kernel

The locking isn't required anymore as stats can get updated only from
one place at a time. Remove it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/cpufreq_stats.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index 498d962ba224..45a067855367 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -19,7 +19,6 @@ struct cpufreq_stats {
 	unsigned int state_num;
 	unsigned int last_index;
 	u64 *time_in_state;
-	spinlock_t lock;
 	unsigned int *freq_table;
 	unsigned int *trans_table;
 
@@ -41,7 +40,6 @@ static void cpufreq_stats_reset_table(struct cpufreq_stats *stats)
 {
 	unsigned int count = stats->max_state;
 
-	spin_lock(&stats->lock);
 	memset(stats->time_in_state, 0, count * sizeof(u64));
 	memset(stats->trans_table, 0, count * count * sizeof(int));
 	stats->last_time = get_jiffies_64();
@@ -50,7 +48,6 @@ static void cpufreq_stats_reset_table(struct cpufreq_stats *stats)
 	/* Adjust for the time elapsed since reset was requested */
 	WRITE_ONCE(stats->reset_pending, 0);
 	cpufreq_stats_update(stats, READ_ONCE(stats->reset_time));
-	spin_unlock(&stats->lock);
 }
 
 static ssize_t show_total_trans(struct cpufreq_policy *policy, char *buf)
@@ -244,7 +241,6 @@ void cpufreq_stats_create_table(struct cpufreq_policy *policy)
 	stats->state_num = i;
 	stats->last_time = get_jiffies_64();
 	stats->last_index = freq_table_get_index(stats, policy->cur);
-	spin_lock_init(&stats->lock);
 
 	policy->stats = stats;
 	ret = sysfs_create_group(&policy->kobj, &stats_attr_group);
@@ -277,11 +273,9 @@ void cpufreq_stats_record_transition(struct cpufreq_policy *policy,
 	if (old_index == -1 || new_index == -1 || old_index == new_index)
 		return;
 
-	spin_lock(&stats->lock);
 	cpufreq_stats_update(stats, stats->last_time);
 
 	stats->last_index = new_index;
 	stats->trans_table[old_index * stats->max_state + new_index]++;
 	stats->total_trans++;
-	spin_unlock(&stats->lock);
 }
-- 
2.25.0.rc1.19.g042ed3e048af


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH V3 3/5] cpufreq: stats: Mark few conditionals with unlikely()
  2020-10-05  7:56 [PATCH V3 0/5] cpufreq: Record stats with fast-switching Viresh Kumar
  2020-10-05  7:56 ` [PATCH V3 1/5] cpufreq: stats: Defer stats update to cpufreq_stats_record_transition() Viresh Kumar
  2020-10-05  7:56 ` [PATCH V3 2/5] cpufreq: stats: Remove locking Viresh Kumar
@ 2020-10-05  7:56 ` Viresh Kumar
  2020-10-05  7:56 ` [PATCH V3 4/5] cpufreq: stats: Enable stats for fast-switch as well Viresh Kumar
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Viresh Kumar @ 2020-10-05  7:56 UTC (permalink / raw)
  To: Rafael Wysocki, Viresh Kumar
  Cc: linux-pm, Vincent Guittot, Lukasz Luba, cristian.marussi,
	sudeep.holla, linux-kernel

Since this will be part of scheduler's hotpath in some cases, use
unlikely() for few of the obvious conditionals.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/cpufreq_stats.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index 45a067855367..bba04da3a278 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -260,7 +260,7 @@ void cpufreq_stats_record_transition(struct cpufreq_policy *policy,
 	struct cpufreq_stats *stats = policy->stats;
 	int old_index, new_index;
 
-	if (!stats)
+	if (unlikely(!stats))
 		return;
 
 	if (unlikely(READ_ONCE(stats->reset_pending)))
@@ -270,7 +270,7 @@ void cpufreq_stats_record_transition(struct cpufreq_policy *policy,
 	new_index = freq_table_get_index(stats, new_freq);
 
 	/* We can't do stats->time_in_state[-1]= .. */
-	if (old_index == -1 || new_index == -1 || old_index == new_index)
+	if (unlikely(old_index == -1 || new_index == -1 || old_index == new_index))
 		return;
 
 	cpufreq_stats_update(stats, stats->last_time);
-- 
2.25.0.rc1.19.g042ed3e048af


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH V3 4/5] cpufreq: stats: Enable stats for fast-switch as well
  2020-10-05  7:56 [PATCH V3 0/5] cpufreq: Record stats with fast-switching Viresh Kumar
                   ` (2 preceding siblings ...)
  2020-10-05  7:56 ` [PATCH V3 3/5] cpufreq: stats: Mark few conditionals with unlikely() Viresh Kumar
@ 2020-10-05  7:56 ` Viresh Kumar
  2020-10-05  7:56 ` [PATCH V3 5/5] cpufreq: Move traces and update to policy->cur to cpufreq core Viresh Kumar
  2020-10-05 13:25 ` [PATCH V3 0/5] cpufreq: Record stats with fast-switching Rafael J. Wysocki
  5 siblings, 0 replies; 7+ messages in thread
From: Viresh Kumar @ 2020-10-05  7:56 UTC (permalink / raw)
  To: Rafael Wysocki, Viresh Kumar
  Cc: linux-pm, Vincent Guittot, Lukasz Luba, cristian.marussi,
	sudeep.holla, linux-kernel

Now that all the blockers are gone for enabling stats in fast-switching
case, enable it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/cpufreq.c       | 4 ++++
 drivers/cpufreq/cpufreq_stats.c | 6 ------
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 2ea245a6c0c0..2d0e2e464b14 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2072,8 +2072,12 @@ unsigned int cpufreq_driver_fast_switch(struct cpufreq_policy *policy,
 	target_freq = clamp_val(target_freq, policy->min, policy->max);
 	freq = cpufreq_driver->fast_switch(policy, target_freq);
 
+	if (!freq)
+		return 0;
+
 	arch_set_freq_scale(policy->related_cpus, freq,
 			    policy->cpuinfo.max_freq);
+	cpufreq_stats_record_transition(policy, freq);
 
 	return freq;
 }
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index bba04da3a278..8e7d64f34041 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -69,9 +69,6 @@ static ssize_t show_time_in_state(struct cpufreq_policy *policy, char *buf)
 	ssize_t len = 0;
 	int i;
 
-	if (policy->fast_switch_enabled)
-		return 0;
-
 	for (i = 0; i < stats->state_num; i++) {
 		if (pending) {
 			if (i == stats->last_index)
@@ -115,9 +112,6 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf)
 	ssize_t len = 0;
 	int i, j, count;
 
-	if (policy->fast_switch_enabled)
-		return 0;
-
 	len += scnprintf(buf + len, PAGE_SIZE - len, "   From  :    To\n");
 	len += scnprintf(buf + len, PAGE_SIZE - len, "         : ");
 	for (i = 0; i < stats->state_num; i++) {
-- 
2.25.0.rc1.19.g042ed3e048af


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH V3 5/5] cpufreq: Move traces and update to policy->cur to cpufreq core
  2020-10-05  7:56 [PATCH V3 0/5] cpufreq: Record stats with fast-switching Viresh Kumar
                   ` (3 preceding siblings ...)
  2020-10-05  7:56 ` [PATCH V3 4/5] cpufreq: stats: Enable stats for fast-switch as well Viresh Kumar
@ 2020-10-05  7:56 ` Viresh Kumar
  2020-10-05 13:25 ` [PATCH V3 0/5] cpufreq: Record stats with fast-switching Rafael J. Wysocki
  5 siblings, 0 replies; 7+ messages in thread
From: Viresh Kumar @ 2020-10-05  7:56 UTC (permalink / raw)
  To: Rafael Wysocki, Viresh Kumar, Ingo Molnar, Peter Zijlstra,
	Juri Lelli, Vincent Guittot, Dietmar Eggemann, Steven Rostedt,
	Ben Segall, Mel Gorman
  Cc: linux-pm, Lukasz Luba, cristian.marussi, sudeep.holla, linux-kernel

The cpufreq core handles the updates to policy->cur and recording of
cpufreq trace events for all the governors except schedutil's fast
switch case.

Move that as well to cpufreq core for consistency and readability.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/cpufreq.c        |  7 +++++++
 kernel/sched/cpufreq_schedutil.c | 12 +-----------
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 2d0e2e464b14..db00693a586a 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2068,6 +2068,7 @@ unsigned int cpufreq_driver_fast_switch(struct cpufreq_policy *policy,
 					unsigned int target_freq)
 {
 	unsigned int freq;
+	int cpu;
 
 	target_freq = clamp_val(target_freq, policy->min, policy->max);
 	freq = cpufreq_driver->fast_switch(policy, target_freq);
@@ -2075,10 +2076,16 @@ unsigned int cpufreq_driver_fast_switch(struct cpufreq_policy *policy,
 	if (!freq)
 		return 0;
 
+	policy->cur = freq;
 	arch_set_freq_scale(policy->related_cpus, freq,
 			    policy->cpuinfo.max_freq);
 	cpufreq_stats_record_transition(policy, freq);
 
+	if (trace_cpu_frequency_enabled()) {
+		for_each_cpu(cpu, policy->cpus)
+			trace_cpu_frequency(freq, cpu);
+	}
+
 	return freq;
 }
 EXPORT_SYMBOL_GPL(cpufreq_driver_fast_switch);
diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c
index e39008242cf4..28f6d1ad608b 100644
--- a/kernel/sched/cpufreq_schedutil.c
+++ b/kernel/sched/cpufreq_schedutil.c
@@ -115,21 +115,11 @@ static void sugov_fast_switch(struct sugov_policy *sg_policy, u64 time,
 			      unsigned int next_freq)
 {
 	struct cpufreq_policy *policy = sg_policy->policy;
-	int cpu;
 
 	if (!sugov_update_next_freq(sg_policy, time, next_freq))
 		return;
 
-	next_freq = cpufreq_driver_fast_switch(policy, next_freq);
-	if (!next_freq)
-		return;
-
-	policy->cur = next_freq;
-
-	if (trace_cpu_frequency_enabled()) {
-		for_each_cpu(cpu, policy->cpus)
-			trace_cpu_frequency(next_freq, cpu);
-	}
+	cpufreq_driver_fast_switch(policy, next_freq);
 }
 
 static void sugov_deferred_update(struct sugov_policy *sg_policy, u64 time,
-- 
2.25.0.rc1.19.g042ed3e048af


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH V3 0/5] cpufreq: Record stats with fast-switching
  2020-10-05  7:56 [PATCH V3 0/5] cpufreq: Record stats with fast-switching Viresh Kumar
                   ` (4 preceding siblings ...)
  2020-10-05  7:56 ` [PATCH V3 5/5] cpufreq: Move traces and update to policy->cur to cpufreq core Viresh Kumar
@ 2020-10-05 13:25 ` Rafael J. Wysocki
  5 siblings, 0 replies; 7+ messages in thread
From: Rafael J. Wysocki @ 2020-10-05 13:25 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Rafael Wysocki, Ben Segall, Dietmar Eggemann, Ingo Molnar,
	Juri Lelli, Mel Gorman, Peter Zijlstra, Steven Rostedt,
	Vincent Guittot, Linux PM, Lukasz Luba, cristian.marussi,
	Sudeep Holla, Linux Kernel Mailing List

On Mon, Oct 5, 2020 at 9:56 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
>
> Hi,
>
> We disabled recording cpufreq stats when fast switching was introduced
> to the cpufreq core as the cpufreq stats required to take a spinlock and
> that can't be allowed (for performance reasons) on scheduler's hot path.
>
> Here is an attempt to get rid of the lock and bring back the support.
>
> V2->V3:
> - Use READ/WRITE_ONCE() for reset-time as well.
> - Use unlikely for few conditionals in the hot path.
> - Better changelogs.
> - Rebase changes.
>
> V1-V2:
> - Use READ_ONCE/WRITE_ONCE instead of atomic in the first patch.
>
> --
> Viresh
>
> Viresh Kumar (5):
>   cpufreq: stats: Defer stats update to
>     cpufreq_stats_record_transition()
>   cpufreq: stats: Remove locking
>   cpufreq: stats: Mark few conditionals with unlikely()
>   cpufreq: stats: Enable stats for fast-switch as well
>   cpufreq: Move traces and update to policy->cur to cpufreq core
>
>  drivers/cpufreq/cpufreq.c        | 11 ++++
>  drivers/cpufreq/cpufreq_stats.c  | 89 ++++++++++++++++++++------------
>  kernel/sched/cpufreq_schedutil.c | 12 +----
>  3 files changed, 69 insertions(+), 43 deletions(-)
>
> --

The entire series applied as 5.10 material with some minor changelog
edits in patch [1/5], thanks!

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-10-05 13:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-05  7:56 [PATCH V3 0/5] cpufreq: Record stats with fast-switching Viresh Kumar
2020-10-05  7:56 ` [PATCH V3 1/5] cpufreq: stats: Defer stats update to cpufreq_stats_record_transition() Viresh Kumar
2020-10-05  7:56 ` [PATCH V3 2/5] cpufreq: stats: Remove locking Viresh Kumar
2020-10-05  7:56 ` [PATCH V3 3/5] cpufreq: stats: Mark few conditionals with unlikely() Viresh Kumar
2020-10-05  7:56 ` [PATCH V3 4/5] cpufreq: stats: Enable stats for fast-switch as well Viresh Kumar
2020-10-05  7:56 ` [PATCH V3 5/5] cpufreq: Move traces and update to policy->cur to cpufreq core Viresh Kumar
2020-10-05 13:25 ` [PATCH V3 0/5] cpufreq: Record stats with fast-switching Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).