psi: pressure stall monitors v6
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v6 Latest7 patches 9 repliesIn review
- v57 patches 2 repliesSuperseded
- v35 patches 14 repliesSuperseded
Earlier versions · 2
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v2 | 5 patches | 11 replies | Superseded | |
| v1 | 6 patches | 15 replies | Superseded |
Changes in v6 from the cover letter
- Fixed psi averaging regression introduced in 4/7 and caused by lack of checking for avg_next_update before calling update_averages in psi_show
- Fixed missing header include in spi-rockchip.c causing kbuild test bot's warning in 6/7
Patches in v6 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/7 | psi: introduce state_mask to represent stalled psi statesinclude/ kernel/ | +25 | 4 replies | |
| 2/7 | psi: make psi_enable statickernel/ | +2 | 1 reply | |
| 3/7 | psi: rename psi fields in preparation for psi trigger additioninclude/ kernel/ | +28 | 1 reply | |
| 4/7 | psi: split update_stats into partskernel/ | +34 | 1 reply | |
| 5/7 | psi: track changed stateskernel/ | +18 | 1 reply | |
| 6/7 | refactor header includes to allow kthread.h inclusion in psi_types.hdrivers/ include/ include/ +1 more | +4 | 1 reply | |
| 7/7 | psi: introduce psi monitorDocumentation/ include/ include/ +2 more | +742 | 0 replies |
Reviews trailers per patch
6 of 7 patches have a Reviewed-by or Acked-by.
| Patch | Johannes Weiner |
|---|---|
| 1/7 | A-b |
| 2/7 | A-b |
| 3/7 | A-b |
| 4/7 | A-b |
| 5/7 | A-b |
| 6/7 | A-b |
| 7/7 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v6 0/7] psi: pressure stall monitors v6
This is respin of:
https://lwn.net/ml/linux-kernel/20190308184311.144521-1-surenb%40google.com/
Android is adopting psi to detect and remedy memory pressure that results in stuttering and decreased responsiveness on mobile devices.
Psi gives us the stall information, but because we're dealing with latencies in the millisecond range, periodically reading the pressure files to detect stalls in a timely fashion is not feasible. Psi also doesn't aggregate its averages at a high-enough frequency right now.
This patch series extends the psi interface such that users can configure sensitive latency thresholds and use poll() and friends to be notified when these are breached.
As high-frequency aggregation is costly, it implements an aggregation method that is optimized for fast, short-interval averaging, and makes the aggregation frequency adaptive, such that high-frequency updates only happen while monitored stall events are actively occurring.
With these patches applied, Android can monitor for, and ward off, mounting memory shortages before they cause problems for the user. For example, using memory stall monitors in userspace low memory killer daemon (lmkd) we can detect mounting pressure and kill less important processes before device becomes visibly sluggish. In our memory stress testing psi memory monitors produce roughly 10x less false positives compared to vmpressure signals. Having ability to specify multiple triggers for the same psi metric allows other parts of Android framework to monitor memory state of the device and act accordingly.
The new interface is straight-forward. The user opens one of the pressure files for writing and writes a trigger description into the file descriptor that defines the stall state - some or full, and the maximum stall time over a given window of time. E.g.:
/* Signal when stall time exceeds 100ms of a 1s window */
char trigger[] = "full 100000 1000000"
fd = open("/proc/pressure/memory")
write(fd, trigger, sizeof(trigger))
while (poll() >= 0) {
...
};
close(fd);When the monitored stall state is entered, psi adapts its aggregation frequency according to what the configured time window requires in order to emit event signals in a timely fashion. Once the stalling subsides, aggregation reverts back to normal.
The trigger is associated with the open file descriptor. To stop monitoring, the user only needs to close the file descriptor and the trigger is discarded.
Patches 1-6 prepare the psi code for polling support. Patch 7 implements the adaptive polling logic, the pressure growth detection optimized for short intervals, and hooks up write() and poll() on the pressure files.
The patches were developed in collaboration with Johannes Weiner.
The patches are based on 5.1-rc1
Suren Baghdasaryan (7):
psi: introduce state_mask to represent stalled psi states
psi: make psi_enable static
psi: rename psi fields in preparation for psi trigger addition
psi: split update_stats into parts
psi: track changed states
refactor header includes to allow kthread.h inclusion in psi_types.h
psi: introduce psi monitor
Documentation/accounting/psi.txt | 107 ++++++ drivers/spi/spi-rockchip.c | 1 + include/linux/kthread.h | 3 +- include/linux/psi.h | 8 + include/linux/psi_types.h | 105 +++++- include/linux/sched.h | 1 - kernel/cgroup/cgroup.c | 71 +++- kernel/kthread.c | 1 + kernel/sched/psi.c | 615 ++++++++++++++++++++++++++++--- 9 files changed, 836 insertions(+), 76 deletions(-)
Changes in v6:
- Fixed psi averaging regression introduced in 4/7 and caused by lack of checking for avg_next_update before calling update_averages in psi_show
- Fixed missing header include in spi-rockchip.c causing kbuild test bot's warning in 6/7
Signature · 1 line
2.21.0.225.g810b269d1ac-goog