* Re: [lm-sensors] sensors-detect: probing i2c sensors racy?
2009-12-09 15:32 [lm-sensors] sensors-detect: probing i2c sensors racy? Forest Bond
@ 2009-12-09 15:56 ` Forest Bond
2009-12-09 16:11 ` Jean Delvare
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Forest Bond @ 2009-12-09 15:56 UTC (permalink / raw)
To: lm-sensors
[-- Attachment #1.1: Type: text/plain, Size: 1338 bytes --]
Hi,
On Wed, Dec 09, 2009 at 10:32:25AM -0500, Forest Bond wrote:
> I am seeing a situation where sensors-detect fails to find sensors in a single
> run due to an apparent race condition. It looks like it loads the i2c-* modules
> and then tries to open /dev/i2c-0 for probing, but it fails to open
> successfully. My sense is that the device is not fully initialize and ready for
> opening immediately following the modprobe calls, but sensors-detect does not
> wait for initialization to complete. I'm not sure what should be happening. It
> seems sensible that modprobe would not return until the device is initialized.
>
> Running sensors-detect again correctly probes the hardware because the i2c bus
> is fully initialized at that point.
>
> I don't know anything about i2c, so I hope the language I'm using to describe
> this situation is reasonable.
>
> I've attached the output from sensors-detect for the first (failed) run and the
> second (successful) run.
FWIW, this issue is also affecting the same hardware:
https://bugs.launchpad.net/ubuntu/+source/lm-sensors-3/+bug/458811
sensors-detect issue was noted while testing with acpi=off to avoid the resource
conflict. Maybe the two issues are related.
-Forest
--
Forest Bond
http://www.alittletooquiet.net
http://www.pytagsfs.org
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 153 bytes --]
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [lm-sensors] sensors-detect: probing i2c sensors racy?
2009-12-09 15:32 [lm-sensors] sensors-detect: probing i2c sensors racy? Forest Bond
2009-12-09 15:56 ` Forest Bond
@ 2009-12-09 16:11 ` Jean Delvare
2009-12-09 16:23 ` Forest Bond
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Jean Delvare @ 2009-12-09 16:11 UTC (permalink / raw)
To: lm-sensors
[-- Attachment #1: Type: text/plain, Size: 1431 bytes --]
Hi Forest,
On Wed, 9 Dec 2009 10:32:25 -0500, Forest Bond wrote:
> I am seeing a situation where sensors-detect fails to find sensors in a single
> run due to an apparent race condition. It looks like it loads the i2c-* modules
> and then tries to open /dev/i2c-0 for probing, but it fails to open
> successfully. My sense is that the device is not fully initialize and ready for
> opening immediately following the modprobe calls, but sensors-detect does not
> wait for initialization to complete. I'm not sure what should be happening. It
> seems sensible that modprobe would not return until the device is initialized.
>
> Running sensors-detect again correctly probes the hardware because the i2c bus
> is fully initialized at that point.
You must be typing very fast to be able to trigger this ;) Or udev is
very slow populating /dev on your machine.
> I don't know anything about i2c, so I hope the language I'm using to describe
> this situation is reasonable.
It is perfect.
> I've attached the output from sensors-detect for the first (failed) run and the
> second (successful) run.
>
> Thoughts?
The version of the sensors-detect you're using is getting old. Please
give a try to the latest one:
http://dl.lm-sensors.org/lm-sensors/files/sensors-detect
If you can still reproduce the problem, then please give a try to the
attached patch and report.
--
Jean Delvare
http://khali.linux-fr.org/wishlist.html
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: sensors-detect-wait-for-i2c-dev-nodes.patch --]
[-- Type: text/x-patch; name=sensors-detect-wait-for-i2c-dev-nodes.patch, Size: 666 bytes --]
Index: sensors-detect
===================================================================
--- sensors-detect (révision 5808)
+++ sensors-detect (copie de travail)
@@ -5812,6 +5812,12 @@
$by_default = 1 if dmi_match('board_vendor', 'asustek', 'tyan',
'supermicro');
+ # udev may take some time to create the device node
+ if (!(-x "/sbin/udevadm" && system("/sbin/udevadm settle") == 0)
+ && !(-x "/sbin/udevsettle" && system("/sbin/udevsettle") == 0)) {
+ sleep(1);
+ }
+
for (my $dev_nr = 0; $dev_nr < @i2c_adapters; $dev_nr++) {
next unless exists $i2c_adapters[$dev_nr];
scan_i2c_adapter($dev_nr, $by_default);
[-- Attachment #3: Type: text/plain, Size: 153 bytes --]
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [lm-sensors] sensors-detect: probing i2c sensors racy?
2009-12-09 15:32 [lm-sensors] sensors-detect: probing i2c sensors racy? Forest Bond
2009-12-09 15:56 ` Forest Bond
2009-12-09 16:11 ` Jean Delvare
@ 2009-12-09 16:23 ` Forest Bond
2009-12-11 3:31 ` Forest Bond
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Forest Bond @ 2009-12-09 16:23 UTC (permalink / raw)
To: lm-sensors
[-- Attachment #1.1: Type: text/plain, Size: 1774 bytes --]
Hi,
Thanks for the quick reply.
On Wed, Dec 09, 2009 at 05:11:48PM +0100, Jean Delvare wrote:
> On Wed, 9 Dec 2009 10:32:25 -0500, Forest Bond wrote:
> > I am seeing a situation where sensors-detect fails to find sensors in a single
> > run due to an apparent race condition. It looks like it loads the i2c-* modules
> > and then tries to open /dev/i2c-0 for probing, but it fails to open
> > successfully. My sense is that the device is not fully initialize and ready for
> > opening immediately following the modprobe calls, but sensors-detect does not
> > wait for initialization to complete. I'm not sure what should be happening. It
> > seems sensible that modprobe would not return until the device is initialized.
> >
> > Running sensors-detect again correctly probes the hardware because the i2c bus
> > is fully initialized at that point.
>
> You must be typing very fast to be able to trigger this ;) Or udev is
> very slow populating /dev on your machine.
You got me ;).
I'm doing this:
yes '' | sensors-detect 2>&1 | tee sensors-detect.log
> > I don't know anything about i2c, so I hope the language I'm using to describe
> > this situation is reasonable.
>
> It is perfect.
>
> > I've attached the output from sensors-detect for the first (failed) run and the
> > second (successful) run.
> >
> > Thoughts?
>
> The version of the sensors-detect you're using is getting old. Please
> give a try to the latest one:
> http://dl.lm-sensors.org/lm-sensors/files/sensors-detect
>
> If you can still reproduce the problem, then please give a try to the
> attached patch and report.
Okay, I'll give this a try.
Thanks,
Forest
--
Forest Bond
http://www.alittletooquiet.net
http://www.pytagsfs.org
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 153 bytes --]
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [lm-sensors] sensors-detect: probing i2c sensors racy?
2009-12-09 15:32 [lm-sensors] sensors-detect: probing i2c sensors racy? Forest Bond
` (2 preceding siblings ...)
2009-12-09 16:23 ` Forest Bond
@ 2009-12-11 3:31 ` Forest Bond
2009-12-11 8:56 ` Jean Delvare
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Forest Bond @ 2009-12-11 3:31 UTC (permalink / raw)
To: lm-sensors
[-- Attachment #1.1: Type: text/plain, Size: 1553 bytes --]
Hi,
On Wed, Dec 09, 2009 at 05:11:48PM +0100, Jean Delvare wrote:
> On Wed, 9 Dec 2009 10:32:25 -0500, Forest Bond wrote:
> > I am seeing a situation where sensors-detect fails to find sensors in a single
> > run due to an apparent race condition. It looks like it loads the i2c-* modules
> > and then tries to open /dev/i2c-0 for probing, but it fails to open
> > successfully. My sense is that the device is not fully initialize and ready for
> > opening immediately following the modprobe calls, but sensors-detect does not
> > wait for initialization to complete. I'm not sure what should be happening. It
> > seems sensible that modprobe would not return until the device is initialized.
> >
> > Running sensors-detect again correctly probes the hardware because the i2c bus
> > is fully initialized at that point.
>
> You must be typing very fast to be able to trigger this ;) Or udev is
> very slow populating /dev on your machine.
>
> > I don't know anything about i2c, so I hope the language I'm using to describe
> > this situation is reasonable.
>
> It is perfect.
>
> > I've attached the output from sensors-detect for the first (failed) run and the
> > second (successful) run.
> >
> > Thoughts?
>
> The version of the sensors-detect you're using is getting old. Please
> give a try to the latest one:
> http://dl.lm-sensors.org/lm-sensors/files/sensors-detect
This seems to work fine. Thanks for the help.
-Forest
--
Forest Bond
http://www.alittletooquiet.net
http://www.pytagsfs.org
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 153 bytes --]
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [lm-sensors] sensors-detect: probing i2c sensors racy?
2009-12-09 15:32 [lm-sensors] sensors-detect: probing i2c sensors racy? Forest Bond
` (3 preceding siblings ...)
2009-12-11 3:31 ` Forest Bond
@ 2009-12-11 8:56 ` Jean Delvare
2009-12-11 12:05 ` Forest Bond
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Jean Delvare @ 2009-12-11 8:56 UTC (permalink / raw)
To: lm-sensors
Hi Forest,
On Thu, 10 Dec 2009 22:31:58 -0500, Forest Bond wrote:
> On Wed, Dec 09, 2009 at 05:11:48PM +0100, Jean Delvare wrote:
> > give a try to the latest one:
> > http://dl.lm-sensors.org/lm-sensors/files/sensors-detect
>
> This seems to work fine. Thanks for the help.
Without the extra patch? Hmm, then I don't know if I should apply it.
On the one hand, why change the code if it works... OTOH, there may be
cases where udev will still be too slow and the bug you've hit will
resurface again.
--
Jean Delvare
http://khali.linux-fr.org/wishlist.html
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [lm-sensors] sensors-detect: probing i2c sensors racy?
2009-12-09 15:32 [lm-sensors] sensors-detect: probing i2c sensors racy? Forest Bond
` (4 preceding siblings ...)
2009-12-11 8:56 ` Jean Delvare
@ 2009-12-11 12:05 ` Forest Bond
2009-12-11 12:56 ` Jean Delvare
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Forest Bond @ 2009-12-11 12:05 UTC (permalink / raw)
To: lm-sensors
[-- Attachment #1.1: Type: text/plain, Size: 999 bytes --]
Hi,
On Fri, Dec 11, 2009 at 09:56:47AM +0100, Jean Delvare wrote:
> Hi Forest,
>
> On Thu, 10 Dec 2009 22:31:58 -0500, Forest Bond wrote:
> > On Wed, Dec 09, 2009 at 05:11:48PM +0100, Jean Delvare wrote:
> > > give a try to the latest one:
> > > http://dl.lm-sensors.org/lm-sensors/files/sensors-detect
> >
> > This seems to work fine. Thanks for the help.
>
> Without the extra patch? Hmm, then I don't know if I should apply it.
> On the one hand, why change the code if it works... OTOH, there may be
> cases where udev will still be too slow and the bug you've hit will
> resurface again.
I only tested once. I guess the race condition is more likely to fall the right
way with the new script (based on your comments, I assume the race still
exists). Would it be helpful if I tested a few more times?
The patch seemed small enough that I wouldn't think it would cause problems.
-Forest
--
Forest Bond
http://www.alittletooquiet.net
http://www.pytagsfs.org
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 153 bytes --]
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [lm-sensors] sensors-detect: probing i2c sensors racy?
2009-12-09 15:32 [lm-sensors] sensors-detect: probing i2c sensors racy? Forest Bond
` (5 preceding siblings ...)
2009-12-11 12:05 ` Forest Bond
@ 2009-12-11 12:56 ` Jean Delvare
2010-02-03 23:47 ` Forest Bond
2010-02-04 8:18 ` Jean Delvare
8 siblings, 0 replies; 10+ messages in thread
From: Jean Delvare @ 2009-12-11 12:56 UTC (permalink / raw)
To: lm-sensors
On Fri, 11 Dec 2009 07:05:22 -0500, Forest Bond wrote:
> Hi,
>
> On Fri, Dec 11, 2009 at 09:56:47AM +0100, Jean Delvare wrote:
> > Hi Forest,
> >
> > On Thu, 10 Dec 2009 22:31:58 -0500, Forest Bond wrote:
> > > On Wed, Dec 09, 2009 at 05:11:48PM +0100, Jean Delvare wrote:
> > > > give a try to the latest one:
> > > > http://dl.lm-sensors.org/lm-sensors/files/sensors-detect
> > >
> > > This seems to work fine. Thanks for the help.
> >
> > Without the extra patch? Hmm, then I don't know if I should apply it.
> > On the one hand, why change the code if it works... OTOH, there may be
> > cases where udev will still be too slow and the bug you've hit will
> > resurface again.
>
> I only tested once. I guess the race condition is more likely to fall the right
> way with the new script (based on your comments, I assume the race still
> exists). Would it be helpful if I tested a few more times?
If you can, yes please.
> The patch seemed small enough that I wouldn't think it would cause problems.
Well, I just would appreciate if you (or others) could test it, to make
sure I didn't accidentally introduce a regression. I think I'll merge
it then.
--
Jean Delvare
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [lm-sensors] sensors-detect: probing i2c sensors racy?
2009-12-09 15:32 [lm-sensors] sensors-detect: probing i2c sensors racy? Forest Bond
` (6 preceding siblings ...)
2009-12-11 12:56 ` Jean Delvare
@ 2010-02-03 23:47 ` Forest Bond
2010-02-04 8:18 ` Jean Delvare
8 siblings, 0 replies; 10+ messages in thread
From: Forest Bond @ 2010-02-03 23:47 UTC (permalink / raw)
To: lm-sensors
[-- Attachment #1.1: Type: text/plain, Size: 1629 bytes --]
Hi,
On Fri, Dec 11, 2009 at 01:56:17PM +0100, Jean Delvare wrote:
> On Fri, 11 Dec 2009 07:05:22 -0500, Forest Bond wrote:
> > Hi,
> >
> > On Fri, Dec 11, 2009 at 09:56:47AM +0100, Jean Delvare wrote:
> > > Hi Forest,
> > >
> > > On Thu, 10 Dec 2009 22:31:58 -0500, Forest Bond wrote:
> > > > On Wed, Dec 09, 2009 at 05:11:48PM +0100, Jean Delvare wrote:
> > > > > give a try to the latest one:
> > > > > http://dl.lm-sensors.org/lm-sensors/files/sensors-detect
> > > >
> > > > This seems to work fine. Thanks for the help.
> > >
> > > Without the extra patch? Hmm, then I don't know if I should apply it.
> > > On the one hand, why change the code if it works... OTOH, there may be
> > > cases where udev will still be too slow and the bug you've hit will
> > > resurface again.
> >
> > I only tested once. I guess the race condition is more likely to fall the right
> > way with the new script (based on your comments, I assume the race still
> > exists). Would it be helpful if I tested a few more times?
>
> If you can, yes please.
>
> > The patch seemed small enough that I wouldn't think it would cause problems.
>
> Well, I just would appreciate if you (or others) could test it, to make
> sure I didn't accidentally introduce a regression. I think I'll merge
> it then.
I finally got around to testing this. As I mentioned before, svn revision 5642
seems to solve my issue, but I see no regressions with your patch applied. I
suspect the udev approach is less prone to races.
Thanks,
Forest
--
Forest Bond
http://www.alittletooquiet.net
http://www.pytagsfs.org
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 153 bytes --]
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [lm-sensors] sensors-detect: probing i2c sensors racy?
2009-12-09 15:32 [lm-sensors] sensors-detect: probing i2c sensors racy? Forest Bond
` (7 preceding siblings ...)
2010-02-03 23:47 ` Forest Bond
@ 2010-02-04 8:18 ` Jean Delvare
8 siblings, 0 replies; 10+ messages in thread
From: Jean Delvare @ 2010-02-04 8:18 UTC (permalink / raw)
To: lm-sensors
On Wed, 3 Feb 2010 18:47:01 -0500, Forest Bond wrote:
> Hi,
>
> On Fri, Dec 11, 2009 at 01:56:17PM +0100, Jean Delvare wrote:
> > On Fri, 11 Dec 2009 07:05:22 -0500, Forest Bond wrote:
> > > Hi,
> > >
> > > On Fri, Dec 11, 2009 at 09:56:47AM +0100, Jean Delvare wrote:
> > > > Hi Forest,
> > > >
> > > > On Thu, 10 Dec 2009 22:31:58 -0500, Forest Bond wrote:
> > > > > On Wed, Dec 09, 2009 at 05:11:48PM +0100, Jean Delvare wrote:
> > > > > > give a try to the latest one:
> > > > > > http://dl.lm-sensors.org/lm-sensors/files/sensors-detect
> > > > >
> > > > > This seems to work fine. Thanks for the help.
> > > >
> > > > Without the extra patch? Hmm, then I don't know if I should apply it.
> > > > On the one hand, why change the code if it works... OTOH, there may be
> > > > cases where udev will still be too slow and the bug you've hit will
> > > > resurface again.
> > >
> > > I only tested once. I guess the race condition is more likely to fall the right
> > > way with the new script (based on your comments, I assume the race still
> > > exists). Would it be helpful if I tested a few more times?
> >
> > If you can, yes please.
> >
> > > The patch seemed small enough that I wouldn't think it would cause problems.
> >
> > Well, I just would appreciate if you (or others) could test it, to make
> > sure I didn't accidentally introduce a regression. I think I'll merge
> > it then.
>
> I finally got around to testing this. As I mentioned before, svn revision 5642
> seems to solve my issue, but I see no regressions with your patch applied. I
> suspect the udev approach is less prone to races.
Patch applied, thanks for reporting.
--
Jean Delvare
http://khali.linux-fr.org/wishlist.html
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 10+ messages in thread