Skip to contentSkip to conversation

Error messages on ignored values

DISCUSSION Applied Michael Carland 2 participants 6 messages May 19, 2005

lore
Share & tools
lore
#0 lore raw

Hi.

I've read the FAQ, and see the error message I am receiving, but the answer does not seem to apply.

I am running Debian sarge, with a 2.6.10 kernel that I have built, the user programs of lm_sensors-2.9.0, and the 2.6.10 kernel patch. I am able to run sensors, and get valid output, but the values that are marked ignore in the sensors.conf are reported as unreadable. I changed a label value in the conf file and saw the output of sensors change, so I know I am looking at the correct configuration file.

I have added a debug message to progs/sensors/chips.c to print out the result of sensors_get_ignored, and see that the config file is being used to determine that the values should be ignored.

mcarland@myth:~/lm_sensors-2.9.0/prog/sensors$ lsmod
Module                  Size  Used by
vt1211                 16692  0 
i2c_sensor              2784  1 vt1211
i2c_isa                 1600  0 
lirc_serial            11328  0 
lirc_dev               11404  1 lirc_serial
mcarland@myth:~/lm_sensors-2.9.0/prog/sensors$ uname -a
Linux myth 2.6.10myth-via #5 Thu Feb 3 21:24:11 UTC 2005 i686 GNU/Linux
mcarland@myth:~/lm_sensors-2.9.0/prog/sensors$ ./sensors -v
sensors version 2.9.0 with libsensors version 2.9.0
mcarland@myth:~/lm_sensors-2.9.0/prog/sensors$ ./sensors
vt1211-isa-6000
Adapter: ISA adapter
Ignored : 0 vt1211
ERROR: Can't get IN0 data!
Ignored : 0 vt1211
ERROR: Can't get IN1 data!
Ignored : 1 vt1211
VCore1:    +1.39 V  (min =  +1.28 V, max =  +1.42 V)   
Ignored : 1 vt1211
+5V:       +5.09 V  (min =  +4.60 V, max =  +5.25 V)   
Ignored : 1 vt1211
+12V:     +12.40 V  (min = +10.81 V, max = +13.20 V)   
Ignored : 1 vt1211
+3.3V:     +3.32 V  (min =  +3.13 V, max =  +3.47 V)   
Ignored : 1 vt1211
System:      0 RPM  (min = 1503 RPM, div = 4)          
Ignored : 1 vt1211
CPU:      6241 RPM  (min = 3006 RPM, div = 2)          
Ignored : 1 vt1211
temp2:     +66.5 C  (high =  +255 C, hyst =    +0 C)   
Ignored : 1 vt1211
CPU:       +28.6 C  (high =   +65 C, hyst =   +60 C)   
Ignored : 1 vt1211
temp4:     +59.0 C  (high =  +255 C, hyst =    +0 C)   
Ignored : 0 vt1211
ERROR: Can't get TEMP5 data!
Ignored : 0 vt1211
ERROR: Can't get TEMP6 data!
Ignored : 0 vt1211
ERROR: Can't get TEMP7 data!
Ignored : 1 vt1211
vid:      +2.050 V  (VRM Version 8.2)

I see that the logic to print out the values checks the ignored status, but doesn't use it until after an attempt to read the values:

if (!sensors_get_label_and_valid(*name,SENSORS_VT1211_IN0,&label,&valid)
&&

      !sensors_get_feature(*name,SENSORS_VT1211_IN0,&cur) &&
      !sensors_get_feature(*name,SENSORS_VT1211_IN0_MIN,&min) &&
      !sensors_get_feature(*name,SENSORS_VT1211_IN0_MAX,&max)) {
    if (valid) {
      print_label(label,10);
      printf("%+6.2f V  (min = %+6.2f V, max = %+6.2f V)   %s\n",
             cur,min,max,alarms&VT1211_ALARM_IN0?"ALARM":"");
    }
  } else
    printf("ERROR: Can't get IN0 data!\n");

free_the_label(&label);

Shouldn't either sensors_get_feature(...) not do the read if the feature is not valid (only that function would have to be changed), or more appropriately change the logic for each section like the one above to break if !valid, before sensors_get_feature(...) is called? Something like

if (sensors_get_label_and_valid(*name,SENSORS_VT1211_IN0,&label,&valid))

{
    printf("ERROR: Can't get IN0 data!\n");
  } else if (valid) {
    if (!sensors_get_feature(*name,SENSORS_VT1211_IN0,&cur) &&
        !sensors_get_feature(*name,SENSORS_VT1211_IN0_MIN,&min) &&
        !sensors_get_feature(*name,SENSORS_VT1211_IN0_MAX,&max)) {
        print_label(label,10);
        printf("%+6.2f V  (min = %+6.2f V, max = %+6.2f V)   %s\n",
               cur,min,max,alarms&VT1211_ALARM_IN0?"ALARM":"");
    } else
    printf("ERROR: Can't get IN0 data!\n");

}
free_the_label(&label);

Or have I got something else wrong?

Thanks,

-Michael

__________________________________
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.
http://mobile.yahoo.com/maildemo

#1 lore raw

Hi Michael,

Quoted 10 lines
Quoted 5 lines

The approach you propose is slightly different, since the user would have to put "ignore" lines in his/her configuration file in order to dismiss the error message. So, while it looks cleaner, I am not sure it is the way to go. If we do what you propose, we are likely to get many reports about the errors, which aren't really errors.

But there may be an error. What I don't like about just dropping the error is that we don't know if the file doesn't exist because that sensor doesn't exist, or there is another error because of a larger problem brewing.

Agreed, this is really only a quick hack, and not a nice one. We might hide errors. However, it is believed that if one possibly-missing value would actually raise an error, the other values would return similar errors, so it is unlikely that actual errors would go unnoticed. It's not like we would hide all errors; typically we only ignore a few ones.

Quoted 4 lines

I've attached a patch that does the above. After writing it, I'm thinking there may be a better way to do this. The patch now checks for SENSORS_ERR_PROC, which is a pretty generic error returned from the library.

True, I don't think there is much chance that you get a different error at this point, so it probably doesn't make any difference with just ignoring the error. But that's stil nice.

Quoted 10 lines

I think a better way to do this is to keep the changes to print_vt1211 that skip the print if the channel is ignored, but instead of checking sensors_get_feature for a specific error code, a function is added to the library to determine if a channel exists, and factor the result of that call into sensors_get_label_and_valid, so that valid would be false that channel is ignore, or if the file for that channel doesn't exist.

If you think this is a good idea, let me know, and I'll take a stab at it.

I don't think it's worth the effort. Face it, libsensors is totally procfs-centric, and won't ever properly deal with the new sysfs interface. It needs to know everything about each chip to display convenient results. With the new standardized sysfs interface it should be possible to design a new library which doesn't need any knowledge about the chips themselves, but would discover everything it needs from the sysfs interface. If we are going to spend energy on making things better for 2.6 kernels, we'd better start working on this library than waste time on the old one, IMHO.

I'll apply your patch, thanks.

Signature · 1 line
Jean Delvare
#2 lore raw
In reply to Michael Carland

Hi Michael,

Quoting myself:

Quoted 1 line

I'll apply your patch, thanks.

On second thought, I think that the patch could be improved a bit:

1* You hide SENSORS_ERR_PROC errors for all channels, but I guess only some of them can actually be missing with the 2.6 driver?

2* You return the exact same error message for the two possible causes of failure (sensors_get_label_and_valid failing and sensors_get_feature failing). Now that you separated the "if" statements, it would be better to have different error messages.

Care to send an updated patch?

Thanks,

Signature · 1 line
Jean Delvare
#3 lore raw
In reply to Michael Carland

Updated patch attached.

Quoted 10 lines · --- Jean Delvare

Hi Michael,

Quoting myself:

Quoted 1 line

I'll apply your patch, thanks.

On second thought, I think that the patch could be improved a bit:

1* You hide SENSORS_ERR_PROC errors for all channels, but I guess only some of them can actually be missing with the 2.6 driver?

Quoted 11 lines

2* You return the exact same error message for the two possible causes of failure (sensors_get_label_and_valid failing and sensors_get_feature failing). Now that you separated the "if" statements, it would be better to have different error messages.

Care to send an updated patch?

Thanks,

Signature · 1 line
Jean Delvare

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lm_sensors-diff
Type: application/octet-stream
Size: 15178 bytes
Desc: lm_sensors-diff
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20050205/fad4ad68/lm_sensors-diff.obj

#5 lore raw
In reply to Michael Carland

Hi Michael,

Quoted 2 lines

I am running Debian sarge, with a 2.6.10 kernel that I have built, the user programs of lm_sensors-2.9.0, and the 2.6.10 kernel patch.

Which patch are you talking about?

Quoted 9 lines

I am able to run sensors, and get valid output, but the values that are marked ignore in the sensors.conf are reported as unreadable. I changed a label value in the conf file and saw the output of sensors change, so I know I am looking at the correct configuration file.

I have added a debug message to progs/sensors/chips.c to print out the result of sensors_get_ignored, and see that the config file is being used to determine that the values should be ignored.

Quoted 9 lines
mcarland@myth:~/lm_sensors-2.9.0/prog/sensors$ lsmod
Module                  Size  Used by
vt1211                 16692  0
i2c_sensor              2784  1 vt1211
i2c_isa                 1600  0
lirc_serial            11328  0
lirc_dev               11404  1 lirc_serial
mcarland@myth:~/lm_sensors-2.9.0/prog/sensors$ uname -a
Linux myth 2.6.10myth-via #5 Thu Feb 3 21:24:11 UTC 2005 i686 GNU/Linux

FWIW, the 2.6.10 linux kernel doesn't have a vt1211 driver, so we can hardly support this.

Quoted 11 lines

I see that the logic to print out the values checks the ignored status, but doesn't use it until after an attempt to read the values:

if (!sensors_get_label_and_valid(*name,SENSORS_VT1211_IN0,&label,&valid) &&

     !sensors_get_feature(*name,SENSORS_VT1211_IN0,&cur) &&
     !sensors_get_feature(*name,SENSORS_VT1211_IN0_MIN,&min) &&
     !sensors_get_feature(*name,SENSORS_VT1211_IN0_MAX,&max)) {
   if (valid) {
     print_label(label,10);
     printf("%+6.2f V  (min = %+6.2f V, max = %+6.2f V)   %s\n",
            cur,min,max,alarms&VT1211_ALARM_IN0?"ALARM":"");
Quoted 4 lines

}
} else
printf("ERROR: Can't get IN0 data!\n");
free_the_label(&label);

I agree with your analysis of the code. Looks suboptimal, since we do read values even when we already know we'll ignore them.

Quoted 2 lines

Shouldn't either sensors_get_feature(...) not do the read if the feature is not valid (only that function would have to be changed),

Bad idea, sensors_get_feature is part of libsensors, on which several other monitoring tools are based. We better don't change the interface without a solid reasons - and this one isn't.

Quoted 15 lines

or more
appropriately change the logic for each section like the one above to break if !valid, before sensors_get_feature(...) is called? Something like

 if (sensors_get_label_and_valid(*name,SENSORS_VT1211_IN0,&label,&valid)) {
   printf("ERROR: Can't get IN0 data!\n");
 } else if (valid) {
   if (!sensors_get_feature(*name,SENSORS_VT1211_IN0,&cur) &&
       !sensors_get_feature(*name,SENSORS_VT1211_IN0_MIN,&min) &&
       !sensors_get_feature(*name,SENSORS_VT1211_IN0_MAX,&max)) {
       print_label(label,10);
       printf("%+6.2f V  (min = %+6.2f V, max = %+6.2f V)   %s\n",
              cur,min,max,alarms&VT1211_ALARM_IN0?"ALARM":"");
   } else
   printf("ERROR: Can't get IN0 data!\n");
Quoted 2 lines

}
free_the_label(&label);

Agreed, that would be better.

Now you might wonder why the problem was never noticed and fixed, since it seems to spread across all chips print functions. The reason is rather simple. In the times of Linux 2.4, hardware monitoring drivers would use procfs as the user-space/kernel interface. With procfs, it was difficult to add or remove individual interface files depending on a given chip configuration, thus it wasn't done. As a result, "sensors" could safely read any value, even if that value wouldn't make any sense, and it was left to the user to add the proper "ignore" lines in the configuration files.

When we started porting drivers to Linux 2.6 and sysfs, we found it was now easy to disable specific interface files when they wouldn't mean a thing for a specific chip configuration. That sounded like a sane thing to do (let's not waste resources) but sensors started complaining in this case. The solution that was used so far was to discard the complaint itself, because a missing interface file was now considered possible and no more necessarily an error.

The approach you propose is slightly different, since the user would have to put "ignore" lines in his/her configuration file in order to dismiss the error message. So, while it looks cleaner, I am not sure it is the way to go. If we do what you propose, we are likely to get many reports about the errors, which aren't really errors.

The idea of not reading values for ignored channels still makes sense though, as it improves performance, and isn't incompatible with hiding errors on missing interface files.

Feel tree to propose a patch for print_vt1211 that will remove the error message for the files that now can possibly not be there, and would also skip reads on ignored channels if you want. We'd apply such a patch.

Thanks,
--
Jean Delvare