Re: /proc/acpi/battery gone again, breaks wmpower

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Rafael, thanks for the follow-up!

On Mon, 21 Feb 2022, Rafael J. Wysocki wrote:

Because we promise that user space won't be broken by kernel changes, it needs to be restored to make wmpower work again.

I'd rather not restore all of it, though, just the part relied on by wmpower.

Please check if the attached patch (on top of 5.17-rc5) is sufficient to restore the wmpower functionality.

When I try to build (v5.17-rc5 + patch) with gcc 11.2.0, I get what looks to be a syntax error in ac.c:

drivers/acpi/ac.c: In function 'acpi_ac_add_fs':
drivers/acpi/ac.c:182:29: error: expected ')' before 'PREFIX'
  182 |         printk(KERN_WARNING PREFIX "Deprecated procfs I/F for AC is loaded,"

I've attached an error.log; if you'd like I can send along my .config also.

...

My thoughts about this though -

I did not really expect to get this interface back after I read the commit message for its removal. I admire your fidelity to the linux user promise, but I don't want to create trouble for you guys either.

I am happy to put in the legwork to get wmpower working using whatever the blessed replacement is for the acpi procfs power stuff. Maybe you can help shed some light on the sysfs interface for me.

I started exploring a bit under /sys/class/power_supply, looking for replacements for the "present rate" and "last full/remaining capacity" items under /proc/acpi/battery. Curiously I have two lenovo ThinkPads, a T510 and a T540p, and one of them has current_now & charge_full/_now, and the other has power_now & energy_full/_now. Are these the only two possibilities for rate & capacity? Or are there other potentially others?

I guess the convenient thing about the /proc/acpi/battery interfaces is that it automatically presents the right info for rate & capacity.

(I felt like I was losing my mind for a bit when I saw the units presented as "mAh" in one after I was sure I had read "mWh" before... But reading your patch helped give me a better clue about what was going on there.)

I'm also curious, is the "BAT[0-*]" pattern for battery names consistent, or are there other possibilities? I had suspected "AC" was the standard power_supply name for the main AC power, but that turned out not to be the case on another (HP) laptop that I took a look at. Which leads me to suspect that "BATX" is not necessarily standard either.

I'm also thinking to enumerate batteries & AC power supplies via /sys/bus/acpi/drivers/{ac,battery} rather than /sys/class/power_supply, as surprisingly even a USB-C stick can show up under power_supply, and it's not obvious if there's a clean way to sort out what's what then.

...

I say all this of course as a laptop end-user, and even with the kernel source docs in front of me I seem to be feeling my way around in the dark. I don't know much about the linux acpi internals, and I did not learn about the acpi procfs power interface being deprecated until after wmpower stopped working for me this month :)

It seems like part of the difficulty is that there is not much of a feedback loop for end users to realize that they are using deprecated procfs interfaces, whether directly in custom battery scripts that scrape /proc/acpi/battery, or unwittingly through other programs they happen to use (in this case wmpower). There are no warnings until it's too late.

And even taking a look at what happened the first time it was removed [1], it seems the conclusion was "some people are still using programs that rely on the interface, so we'll add it back" ... But it's not obvious if any effort was made to contact maintainers with a little nudge, to let them know that it's (still) deprecated and what the replacement interface is.

Not sure what the general solution is there, but in any case I'll cheerfully fix up wmpower.


Thanks again and sorry for the long mail :)

Carl


[1] https://lkml.org/lkml/2014/4/21/152
  CC [M]  drivers/acpi/ac.o
In file included from ./include/linux/kernel.h:29,
                 from drivers/acpi/ac.c:11:
drivers/acpi/ac.c: In function 'acpi_ac_add_fs':
drivers/acpi/ac.c:182:29: error: expected ')' before 'PREFIX'
  182 |         printk(KERN_WARNING PREFIX "Deprecated procfs I/F for AC is loaded,"
      |                             ^~~~~~
./include/linux/printk.h:418:25: note: in definition of macro 'printk_index_wra'
  418 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
      |                         ^~~~
drivers/acpi/ac.c:182:9: note: in expansion of macro 'printk'
  182 |         printk(KERN_WARNING PREFIX "Deprecated procfs I/F for AC is loaded,"
      |         ^~~~~~
./include/linux/printk.h:418:24: note: to match this '('
  418 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
      |                        ^
./include/linux/printk.h:446:26: note: in expansion of macro 'printk_index_wrap'
  446 | #define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__)
      |                          ^~~~~~~~~~~~~~~~~
drivers/acpi/ac.c:182:9: note: in expansion of macro 'printk'
  182 |         printk(KERN_WARNING PREFIX "Deprecated procfs I/F for AC is loaded,"
      |         ^~~~~~

[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux