mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Shem Multinymous" <multinymous@gmail.com>
To: "Jean Delvare" <khali@linux-fr.org>
Cc: "Vojtech Pavlik" <vojtech@suse.cz>,
	"Brown, Len" <len.brown@intel.com>,
	"Pavel Machek" <pavel@suse.cz>,
	"Matthew Garrett" <mjg59@srcf.ucam.org>,
	"kernel list" <linux-kernel@vger.kernel.org>,
	linux-thinkpad@linux-thinkpad.org, linux-acpi@vger.kernel.org,
	"Henrique de Moraes Holschuh" <hmh@debian.org>,
	"Mark Underwood" <basicmark@yahoo.com>,
	"Greg KH" <greg@kroah.com>
Subject: Re: Generic battery interface
Date: Tue, 1 Aug 2006 01:34:30 +0300	[thread overview]
Message-ID: <41840b750607311534n31e45ca4xbbf98bf4c8085cea@mail.gmail.com> (raw)
In-Reply-To: <20060731233536.92b39035.khali@linux-fr.org>

Hi Jean,

On 8/1/06, Jean Delvare <khali@linux-fr.org> wrote:
> Disclaimer: I have no idea how the input interface works currently. And
> I don't know what problem you are trying to solve. I just thought my
> hwmon-oriented comments might help.

Your comments are highly relevant! Almost everything said in this
thread, apart from "where should we put battery readouts", is
applicable to hwmon.

The problem we're trying to solve is minimizing system load and timer
interrupts caused by apps that track kernel-issued readouts (e.g.,
hwmon's), without the application making unnecessary assumptions about
the driver or vice versa.


> > 1. A new ioctl DELAYED_UPDATE, with parameters min_wait and
> >    min_fresh, meaning: "I want an a fresh readout. If I poll() this FD
> >    with POLLIN then send an input-ready event at time is T+min_wait, or
> >    when you have a readout that was received from the hardware at  time
> >    T+min_fresh, whichever is *later*. Likewise if I select()".
> >    Here T is the time of the ioctl call and min_wait>=min_fresh.
>
> "A or B, whichever is later", effectively means "A and B". Or am I
> missing something?

The equivlent phrasing using "and" is s follows:

"as soon as the current time is at least T+min_wait *and* you have a
readout that was received from the hardware at  time at least
T+min_fresh."


> I fail to see the difference between min_wait and min_fresh.

Here's an example illustrating all parameters.

Suppose the app does a DELAYED_UPDATE with min_wait=700 and
min_fresh=1000 at time T, and then poll()s with a timeout of 9999.

At time T+600 the driver receives update events (yeah, it' that kind
of driver). If this is all that happens, the app will remain blocked
for 9999ms -- the requirement for a readout fresher than T+700 is
never fulfilled.

If the driver get a second event at time T+800, the app will be
unblocked at time T+1000. If, instead, the driver gets the second
event at time T+1200, the app will be unblocked immediately.


> The hwmon interface (sysfs now, procfs before) has been returning
> cached values by defaut for years. Changing this at this point might be
> confusing.

Yes. All those should be told to use O_NONBLOCK, or be delayed by one
readout cycle whenever they poll an attribute. How serious is this?

The essential problem is that we don't want drivers to query the
hardware and cause timer interrups when nobody's listening, so cached
values can get arbitrarily stale. Thus, an out-of-the-blue read by a
*must* wait for a refresh (i.e., hardware query). I don't see a
non-kludgy way out of it.


> I don't see much benefit in waiting for updated values
> compared to reading them from the cache. The driver knows better how
> frequently it can read from the chip.

Yes, but the driver doesn't know how frequently apps *need* it to read
from the chip.

Take the hdaps driver, for example. The hardware can provide fresh
readouts at a rate of 500Hz. Some apps (e.g., hdapsd) actually need a
high poll rate. Others (e.g., joystick emulation and hdaps-gl) work
nicely with 20Hz. And the tp-theft app will be useful even with 1Hz,
and may change its poll rate depending on circumstances. So, what is
the driver supposed to do?

In my proposal, the the driver and all app (implicitly) negotiate a
poll rate which makes sense for all parties involved.


> And no hardware monitoring chip I
> know of can tell when the monitored value has changed - you have to read
> the chip registers to know.

Yes, this may not be relevant for traditional hwmon chips, but we're
trying to handle event-based data sources too. You might get an ACPI
event on temperature change, or a "critical temperature" interrupt
(which flips a boolean sysfs attr) , etc. I can't think of a really
convincing example, but we certainly want an interface that will
support such drivers transparently to userspace.


> > To illustrate, here's an example of a proper polling loop (sans error
> > checking). This app wants to refresh its display when the data has
> > changed, but not more often than once per second. It wants the
> > readouts to be reasonly spaced: they should be obtained at least 700ms
> > apart. And it needs to update its GUI every 3 seconds regardless of
> > readouts.
>
> I don't see the point in the 700ms rule. If you don't want new data
> more often than once per second, the readouts will be spaced by one
> second, which implies > 700ms already.

Only on average. If you use min_wait=1000 and min_fresh=0, you might
be seeing cached readouts that were obtained at times
999,1001,2999,3001,4999,5001,...
which is probably not what you want.


> No seek(fd, ..., 0) here? sysfs files are supposed to be simple text
> files, aren't they?

Yes, for sysfs there's a seek(fd, ..., 0). There isn't one if you use
the input infrastructure's approach, where read()s return a stream of
event records.

  Shem

  reply	other threads:[~2006-07-31 22:34 UTC|newest]

Thread overview: 91+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-27 20:06 Brown, Len
2006-07-27 20:32 ` Shem Multinymous
2006-07-27 23:24   ` Vojtech Pavlik
2006-07-28  0:27     ` Shem Multinymous
2006-07-28  0:36       ` Matthew Garrett
2006-07-28  7:42       ` Vojtech Pavlik
2006-07-28 12:25         ` Pavel Machek
2006-07-28 13:43           ` Vojtech Pavlik
2006-07-28 15:38             ` Shem Multinymous
2006-07-28 15:57               ` Valdis.Kletnieks
2006-07-28 22:10                 ` Shem Multinymous
2006-07-28 23:14                   ` Valdis.Kletnieks
2006-07-29  9:48                     ` Shem Multinymous
2006-07-29 10:17                       ` Vojtech Pavlik
2006-07-29 10:30                         ` Shem Multinymous
2006-07-29 10:37                       ` Mark Underwood
2006-07-29 11:35                         ` Shem Multinymous
2006-07-30  8:35                       ` Valdis.Kletnieks
2006-07-30 11:44                         ` Vojtech Pavlik
2006-07-30 11:48                         ` Shem Multinymous
2006-07-31  0:58                           ` Valdis.Kletnieks
2006-07-31  1:34                             ` Shem Multinymous
2006-07-30  9:18             ` Pavel Machek
2006-07-30 10:14               ` Shem Multinymous
2006-07-30 11:33                 ` Shem Multinymous
2006-07-28 12:25         ` Dmitry Torokhov
2006-07-28 13:44           ` Vojtech Pavlik
2006-07-28 15:19           ` Shem Multinymous
2006-07-28 16:10             ` Dmitry Torokhov
2006-07-30  8:55               ` Greg KH
2006-07-30  9:52                 ` Shem Multinymous
2006-07-30 11:47                   ` Vojtech Pavlik
2006-07-30 12:50                     ` Shem Multinymous
2006-07-30 14:29                   ` Tomasz Torcz
2006-07-30 14:48                     ` Shem Multinymous
2006-07-30 11:46                 ` Vojtech Pavlik
2006-07-28 15:14         ` Shem Multinymous
2006-07-28 20:23           ` Vojtech Pavlik
2006-07-28 22:48             ` Shem Multinymous
2006-07-28 23:17               ` Pavel Machek
2006-07-29 10:36               ` Vojtech Pavlik
2006-07-29 11:32                 ` Shem Multinymous
2006-07-29 12:04                   ` Vojtech Pavlik
2006-07-29 12:51                     ` Shem Multinymous
2006-07-29 13:42                       ` Vojtech Pavlik
2006-07-30  9:00                         ` Greg KH
2006-07-29 21:06               ` Shem Multinymous
2006-07-30 10:05                 ` Pavel Machek
2006-07-30 10:34                   ` Shem Multinymous
2006-07-30 10:37                     ` Pavel Machek
2006-07-30 18:37                 ` Shem Multinymous
     [not found]                   ` <20060731113735.GA22081@creature.apm.etc.tu-bs.de>
2006-07-31 15:18                     ` [ltp] " Shem Multinymous
     [not found]                       ` <20060731183719.GB22081@creature.apm.etc.tu-bs.de>
2006-07-31 22:45                         ` Shem Multinymous
     [not found]                           ` <20060801114303.GA13000@creature.apm.etc.tu-bs.de>
2006-08-02 21:59                             ` Shem Multinymous
2006-07-31 21:35                   ` Jean Delvare
2006-07-31 22:34                     ` Shem Multinymous [this message]
2006-07-31 23:01                     ` Pavel Machek
2006-08-02  7:18                       ` Jean Delvare
2006-08-02  7:46                         ` Marek Wawrzyczny
2006-08-03 11:29                         ` Thomas Renninger
2006-08-03 16:33                           ` Pavel Machek
2006-07-27 22:16 ` Pavel Machek
2006-07-27 22:56   ` Shem Multinymous
2006-07-27 23:08     ` Greg KH
2006-07-27 23:24       ` Pavel Machek
2006-07-30 12:29         ` Jean Delvare
2006-08-02 19:51           ` Pavel Machek
2006-08-03  9:20             ` Jean Delvare
2006-07-27 22:56   ` Greg KH
2006-07-27 23:31   ` Vojtech Pavlik
2006-07-28  0:35     ` Shem Multinymous
2006-07-28 10:11       ` Vojtech Pavlik
  -- strict thread matches above, loose matches on Subject: below --
2006-07-28  4:05 Brown, Len
2006-07-28  8:22 ` Johan Vromans
2006-07-28  9:58 ` Matthew Garrett
2006-07-28 10:10   ` Vojtech Pavlik
2006-07-28 12:21 ` Pavel Machek
2006-07-28 14:13 ` Shem Multinymous
2006-07-27 23:20 Brown, Len
2006-07-28  0:10 ` Shem Multinymous
2006-07-27 15:40 Brown, Len
2006-07-27 16:23 ` Shem Multinymous
2006-07-27 16:50   ` Daniel Barkalow
2006-07-27 20:07     ` Shem Multinymous
2006-07-27  0:20 Pavel Machek
2006-07-27 14:05 ` Matthew Garrett
2006-07-27 14:39   ` Shem Multinymous
2006-07-27 14:44     ` Matthew Garrett
2006-07-27 22:42       ` Greg KH
2006-07-27 14:59     ` Pavel Machek
2006-07-27 15:10       ` Shem Multinymous

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=41840b750607311534n31e45ca4xbbf98bf4c8085cea@mail.gmail.com \
    --to=multinymous@gmail.com \
    --cc=basicmark@yahoo.com \
    --cc=greg@kroah.com \
    --cc=hmh@debian.org \
    --cc=khali@linux-fr.org \
    --cc=len.brown@intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-thinkpad@linux-thinkpad.org \
    --cc=mjg59@srcf.ucam.org \
    --cc=pavel@suse.cz \
    --cc=vojtech@suse.cz \
    /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®