linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Properly fix sysfs_get_idlestate_count()
@ 2014-12-14 14:06 Prarit Bhargava
  2014-12-14 14:06 ` [PATCH 1/2] Revert "tools: cpupower: fix return checks for sysfs_get_idlestate_count()" Prarit Bhargava
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Prarit Bhargava @ 2014-12-14 14:06 UTC (permalink / raw)
  To: linux-pm, linux-kernel
  Cc: Prarit Bhargava, Thomas Renninger, Rafael J. Wysocki

My previous commit 16b7c275c055 ("tools: cpupower: fix return checks for
sysfs_get_idlestate_count()") was not correct.  After looking
at the changelog for cpupower I noticed that Thomas had changed the return of
sysfs_get_idlestate_count() to an unsigned int to simplify the code.  The
problem is really that both he (in his original change) and I (in my new
change) missed the obvious that sysfs_get_idlestate_count()
can't return -ENODEV.  It should just return 0 for "no c-states".

Patch 1 reverts my recent change and patch 2 fixes the problem correctly.

Sorry 'bout that Thomas.  I should have caught that the the first time.

Cc: Thomas Renninger <trenn@suse.de>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Prarit Bhargava <prarit@redhat.com>

Prarit Bhargava (2):
  Revert "tools: cpupower: fix return checks for
    sysfs_get_idlestate_count()"
  Fix no idle state information return value

 tools/power/cpupower/utils/cpuidle-info.c  |    8 ++++----
 tools/power/cpupower/utils/helpers/sysfs.c |    2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

-- 
1.7.9.3


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

* [PATCH 1/2] Revert "tools: cpupower: fix return checks for sysfs_get_idlestate_count()"
  2014-12-14 14:06 [PATCH 0/2] Properly fix sysfs_get_idlestate_count() Prarit Bhargava
@ 2014-12-14 14:06 ` Prarit Bhargava
  2014-12-14 14:06 ` [PATCH 2/2] Fix no idle state information return value Prarit Bhargava
  2014-12-14 21:30 ` [PATCH 0/2] Properly fix sysfs_get_idlestate_count() Rafael J. Wysocki
  2 siblings, 0 replies; 5+ messages in thread
From: Prarit Bhargava @ 2014-12-14 14:06 UTC (permalink / raw)
  To: linux-pm, linux-kernel
  Cc: Prarit Bhargava, Thomas Renninger, Rafael J. Wysocki

This reverts commit 16b7c275c055cc36218404b5d147be7f76575087.

My previous commit 16b7c275c055 ("tools: cpupower: fix return checks for
sysfs_get_idlestate_count()") was not correct.  After looking
at the changelog for cpupower I noticed that Thomas had changed the return of
sysfs_get_idlestate_count() to an unsigned int to simplify the code.  The
problem is really that both he (in his original change) and I (in my new
change) missed the obvious that sysfs_get_idlestate_count()
can't return -ENODEV.  It should just return 0 for "no c-states".

Cc: Thomas Renninger <trenn@suse.de>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Prarit Bhargava <prarit@redhat.com>
---
 tools/power/cpupower/utils/cpuidle-info.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/power/cpupower/utils/cpuidle-info.c b/tools/power/cpupower/utils/cpuidle-info.c
index 458d69b..75e66de 100644
--- a/tools/power/cpupower/utils/cpuidle-info.c
+++ b/tools/power/cpupower/utils/cpuidle-info.c
@@ -22,13 +22,13 @@
 
 static void cpuidle_cpu_output(unsigned int cpu, int verbose)
 {
-	int idlestates, idlestate;
+	unsigned int idlestates, idlestate;
 	char *tmp;
 
 	printf(_ ("Analyzing CPU %d:\n"), cpu);
 
 	idlestates = sysfs_get_idlestate_count(cpu);
-	if (idlestates < 1) {
+	if (idlestates == 0) {
 		printf(_("CPU %u: No idle states\n"), cpu);
 		return;
 	}
@@ -100,10 +100,10 @@ static void cpuidle_general_output(void)
 static void proc_cpuidle_cpu_output(unsigned int cpu)
 {
 	long max_allowed_cstate = 2000000000;
-	int cstate, cstates;
+	unsigned int cstate, cstates;
 
 	cstates = sysfs_get_idlestate_count(cpu);
-	if (cstates < 1) {
+	if (cstates == 0) {
 		printf(_("CPU %u: No C-states info\n"), cpu);
 		return;
 	}
-- 
1.7.9.3


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

* [PATCH 2/2] Fix no idle state information return value
  2014-12-14 14:06 [PATCH 0/2] Properly fix sysfs_get_idlestate_count() Prarit Bhargava
  2014-12-14 14:06 ` [PATCH 1/2] Revert "tools: cpupower: fix return checks for sysfs_get_idlestate_count()" Prarit Bhargava
@ 2014-12-14 14:06 ` Prarit Bhargava
  2014-12-17 16:27   ` Thomas Renninger
  2014-12-14 21:30 ` [PATCH 0/2] Properly fix sysfs_get_idlestate_count() Rafael J. Wysocki
  2 siblings, 1 reply; 5+ messages in thread
From: Prarit Bhargava @ 2014-12-14 14:06 UTC (permalink / raw)
  To: linux-pm, linux-kernel
  Cc: Prarit Bhargava, Thomas Renninger, Rafael J. Wysocki

sysfs_get_idlestate_count() returns an unsigned int.  Returning -ENODEV
is not the right thing to do here, and in any case is handled the same
way as if there are no states found.

Cc: Thomas Renninger <trenn@suse.de>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Prarit Bhargava <prarit@redhat.com>
---
 tools/power/cpupower/utils/helpers/sysfs.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/power/cpupower/utils/helpers/sysfs.c b/tools/power/cpupower/utils/helpers/sysfs.c
index 09afe5d..4e8fe2c 100644
--- a/tools/power/cpupower/utils/helpers/sysfs.c
+++ b/tools/power/cpupower/utils/helpers/sysfs.c
@@ -361,7 +361,7 @@ unsigned int sysfs_get_idlestate_count(unsigned int cpu)
 
 	snprintf(file, SYSFS_PATH_MAX, PATH_TO_CPU "cpuidle");
 	if (stat(file, &statbuf) != 0 || !S_ISDIR(statbuf.st_mode))
-		return -ENODEV;
+		return 0;
 
 	snprintf(file, SYSFS_PATH_MAX, PATH_TO_CPU "cpu%u/cpuidle/state0", cpu);
 	if (stat(file, &statbuf) != 0 || !S_ISDIR(statbuf.st_mode))
-- 
1.7.9.3


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

* Re: [PATCH 0/2] Properly fix sysfs_get_idlestate_count()
  2014-12-14 14:06 [PATCH 0/2] Properly fix sysfs_get_idlestate_count() Prarit Bhargava
  2014-12-14 14:06 ` [PATCH 1/2] Revert "tools: cpupower: fix return checks for sysfs_get_idlestate_count()" Prarit Bhargava
  2014-12-14 14:06 ` [PATCH 2/2] Fix no idle state information return value Prarit Bhargava
@ 2014-12-14 21:30 ` Rafael J. Wysocki
  2 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2014-12-14 21:30 UTC (permalink / raw)
  To: Prarit Bhargava
  Cc: linux-pm, linux-kernel, Thomas Renninger, Rafael J. Wysocki

On Sunday, December 14, 2014 09:06:36 AM Prarit Bhargava wrote:
> My previous commit 16b7c275c055 ("tools: cpupower: fix return checks for
> sysfs_get_idlestate_count()") was not correct.  After looking
> at the changelog for cpupower I noticed that Thomas had changed the return of
> sysfs_get_idlestate_count() to an unsigned int to simplify the code.  The
> problem is really that both he (in his original change) and I (in my new
> change) missed the obvious that sysfs_get_idlestate_count()
> can't return -ENODEV.  It should just return 0 for "no c-states".
> 
> Patch 1 reverts my recent change and patch 2 fixes the problem correctly.
> 
> Sorry 'bout that Thomas.  I should have caught that the the first time.
> 
> Cc: Thomas Renninger <trenn@suse.de>
> Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Signed-off-by: Prarit Bhargava <prarit@redhat.com>
> 
> Prarit Bhargava (2):
>   Revert "tools: cpupower: fix return checks for
>     sysfs_get_idlestate_count()"
>   Fix no idle state information return value
> 
>  tools/power/cpupower/utils/cpuidle-info.c  |    8 ++++----
>  tools/power/cpupower/utils/helpers/sysfs.c |    2 +-
>  2 files changed, 5 insertions(+), 5 deletions(-)

I'll queue up the revert, but I need an ACK from Thomas for the second patch.


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

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

* Re: [PATCH 2/2] Fix no idle state information return value
  2014-12-14 14:06 ` [PATCH 2/2] Fix no idle state information return value Prarit Bhargava
@ 2014-12-17 16:27   ` Thomas Renninger
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Renninger @ 2014-12-17 16:27 UTC (permalink / raw)
  To: Prarit Bhargava; +Cc: linux-pm, linux-kernel, Rafael J. Wysocki

On Sunday, December 14, 2014 09:06:38 AM Prarit Bhargava wrote:
> sysfs_get_idlestate_count() returns an unsigned int.  Returning -ENODEV
> is not the right thing to do here, and in any case is handled the same
> way as if there are no states found.
Yep, returning zero states instead of an error code makes a lot sense
here.

> 
> Cc: Thomas Renninger <trenn@suse.de>
> Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Acked-by: Thomas Renninger <trenn@suse.de>

Thanks!

    Thomas

> ---
>  tools/power/cpupower/utils/helpers/sysfs.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/power/cpupower/utils/helpers/sysfs.c
> b/tools/power/cpupower/utils/helpers/sysfs.c index 09afe5d..4e8fe2c 100644
> --- a/tools/power/cpupower/utils/helpers/sysfs.c
> +++ b/tools/power/cpupower/utils/helpers/sysfs.c
> @@ -361,7 +361,7 @@ unsigned int sysfs_get_idlestate_count(unsigned int cpu)
> 
>  	snprintf(file, SYSFS_PATH_MAX, PATH_TO_CPU "cpuidle");
>  	if (stat(file, &statbuf) != 0 || !S_ISDIR(statbuf.st_mode))
> -		return -ENODEV;
> +		return 0;
> 
>  	snprintf(file, SYSFS_PATH_MAX, PATH_TO_CPU "cpu%u/cpuidle/state0", 
cpu);
>  	if (stat(file, &statbuf) != 0 || !S_ISDIR(statbuf.st_mode))


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

end of thread, other threads:[~2014-12-17 16:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-14 14:06 [PATCH 0/2] Properly fix sysfs_get_idlestate_count() Prarit Bhargava
2014-12-14 14:06 ` [PATCH 1/2] Revert "tools: cpupower: fix return checks for sysfs_get_idlestate_count()" Prarit Bhargava
2014-12-14 14:06 ` [PATCH 2/2] Fix no idle state information return value Prarit Bhargava
2014-12-17 16:27   ` Thomas Renninger
2014-12-14 21:30 ` [PATCH 0/2] Properly fix sysfs_get_idlestate_count() 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).