From: Alexey Starikovskiy <astarikovskiy@suse.de>
To: Michal Hocko <mstsxfx@gmail.com>
Cc: power@bughost.org, arjan@linux.intel.com, linux-kernel@vger.kernel.org
Subject: Re: Why is /sys/class/power_supply/CMB1/energy_now not exported?
Date: Tue, 22 Jul 2008 09:49:03 +0400 [thread overview]
Message-ID: <488574CF.7010501@suse.de> (raw)
In-Reply-To: <20080722030412.GA5969@dhcp35.suse.cz>
It looks like you use current_now as power, not multiplying it by voltage.
You should either not multiply anything, then you have similar units -- charge and current,
or multiply _both_ by voltage_now, then again you have similar units -- power and energy.
In these both cases you'll have hours or remaining capacity.
Michal Hocko wrote:
> [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
>
next prev parent reply other threads:[~2008-07-22 5:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20080721041213.GA3491@dhcp35.suse.cz>
[not found] ` <48841AE3.3000004@suse.de>
[not found] ` <20080721165921.GB3491@dhcp35.suse.cz>
[not found] ` <4884F98F.4060903@suse.de>
2008-07-22 3:04 ` Why is /sys/class/power_supply/CMB1/energy_now not exported? Michal Hocko
2008-07-22 5:49 ` Alexey Starikovskiy [this message]
2008-07-22 14:19 ` Michal Hocko
2008-09-04 19:40 ` Michal Hocko
2008-09-16 17:22 ` Kok, Auke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=488574CF.7010501@suse.de \
--to=astarikovskiy@suse.de \
--cc=arjan@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mstsxfx@gmail.com \
--cc=power@bughost.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.