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

in_thermal: support hwmon #8016

Merged
merged 1 commit into from
Nov 7, 2023
Merged

Conversation

nokute78
Copy link
Collaborator

@nokute78 nokute78 commented Oct 8, 2023

This patch is to support to read a temperature from hwmon subsystem. See also #7955
https://www.kernel.org/doc/Documentation/hwmon/sysfs-interface

in_thermal tries to read a temperature from /sys/class/thermal first.
If in_thermal can't read it, in_thermal tries to read /sys/class/hwmon.


Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • [N/A] Example configuration file for the change
  • Debug log output from testing the change
  • Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • [N/A] Run local packaging test showing all targets (including any new ones) build.
  • [N/A] Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • [N/A] Documentation required for this feature

Backporting

  • [N/A] Backport to latest stable release.

Debug/Valgrind output

Note: I modified source not to read /sys/class/thermal to enforce reading from /sys/class/hwmon.

$ valgrind --leak-check=full bin/fluent-bit -i thermal -o stdout
==25894== Memcheck, a memory error detector
==25894== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==25894== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==25894== Command: bin/fluent-bit -i thermal -o stdout
==25894== 
Fluent Bit v2.2.0
* Copyright (C) 2015-2022 The Fluent Bit Authors
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io

[2023/10/08 10:22:15] [ info] [fluent bit] version=2.2.0, commit=cfca7ca8ac, pid=25894
[2023/10/08 10:22:15] [ info] [storage] ver=1.5.1, type=memory, sync=normal, checksum=off, max_chunks_up=128
[2023/10/08 10:22:15] [ info] [cmetrics] version=0.6.3
[2023/10/08 10:22:15] [ info] [ctraces ] version=0.3.1
[2023/10/08 10:22:15] [ info] [input:thermal:thermal.0] initializing
[2023/10/08 10:22:15] [ info] [input:thermal:thermal.0] storage_strategy='memory' (memory only)
[2023/10/08 10:22:15] [ info] [output:stdout:stdout.0] worker #0 started
[2023/10/08 10:22:15] [ info] [sp] stream processor started
==25894== Warning: client switching stacks?  SP change: 0x6f68ba0 --> 0x54c5df0
==25894==          to suppress, use: --max-stackframe=27930032 or greater
==25894== Warning: client switching stacks?  SP change: 0x54c5cf0 --> 0x6f68ba0
==25894==          to suppress, use: --max-stackframe=27930288 or greater
==25894== Warning: client switching stacks?  SP change: 0x6f68ba0 --> 0x54c5cf0
==25894==          to suppress, use: --max-stackframe=27930288 or greater
==25894==          further instances of this message will not be shown.
[0] thermal.0: [[1696728135.681488126, {}], {"name"=>"hwmon6_temp1_input", "type"=>"npu_thermal", "temp"=>39.769000}]
[1] thermal.0: [[1696728135.699476030, {}], {"name"=>"hwmon4_temp1_input", "type"=>"center_thermal", "temp"=>39.769000}]
[2] thermal.0: [[1696728135.699658327, {}], {"name"=>"hwmon2_temp1_input", "type"=>"bigcore1_thermal", "temp"=>40.692000}]
[3] thermal.0: [[1696728135.699734454, {}], {"name"=>"hwmon0_temp1_input", "type"=>"soc_thermal", "temp"=>40.692000}]
[4] thermal.0: [[1696728135.699821956, {}], {"name"=>"hwmon5_temp1_input", "type"=>"gpu_thermal", "temp"=>39.769000}]
[5] thermal.0: [[1696728135.699894292, {}], {"name"=>"hwmon3_temp1_input", "type"=>"littlecore_thermal", "temp"=>39.769000}]
[6] thermal.0: [[1696728135.699965169, {}], {"name"=>"hwmon1_temp1_input", "type"=>"bigcore0_thermal", "temp"=>39.769000}]
^C[2023/10/08 10:22:17] [engine] caught signal (SIGINT)
[2023/10/08 10:22:17] [ warn] [engine] service will shutdown in max 5 seconds
[0] thermal.0: [[1696728136.677026745, {}], {"name"=>"hwmon6_temp1_input", "type"=>"npu_thermal", "temp"=>39.769000}]
[1] thermal.0: [[1696728136.677146040, {}], {"name"=>"hwmon4_temp1_input", "type"=>"center_thermal", "temp"=>39.769000}]
[2] thermal.0: [[1696728136.677217500, {}], {"name"=>"hwmon2_temp1_input", "type"=>"bigcore1_thermal", "temp"=>39.769000}]
[3] thermal.0: [[1696728136.677286336, {}], {"name"=>"hwmon0_temp1_input", "type"=>"soc_thermal", "temp"=>39.769000}]
[4] thermal.0: [[1696728136.677356046, {}], {"name"=>"hwmon5_temp1_input", "type"=>"gpu_thermal", "temp"=>38.846000}]
[5] thermal.0: [[1696728136.677429840, {}], {"name"=>"hwmon3_temp1_input", "type"=>"littlecore_thermal", "temp"=>39.769000}]
[6] thermal.0: [[1696728136.677496925, {}], {"name"=>"hwmon1_temp1_input", "type"=>"bigcore0_thermal", "temp"=>39.769000}]
[2023/10/08 10:22:17] [ info] [input] pausing thermal.0
[2023/10/08 10:22:17] [ info] [engine] service has stopped (0 pending tasks)
[2023/10/08 10:22:17] [ info] [input] pausing thermal.0
[2023/10/08 10:22:17] [ info] [output:stdout:stdout.0] thread worker #0 stopping...
[2023/10/08 10:22:17] [ info] [output:stdout:stdout.0] thread worker #0 stopped
==25894== 
==25894== HEAP SUMMARY:
==25894==     in use at exit: 0 bytes in 0 blocks
==25894==   total heap usage: 1,926 allocs, 1,926 frees, 1,800,381 bytes allocated
==25894== 
==25894== All heap blocks were freed -- no leaks are possible
==25894== 
==25894== For lists of detected and suppressed errors, rerun with: -s
==25894== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

Signed-off-by: Takahiro Yamashita <[email protected]>
@mmguero
Copy link

mmguero commented Oct 10, 2023

I tested this patch (I'm the reporter of #7955) and can confirm it did work for me and resolve the reported issue.

@mmguero
Copy link

mmguero commented Oct 25, 2023

Any chance we can get this merged soon-ish?

@nokute78
Copy link
Collaborator Author

@edsiper @leonardo-albertovich Could you review this ?

@edsiper edsiper merged commit fca5bf4 into fluent:master Nov 7, 2023
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants