mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Shem Multinymous" <multinymous@gmail.com>
To: "David Zeuthen" <davidz@redhat.com>
Cc: "David Woodhouse" <dwmw2@infradead.org>,
	linux-kernel@vger.kernel.org, olpc-dev@laptop.org,
	greg@kroah.com, mjg59@srcf.ucam.org, len.brown@intel.com,
	sfr@canb.auug.org.au, benh@kernel.crashing.org
Subject: Re: Battery class driver.
Date: Tue, 24 Oct 2006 04:56:30 +0200	[thread overview]
Message-ID: <41840b750610231956ib1c7204tafb23ecd76f5d9d2@mail.gmail.com> (raw)
In-Reply-To: <1161641703.2597.115.camel@zelda.fubar.dk>

Hi,

On 10/24/06, David Zeuthen <davidz@redhat.com> wrote:

> How do we plan to get updates to user space?

There was a long LKML thread ("Generic battery interface") about this in July.
This a general issue in sysfs, applicably whenever sysfs is used to
communicate device data (as opposed to system configuration). We need
a generic solution. Here are a few of the considerations that came up
in that thread:

- Efficiency on both poll-based and event-based hardware data sources.
- Avoiding unnecessary timer interrupts on tickless kernels.
- Letting multiple userspace clients poll the same data source at
different rates, without causing duplicate queries or unnecessary
process wakeups.
- Avoiding duplicate queries on poll-based hardware that provides
several attributes simultaneously.

Here's my latest proposed solution in that thread (but see the dozens
of messages before and after for context...):
http://lkml.org/lkml/2006/7/30/193


> The ACPI code today
> provides updates via the ACPI socket but that is broken on some hardware
> so essentially HAL polls by reading /proc/acpi/battery/BAT0/state some
> every 30 secs on, and, on some boxen, that generates a SMBIOS trap or
> some other expensive operation. That's wrong.

30 seconds? I've seen battery applets that poll 1sec intervals (that's
actually useful when you tweak power saving). And for things like the
hdaps accelerometer driver, we're at the 50HZ region.


> So, perhaps the battery class should provide a file called 'timestamp'
> or something that is only writable by the super user. If you read from
> that file it gives the time when the information was last updated. If
> you write to the file it will force the driver query the hardware and
> update the other files. Reading any other file than 'timestamp' will
> just read cached information.
>
> The mechanism to notify user space that something have been updated
> would be either to make the timestamp file pollable or use an uevent or
> something else (no input drivers please).
>
> If the hardware is able to generate an interrupt when certain data on
> the battery has changed the driver simply updates the timestamp file.
>
> With this scheme, user space simply does this
>
>  10 poll on /sys/class/battery/BAT0/timestamp with timeout=30sec
>  20 if timeout, write to 'timestamp' file to force polling
>  30 read values from sysfs and update graphics for battery icon etc.
>  40 goto 10
>
> and we only poll when the hardware don't provide such interrupts /
> hardware is broken so it don't provide interrupts.
>
> Specifically, user space can decide to make the timeout infinite or
> decide not to poll under certain conditions etc. etc.

This is a very interesting approach; I don't recall anything like this
from on the older thread.
There are a few problems though:
You can't require reading battery status to be a root-only operation.
When mutiple userspace apps poll the battery, you'll get race
conditions on timestamp, and even in the best case all the apps will
be woken up at the poll rate of the most-frequently-polling app (think
of that happening at 50HZ for hdaps...).

  Shem

  parent reply	other threads:[~2006-10-24  2:56 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-23 18:20 David Woodhouse
2006-10-23 18:26 ` Matthew Garrett
2006-10-23 18:30   ` David Woodhouse
2006-10-24  3:36   ` Benjamin Herrenschmidt
2006-10-23 18:30 ` Greg KH
2006-10-23 18:32   ` Greg KH
2006-10-23 18:50   ` David Woodhouse
2006-10-24  3:39     ` Benjamin Herrenschmidt
2006-10-23 21:04   ` Jean Delvare
2006-10-23 22:15 ` David Zeuthen
2006-10-23 22:59   ` Greg KH
2006-10-24  1:31     ` David Zeuthen
2006-10-24  3:04       ` Shem Multinymous
2006-10-24  2:56   ` Shem Multinymous [this message]
2006-10-24  3:27     ` Matthew Garrett
2006-10-24  3:48       ` Benjamin Herrenschmidt
2006-10-24  3:53         ` Matthew Garrett
2006-10-24  5:43           ` Benjamin Herrenschmidt
2006-10-24 11:09           ` Shem Multinymous
2006-10-24  2:04 ` Shem Multinymous
2006-10-25 10:45 ` Pavel Machek
     [not found] <1161628327.19446.391.camel@pmac.infradead.org>
2006-10-23 19:18 ` Dan Williams
2006-10-23 19:58   ` Richard Hughes
2006-10-23 20:10     ` Roland Dreier
2006-10-23 20:48     ` David Woodhouse
2006-10-24  3:44       ` Benjamin Herrenschmidt
2006-10-24 17:18       ` Richard Hughes
2006-10-24  3:41     ` Benjamin Herrenschmidt

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=41840b750610231956ib1c7204tafb23ecd76f5d9d2@mail.gmail.com \
    --to=multinymous@gmail.com \
    --cc=benh@kernel.crashing.org \
    --cc=davidz@redhat.com \
    --cc=dwmw2@infradead.org \
    --cc=greg@kroah.com \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjg59@srcf.ucam.org \
    --cc=olpc-dev@laptop.org \
    --cc=sfr@canb.auug.org.au \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®