Commit Graph
595 Commits
Author SHA1 Message Date
Jean Delvare b7b2c45789 libsensors: Get rid of arbitrary limit on per-type sensor count
When gathering the attributes of each hwmon chip, libsensors uses a
temporary structure in memory to order and group all the attributes
into features. This temporary structure used to be a single array with
room for every possible attribute/subfeature. While simple, this
approach required to predefine a maximum number of per-type sensor
that could be handled.

In order to get rid of this arbitrary limit, which we hit and had to
raise three times already, I changed the temporary structure to an
array of dynamically allocated per-type subattribute arrays. This lets
us not allocate any memory for types which aren't implemented by a
given chip, and more importantly, this lets us reallocate room for
more attributes of a given type as needed.

I decided to allocate chunks of 8 attributes at a time, as this seemed
a good compromise between two frequent reallocations and
over-provisioning. It could be tweaked if needed.

Icing on the cake, I benchmarked this change on two different systems
and it results in performance gains. The total heap usage as reported
by valgrind is down by 50% on average, with peak memory consumption
(as reported by valgrind's massif) also down by 43% on average. The
total instructions count (as reported by valgrind's callgrind) is down
by 11% on average, with measured execution time also down by a few
percents. Valgrind rocks, BTW.

I have some ideas to optimize the memory allocations further, but I do
not expect such a huge gain from them. They may not even improve peak
memory consumption as massif shows the peak is somewhere else now at
least in some cases.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2014-01-25 09:41:03 -08:00
Jean Delvare 2252b49e2b libsensors: Increase MAX_SENSORS_PER_TYPE to 33
This is needed to properly support all temperatures reported by the
coretemp driver on recent hardware.
2014-01-14 14:49:04 +00:00
Jean Delvare a3f215218f Extend the documentation of sensors_init() and
sensors_get_adapter_name(). Paul Crawford asked questions about these
as he found the original documentation unclear. I'm including my
answers to his questions here, reformatted, so that other developers
can benefit from them too.
2013-09-11 11:56:08 +00:00
Jean Delvare 122780fc96 sensors.conf.5: Mention "sensors -u" to get the raw feature names.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@6091 7894878c-1315-0410-8ee3-d5d059ff63e0
2012-11-12 09:48:37 +00:00
Jean Delvare 6ee8f6096d Merge 4 regular expressions into a single one, this is faster.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@6046 7894878c-1315-0410-8ee3-d5d059ff63e0
2012-04-19 13:21:00 +00:00
Jean Delvare 08d713c412 libsensors: Fix warning about library path not in /etc/ld.so.conf
On recent systems, extra configuration files can live in
/etc/ld.so.conf.d, so check this directory too, before warning.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@6045 7894878c-1315-0410-8ee3-d5d059ff63e0
2012-04-19 13:18:45 +00:00
Jean Delvare ae877a1e55 Prepare for release.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@6035 7894878c-1315-0410-8ee3-d5d059ff63e0
2012-03-14 07:43:39 +00:00
Jean Delvare a3e40509e0 Add support for fan[1-*]_max, fan[1-*]_min_alarm and fan[1-*]_max_alarm
attributes. These are defined in the standard sysfs interface for quite
some time, and at least three drivers (max6650, lm63 and applesmc)
implement them so we should support them.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@6029 7894878c-1315-0410-8ee3-d5d059ff63e0
2012-03-06 07:34:13 +00:00
Jean Delvare ae32c8a919 Upcoming change in sysfs will break the way libsensors detects if
sysfs is mounted. Adjust the implementation so that it still works after
said change.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@6017 7894878c-1315-0410-8ee3-d5d059ff63e0
2012-01-31 12:54:03 +00:00
Guenter Roeck 273102f2c9 Add support for additional sysfs attributes to libsensors and to sensors command
inX_average
inX_lowest
inX_highest
tempX_lowest
tempX_highest
currX_average
currX_lowest
currX_highest




git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@6007 7894878c-1315-0410-8ee3-d5d059ff63e0
2012-01-09 17:30:10 +00:00
Jean Delvare 159cceaa24 Prepare for release.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5949 7894878c-1315-0410-8ee3-d5d059ff63e0
2011-03-28 07:02:37 +00:00
Jean Delvare cae654385e Only export from libsensors symbols which are actually public (i.e.
listed in the public header files and documented in the manual page.)
Patch from Cristian Rodriguez <crrodriguez@opensuse.org>.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5939 7894878c-1315-0410-8ee3-d5d059ff63e0
2011-03-06 20:20:55 +00:00
Guenter Roeck eaf86b0c49 Added support for SENSORS_SUBFEATURE_FAN_PULSES to libsensors.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5938 7894878c-1315-0410-8ee3-d5d059ff63e0
2011-03-04 20:37:43 +00:00
Guenter Roeck c618c56023 Added support for humidity sensors to libsensors
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5918 7894878c-1315-0410-8ee3-d5d059ff63e0
2011-02-13 18:55:09 +00:00
Guenter Roeck fb325cf089 Add support for recently added sysfs ABI attributes
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5917 7894878c-1315-0410-8ee3-d5d059ff63e0
2011-02-09 19:25:22 +00:00
Guenter Roeck 443b54b325 Added support for new sysfs attributes
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5898 7894878c-1315-0410-8ee3-d5d059ff63e0
2010-12-14 20:26:27 +00:00
Jean Delvare ff0bfc174d Compute MAX_*_SENSOR_TYPES at build time (#2378).
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5897 7894878c-1315-0410-8ee3-d5d059ff63e0
2010-12-14 09:09:42 +00:00
Jean Delvare a29f126e08 Compute MAX_SUBFEATURES at run-time (#2378).
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5896 7894878c-1315-0410-8ee3-d5d059ff63e0
2010-12-14 09:06:19 +00:00
Guenter Roeck 5cd466477f Fixed typo in lib/sensors.conf.5.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5887 7894878c-1315-0410-8ee3-d5d059ff63e0
2010-12-09 16:31:03 +00:00
Jean Delvare 05a24e5bb2 libsensors: Add support for intrusion detection.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5879 7894878c-1315-0410-8ee3-d5d059ff63e0
2010-11-03 13:00:59 +00:00
Jean Delvare 7f1c32dbd2 Some features are never scaled.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5876 7894878c-1315-0410-8ee3-d5d059ff63e0
2010-11-02 13:00:19 +00:00
Jean Delvare 9b44cc2819 Work with the feature type instead of the shifted subfeature type where
possible. This makes the code more readable.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5875 7894878c-1315-0410-8ee3-d5d059ff63e0
2010-11-02 12:59:31 +00:00
Jean Delvare 62fd781722 Reorganize the temporary sparse subfeature table. It's a little larger
now, but this make it possible to add more feature types without
increasing the code complexity beyond reason. Define constants and use
them to make the code even easier to understand.

If anyone is really worried about the relatively large memory
allocation, one way to improve the situation would be a two-pass
approach. But remember the memory is only needed for a short time...


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5874 7894878c-1315-0410-8ee3-d5d059ff63e0
2010-11-02 12:57:11 +00:00
Jean Delvare f292e9f408 Prepare for release.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5863 7894878c-1315-0410-8ee3-d5d059ff63e0
2010-10-10 19:15:54 +00:00
Jean Delvare e369e65d42 Change libsensors license from GPL to LGPL.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5844 7894878c-1315-0410-8ee3-d5d059ff63e0
2010-07-01 11:56:42 +00:00
Jean Delvare 60635dafc6 Map individual beep features. We had symbols for them for a long time,
I have no idea why they weren't mapped to the sysfs file names.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5843 7894878c-1315-0410-8ee3-d5d059ff63e0
2010-06-21 09:02:30 +00:00
Jean Delvare 573b707d5f Fix a comment.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5827 7894878c-1315-0410-8ee3-d5d059ff63e0
2010-02-23 13:36:46 +00:00
Jean Delvare 5fe10beeda Increase MAX_SENSORS_PER_TYPE to 24. The old value of 20 isn't enough
at least for the W83795G, which has up to 21 voltage inputs.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5826 7894878c-1315-0410-8ee3-d5d059ff63e0
2010-02-23 13:29:05 +00:00
Jean Delvare 6e78c8c779 Prepare for release.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5819 7894878c-1315-0410-8ee3-d5d059ff63e0
2010-02-02 20:14:53 +00:00
Jean Delvare 7c37bd44ac Add support for HID devices.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5786 7894878c-1315-0410-8ee3-d5d059ff63e0
2009-10-18 12:05:16 +00:00
Hans de Goede 271aec857a Add sensor3.conf.5 symlink to sensors.conf.5 manpage
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5776 7894878c-1315-0410-8ee3-d5d059ff63e0
2009-10-01 07:43:41 +00:00
Jean Delvare 4d3ee85bae Support upcoming sysfs path to i2c adapters.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5759 7894878c-1315-0410-8ee3-d5d059ff63e0
2009-07-22 12:53:51 +00:00
Jean Delvare 6868367764 sensors_get_label: Merge pathname and label buffers (patch from
George Spelvin).
    
The lifetimes of the path and label name buffers are
disjoint, so a single buffer can be used for both purposes.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5748 7894878c-1315-0410-8ee3-d5d059ff63e0
2009-06-30 20:52:20 +00:00
Jean Delvare b3f39211b2 Consolidate strdup calls in sensors_get_label (patch from George Spelvin).
There were multiple in-line calls that then fell through to
a common exit.  Instead, set up a pointer to the original
strings, and have a single strdup in the common code.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5747 7894878c-1315-0410-8ee3-d5d059ff63e0
2009-06-30 20:47:53 +00:00
Jean Delvare 0a55087719 Bump library version to 4.2.0.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5741 7894878c-1315-0410-8ee3-d5d059ff63e0
2009-06-20 12:00:22 +00:00
Jean Delvare 78f496ca62 libsensors: New method to free the memory allocated for the internal
representation of chip names.
sensord, sensors: Fix a memory leak when one or more chip names are
provided on the command line.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5740 7894878c-1315-0410-8ee3-d5d059ff63e0
2009-06-20 10:04:52 +00:00
Jean Delvare ee26e6d2b0 From Yuriy Kaminskiy:
Most filesystems (in particular - reiserfs, jfs, xfs, nfs); maybe,
some legacy installation of ext2/3 too) always return dirent->dt_type =
DT_UNKNOWN, so libsensors fails to parse /etc/sensors.d.
  Also, symlink (DT_LNK) can point to directory, or FIFO/socket/device
(very bad!) - current check insufficient anyways.

Fixed by always using stat() to check what each entry is, rather than
relying on dirent->dt_type.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5730 7894878c-1315-0410-8ee3-d5d059ff63e0
2009-06-05 15:17:29 +00:00
Andre Prendel 3e310f8a8f libsensors: Take into account distribution LDFLAGS (Patch from Didier Roche).
From: Didier Roche <didrocks@ubuntu.com>

Hi lm-sensors developer,

It would be great if lm-sensors can take into account distribution
LDFLAGS so that exported variables change linker behavior.

For instance, ubuntu uses -Wl,-Bsymbolic-functions. Taking this patch
will enable us to just sync from debian on this package.

In Ubuntu, we've applied the attached patch to achieve the following:

  * handle default ubuntu LDFLAGS for linking option (LP: #321632)
    - Remove the old hack directly pushed in lib/Module.mk (now
      lib/Module.mk if from pristine source)
    - add debian/patches/07-use-LDFLAGS.patch to take LDFLAGS into account

Debian and Ubuntu thought you might be interested to handle this
directly upstream.



git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5713 7894878c-1315-0410-8ee3-d5d059ff63e0
2009-04-28 11:54:40 +00:00
Jean Delvare 2ea3bf392b Make it possible to skip building of the static library. Just run:
make BUILD_STATIC_LIB=0


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5711 7894878c-1315-0410-8ee3-d5d059ff63e0
2009-04-20 09:18:06 +00:00
Jean Delvare e0ad43a545 Include generated source files in dependency checking.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5710 7894878c-1315-0410-8ee3-d5d059ff63e0
2009-04-20 08:42:11 +00:00
Andre Prendel a03ec09359 Use __func__ in sensors_fatal_error() to get function name.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5674 7894878c-1315-0410-8ee3-d5d059ff63e0
2009-03-02 13:07:23 +00:00
Jean Delvare c7eab7030f Fix segmentation fault when passing a custom configuration file.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5665 7894878c-1315-0410-8ee3-d5d059ff63e0
2009-02-26 14:46:47 +00:00
Jean Delvare 0ffa44331c Set library version to 4.1.0.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5663 7894878c-1315-0410-8ee3-d5d059ff63e0
2009-02-25 07:47:13 +00:00
Jean Delvare c1a066a307 If str(n)dup fails, there is no more memory left. We should exit with
"Out of memory". Patch from Andre Prendel.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5661 7894878c-1315-0410-8ee3-d5d059ff63e0
2009-02-20 10:56:52 +00:00
Jean Delvare 680d5515f6 It is not an error if /etc/sensors.d doesn't exist.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5656 7894878c-1315-0410-8ee3-d5d059ff63e0
2009-02-18 10:17:13 +00:00
Jean Delvare cba60674e5 Document error-related functions.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5654 7894878c-1315-0410-8ee3-d5d059ff63e0
2009-02-15 20:47:33 +00:00
Jean Delvare 5d30872044 Document function sensors_snprintf_chip_name.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5653 7894878c-1315-0410-8ee3-d5d059ff63e0
2009-02-15 20:46:13 +00:00
Jean Delvare 42beaab3fc Reorder description section to match synopsis order. Move structure
definitions to their own subsection.


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5652 7894878c-1315-0410-8ee3-d5d059ff63e0
2009-02-15 20:45:36 +00:00
Jean Delvare fa3d63daeb Reformat description section.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5651 7894878c-1315-0410-8ee3-d5d059ff63e0
2009-02-15 20:43:36 +00:00
Jean Delvare e8ff9211ff Reformat synopsis section.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5650 7894878c-1315-0410-8ee3-d5d059ff63e0
2009-02-15 20:42:43 +00:00