From: ppokorny@penguincomputing.com (Philip Pokorny)
To: lm-sensors@vger.kernel.org
Subject: driver design question
Date: Thu, 19 May 2005 06:24:09 +0000 [thread overview]
Message-ID: <3F293974.7000302@penguincomputing.com> (raw)
In-Reply-To: <20030728153714.7b09e0b7.khali@linux-fr.org>
Jean Delvare wrote:
>>>Quick note: The refresh frequency limit was introduced because the
>>>hardware would give bad results if you polled it too fast. So,
>>>depending on what the datasheet for the chip says, we adjust the
>>>max polling frequency to match. So this was to ensure accurate
>>>results from the hardware, not as a performace optimization.
>>>
>
>>Take a look at the ADM1026 driver (by Phil P.) as a counter-example.
>>The update routine is apropos to this thread. He uses two different
>>refresh frequencies - the slower one for config data. I thought this
>>was a good idea when I first saw it.
>>
>
> Exactly what I had in mind. I didn't know someone else already did that
> :)
>
> After some more thinking however, I'm not sure it's what we really want.
> We are talking (correct me if I'm wrong there) about data that should
> not change *at all*, not data that should not change *often*. So
> sampling their value every 5 minutes doesn't make much sense. If they
> change and we are not aware of the change, it's likely to cause trouble
> that will solve only up to 5 minutes later. The user will probably get
> mad about this (by the time he/she tries to figure out what's wrong, the
> problem will solve by itself). So I think we should opt for one of the
> following policy:
That's one of the reasons that I still poll the data that I don't expect to be
different. I made sure to update the cache immediately when I change a
configuration parameter so that future reads will return the correct data.
But then at some time later, The driver will read the actual hardware so you
can always be sure that after some period of time what you see from the driver
is what's actually on the chip.
This turned out to be important because it helped me find a programming bug in
my driver. I wasn't bit shifting and masking one of the parameters correctly
in and out of the chip. The result was that some settings didn't get changed
correctly. The cache was what I "wanted" but the chip was set to something
different. If I hadn't included the re-read of the chip, I don't think I
would have found this bug.
A cache is just a cache. It's not the real thing. You must include a way to
update the cache to make it consistent with the "real thing". That might be
some other parameter/attribute that you write to to trigger a cache update on
demand. Or it can be a timeout as implemented in the adm1026 driver.
With ACPI and IPMI poking at these monitoring chips, I think it's dangerous
for us to assume that we know everything that's going on with the sensor.
Witness Margit's experience where we programmed the limits incorrectly and the
BIOS shut down his machine. Or where we set off alarm beepers because the
limits are wrong.
> 1* We refresh these values as often as the other ones (what most of our
> drivers do) and don't care about the performance cost. Play it safe,
> Phil E. said.
That's reasonable for simple chips with few registers. But consider that just
about every chip has twice as many limit values (min and max) as current
readings. That means that only 35% of the data is changing rapidly. That's a
significant performance optimization to reduce 65% of reads.
> 2* We say these values should *NOT* change, we don't sample them, and if
> something goes wrong, obviously it's not our fault (though the user will
> certainly complain to us). We can enable a check (that is, sampling the
> should-not-change data as in 1* and emit a warning if we see a change in
> the values) in debug mode (or additional parameter?) to catch the
> problem.
As I said above, I think we should just read the bits once in a while. Adding
checks for unexpected changes could add significantly to the code.
> One more thought though: remember that these things are very unlikely to
> happen. We have the adm1026 driver which as a different policy, now the
> adm1025 has its own one too. These are good tests. If we have no bad
> feedback about these, it must mean it's safe to change our global policy
> to either of those.
>
>>>Now, your point about reducing a significant amount of latency is a
>>>good one. That's a reasonable reason for such an optimization. I'm
>>>not sure if it is a strong enough reason, though. I think we'd need
>>>to do a little math to figure out exactly how much it 'costs' to
>>>read limits and what it would save us to poll them less frequently.
>>>
>>It depends on the chip of course - but I think the ADM1026 driver
>>might be a good model to follow for others which are deemed worth
>>optimizing.
>
> What about trying some real-life tests (that's what it's all about after
> all)? I could try the different policies on the w83781d driver and
> measure how much time module loads and data refreshs take.
Real world test data is always best.
:v)
next prev parent reply other threads:[~2005-05-19 6:24 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-19 6:24 driver design question Jean Delvare
2005-05-19 6:24 ` Philip Edelbrock
2005-05-19 6:24 ` Philip Edelbrock
2005-05-19 6:24 ` Jean Delvare
2005-05-19 6:24 ` Philip Edelbrock
2005-05-19 6:24 ` Jean Delvare
2005-05-19 6:24 ` Philip Pokorny
2005-05-19 6:24 ` Mark M. Hoffman
2005-05-19 6:24 ` Jean Delvare
2005-05-19 6:24 ` Mark D. Studebaker
2005-05-19 6:24 ` Philip Pokorny [this message]
-- strict thread matches above, loose matches on Subject: below --
2006-09-12 20:27 Driver " Lee Revell
2006-09-14 11:29 Takashi Iwai
2006-09-15 14:47 ` Lee Revell
2006-09-19 15:15 ` Takashi Iwai
2006-09-25 19:54 ` Lee Revell
2006-09-27 17:18 ` Takashi Iwai
2006-09-27 17:38 ` Lee Revell
2006-09-30 2:03 ` Lee Revell
2006-10-03 15:35 ` Lee Revell
2006-10-04 9:17 ` Takashi Iwai
2006-10-19 22:12 ` Lee Revell
2006-10-20 12:55 ` Takashi Iwai
2006-10-20 20:12 ` Lee Revell
2006-10-23 13:09 ` Takashi Iwai
2006-10-23 17:46 ` Lee Revell
2006-10-24 15:01 ` Takashi Iwai
2006-10-24 15:30 ` Lee Revell
2006-10-24 23:54 ` Lee Revell
2006-10-04 9:07 ` Takashi Iwai
2006-09-27 13:58 ` Lee Revell
2006-09-27 16:52 ` Takashi Iwai
2013-10-22 7:02 Driver Design Question Johannes Thumshirn
2013-10-23 3:10 ` Guenter Roeck
2013-10-23 7:29 ` Johannes Thumshirn
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=3F293974.7000302@penguincomputing.com \
--to=ppokorny@penguincomputing.com \
--cc=lm-sensors@vger.kernel.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.