Skip to content

tuned-ppd: Fix inotify watch for performance degradation #753

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

msizanoen1
Copy link

@msizanoen1 msizanoen1 commented Feb 26, 2025

See individual commits for more details.

Ensure the parameters for PerformanceDegradedEventHandler are passed in
the correct order.
@zacikpa
Copy link
Contributor

zacikpa commented Feb 27, 2025

Oh, wow, good catch, thanks!

The inodes backing the kernfs virtual files for the attributes we watch
may be dropped by the kernel due to memory exhaustion or explicit user
action (sysctl vm.drop_caches). This causes inotify events to not be
delivered as kernfs_notify() simply drops the event if the inode cannot
be found in the kernel caches.

Fix this by explicitly pinning the attributes virtual files in memory to
ensure we receive inotify events.
@msizanoen1 msizanoen1 requested a review from zacikpa March 16, 2025 08:23
@zacikpa
Copy link
Contributor

zacikpa commented Mar 18, 2025

@msizanoen1, I'm not able to reproduce the inode caching issue without the last commit applied. Could you please clarify how you're reproducing it and on what system? I tried writing "3" to /proc/sys/vm/drop_caches, but inotify events were still delivered properly to tuned-ppd after that.

@msizanoen1
Copy link
Author

I was able to reproduce this on a ThinkPad X1 Carbon 9th gen running Fedora 41, against the dytc_lapmode trigger specifically. I just put it on my lap, wait until dytc_lapmode is 1, run sysctl vm.drop_caches=3, close the lid, move it to a stable surface, then reopen it. After reopening the lid dytc_lapmode should be 0 but GNOME Settings still reports that the lap sensor is triggered and /var/log/tuned/tuned-ppd.log doesn't report any changes.

The specific problematic kernel line of code is https://github.com/torvalds/linux/blob/76b6905c11fd3c6dc4562aefc3e8c4429fefae1e/fs/kernfs/file.c#L926 (should be kernfs_get_inode(info->sb, kn) instead) but it's arguable whether this is a kernel bug considering that using inotify on sysfs is not officially supported and changes to attributes should be listened to with poll() instead.

@msizanoen1
Copy link
Author

msizanoen1 commented Mar 18, 2025

Please note that the dytc_lapmode file must not be open by any process on the system (check with lsof before running sysctl vm.drop_caches=3) for this to be reproducible.

Copy link
Contributor

@zacikpa zacikpa left a comment

Choose a reason for hiding this comment

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

Thanks for the quick response and detailed instructions! I was able to reproduce the issue and can confirm that keeping the files open resolves it.

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

Successfully merging this pull request may close these issues.

2 participants