Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux/LibSensors: adjust data for k10temp #1249

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

cgzones
Copy link
Member

@cgzones cgzones commented May 21, 2023

Adjust the temperature data gathered from the k10temp driver.
Only a control value, an optional die value, and one value per CCD are provided.

See https://www.kernel.org/doc/html/latest/hwmon/k10temp.html for details.

@cgzones cgzones added the Linux 🐧 Linux related issues label May 21, 2023
Copy link
Member

@BenBE BenBE left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm all for dropping the first (align macro definition) commit.

linux/LibSensors.c Outdated Show resolved Hide resolved
@BenBE BenBE added the enhancement Extension or improvement to existing feature label May 21, 2023
@BenBE BenBE added this to the 3.3.0 milestone May 21, 2023
@BenBE
Copy link
Member

BenBE commented May 21, 2023

Re the double->float patch: While we are not showing anything more than 1 fractional digit, the data acquisition is done using doubles, thus sticking to keeping the native type here is IMO preferable (avoids rounding errors due to type conversion).

linux/LibSensors.c Outdated Show resolved Hide resolved
@BenBE BenBE modified the milestones: 3.3.0, 3.4.0 Dec 26, 2023
@cgzones cgzones marked this pull request as draft January 8, 2024 14:09
@cgzones
Copy link
Member Author

cgzones commented Jan 8, 2024

Might get superseded by #1352.

cgzones added 6 commits April 9, 2024 16:52
More than one digit of temperature precision is never printed and barely
useful.
Store the driver used for temperature gathering for later adjustments.
Can be used for temperature sensor data assignments.
Adjust the temperature data gathered from the k10temp driver.  Only a
control value, an optional die value, and one value per CCD are
provided.

See https://www.kernel.org/doc/html/latest/hwmon/k10temp.html for
details.
}

DIR* dir = opendir("/sys/devices/system/cpu");
if (!dir)
return;

unsigned int currExisting = super->existingCPUs;
unsigned short maxCoreId = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we bother with the unsigned short data type here (rather than unsigned int)? There is no space constraint here (it's not an array) and short data types typically process slower in most CPU architectures.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To save two bytes in the CPUData struct.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cgzones Not worth it when your other code becomes larger due to the instructions processing 16-bit registers. (At least in IA-32 & x86-64, instructions processing 16-bit registers need a prefix and each becomes one byte larger than 32-bit counterparts.)

@cgzones cgzones marked this pull request as ready for review April 13, 2024 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Extension or improvement to existing feature Linux 🐧 Linux related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants