linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] cpu: clean up register_cpu func
@ 2016-08-19  8:25 Alex Shi
  2016-08-19  8:25 ` [PATCH 2/4] cpu: expose pm_qos_resume_latency for each cpu Alex Shi
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Alex Shi @ 2016-08-19  8:25 UTC (permalink / raw)
  Cc: Daniel Lezcano, Greg Kroah-Hartman, open list

This patch could reduce one branch in this function. Also
make the code more readble.

Signed-off-by: Alex Shi <alex.shi@linaro.org>
To: linux-kernel@vger.kernel.org
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/base/cpu.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 691eeea..4c28e1a 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -371,12 +371,13 @@ int register_cpu(struct cpu *cpu, int num)
 	if (cpu->hotpluggable)
 		cpu->dev.groups = hotplugable_cpu_attr_groups;
 	error = device_register(&cpu->dev);
-	if (!error)
-		per_cpu(cpu_sys_devices, num) = &cpu->dev;
-	if (!error)
-		register_cpu_under_node(num, cpu_to_node(num));
+	if (error)
+		return error;
 
-	return error;
+	per_cpu(cpu_sys_devices, num) = &cpu->dev;
+	register_cpu_under_node(num, cpu_to_node(num));
+
+	return 0;
 }
 
 struct device *get_cpu_device(unsigned cpu)
-- 
2.8.1.101.g72d917a

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

* [PATCH 2/4] cpu: expose pm_qos_resume_latency for each cpu
  2016-08-19  8:25 [PATCH 1/4] cpu: clean up register_cpu func Alex Shi
@ 2016-08-19  8:25 ` Alex Shi
  2016-08-22  4:49   ` Alex Shi
  2016-08-19  8:25 ` [PATCH 3/4] cpuidle/menu: stop seeking deeper idle if current state is too deep Alex Shi
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Alex Shi @ 2016-08-19  8:25 UTC (permalink / raw)
  Cc: Daniel Lezcano, Greg Kroah-Hartman, open list

The cpu-dma PM QoS constraint impacts all the cpus in the system. There
is no way to let the user to choose a PM QoS constraint per cpu.

The following patch exposes to the userspace a per cpu based sysfs file
in order to let the userspace to change the value of the PM QoS latency
constraint.

This change is inoperative in its form and the cpuidle governors have to
take into account the per cpu latency constraint in addition to the
global cpu-dma latency constraint in order to operate properly.

BTW
The pm_qos_resume_latency usage defined in
Documentation/ABI/testing/sysfs-devices-power
The /sys/devices/.../power/pm_qos_resume_latency_us attribute
contains the PM QoS resume latency limit for the given device,
which is the maximum allowed time it can take to resume the
device, after it has been suspended at run time, from a resume
request to the moment the device will be ready to process I/O,
in microseconds.  If it is equal to 0, however, this means that
the PM QoS resume latency may be arbitrary.

Signed-off-by: Alex Shi <alex.shi@linaro.org>
To: linux-kernel@vger.kernel.org
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/base/cpu.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 4c28e1a..2c3b359 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -17,6 +17,7 @@
 #include <linux/of.h>
 #include <linux/cpufeature.h>
 #include <linux/tick.h>
+#include <linux/pm_qos.h>
 
 #include "base.h"
 
@@ -376,6 +377,7 @@ int register_cpu(struct cpu *cpu, int num)
 
 	per_cpu(cpu_sys_devices, num) = &cpu->dev;
 	register_cpu_under_node(num, cpu_to_node(num));
+	dev_pm_qos_expose_latency_limit(&cpu->dev, 0);
 
 	return 0;
 }
-- 
2.8.1.101.g72d917a

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

* [PATCH 3/4] cpuidle/menu: stop seeking deeper idle if current state is too deep
  2016-08-19  8:25 [PATCH 1/4] cpu: clean up register_cpu func Alex Shi
  2016-08-19  8:25 ` [PATCH 2/4] cpu: expose pm_qos_resume_latency for each cpu Alex Shi
@ 2016-08-19  8:25 ` Alex Shi
  2016-08-19  8:25 ` [PATCH 4/4] cpuidle/menu: add per cpu pm_qos_resume_latency consideration Alex Shi
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Alex Shi @ 2016-08-19  8:25 UTC (permalink / raw)
  Cc: Daniel Lezcano, Rasmus Villemoes, Arjan van de Ven, Rik van Riel,
	Rafael J. Wysocki, open list

The obsolete commit 71abbbf85 want to introduce a dynamic cstates,
but it was removed for long time. Just left the nonsense deeper cstate
checking.

Since all target_residency and exit_latency are going longer in deeper
idle state, no needs to waste some cpu cycle on useless seeking.

Signed-off-by: Alex Shi <alex.shi@linaro.org>
To: linux-kernel@vger.kernel.org
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Alex Shi <alex.shi@linaro.org>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
---
 drivers/cpuidle/governors/menu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index 03d38c2..bb58e2a 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -358,9 +358,9 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
 		if (s->disabled || su->disable)
 			continue;
 		if (s->target_residency > data->predicted_us)
-			continue;
+			break;
 		if (s->exit_latency > latency_req)
-			continue;
+			break;
 
 		data->last_state_idx = i;
 	}
-- 
2.8.1.101.g72d917a

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

* [PATCH 4/4] cpuidle/menu: add per cpu pm_qos_resume_latency consideration
  2016-08-19  8:25 [PATCH 1/4] cpu: clean up register_cpu func Alex Shi
  2016-08-19  8:25 ` [PATCH 2/4] cpu: expose pm_qos_resume_latency for each cpu Alex Shi
  2016-08-19  8:25 ` [PATCH 3/4] cpuidle/menu: stop seeking deeper idle if current state is too deep Alex Shi
@ 2016-08-19  8:25 ` Alex Shi
  2016-08-22  3:26 ` [PATCH 1/4] cpu: clean up register_cpu func Alex Shi
  2016-08-22 16:52 ` Daniel Lezcano
  4 siblings, 0 replies; 10+ messages in thread
From: Alex Shi @ 2016-08-19  8:25 UTC (permalink / raw)
  Cc: Daniel Lezcano, Rasmus Villemoes, Arjan van de Ven, Rik van Riel,
	Rafael J. Wysocki, open list

Kernel or user may have special requirement on cpu response time, like
if a interrupt is pinned to a cpu, we don't want the cpu goes too deep
sleep. This patch can prevent this thing happen by consider per cpu
resume_latency setting in cpu sleep state selection in menu governor.

The pm_qos_resume_latency ask device to give reponse in this time. That's
similar with cpu cstates' entry_latency + exit_latency. But since
most of cpu cstate either has no entry_latency or add it into exit_latency
So, we just can restrict this time requirement as states exit_latency.

The 0 value of pm_qos_resume_latency is for no limitation according ABI
definition. So set the value 1 could get the 0 latency if it's needed.

Signed-off-by: Alex Shi <alex.shi@linaro.org>
To: linux-kernel@vger.kernel.org
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Alex Shi <alex.shi@linaro.org>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
---
 drivers/cpuidle/governors/menu.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index bb58e2a..e354880 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -12,6 +12,7 @@
 
 #include <linux/kernel.h>
 #include <linux/cpuidle.h>
+#include <linux/cpu.h>
 #include <linux/pm_qos.h>
 #include <linux/time.h>
 #include <linux/ktime.h>
@@ -281,17 +282,23 @@ again:
 static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
 {
 	struct menu_device *data = this_cpu_ptr(&menu_devices);
+	struct device *device = get_cpu_device(dev->cpu);
 	int latency_req = pm_qos_request(PM_QOS_CPU_DMA_LATENCY);
 	int i;
 	unsigned int interactivity_req;
 	unsigned int expected_interval;
 	unsigned long nr_iowaiters, cpu_load;
+	int resume_latency = dev_pm_qos_read_value(device);
 
 	if (data->needs_update) {
 		menu_update(drv, dev);
 		data->needs_update = 0;
 	}
 
+	/* resume_latency is 0 means no restriction */
+	if (resume_latency && resume_latency < latency_req)
+		latency_req = resume_latency;
+
 	/* Special case when user has set very strict latency requirement */
 	if (unlikely(latency_req == 0))
 		return 0;
-- 
2.8.1.101.g72d917a

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

* Re: [PATCH 1/4] cpu: clean up register_cpu func
  2016-08-19  8:25 [PATCH 1/4] cpu: clean up register_cpu func Alex Shi
                   ` (2 preceding siblings ...)
  2016-08-19  8:25 ` [PATCH 4/4] cpuidle/menu: add per cpu pm_qos_resume_latency consideration Alex Shi
@ 2016-08-22  3:26 ` Alex Shi
  2016-08-22 16:52 ` Daniel Lezcano
  4 siblings, 0 replies; 10+ messages in thread
From: Alex Shi @ 2016-08-22  3:26 UTC (permalink / raw)
  Cc: Daniel Lezcano, Greg Kroah-Hartman, open list

Is there any comments for this patch series?

Thanks!

On 08/19/2016 04:25 PM, Alex Shi wrote:
> This patch could reduce one branch in this function. Also
> make the code more readble.
> 
> Signed-off-by: Alex Shi <alex.shi@linaro.org>
> To: linux-kernel@vger.kernel.org
> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
>  drivers/base/cpu.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
> index 691eeea..4c28e1a 100644
> --- a/drivers/base/cpu.c
> +++ b/drivers/base/cpu.c
> @@ -371,12 +371,13 @@ int register_cpu(struct cpu *cpu, int num)
>  	if (cpu->hotpluggable)
>  		cpu->dev.groups = hotplugable_cpu_attr_groups;
>  	error = device_register(&cpu->dev);
> -	if (!error)
> -		per_cpu(cpu_sys_devices, num) = &cpu->dev;
> -	if (!error)
> -		register_cpu_under_node(num, cpu_to_node(num));
> +	if (error)
> +		return error;
>  
> -	return error;
> +	per_cpu(cpu_sys_devices, num) = &cpu->dev;
> +	register_cpu_under_node(num, cpu_to_node(num));
> +
> +	return 0;
>  }
>  
>  struct device *get_cpu_device(unsigned cpu)
> 

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

* Re: [PATCH 2/4] cpu: expose pm_qos_resume_latency for each cpu
  2016-08-19  8:25 ` [PATCH 2/4] cpu: expose pm_qos_resume_latency for each cpu Alex Shi
@ 2016-08-22  4:49   ` Alex Shi
  0 siblings, 0 replies; 10+ messages in thread
From: Alex Shi @ 2016-08-22  4:49 UTC (permalink / raw)
  Cc: Daniel Lezcano, Greg Kroah-Hartman, open list

Add a pr_debug for failure output.


>From dc5111ed3974f994a9f1d88fdd8dc813359a3b6c Mon Sep 17 00:00:00 2001
From: Alex Shi <alex.shi@linaro.org>
Date: Tue, 16 Aug 2016 15:29:01 +0800
Subject: [PATCH 2/4] cpu: expose pm_qos_resume_latency for each cpu

The cpu-dma PM QoS constraint impacts all the cpus in the system. There
is no way to let the user to choose a PM QoS constraint per cpu.

The following patch exposes to the userspace a per cpu based sysfs file
in order to let the userspace to change the value of the PM QoS latency
constraint.

This change is inoperative in its form and the cpuidle governors have to
take into account the per cpu latency constraint in addition to the
global cpu-dma latency constraint in order to operate properly.

BTW
The pm_qos_resume_latency usage defined in
Documentation/ABI/testing/sysfs-devices-power
The /sys/devices/.../power/pm_qos_resume_latency_us attribute
contains the PM QoS resume latency limit for the given device,
which is the maximum allowed time it can take to resume the
device, after it has been suspended at run time, from a resume
request to the moment the device will be ready to process I/O,
in microseconds.  If it is equal to 0, however, this means that
the PM QoS resume latency may be arbitrary.

Signed-off-by: Alex Shi <alex.shi@linaro.org>
---
 drivers/base/cpu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 4c28e1a..ba11e23 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -17,6 +17,7 @@
 #include <linux/of.h>
 #include <linux/cpufeature.h>
 #include <linux/tick.h>
+#include <linux/pm_qos.h>
 
 #include "base.h"
 
@@ -376,6 +377,8 @@ int register_cpu(struct cpu *cpu, int num)
 
 	per_cpu(cpu_sys_devices, num) = &cpu->dev;
 	register_cpu_under_node(num, cpu_to_node(num));
+	if (dev_pm_qos_expose_latency_limit(&cpu->dev, 0))
+		pr_debug("CPU%d: add resume latency failed\n", num);
 
 	return 0;
 }
-- 
2.8.1.101.g72d917a

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

* Re: [PATCH 1/4] cpu: clean up register_cpu func
  2016-08-19  8:25 [PATCH 1/4] cpu: clean up register_cpu func Alex Shi
                   ` (3 preceding siblings ...)
  2016-08-22  3:26 ` [PATCH 1/4] cpu: clean up register_cpu func Alex Shi
@ 2016-08-22 16:52 ` Daniel Lezcano
  4 siblings, 0 replies; 10+ messages in thread
From: Daniel Lezcano @ 2016-08-22 16:52 UTC (permalink / raw)
  To: Alex Shi; +Cc: Greg Kroah-Hartman, open list

On 08/19/2016 10:25 AM, Alex Shi wrote:
> This patch could reduce one branch in this function. Also
> make the code more readble.
> 
> Signed-off-by: Alex Shi <alex.shi@linaro.org>
> To: linux-kernel@vger.kernel.org
> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---

Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>

-- 
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

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

* Re: [PATCH 1/4] cpu: clean up register_cpu func
  2016-08-31 10:45 ` Alex Shi
@ 2016-08-31 13:17   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 10+ messages in thread
From: Greg Kroah-Hartman @ 2016-08-31 13:17 UTC (permalink / raw)
  To: Alex Shi; +Cc: open list, linux-pm, Ulf Hansson, Daniel Lezcano

On Wed, Aug 31, 2016 at 06:45:35PM +0800, Alex Shi wrote:
> Hi,
> 
> Is there any concern on this patch?

For minor cleanup patches like this, relax, they will be reviewed
eventually...

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

* Re: [PATCH 1/4] cpu: clean up register_cpu func
  2016-08-25  8:42 Alex Shi
@ 2016-08-31 10:45 ` Alex Shi
  2016-08-31 13:17   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 10+ messages in thread
From: Alex Shi @ 2016-08-31 10:45 UTC (permalink / raw)
  To: Greg Kroah-Hartman, open list; +Cc: linux-pm, Ulf Hansson, Daniel Lezcano

Hi,

Is there any concern on this patch?

Regards
Alex

On 08/25/2016 04:42 PM, Alex Shi wrote:
> This patch could reduce one branch in this function. Also
> make the code more readble.
> 
> Signed-off-by: Alex Shi <alex.shi@linaro.org>
> Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> To: linux-kernel@vger.kernel.org
> To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: linux-pm@vger.kernel.org
> Cc: Ulf Hansson <ulf.hansson@linaro.org>
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
>  drivers/base/cpu.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
> index 691eeea..4c28e1a 100644
> --- a/drivers/base/cpu.c
> +++ b/drivers/base/cpu.c
> @@ -371,12 +371,13 @@ int register_cpu(struct cpu *cpu, int num)
>  	if (cpu->hotpluggable)
>  		cpu->dev.groups = hotplugable_cpu_attr_groups;
>  	error = device_register(&cpu->dev);
> -	if (!error)
> -		per_cpu(cpu_sys_devices, num) = &cpu->dev;
> -	if (!error)
> -		register_cpu_under_node(num, cpu_to_node(num));
> +	if (error)
> +		return error;
>  
> -	return error;
> +	per_cpu(cpu_sys_devices, num) = &cpu->dev;
> +	register_cpu_under_node(num, cpu_to_node(num));
> +
> +	return 0;
>  }
>  
>  struct device *get_cpu_device(unsigned cpu)
> 

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

* [PATCH 1/4] cpu: clean up register_cpu func
@ 2016-08-25  8:42 Alex Shi
  2016-08-31 10:45 ` Alex Shi
  0 siblings, 1 reply; 10+ messages in thread
From: Alex Shi @ 2016-08-25  8:42 UTC (permalink / raw)
  To: Greg Kroah-Hartman, open list; +Cc: linux-pm, Ulf Hansson, Daniel Lezcano

This patch could reduce one branch in this function. Also
make the code more readble.

Signed-off-by: Alex Shi <alex.shi@linaro.org>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
To: linux-kernel@vger.kernel.org
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-pm@vger.kernel.org
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/base/cpu.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 691eeea..4c28e1a 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -371,12 +371,13 @@ int register_cpu(struct cpu *cpu, int num)
 	if (cpu->hotpluggable)
 		cpu->dev.groups = hotplugable_cpu_attr_groups;
 	error = device_register(&cpu->dev);
-	if (!error)
-		per_cpu(cpu_sys_devices, num) = &cpu->dev;
-	if (!error)
-		register_cpu_under_node(num, cpu_to_node(num));
+	if (error)
+		return error;
 
-	return error;
+	per_cpu(cpu_sys_devices, num) = &cpu->dev;
+	register_cpu_under_node(num, cpu_to_node(num));
+
+	return 0;
 }
 
 struct device *get_cpu_device(unsigned cpu)
-- 
2.8.1.101.g72d917a

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

end of thread, other threads:[~2016-08-31 13:17 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-19  8:25 [PATCH 1/4] cpu: clean up register_cpu func Alex Shi
2016-08-19  8:25 ` [PATCH 2/4] cpu: expose pm_qos_resume_latency for each cpu Alex Shi
2016-08-22  4:49   ` Alex Shi
2016-08-19  8:25 ` [PATCH 3/4] cpuidle/menu: stop seeking deeper idle if current state is too deep Alex Shi
2016-08-19  8:25 ` [PATCH 4/4] cpuidle/menu: add per cpu pm_qos_resume_latency consideration Alex Shi
2016-08-22  3:26 ` [PATCH 1/4] cpu: clean up register_cpu func Alex Shi
2016-08-22 16:52 ` Daniel Lezcano
2016-08-25  8:42 Alex Shi
2016-08-31 10:45 ` Alex Shi
2016-08-31 13:17   ` Greg Kroah-Hartman

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).