History

Merge tag 'sched-psi-2022-10-14' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull PSI updates from Ingo Molnar: - Various performance optimizations, resulting in a 4%-9% speedup in the mmtests/config-scheduler-perfpipe micro-benchmark. - New interface to turn PSI on/off on a per cgroup level. * tag 'sched-psi-2022-10-14' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: sched/psi: Per-cgroup PSI accounting disable/re-enable interface sched/psi: Cache parent psi_group to speed up group iteration sched/psi: Consolidate cgroup_psi() sched/psi: Add PSI_IRQ to track IRQ/SOFTIRQ pressure sched/psi: Remove NR_ONCPU task accounting sched/psi: Optimize task switch inside shared cgroups again sched/psi: Move private helpers to sched/stats.h sched/psi: Save percpu memory when !psi_cgroups_enabled sched/psi: Don't create cgroup PSI files when psi_disabled sched/psi: Fix periodic aggregation shut off

Linus Torvalds committed 4 years ago

Commit bd9a3db2 parents 1df046a 34f26a19 files · +362 −103Browse files

Showing the changes to include (4 of 9 files). Show all

Unified · Split

4 files
  1. include/linux/cgroup-defs.h +3 −0
  2. include/linux/cgroup.h +0 −5
  3. include/linux/psi.h +8 −4
  4. include/linux/psi_types.h +20 −11
include/linux/cgroup-defs.h+3−0
@@ -428,6 +428,9 @@ struct cgroup { · 427 unmodified lines
428428 struct cgroup_file procs_file; /* handle for "cgroup.procs" */
429429 struct cgroup_file events_file; /* handle for "cgroup.events" */
430430
431+ /* handles for "{cpu,memory,io,irq}.pressure" */
432+ struct cgroup_file psi_files[NR_PSI_RESOURCES];
433+
431434 /*
432435 * The bitmask of subsystems enabled on the child cgroups.
433436 * ->subtree_control is the one configured through
include/linux/cgroup.h+0−5
@@ -682,11 +682,6 @@ static inline void pr_cont_cgroup_path(struct cgroup *cgrp) · 681 unmodified lines
682682 pr_cont_kernfs_path(cgrp->kn);
683683 }
684684
685−static inline struct psi_group *cgroup_psi(struct cgroup *cgrp)
686−{
687− return cgrp->psi;
688−}
689−
690685 bool cgroup_psi_enabled(void);
691686
692687 static inline void cgroup_init_kthreadd(void)
include/linux/psi.h+8−4
@@ -7,6 +7,7 @@ · 6 unmodified lines
77 #include <linux/sched.h>
88 #include <linux/poll.h>
99 #include <linux/cgroup-defs.h>
10+#include <linux/cgroup.h>
1011
1112 struct seq_file;
1213 struct css_set;
@@ -18,10 +19,6 @@ extern struct psi_group psi_system; · 5 unmodified lines
1819
1920 void psi_init(void);
2021
21−void psi_task_change(struct task_struct *task, int clear, int set);
22−void psi_task_switch(struct task_struct *prev, struct task_struct *next,
23− bool sleep);
24−
2522 void psi_memstall_enter(unsigned long *flags);
2623 void psi_memstall_leave(unsigned long *flags);
2724
@@ -34,9 +31,15 @@ __poll_t psi_trigger_poll(void **trigger_ptr, struct file *file, · 6 unmodified lines
3431 poll_table *wait);
3532
3633 #ifdef CONFIG_CGROUPS
34+static inline struct psi_group *cgroup_psi(struct cgroup *cgrp)
35+{
36+ return cgroup_ino(cgrp) == 1 ? &psi_system : cgrp->psi;
37+}
38+
3739 int psi_cgroup_alloc(struct cgroup *cgrp);
3840 void psi_cgroup_free(struct cgroup *cgrp);
3941 void cgroup_move_task(struct task_struct *p, struct css_set *to);
42+void psi_cgroup_restart(struct psi_group *group);
4043 #endif
4144
4245 #else /* CONFIG_PSI */
@@ -58,6 +61,7 @@ static inline void cgroup_move_task(struct task_struct *p, struct css_set *to) · 15 unmodified lines
5861 {
5962 rcu_assign_pointer(p->cgroups, to);
6063 }
64+static inline void psi_cgroup_restart(struct psi_group *group) {}
6165 #endif
6266
6367 #endif /* CONFIG_PSI */
include/linux/psi_types.h+20−11
@@ -15,13 +15,6 @@ enum psi_task_count { · 14 unmodified lines
1515 NR_IOWAIT,
1616 NR_MEMSTALL,
1717 NR_RUNNING,
18− /*
19− * This can't have values other than 0 or 1 and could be
20− * implemented as a bit flag. But for now we still have room
21− * in the first cacheline of psi_group_cpu, and this way we
22− * don't have to special case any state tracking for it.
23− */
24− NR_ONCPU,
2518 /*
2619 * For IO and CPU stalls the presence of running/oncpu tasks
2720 * in the domain means a partial rather than a full stall.
@@ -32,22 +25,27 @@ enum psi_task_count { · 4 unmodified lines
3225 * threads and memstall ones.
3326 */
3427 NR_MEMSTALL_RUNNING,
35− NR_PSI_TASK_COUNTS = 5,
28+ NR_PSI_TASK_COUNTS = 4,
3629 };
3730
3831 /* Task state bitmasks */
3932 #define TSK_IOWAIT (1 << NR_IOWAIT)
4033 #define TSK_MEMSTALL (1 << NR_MEMSTALL)
4134 #define TSK_RUNNING (1 << NR_RUNNING)
42−#define TSK_ONCPU (1 << NR_ONCPU)
4335 #define TSK_MEMSTALL_RUNNING (1 << NR_MEMSTALL_RUNNING)
4436
37+/* Only one task can be scheduled, no corresponding task count */
38+#define TSK_ONCPU (1 << NR_PSI_TASK_COUNTS)
39+
4540 /* Resources that workloads could be stalled on */
4641 enum psi_res {
4742 PSI_IO,
4843 PSI_MEM,
4944 PSI_CPU,
50− NR_PSI_RESOURCES = 3,
45+#ifdef CONFIG_IRQ_TIME_ACCOUNTING
46+ PSI_IRQ,
47+#endif
48+ NR_PSI_RESOURCES,
5149 };
5250
5351 /*
@@ -63,11 +61,17 @@ enum psi_states { · 9 unmodified lines
6361 PSI_MEM_FULL,
6462 PSI_CPU_SOME,
6563 PSI_CPU_FULL,
64+#ifdef CONFIG_IRQ_TIME_ACCOUNTING
65+ PSI_IRQ_FULL,
66+#endif
6667 /* Only per-CPU, to weigh the CPU in the global average: */
6768 PSI_NONIDLE,
68− NR_PSI_STATES = 7,
69+ NR_PSI_STATES,
6970 };
7071
72+/* Use one bit in the state mask to track TSK_ONCPU */
73+#define PSI_ONCPU (1 << NR_PSI_STATES)
74+
7175 enum psi_aggregators {
7276 PSI_AVGS = 0,
7377 PSI_POLL,
@@ -147,6 +151,9 @@ struct psi_trigger { · 73 unmodified lines
147151 };
148152
149153 struct psi_group {
154+ struct psi_group *parent;
155+ bool enabled;
156+
150157 /* Protects data used by the aggregator */
151158 struct mutex avgs_lock;
152159
@@ -188,6 +195,8 @@ struct psi_group { · 35 unmodified lines
188195
189196 #else /* CONFIG_PSI */
190197
198+#define NR_PSI_RESOURCES 0
199+
191200 struct psi_group { };
192201
193202 #endif /* CONFIG_PSI */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t