From: Suren Baghdasaryan Date: Tue, 4 Dec 2018 01:36:42 +0000 (-0800) Subject: FROMLIST: psi: introduce psi monitor X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=04aa91117ce251627ac4d5ecaae66e7c888b7fb4;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git FROMLIST: psi: introduce psi monitor Psi monitor aims to provide a low-latency short-term pressure detection mechanism configurable by users. It allows users to monitor psi metrics growth and trigger events whenever a metric raises above user-defined threshold within user-defined time window. Time window and threshold are both expressed in usecs. Multiple psi resources with different thresholds and window sizes can be monitored concurrently. Psi monitors activate when system enters stall state for the monitored psi metric and deactivate upon exit from the stall state. While system is in the stall state psi signal growth is monitored at a rate of 10 times per tracking window. Min window size is 500ms, therefore the min monitoring interval is 50ms. Max window size is 10s with monitoring interval of 1s. When activated psi monitor stays active for at least the duration of one tracking window to avoid repeated activations/deactivations when psi signal is bouncing. Notifications to the users are rate-limited to one per tracking window. Signed-off-by: Suren Baghdasaryan Signed-off-by: Johannes Weiner (not upstream yet, latest version published at: https://lore.kernel.org/patchwork/patch/1052418/) Conflicts: include/linux/psi.h kernel/cgroup/cgroup.c kernel/sched/psi.c (1. replaced __poll_t with unsigned int 2. replaced EPOLLERR/EPOLLPRI with POLLERR/POLLPRI (values are the same) 3. include in include/linux/psi.h 4. include in kernel/sched/psi.c) Bug: 127712811 Bug: 129157727 Test: lmkd in PSI mode Change-Id: I1688f047e98e1f109627dad72a33d2f70e575268 Signed-off-by: Suren Baghdasaryan --- diff --git a/Documentation/accounting/psi.txt b/Documentation/accounting/psi.txt index b8ca28b60215..4fb40fe94828 100644 --- a/Documentation/accounting/psi.txt +++ b/Documentation/accounting/psi.txt @@ -63,6 +63,110 @@ tracked and exported as well, to allow detection of latency spikes which wouldn't necessarily make a dent in the time averages, or to average trends over custom time frames. +Monitoring for pressure thresholds +================================== + +Users can register triggers and use poll() to be woken up when resource +pressure exceeds certain thresholds. + +A trigger describes the maximum cumulative stall time over a specific +time window, e.g. 100ms of total stall time within any 500ms window to +generate a wakeup event. + +To register a trigger user has to open psi interface file under +/proc/pressure/ representing the resource to be monitored and write the +desired threshold and time window. The open file descriptor should be +used to wait for trigger events using select(), poll() or epoll(). +The following format is used: + +