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>
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.
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
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
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
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
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
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
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
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