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

Reduce logging of wmi_*_fancurve_custom #276

Open
chennin opened this issue Nov 11, 2024 · 2 comments
Open

Reduce logging of wmi_*_fancurve_custom #276

chennin opened this issue Nov 11, 2024 · 2 comments

Comments

@chennin
Copy link

chennin commented Nov 11, 2024

Is your feature request related to a problem? Please describe.
My log files are huge. Please help reduce. 36,000 messages in an hour:

# journalctl -b0 -S "1 hour ago" | grep -c "legion_laptop fan table wmi"
36012

mostly of the form:

Nov 10 21:21:42 tycho kernel: legion_laptop: Size of object: 48
Nov 10 21:21:42 tycho kernel: legion_laptop fan table wmi buffer00000000ae58b4be: 0a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
Nov 10 21:21:42 tycho kernel: legion_laptop fan table wmi buffer000000001be4c2e8: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
Nov 10 21:21:42 tycho kernel: legion_laptop fan table wmi buffer00000000c30040ae: 00 00 00 00 00 00 00 00 00 00 00 00 0a 00 00 00  ................
Nov 10 21:21:42 tycho kernel: legion_laptop fan table wmi buffer000000005901c707: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
Nov 10 21:21:42 tycho kernel: legion_laptop fan table wmi buffer0000000019324a2b: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
Nov 10 21:21:42 tycho kernel: legion_laptop fan table wmi buffer0000000042efaaa8: 00 00 00 00 00 00 00 00                          ........

Which, as a user who hasn't even seen a need to customize fan curves, I cannot see the use of.

I'm not actually sure what's causing it, as the printing doesn't seem to be related to reading the sensors with sensors or telegraf.

Describe the solution you'd like

pr_info("Size of object: %lu\n", sizeof(struct WMIFanTableRead));
err = wmi_exec_noarg_ints(WMI_GUID_LENOVO_FAN_METHOD, 0,
WMI_METHOD_ID_FAN_GET_TABLE, buffer,
sizeof(buffer));
print_hex_dump(KERN_INFO, "legion_laptop fan table wmi buffer",
DUMP_PREFIX_ADDRESS, 16, 1, buffer, sizeof(buffer),
true);

Consider commenting it out, or making it (logging) configurable with a module option, or using print_hex_dump_debug() instead (then I'd probably be able to filter it out with dynamic debugging). Line 2939 as well.

Describe alternatives you've considered

Model and Debug Info

Distribution: Arch, using lenovolegionlinux-dkms-git r834.714cd25-1 and lenovolegionlinux-git r832.680ed61-1 from AUR.
Model name: Legion Pro 5 16ARX8
CPU model:AMD Ryzen 9 7945HX
GPU model: GeForce RTX 4070 Max-Q
Keyboard backlight: Off/don't care
Light in lid or logo: ???
Light at IO-Ports at back: ???

Output of sudo dmidecode -t system. Please remove Serial Number and UUID for privacy:

# dmidecode 3.6
Getting SMBIOS data from sysfs.
SMBIOS 3.4.0 present.

Handle 0x0001, DMI type 1, 27 bytes
System Information
	Manufacturer: LENOVO
	Product Name: 82WM
	Version: Legion Pro 5 16ARX8
	Serial Number: -
	UUID: -
	Wake-up Type: Power Switch
	SKU Number: LENOVO_MT_82WM_BU_idea_FM_Legion Pro 5 16ARX8
	Family: Legion Pro 5 16ARX8

Handle 0x0017, DMI type 12, 5 bytes
System Configuration Options
	Option 1: String1 for Type12 Equipment Manufacturer
	Option 2: String2 for Type12 Equipment Manufacturer
	Option 3: String3 for Type12 Equipment Manufacturer
	Option 4: String4 for Type12 Equipment Manufacturer

Handle 0x0026, DMI type 32, 20 bytes
System Boot Information
	Status: No errors detected

Output of sudo dmidecode -t bios:

# dmidecode 3.6
Getting SMBIOS data from sysfs.
SMBIOS 3.4.0 present.

Handle 0x0000, DMI type 0, 26 bytes
BIOS Information
	Vendor: LENOVO
	Version: LPCN52WW
	Release Date: 05/21/2024
	Address: 0xE0000
	Runtime Size: 128 kB
	ROM Size: 32 MB
	Characteristics:
		PCI is supported
		PNP is supported
		BIOS is upgradeable
		BIOS shadowing is allowed
		Boot from CD is supported
		Selectable boot is supported
		EDD is supported
		ACPI is supported
		USB legacy is supported
		BIOS boot specification is supported
		Function key-initiated network boot is supported
		Targeted content distribution is supported
		UEFI is supported
	BIOS Revision: 1.52
	Firmware Revision: 1.52

Handle 0x0018, DMI type 13, 22 bytes
BIOS Language Information
	Language Description Format: Long
	Installable Languages: 4
		en|US|iso8859-1
		fr|FR|iso8859-1
		ja|JP|unicode
		zh|TW|unicode
	Currently Installed Language: en|US|iso8859-1

Output of sudo cat /sys/kernel/debug/legion/fancurve:

EC Chip ID: 5507
EC Chip Version: 2a4
legion_laptop features: fancurve powermode platformprofile platformprofilenotify minifancurve
legion_laptop ec_readonly: 0
ACPI CFG error: 0
ACPI CFG: 2081289482
temperature access method: 5
CPU temperature error: 0
CPU temperature: 50
CPU temperature EC error: 0
CPU temperature EC: 0
CPU temperature ACPI error: 0
CPU temperature ACPI: 50
CPU temperature WMI error: 0
CPU temperature WMI: 0
CPU temperature WMI2 error: 0
CPU temperature WMI2: 0
CPU temperature WMI3 error: 0
CPU temperature WMI3: 50
GPU temperature error: 0
GPU temperature: 0
GPU temperature EC error: 0
GPU temperature EC: 0
GPU temperature ACPI error: 0
GPU temperature ACPI: 0
GPU temperature WMI error: 0
GPU temperature WMI: 0
GPU temperature WMI2 error: 0
GPU temperature WMI2: 0
GPU temperature WMI3 error: 0
GPU temperature WMI3: 0
fan speed access method: 5
1 fanspeed error: 0
1 fanspeed: 1700
1 fanspeed EC error: 0
1 fanspeed EC: 48
1 fanspeed ACPI error: 0
1 fanspeed ACPI: 1700
1 fanspeed WMI error: 0
1 fanspeed WMI: 0
1 fanspeed WMI2 error: 0
1 fanspeed WMI2: 0
1 fanspeed WMI3 error: 0
1 fanspeed WMI3: 1700
2 fanspeed error: 0
2 fanspeed: 1600
2 fanspeed EC error: 0
2 fanspeed EC: 0
2 fanspeed ACPI error: 0
2 fanspeed ACPI: 1600
2 fanspeed WMI error: 0
2 fanspeed WMI: 0
2 fanspeed WMI2 error: 0
2 fanspeed WMI2: 0
2 fanspeed WMI3 error: 0
2 fanspeed WMI3: 1600
powermode access method: 3
powermode error: 0
powermode: 2
powermode EC error: 0
powermode EC: 0
powermode ACPI error: -5
powermode ACPI: 0
powermode WMI error: 0
powermode WMI: 2
has custom powermode: 1
ACPI rapidcharge error: 0
ACPI rapidcharge: 1
WMI backlight 2 state: 0
WMI backlight 3 state: -14
WMI light IO port: 0
WMI light Y logo/lid: 0
EC minifancurve feature enabled: 0
EC minifancurve on cool: error
EC lockfancontroller error: 0
EC lockfancontroller: false
fanfullspeed error: 0
fanfullspeed: 0
fanfullspeed EC error: 0
fanfullspeed EC: 0
EC fan curve current point id: 0
EC fan curve points size: 10
Current fan curve in hardware:
rpm1|rpm2|acceleration|deceleration|cpu_min_temp|cpu_max_temp|gpu_min_temp|gpu_max_temp|ic_min_temp|ic_max_temp
0	 0	 0	 0	 0	 0	 0	 0	 0	 0
0	 0	 0	 0	 0	 0	 0	 0	 0	 0
0	 0	 0	 0	 0	 0	 0	 0	 0	 0
0	 0	 0	 0	 0	 0	 0	 0	 0	 0
0	 0	 0	 0	 0	 0	 0	 0	 0	 0
0	 0	 0	 0	 0	 0	 0	 0	 0	 0
0	 0	 0	 0	 0	 0	 0	 0	 0	 0
0	 0	 0	 0	 0	 0	 0	 0	 0	 0
0	 0	 0	 0	 0	 0	 0	 0	 0	 0
0	 0	 0	 0	 0	 0	 0	 0	 0	 0
=====================
Current fan curve in hardware (WMI; might be empty)
rpm1|rpm2|acceleration|deceleration|cpu_min_temp|cpu_max_temp|gpu_min_temp|gpu_max_temp|ic_min_temp|ic_max_temp
0	 0	 0	 0	 0	 0	 0	 0	 0	 0
0	 0	 0	 0	 0	 0	 0	 0	 0	 0
0	 0	 0	 0	 0	 0	 0	 0	 0	 0
0	 0	 0	 0	 0	 0	 0	 0	 0	 0
0	 0	 0	 0	 0	 0	 0	 0	 0	 0
0	 0	 0	 0	 0	 0	 0	 0	 0	 0
0	 0	 0	 0	 0	 0	 0	 0	 0	 0
0	 0	 0	 0	 0	 0	 0	 0	 0	 0
0	 0	 0	 0	 0	 0	 0	 0	 0	 0
0	 0	 0	 0	 0	 0	 0	 0	 0	 0
=====================
@johnfanv2
Copy link
Owner

Thanks for this report. This crazy logging got into main by accident. Try the new version on main branch, where it now should log to "debug" level. Currently, this is needed for debugging but will later be completely removed. Do you see any other problems?

@chennin
Copy link
Author

chennin commented Nov 13, 2024

Thank you. After building that I can confirm the level changed - journalctl prints the messages in a darker grey - but the messages still were printed to the journal, and dynamic debug was not able to see them.

If I apply the following patch then the fan table wmi buffer messages are not printed to the journal (I don't quite understand the difference between the functions) and I can control them with dynamic debug, though I do get a lot of new messages, probably because I just skipped from 714cd25 to 5511215.

For now, I now know how to suppress logging better via patches and recompiling, but I would still like to request less debug logging when possible, maybe a module option :).

New messages:

Nov 13 16:09:41 tycho kernel: legion_laptop: Reading fancurve
Nov 13 16:09:41 tycho kernel: legion_laptop: Size of object: 48
Nov 13 16:09:41 tycho kernel: legion_laptop: autopoint_show 2 point id=8, fancurve_attr_id id=10, err=0, fancurve.fan_speed_unit=1, fancurve.size=10
Nov 13 16:09:41 tycho kernel: legion_laptop: autopoint_show 4b XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Nov 13 16:09:41 tycho kernel: legion_laptop: autopoint_show 1 point id=8, fancurve_attr_id id=1, fancurve.fan_speed_unit=0, fancurve.size=0

Patch:

diff --git a/kernel_module/legion-laptop.c b/kernel_module/legion-laptop.c
index 227588e..3094f7f 100644
--- a/kernel_module/legion-laptop.c
+++ b/kernel_module/legion-laptop.c
@@ -2878,7 +2878,7 @@ static ssize_t wmi_read_fancurve_custom(const struct model_config *model,
 	err = wmi_exec_noarg_ints(WMI_GUID_LENOVO_FAN_METHOD, 0,
 				  WMI_METHOD_ID_FAN_GET_TABLE, buffer,
 				  sizeof(buffer));
-	print_hex_dump(KERN_DEBUG, "legion_laptop fan table wmi buffer",
+	print_hex_dump_debug("legion_laptop fan table wmi buffer",
 		       DUMP_PREFIX_ADDRESS, 16, 1, buffer, sizeof(buffer),
 		       true);
 	if (!err) {
@@ -2936,7 +2936,7 @@ static ssize_t wmi_write_fancurve_custom(const struct model_config *model,
 	buffer[0x16] = fancurve->points[8].speed1;
 	buffer[0x18] = fancurve->points[9].speed1;

-	print_hex_dump(KERN_DEBUG, "legion_laptop fan table wmi write buffer",
+	print_hex_dump_debug("legion_laptop fan table wmi write buffer",
 		       DUMP_PREFIX_ADDRESS, 16, 1, buffer, sizeof(buffer),
 		       true);
 	err = wmi_exec_arg(WMI_GUID_LENOVO_FAN_METHOD, 0,

And for my reference, dynamic debug can control the messages when the module is loaded and this has output:

# grep legion /sys/kernel/debug/dynamic_debug/control
/var/lib/dkms/lenovolegionlinux/1.0.0/build/legion-laptop.c:2881 [legion_laptop]wmi_read_fancurve_custom =_ "legion_laptop fan table wmi buffer"
/var/lib/dkms/lenovolegionlinux/1.0.0/build/legion-laptop.c:2939 [legion_laptop]wmi_write_fancurve_custom =_ "legion_laptop fan table wmi write buffer"

And control looks like this, to enable:

echo -n "module legion_laptop +p" > /sys/kernel/debug/dynamic_debug/control

or disable:

echo -n "module legion_laptop -p" > /sys/kernel/debug/dynamic_debug/control

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants