Skip to contentSkip to conversation

intel_idle: Set dev->power_specified

PATCH In review Jean Delvare 2 participants 3 messages Oct 8, 2010 – Oct 16, 2010 Intel idle driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 intel_idle: Set dev->power_specified

The intel_idle driver defines power consumption for all states, but they can't be seen in sysfs because the driver doesn't set dev->power_specified, while the idle code expects that.

---
This is the simple fix. But in all honesty, I don't get the point of dev->power_specified. It should be equally easy to check if the first state's .power has a non-zero value, and at least this doesn't require any cooperation from the driver. As it stands, I expect that future drivers will have the same problem intel_idle had, i.e. they will forget to set dev->power_specified and power consumption values won't be visible in syfs.

Am I missing any obvious problem? If not, I'll be happy to provide an alternative patch dropping dev->power_specified altogether.

 drivers/idle/intel_idle.c |    1 +
 1 file changed, 1 insertion(+)
drivers/idle/intel_idle.c +1 -0
@@ -369,6 +369,7 @@ static int intel_idle_cpuidle_devices_in
 			dev->state_count += 1;
 		}
 
+		dev->power_specified = 1;
 		dev->cpu = i;
 		if (cpuidle_register_device(dev)) {
 			pr_debug(PREFIX "cpuidle_register_device %d failed!\n",
Signature · 1 line
Jean Delvare
#1 lore raw

Hi again Len,

Quoted 6 lines · Jean Delvare

The intel_idle driver defines power consumption for all states, but they can't be seen in sysfs because the driver doesn't set dev->power_specified, while the idle code expects that.

Quoted 8 lines

---
This is the simple fix. But in all honesty, I don't get the point of dev->power_specified. It should be equally easy to check if the first state's .power has a non-zero value, and at least this doesn't require any cooperation from the driver. As it stands, I expect that future drivers will have the same problem intel_idle had, i.e. they will forget to set dev->power_specified and power consumption values won't be visible in syfs.

Apparently I couldn't be more right: the acpi/processor_idle driver also doesn't set dev->power_specified even if power consumption values are available. Grepping the whole kernel source tree, it appears that none of the cpuidle drivers sets dev->power_specified, so I'm not sure if that code path was even tested (at least it works for me...)

Good news is that it means that getting rid of that flag should be easy, if you agree with that approach.

Quoted 17 lines

Am I missing any obvious problem? If not, I'll be happy to provide an alternative patch dropping dev->power_specified altogether.

 drivers/idle/intel_idle.c |    1 +
 1 file changed, 1 insertion(+)
drivers/idle/intel_idle.c +1 -0
@@ -369,6 +369,7 @@ static int intel_idle_cpuidle_devices_in
 			dev->state_count += 1;
 		}
 
+		dev->power_specified = 1;
 		dev->cpu = i;
 		if (cpuidle_register_device(dev)) {
 			pr_debug(PREFIX "cpuidle_register_device %d failed!\n",
Signature · 1 line
Jean Delvare
reviewer
#2 lore raw
Quoted 16 lines · Jean Delvare
Quoted 6 lines

The intel_idle driver defines power consumption for all states, but they can't be seen in sysfs because the driver doesn't set dev->power_specified, while the idle code expects that.

Quoted 8 lines

---
This is the simple fix. But in all honesty, I don't get the point of dev->power_specified. It should be equally easy to check if the first state's .power has a non-zero value, and at least this doesn't require any cooperation from the driver. As it stands, I expect that future drivers will have the same problem intel_idle had, i.e. they will forget to set dev->power_specified and power consumption values won't be visible in syfs.

Quoted 8 lines

Apparently I couldn't be more right: the acpi/processor_idle driver also doesn't set dev->power_specified even if power consumption values are available. Grepping the whole kernel source tree, it appears that none of the cpuidle drivers sets dev->power_specified, so I'm not sure if that code path was even tested (at least it works for me...)

Good news is that it means that getting rid of that flag should be easy, if you agree with that approach.

Sorry I didn't notice your e-mail until today -- for this afternoon I noticed the same problem you did.

The power_specified flag was added in 2.6.36-rc, and intel_idle, acpi_idle, and sh_idle do not know about it and so they get these crazy negative-shown-as-large-positive numbers in sysfs now.

But I was actually planning to delete all the power_usage numbers in these drivers anyway, because they are bogus, and I sent a patch to do that to intel_idle and acpi_idle this afternoon.

Unfortunately, the power_specified patch makes power_usage significant for the first time, apparently because the out of tree ARM stuff is doing that. I'm not immediately excited about it...

thanks,
Len Brown, Intel Open Source Technology Center

Quoted 21 lines
Quoted 17 lines

Am I missing any obvious problem? If not, I'll be happy to provide an alternative patch dropping dev->power_specified altogether.

 drivers/idle/intel_idle.c |    1 +
 1 file changed, 1 insertion(+)
drivers/idle/intel_idle.c +1 -0
@@ -369,6 +369,7 @@ static int intel_idle_cpuidle_devices_in
 			dev->state_count += 1;
 		}
 
+		dev->power_specified = 1;
 		dev->cpu = i;
 		if (cpuidle_register_device(dev)) {
 			pr_debug(PREFIX "cpuidle_register_device %d failed!\n",
Signature · 1 line
Jean Delvare