aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/sched.h
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@cmpxchg.org>2018-10-26 18:06:27 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-10-26 19:26:32 -0400
commiteb414681d5a07d28d2ff90dc05f69ec6b232ebd2 (patch)
tree69e37010954e597b404709ecd9a11b9f7373cf0f /include/linux/sched.h
parent246b3b3342c9b0a2e24cda2178be87bc36e1c874 (diff)
psi: pressure stall information for CPU, memory, and IO
When systems are overcommitted and resources become contended, it's hard to tell exactly the impact this has on workload productivity, or how close the system is to lockups and OOM kills. In particular, when machines work multiple jobs concurrently, the impact of overcommit in terms of latency and throughput on the individual job can be enormous. In order to maximize hardware utilization without sacrificing individual job health or risk complete machine lockups, this patch implements a way to quantify resource pressure in the system. A kernel built with CONFIG_PSI=y creates files in /proc/pressure/ that expose the percentage of time the system is stalled on CPU, memory, or IO, respectively. Stall states are aggregate versions of the per-task delay accounting delays: cpu: some tasks are runnable but not executing on a CPU memory: tasks are reclaiming, or waiting for swapin or thrashing cache io: tasks are waiting for io completions These percentages of walltime can be thought of as pressure percentages, and they give a general sense of system health and productivity loss incurred by resource overcommit. They can also indicate when the system is approaching lockup scenarios and OOMs. To do this, psi keeps track of the task states associated with each CPU and samples the time they spend in stall states. Every 2 seconds, the samples are averaged across CPUs - weighted by the CPUs' non-idle time to eliminate artifacts from unused CPUs - and translated into percentages of walltime. A running average of those percentages is maintained over 10s, 1m, and 5m periods (similar to the loadaverage). [hannes@cmpxchg.org: doc fixlet, per Randy] Link: http://lkml.kernel.org/r/20180828205625.GA14030@cmpxchg.org [hannes@cmpxchg.org: code optimization] Link: http://lkml.kernel.org/r/20180907175015.GA8479@cmpxchg.org [hannes@cmpxchg.org: rename psi_clock() to psi_update_work(), per Peter] Link: http://lkml.kernel.org/r/20180907145404.GB11088@cmpxchg.org [hannes@cmpxchg.org: fix build] Link: http://lkml.kernel.org/r/20180913014222.GA2370@cmpxchg.org Link: http://lkml.kernel.org/r/20180828172258.3185-9-hannes@cmpxchg.org Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Tested-by: Daniel Drake <drake@endlessm.com> Tested-by: Suren Baghdasaryan <surenb@google.com> Cc: Christopher Lameter <cl@linux.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Johannes Weiner <jweiner@fb.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Enderborg <peter.enderborg@sony.com> Cc: Randy Dunlap <rdunlap@infradead.org> Cc: Shakeel Butt <shakeelb@google.com> Cc: Tejun Heo <tj@kernel.org> Cc: Vinayak Menon <vinmenon@codeaurora.org> Cc: Randy Dunlap <rdunlap@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/sched.h')
-rw-r--r--include/linux/sched.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index adfb3f9a7597..b8fcc6b3080c 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -25,6 +25,7 @@
25#include <linux/latencytop.h> 25#include <linux/latencytop.h>
26#include <linux/sched/prio.h> 26#include <linux/sched/prio.h>
27#include <linux/signal_types.h> 27#include <linux/signal_types.h>
28#include <linux/psi_types.h>
28#include <linux/mm_types_task.h> 29#include <linux/mm_types_task.h>
29#include <linux/task_io_accounting.h> 30#include <linux/task_io_accounting.h>
30#include <linux/rseq.h> 31#include <linux/rseq.h>
@@ -706,6 +707,10 @@ struct task_struct {
706 unsigned sched_contributes_to_load:1; 707 unsigned sched_contributes_to_load:1;
707 unsigned sched_migrated:1; 708 unsigned sched_migrated:1;
708 unsigned sched_remote_wakeup:1; 709 unsigned sched_remote_wakeup:1;
710#ifdef CONFIG_PSI
711 unsigned sched_psi_wake_requeue:1;
712#endif
713
709 /* Force alignment to the next boundary: */ 714 /* Force alignment to the next boundary: */
710 unsigned :0; 715 unsigned :0;
711 716
@@ -965,6 +970,10 @@ struct task_struct {
965 kernel_siginfo_t *last_siginfo; 970 kernel_siginfo_t *last_siginfo;
966 971
967 struct task_io_accounting ioac; 972 struct task_io_accounting ioac;
973#ifdef CONFIG_PSI
974 /* Pressure stall state */
975 unsigned int psi_flags;
976#endif
968#ifdef CONFIG_TASK_XACCT 977#ifdef CONFIG_TASK_XACCT
969 /* Accumulated RSS usage: */ 978 /* Accumulated RSS usage: */
970 u64 acct_rss_mem1; 979 u64 acct_rss_mem1;
@@ -1391,6 +1400,7 @@ extern struct pid *cad_pid;
1391#define PF_KTHREAD 0x00200000 /* I am a kernel thread */ 1400#define PF_KTHREAD 0x00200000 /* I am a kernel thread */
1392#define PF_RANDOMIZE 0x00400000 /* Randomize virtual address space */ 1401#define PF_RANDOMIZE 0x00400000 /* Randomize virtual address space */
1393#define PF_SWAPWRITE 0x00800000 /* Allowed to write to swap */ 1402#define PF_SWAPWRITE 0x00800000 /* Allowed to write to swap */
1403#define PF_MEMSTALL 0x01000000 /* Stalled due to lack of memory */
1394#define PF_NO_SETAFFINITY 0x04000000 /* Userland is not allowed to meddle with cpus_allowed */ 1404#define PF_NO_SETAFFINITY 0x04000000 /* Userland is not allowed to meddle with cpus_allowed */
1395#define PF_MCE_EARLY 0x08000000 /* Early kill for mce process policy */ 1405#define PF_MCE_EARLY 0x08000000 /* Early kill for mce process policy */
1396#define PF_MUTEX_TESTER 0x20000000 /* Thread belongs to the rt mutex tester */ 1406#define PF_MUTEX_TESTER 0x20000000 /* Thread belongs to the rt mutex tester */