lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 21 Jul 2008 21:04:13 -0600
From:	Michal Hocko <mstsxfx@...il.com>
To:	Alexey Starikovskiy <astarikovskiy@...e.de>
Cc:	power@...host.org, arjan@...ux.intel.com,
	linux-kernel@...r.kernel.org
Subject: Re: Why is /sys/class/power_supply/CMB1/energy_now not exported?

[fixing bad linux kernel mailing list email address - sorry, but gmail's
thrown mailing delivery error to the spam]

On Tue, Jul 22, 2008 at 01:03:11AM +0400, Alexey Starikovskiy wrote:
> Hi Michal,

Hi Alexey,

>
> the charge_now part of your patch seems to be correct, but the
> calculation is somehow broken --

I have made some experiments and the result is quite surprising to me.
It seems that this problem is somehow related to Debian distribution
kernel, because I wasn't able to reproduce it with the Vanilla kernel (I
had to screw something up last time when I have checked that and
reported in the original message).

I have tried 3 configurations:
* 2.6.25 - Vanilla kernel with config-2.6.25 config and result output in
  powertop-2.6.25-good
* 2.6.25-2 - Debian distribution kernel with config-2.6.25-2 config and
  powertop-2.6.25-2-bad output
* 2.6.26 - Vanilla kernel with config-2.6.26 config and result output in
  powertop-2.6.26-good

with the following scenario (powertop patched with attached
charge-read.patch):
* wait for /sys/class/power_class/CMB1/status FULL on AC
* get values from all files in ..CMB1 to output file
* unplug AC
* run powertop
* get values from all files in CMB1 again to the same file
* get output of power consumption to the output file


             |  2.6.25          2.6.25-2        2.6.26
===========================================================================
voltage_now  |  12222000        12206000        12218000
charge_now   |  4850000         4850000         4850000
current_now  |  1398000         1334000         1313000
---------------------------------------------------------------------------
reported     |  16.6            1.4             16.3
consumption  |
---------------------------------------------------------------------------
calculated   |  24.5            3.63            3.69
consumption  |
===========================================================================

Charge value is stable for all 3 configurations and current_now is
2.5.25 > 2.6.25-2 > 2.6.26 so I would expect that reported consumption
is for 2.6.25-2 would be somewhere between values for good
configurations. 

If I use your calculation (charge_now/current_now), than the results are
even more confusing, because 2.6.26 are similar to 2.6.25-2 (but reported
value is like I would expect).

Someone has an idea what could be wrong?

>
> This is what we have:
> ./voltage_min_design
> 10800000
> ./voltage_now
> 11900000
> ./current_now
> 1609000
> ./charge_full_design
> 5200000
> ./charge_full
> 4996000
> ./charge_now
> 4600000
>
> if we do charge_now/current_now, we'll get: 2.86 (hours) or 2 hours 52 
> minutes.
> let's now calculate power consumption:
> voltage_now * current_now = 11900000 * 1609000 / 10^12 = 19.15 W
> and last, let's calculate remaining battery energy:
> voltage_now * charge_now = 11900000 * 4600000 / 10^12 = 54.74 Wh
> and once again, remaining time:
> 54.74 / 19.15 = 2.86
>
> Regards,
> Alex.
>
> Michal Hocko wrote:
>> [CCing powertop mailing list]
>>
>> On Mon, Jul 21, 2008 at 09:13:07AM +0400, Alexey Starikovskiy wrote:
>>> Hi Michal,
>>
>> Hi Alexey,
>>
>>> Battery can return either energy (voltage*charge) or just charge.
>>> In your case it returns only charge. You need to multiply by voltage to
>>> get energy.
>>
>> Thanks for your information. I was confused that both (CHARGE_ and
>> ENERGY_) cases were handled by the same value but didn't realize that
>> the value itself may come from different source.
>>
>> Based on your suggestion, I am attaching patch for current powertop
>> which reads charge_now if energy_now is not present.
>>
>> I am not sure whether this is correct, testing on my laptop shows weird
>> values for current consumption:
>> Power usage (ACPI estimate): 1.4W (40.7 hours) (long term: 24.4W,/2.3h)
>>
>> Even long term value seems to not correspond with the value exported by
>> KPowersafe which shows 3:18 at this moment. 
>>
>> Is there something wrong in the patch or it is just my battery exporting
>> bad values? Current values from sys are attached too.
>>
>>> Regards,
>>> Alex.
>>>
>>>
>>> Michal Hocko wrote:
>>>> Hi,
>>>>
>>>> I am trying to use powertop on my computer, but I am not able to get
>>>> power consumption (powertop complains with "no ACPI power usage estimate
>>>> available").
>>>>
>>>> After powertop code reading it seems that problem is that it expects
>>>> %subj file to be present what is not a case for my Fujitsu Siemens
>>>> Lifebook S71110 notbebook:
>>>>
>>>> /sys/class/power_supply/CMB1 $ find -type f
>>>> ./uevent
>>>> ./power/wakeup
>>>> ./type
>>>> ./status
>>>> ./present
>>>> ./technology
>>>> ./voltage_min_design
>>>> ./voltage_now
>>>> ./current_now
>>>> ./charge_full_design
>>>> ./charge_full
>>>> ./charge_now
>>>> ./model_name
>>>> ./manufacturer
>>>> ./serial_number
>>>> ./alarm
>>>>
>>>> I can see only charge_* files but no energy_* one. 
>>>>
>>>> Documentation/power/power_supply_class.txt notes that ENERGY_* and
>>>> CHARGE_* attributes shouldn't be mixed because of different measurements
>>>> units.
>>>>
>>>> However, It looks like battery module doesn't make any difference when
>>>> reading values for ENERGY_ and CHARGE_ attributes:
>>>> drivers/acpi/battery.c:
>>>> acpi_battery_get_property
>>>> [...]
>>>>         case POWER_SUPPLY_PROP_CHARGE_NOW:
>>>>         case POWER_SUPPLY_PROP_ENERGY_NOW:
>>>>                 val->intval = battery->capacity_now * 1000;
>>>>                 break;
>>>> [...]
>>>>
>>>> So the question is, why this file is not exported when the module can
>>>> provide its value?
>>>>
>>>> If this is correct and it somehow depends on BIOS, how should powertop
>>>> handle such a case when only charge_* files are available?
>>>>
>>>> I am using Debian distribution 2.6.25 kernel (but the same issue is
>>>> present also in Vanilla 2.6.26 kernel).
>>>>
>>>> Let me know, if you need some more information.
>>>>
>>>> Thanks for any hint and
>>>> best regards
>>

-- 
Michal Hocko

View attachment "powertop-2.6.25-2-bad" of type "text/plain" (1755 bytes)

View attachment "powertop-2.6.25-good" of type "text/plain" (1755 bytes)

View attachment "powertop-2.6.26-good" of type "text/plain" (1755 bytes)

View attachment "config-2.6.25-2-686" of type "text/plain" (88589 bytes)

View attachment "config-2.6.25" of type "text/plain" (47073 bytes)

View attachment "config-2.6.26" of type "text/plain" (48418 bytes)

View attachment "charge-read.patch" of type "text/x-diff" (1110 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ