Re: Hackbench pipes regression bisected to PSI

2018-11-27 Thread Johannes Weiner
On Tue, Nov 27, 2018 at 11:46:17AM -0500, Johannes Weiner wrote:
> From 347b69a52d1ec7e71df1108cbc5703d6dd0616ba Mon Sep 17 00:00:00 2001
> From: Johannes Weiner 
> Date: Mon, 26 Nov 2018 09:39:23 -0500
> Subject: [PATCH] psi: make disabling/enabling easier for vendor kernels
> 
> Mel Gorman reports a hackbench regression with psi that would prohibit
> shipping the suse kernel with it default-enabled, but he'd still like
> users to be able to opt in at little to no cost to others.
> 
> With the current combination of CONFIG_PSI and the psi_disabled bool
> set from the commandline, this is a challenge. Do the following things
> to make it easier:
> 
> 1. Add a config option CONFIG_PSI_DEFAULT_ENABLED that allows distros

This should be:  CONFIG_PSI_DEFAULT_DISABLED

Refreshed the patch.

---

>From dc1511101b4c6aa3f7cfb91d8634a682fe7c147e Mon Sep 17 00:00:00 2001
From: Johannes Weiner 
Date: Mon, 26 Nov 2018 09:39:23 -0500
Subject: [PATCH] psi: make disabling/enabling easier for vendor kernels

Mel Gorman reports a hackbench regression with psi that would prohibit
shipping the suse kernel with it default-enabled, but he'd still like
users to be able to opt in at little to no cost to others.

With the current combination of CONFIG_PSI and the psi_disabled bool
set from the commandline, this is a challenge. Do the following things
to make it easier:

1. Add a config option CONFIG_PSI_DEFAULT_DISABLED that allows distros
   to enable CONFIG_PSI in their kernel but leave the feature disabled
   unless a user requests it at boot-time.

   To avoid double negatives, rename psi_disabled= to psi=.

2. Make psi_disabled a static branch to eliminate any branch costs
   when the feature is disabled.

In terms of numbers before and after this patch, Mel says:

: The following is a comparision using CONFIG_PSI=n as a baseline against
: your patch and a vanilla kernel
:
:  4.20.0-rc4 4.20.0-rc4 
4.20.0-rc4
: kconfigdisable-v1r1vanilla
psidisable-v1r1
: Amean 1   1.3100 (   0.00%)  1.3923 (  -6.28%)  1.3427 (  
-2.49%)
: Amean 3   3.8860 (   0.00%)  4.1230 *  -6.10%*  3.8860 (  
-0.00%)
: Amean 5   6.8847 (   0.00%)  8.0390 * -16.77%*  6.7727 (   
1.63%)
: Amean 7   9.9310 (   0.00%) 10.8367 *  -9.12%*  9.9910 (  
-0.60%)
: Amean 12 16.6577 (   0.00%) 18.2363 *  -9.48%* 17.1083 (  
-2.71%)
: Amean 18 26.5133 (   0.00%) 27.8833 *  -5.17%* 25.7663 (   
2.82%)
: Amean 24 34.3003 (   0.00%) 34.6830 (  -1.12%) 32.0450 (   
6.58%)
: Amean 30 40.0063 (   0.00%) 40.5800 (  -1.43%) 41.5087 (  
-3.76%)
: Amean 32 40.1407 (   0.00%) 41.2273 (  -2.71%) 39.9417 (   
0.50%)
:
: It's showing that the vanilla kernel takes a hit (as the bisection
: indicated it would) and that disabling PSI by default is reasonably
: close in terms of performance for this particular workload on this
: particular machine so;

Tested-by: Mel Gorman 
Reported-by: Mel Gorman 
Signed-off-by: Johannes Weiner 
---
 .../admin-guide/kernel-parameters.txt |  4 +++
 include/linux/psi.h   |  3 +-
 init/Kconfig  |  9 ++
 kernel/sched/psi.c| 30 +--
 kernel/sched/stats.h  |  8 ++---
 5 files changed, 40 insertions(+), 14 deletions(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt 
b/Documentation/admin-guide/kernel-parameters.txt
index 19f4423e70d9..8760a343c6d8 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -3504,6 +3504,10 @@
before loading.
See Documentation/blockdev/ramdisk.txt.
 
+   psi=[KNL] Enable or disable pressure stall information
+   tracking.
+   Format: 
+
psmouse.proto=  [HW,MOUSE] Highest PS2 mouse protocol extension to
probe for; one of (bare|imps|exps|lifebook|any).
psmouse.rate=   [HW,MOUSE] Set desired mouse report rate, in reports
diff --git a/include/linux/psi.h b/include/linux/psi.h
index 8e0725aac0aa..7006008d5b72 100644
--- a/include/linux/psi.h
+++ b/include/linux/psi.h
@@ -1,6 +1,7 @@
 #ifndef _LINUX_PSI_H
 #define _LINUX_PSI_H
 
+#include 
 #include 
 #include 
 
@@ -9,7 +10,7 @@ struct css_set;
 
 #ifdef CONFIG_PSI
 
-extern bool psi_disabled;
+extern struct static_key_false psi_disabled;
 
 void psi_init(void);
 
diff --git a/init/Kconfig b/init/Kconfig
index a4112e95724a..cf5b5a0dcbc2 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -509,6 +509,15 @@ config PSI
 
  Say N if unsure.
 
+config PSI_DEFAULT_DISABLED
+   bool "Require boot parameter to enable pressure stall information 
tracking"
+   default n
+   depends on PSI

Re: Hackbench pipes regression bisected to PSI

2018-11-27 Thread Johannes Weiner
On Tue, Nov 27, 2018 at 11:46:17AM -0500, Johannes Weiner wrote:
> From 347b69a52d1ec7e71df1108cbc5703d6dd0616ba Mon Sep 17 00:00:00 2001
> From: Johannes Weiner 
> Date: Mon, 26 Nov 2018 09:39:23 -0500
> Subject: [PATCH] psi: make disabling/enabling easier for vendor kernels
> 
> Mel Gorman reports a hackbench regression with psi that would prohibit
> shipping the suse kernel with it default-enabled, but he'd still like
> users to be able to opt in at little to no cost to others.
> 
> With the current combination of CONFIG_PSI and the psi_disabled bool
> set from the commandline, this is a challenge. Do the following things
> to make it easier:
> 
> 1. Add a config option CONFIG_PSI_DEFAULT_ENABLED that allows distros

This should be:  CONFIG_PSI_DEFAULT_DISABLED

Refreshed the patch.

---

>From dc1511101b4c6aa3f7cfb91d8634a682fe7c147e Mon Sep 17 00:00:00 2001
From: Johannes Weiner 
Date: Mon, 26 Nov 2018 09:39:23 -0500
Subject: [PATCH] psi: make disabling/enabling easier for vendor kernels

Mel Gorman reports a hackbench regression with psi that would prohibit
shipping the suse kernel with it default-enabled, but he'd still like
users to be able to opt in at little to no cost to others.

With the current combination of CONFIG_PSI and the psi_disabled bool
set from the commandline, this is a challenge. Do the following things
to make it easier:

1. Add a config option CONFIG_PSI_DEFAULT_DISABLED that allows distros
   to enable CONFIG_PSI in their kernel but leave the feature disabled
   unless a user requests it at boot-time.

   To avoid double negatives, rename psi_disabled= to psi=.

2. Make psi_disabled a static branch to eliminate any branch costs
   when the feature is disabled.

In terms of numbers before and after this patch, Mel says:

: The following is a comparision using CONFIG_PSI=n as a baseline against
: your patch and a vanilla kernel
:
:  4.20.0-rc4 4.20.0-rc4 
4.20.0-rc4
: kconfigdisable-v1r1vanilla
psidisable-v1r1
: Amean 1   1.3100 (   0.00%)  1.3923 (  -6.28%)  1.3427 (  
-2.49%)
: Amean 3   3.8860 (   0.00%)  4.1230 *  -6.10%*  3.8860 (  
-0.00%)
: Amean 5   6.8847 (   0.00%)  8.0390 * -16.77%*  6.7727 (   
1.63%)
: Amean 7   9.9310 (   0.00%) 10.8367 *  -9.12%*  9.9910 (  
-0.60%)
: Amean 12 16.6577 (   0.00%) 18.2363 *  -9.48%* 17.1083 (  
-2.71%)
: Amean 18 26.5133 (   0.00%) 27.8833 *  -5.17%* 25.7663 (   
2.82%)
: Amean 24 34.3003 (   0.00%) 34.6830 (  -1.12%) 32.0450 (   
6.58%)
: Amean 30 40.0063 (   0.00%) 40.5800 (  -1.43%) 41.5087 (  
-3.76%)
: Amean 32 40.1407 (   0.00%) 41.2273 (  -2.71%) 39.9417 (   
0.50%)
:
: It's showing that the vanilla kernel takes a hit (as the bisection
: indicated it would) and that disabling PSI by default is reasonably
: close in terms of performance for this particular workload on this
: particular machine so;

Tested-by: Mel Gorman 
Reported-by: Mel Gorman 
Signed-off-by: Johannes Weiner 
---
 .../admin-guide/kernel-parameters.txt |  4 +++
 include/linux/psi.h   |  3 +-
 init/Kconfig  |  9 ++
 kernel/sched/psi.c| 30 +--
 kernel/sched/stats.h  |  8 ++---
 5 files changed, 40 insertions(+), 14 deletions(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt 
b/Documentation/admin-guide/kernel-parameters.txt
index 19f4423e70d9..8760a343c6d8 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -3504,6 +3504,10 @@
before loading.
See Documentation/blockdev/ramdisk.txt.
 
+   psi=[KNL] Enable or disable pressure stall information
+   tracking.
+   Format: 
+
psmouse.proto=  [HW,MOUSE] Highest PS2 mouse protocol extension to
probe for; one of (bare|imps|exps|lifebook|any).
psmouse.rate=   [HW,MOUSE] Set desired mouse report rate, in reports
diff --git a/include/linux/psi.h b/include/linux/psi.h
index 8e0725aac0aa..7006008d5b72 100644
--- a/include/linux/psi.h
+++ b/include/linux/psi.h
@@ -1,6 +1,7 @@
 #ifndef _LINUX_PSI_H
 #define _LINUX_PSI_H
 
+#include 
 #include 
 #include 
 
@@ -9,7 +10,7 @@ struct css_set;
 
 #ifdef CONFIG_PSI
 
-extern bool psi_disabled;
+extern struct static_key_false psi_disabled;
 
 void psi_init(void);
 
diff --git a/init/Kconfig b/init/Kconfig
index a4112e95724a..cf5b5a0dcbc2 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -509,6 +509,15 @@ config PSI
 
  Say N if unsure.
 
+config PSI_DEFAULT_DISABLED
+   bool "Require boot parameter to enable pressure stall information 
tracking"
+   default n
+   depends on PSI

Re: Hackbench pipes regression bisected to PSI

2018-11-27 Thread Johannes Weiner
On Mon, Nov 26, 2018 at 11:29:26PM +, Mel Gorman wrote:
> The following is a comparision using CONFIG_PSI=n as a baseline against
> your patch and a vanilla kernel
> 
>  4.20.0-rc4 4.20.0-rc4 
> 4.20.0-rc4
> kconfigdisable-v1r1vanilla
> psidisable-v1r1
> Amean 1   1.3100 (   0.00%)  1.3923 (  -6.28%)  1.3427 (  
> -2.49%)
> Amean 3   3.8860 (   0.00%)  4.1230 *  -6.10%*  3.8860 (  
> -0.00%)
> Amean 5   6.8847 (   0.00%)  8.0390 * -16.77%*  6.7727 (   
> 1.63%)
> Amean 7   9.9310 (   0.00%) 10.8367 *  -9.12%*  9.9910 (  
> -0.60%)
> Amean 12 16.6577 (   0.00%) 18.2363 *  -9.48%* 17.1083 (  
> -2.71%)
> Amean 18 26.5133 (   0.00%) 27.8833 *  -5.17%* 25.7663 (   
> 2.82%)
> Amean 24 34.3003 (   0.00%) 34.6830 (  -1.12%) 32.0450 (   
> 6.58%)
> Amean 30 40.0063 (   0.00%) 40.5800 (  -1.43%) 41.5087 (  
> -3.76%)
> Amean 32 40.1407 (   0.00%) 41.2273 (  -2.71%) 39.9417 (   
> 0.50%)
> 
> It's showing that the vanilla kernel takes a hit (as the bisection
> indicated it would) and that disabling PSI by default is reasonably
> close in terms of performance for this particular workload on this
> particular machine so;
> 
> Tested-by: Mel Gorman 

Thanks for testing it. Let's add these results to the changelog:

---

>From 347b69a52d1ec7e71df1108cbc5703d6dd0616ba Mon Sep 17 00:00:00 2001
From: Johannes Weiner 
Date: Mon, 26 Nov 2018 09:39:23 -0500
Subject: [PATCH] psi: make disabling/enabling easier for vendor kernels

Mel Gorman reports a hackbench regression with psi that would prohibit
shipping the suse kernel with it default-enabled, but he'd still like
users to be able to opt in at little to no cost to others.

With the current combination of CONFIG_PSI and the psi_disabled bool
set from the commandline, this is a challenge. Do the following things
to make it easier:

1. Add a config option CONFIG_PSI_DEFAULT_ENABLED that allows distros
   to enable CONFIG_PSI in their kernel, but leaving the feature
   disabled unless a user requests it at boot-time.

   To avoid double negatives, rename psi_disabled= to psi=.

2. Make psi_disabled a static branch to eliminate any branch costs
   when the feature is disabled.

In terms of numbers before and after this patch, Mel says:

: The following is a comparision using CONFIG_PSI=n as a baseline against
: your patch and a vanilla kernel
: 
:  4.20.0-rc4 4.20.0-rc4 
4.20.0-rc4
: kconfigdisable-v1r1vanilla
psidisable-v1r1
: Amean 1   1.3100 (   0.00%)  1.3923 (  -6.28%)  1.3427 (  
-2.49%)
: Amean 3   3.8860 (   0.00%)  4.1230 *  -6.10%*  3.8860 (  
-0.00%)
: Amean 5   6.8847 (   0.00%)  8.0390 * -16.77%*  6.7727 (   
1.63%)
: Amean 7   9.9310 (   0.00%) 10.8367 *  -9.12%*  9.9910 (  
-0.60%)
: Amean 12 16.6577 (   0.00%) 18.2363 *  -9.48%* 17.1083 (  
-2.71%)
: Amean 18 26.5133 (   0.00%) 27.8833 *  -5.17%* 25.7663 (   
2.82%)
: Amean 24 34.3003 (   0.00%) 34.6830 (  -1.12%) 32.0450 (   
6.58%)
: Amean 30 40.0063 (   0.00%) 40.5800 (  -1.43%) 41.5087 (  
-3.76%)
: Amean 32 40.1407 (   0.00%) 41.2273 (  -2.71%) 39.9417 (   
0.50%)
: 
: It's showing that the vanilla kernel takes a hit (as the bisection
: indicated it would) and that disabling PSI by default is reasonably
: close in terms of performance for this particular workload on this
: particular machine so;

Tested-by: Mel Gorman 
Reported-by: Mel Gorman 
Signed-off-by: Johannes Weiner 
---
 .../admin-guide/kernel-parameters.txt |  4 +++
 include/linux/psi.h   |  3 +-
 init/Kconfig  |  9 ++
 kernel/sched/psi.c| 30 +--
 kernel/sched/stats.h  |  8 ++---
 5 files changed, 40 insertions(+), 14 deletions(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt 
b/Documentation/admin-guide/kernel-parameters.txt
index 19f4423e70d9..8760a343c6d8 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -3504,6 +3504,10 @@
before loading.
See Documentation/blockdev/ramdisk.txt.
 
+   psi=[KNL] Enable or disable pressure stall information
+   tracking.
+   Format: 
+
psmouse.proto=  [HW,MOUSE] Highest PS2 mouse protocol extension to
probe for; one of (bare|imps|exps|lifebook|any).
psmouse.rate=   [HW,MOUSE] Set desired mouse report rate, in reports
diff --git a/include/linux/psi.h b/include/linux/psi.h
index 

Re: Hackbench pipes regression bisected to PSI

2018-11-27 Thread Johannes Weiner
On Mon, Nov 26, 2018 at 11:29:26PM +, Mel Gorman wrote:
> The following is a comparision using CONFIG_PSI=n as a baseline against
> your patch and a vanilla kernel
> 
>  4.20.0-rc4 4.20.0-rc4 
> 4.20.0-rc4
> kconfigdisable-v1r1vanilla
> psidisable-v1r1
> Amean 1   1.3100 (   0.00%)  1.3923 (  -6.28%)  1.3427 (  
> -2.49%)
> Amean 3   3.8860 (   0.00%)  4.1230 *  -6.10%*  3.8860 (  
> -0.00%)
> Amean 5   6.8847 (   0.00%)  8.0390 * -16.77%*  6.7727 (   
> 1.63%)
> Amean 7   9.9310 (   0.00%) 10.8367 *  -9.12%*  9.9910 (  
> -0.60%)
> Amean 12 16.6577 (   0.00%) 18.2363 *  -9.48%* 17.1083 (  
> -2.71%)
> Amean 18 26.5133 (   0.00%) 27.8833 *  -5.17%* 25.7663 (   
> 2.82%)
> Amean 24 34.3003 (   0.00%) 34.6830 (  -1.12%) 32.0450 (   
> 6.58%)
> Amean 30 40.0063 (   0.00%) 40.5800 (  -1.43%) 41.5087 (  
> -3.76%)
> Amean 32 40.1407 (   0.00%) 41.2273 (  -2.71%) 39.9417 (   
> 0.50%)
> 
> It's showing that the vanilla kernel takes a hit (as the bisection
> indicated it would) and that disabling PSI by default is reasonably
> close in terms of performance for this particular workload on this
> particular machine so;
> 
> Tested-by: Mel Gorman 

Thanks for testing it. Let's add these results to the changelog:

---

>From 347b69a52d1ec7e71df1108cbc5703d6dd0616ba Mon Sep 17 00:00:00 2001
From: Johannes Weiner 
Date: Mon, 26 Nov 2018 09:39:23 -0500
Subject: [PATCH] psi: make disabling/enabling easier for vendor kernels

Mel Gorman reports a hackbench regression with psi that would prohibit
shipping the suse kernel with it default-enabled, but he'd still like
users to be able to opt in at little to no cost to others.

With the current combination of CONFIG_PSI and the psi_disabled bool
set from the commandline, this is a challenge. Do the following things
to make it easier:

1. Add a config option CONFIG_PSI_DEFAULT_ENABLED that allows distros
   to enable CONFIG_PSI in their kernel, but leaving the feature
   disabled unless a user requests it at boot-time.

   To avoid double negatives, rename psi_disabled= to psi=.

2. Make psi_disabled a static branch to eliminate any branch costs
   when the feature is disabled.

In terms of numbers before and after this patch, Mel says:

: The following is a comparision using CONFIG_PSI=n as a baseline against
: your patch and a vanilla kernel
: 
:  4.20.0-rc4 4.20.0-rc4 
4.20.0-rc4
: kconfigdisable-v1r1vanilla
psidisable-v1r1
: Amean 1   1.3100 (   0.00%)  1.3923 (  -6.28%)  1.3427 (  
-2.49%)
: Amean 3   3.8860 (   0.00%)  4.1230 *  -6.10%*  3.8860 (  
-0.00%)
: Amean 5   6.8847 (   0.00%)  8.0390 * -16.77%*  6.7727 (   
1.63%)
: Amean 7   9.9310 (   0.00%) 10.8367 *  -9.12%*  9.9910 (  
-0.60%)
: Amean 12 16.6577 (   0.00%) 18.2363 *  -9.48%* 17.1083 (  
-2.71%)
: Amean 18 26.5133 (   0.00%) 27.8833 *  -5.17%* 25.7663 (   
2.82%)
: Amean 24 34.3003 (   0.00%) 34.6830 (  -1.12%) 32.0450 (   
6.58%)
: Amean 30 40.0063 (   0.00%) 40.5800 (  -1.43%) 41.5087 (  
-3.76%)
: Amean 32 40.1407 (   0.00%) 41.2273 (  -2.71%) 39.9417 (   
0.50%)
: 
: It's showing that the vanilla kernel takes a hit (as the bisection
: indicated it would) and that disabling PSI by default is reasonably
: close in terms of performance for this particular workload on this
: particular machine so;

Tested-by: Mel Gorman 
Reported-by: Mel Gorman 
Signed-off-by: Johannes Weiner 
---
 .../admin-guide/kernel-parameters.txt |  4 +++
 include/linux/psi.h   |  3 +-
 init/Kconfig  |  9 ++
 kernel/sched/psi.c| 30 +--
 kernel/sched/stats.h  |  8 ++---
 5 files changed, 40 insertions(+), 14 deletions(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt 
b/Documentation/admin-guide/kernel-parameters.txt
index 19f4423e70d9..8760a343c6d8 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -3504,6 +3504,10 @@
before loading.
See Documentation/blockdev/ramdisk.txt.
 
+   psi=[KNL] Enable or disable pressure stall information
+   tracking.
+   Format: 
+
psmouse.proto=  [HW,MOUSE] Highest PS2 mouse protocol extension to
probe for; one of (bare|imps|exps|lifebook|any).
psmouse.rate=   [HW,MOUSE] Set desired mouse report rate, in reports
diff --git a/include/linux/psi.h b/include/linux/psi.h
index 

Re: Hackbench pipes regression bisected to PSI

2018-11-26 Thread Mel Gorman
On Mon, Nov 26, 2018 at 12:32:18PM -0500, Johannes Weiner wrote:
> > 
> > Bit late to notice but this switch should be in
> > Documentation/admin-guide/kernel-parameters.txt. If you really want to
> > match the automatic numa balancing switch then it also should be
> > psi=[enable|disable] instead of psi_enable=[1|0]
> 
> Done and done, thanks. Updated patch:
> 

The following is a comparision using CONFIG_PSI=n as a baseline against
your patch and a vanilla kernel

 4.20.0-rc4 4.20.0-rc4 
4.20.0-rc4
kconfigdisable-v1r1vanilla
psidisable-v1r1
Amean 1   1.3100 (   0.00%)  1.3923 (  -6.28%)  1.3427 (  
-2.49%)
Amean 3   3.8860 (   0.00%)  4.1230 *  -6.10%*  3.8860 (  
-0.00%)
Amean 5   6.8847 (   0.00%)  8.0390 * -16.77%*  6.7727 (   
1.63%)
Amean 7   9.9310 (   0.00%) 10.8367 *  -9.12%*  9.9910 (  
-0.60%)
Amean 12 16.6577 (   0.00%) 18.2363 *  -9.48%* 17.1083 (  
-2.71%)
Amean 18 26.5133 (   0.00%) 27.8833 *  -5.17%* 25.7663 (   
2.82%)
Amean 24 34.3003 (   0.00%) 34.6830 (  -1.12%) 32.0450 (   
6.58%)
Amean 30 40.0063 (   0.00%) 40.5800 (  -1.43%) 41.5087 (  
-3.76%)
Amean 32 40.1407 (   0.00%) 41.2273 (  -2.71%) 39.9417 (   
0.50%)

It's showing that the vanilla kernel takes a hit (as the bisection
indicated it would) and that disabling PSI by default is reasonably
close in terms of performance for this particular workload on this
particular machine so;

Tested-by: Mel Gorman 

Thanks!

-- 
Mel Gorman
SUSE Labs


Re: Hackbench pipes regression bisected to PSI

2018-11-26 Thread Mel Gorman
On Mon, Nov 26, 2018 at 12:32:18PM -0500, Johannes Weiner wrote:
> > 
> > Bit late to notice but this switch should be in
> > Documentation/admin-guide/kernel-parameters.txt. If you really want to
> > match the automatic numa balancing switch then it also should be
> > psi=[enable|disable] instead of psi_enable=[1|0]
> 
> Done and done, thanks. Updated patch:
> 

The following is a comparision using CONFIG_PSI=n as a baseline against
your patch and a vanilla kernel

 4.20.0-rc4 4.20.0-rc4 
4.20.0-rc4
kconfigdisable-v1r1vanilla
psidisable-v1r1
Amean 1   1.3100 (   0.00%)  1.3923 (  -6.28%)  1.3427 (  
-2.49%)
Amean 3   3.8860 (   0.00%)  4.1230 *  -6.10%*  3.8860 (  
-0.00%)
Amean 5   6.8847 (   0.00%)  8.0390 * -16.77%*  6.7727 (   
1.63%)
Amean 7   9.9310 (   0.00%) 10.8367 *  -9.12%*  9.9910 (  
-0.60%)
Amean 12 16.6577 (   0.00%) 18.2363 *  -9.48%* 17.1083 (  
-2.71%)
Amean 18 26.5133 (   0.00%) 27.8833 *  -5.17%* 25.7663 (   
2.82%)
Amean 24 34.3003 (   0.00%) 34.6830 (  -1.12%) 32.0450 (   
6.58%)
Amean 30 40.0063 (   0.00%) 40.5800 (  -1.43%) 41.5087 (  
-3.76%)
Amean 32 40.1407 (   0.00%) 41.2273 (  -2.71%) 39.9417 (   
0.50%)

It's showing that the vanilla kernel takes a hit (as the bisection
indicated it would) and that disabling PSI by default is reasonably
close in terms of performance for this particular workload on this
particular machine so;

Tested-by: Mel Gorman 

Thanks!

-- 
Mel Gorman
SUSE Labs


Re: Hackbench pipes regression bisected to PSI

2018-11-26 Thread Mel Gorman
On Mon, Nov 26, 2018 at 12:32:18PM -0500, Johannes Weiner wrote:
> On Mon, Nov 26, 2018 at 04:54:47PM +, Mel Gorman wrote:
> > On Mon, Nov 26, 2018 at 11:07:24AM -0500, Johannes Weiner wrote:
> > > @@ -509,6 +509,15 @@ config PSI
> > >  
> > > Say N if unsure.
> > >  
> > > +config PSI_DEFAULT_DISABLED
> > > + bool "Require boot parameter to enable pressure stall information 
> > > tracking"
> > > + default n
> > > + depends on PSI
> > > + help
> > > +   If set, pressure stall information tracking will be disabled
> > > +   per default but can be enabled through passing psi_enable=1
> > > +   on the kernel commandline during boot.
> > > +
> > >  endmenu # "CPU/Task time and stats accounting"
> > >  
> > 
> > Should this default y on the basis that someone only wants the feature if
> > they are aware of it? This is not that important as CONFIG_PSI is disabled
> > by default and it's up to distribution maintainers to use their brain.
> 
> I went with the NUMA balancing example again here, which defaults to
> enabling the feature at boot time. IMO that makes sense, as somebody
> would presumably first read through the PSI help text, then decide y
> on that before being asked the second question. A "yes, but
> " for vendor kernels seems more appropriate than
> requiring a double yes for other users to simply get the feature.
> 

That's fair enough. The original NUMA balancing thinking was that it
should be enabled because there is a reasonable expectation that it
would improve performance regardless of user awareness. PSI is not
necessarily the same as it requires a consumer but I accept that a
distro maintainer should read the Kconfig text and figure it out.

I'll make sure the updated version gets tested, thanks.

-- 
Mel Gorman
SUSE Labs


Re: Hackbench pipes regression bisected to PSI

2018-11-26 Thread Mel Gorman
On Mon, Nov 26, 2018 at 12:32:18PM -0500, Johannes Weiner wrote:
> On Mon, Nov 26, 2018 at 04:54:47PM +, Mel Gorman wrote:
> > On Mon, Nov 26, 2018 at 11:07:24AM -0500, Johannes Weiner wrote:
> > > @@ -509,6 +509,15 @@ config PSI
> > >  
> > > Say N if unsure.
> > >  
> > > +config PSI_DEFAULT_DISABLED
> > > + bool "Require boot parameter to enable pressure stall information 
> > > tracking"
> > > + default n
> > > + depends on PSI
> > > + help
> > > +   If set, pressure stall information tracking will be disabled
> > > +   per default but can be enabled through passing psi_enable=1
> > > +   on the kernel commandline during boot.
> > > +
> > >  endmenu # "CPU/Task time and stats accounting"
> > >  
> > 
> > Should this default y on the basis that someone only wants the feature if
> > they are aware of it? This is not that important as CONFIG_PSI is disabled
> > by default and it's up to distribution maintainers to use their brain.
> 
> I went with the NUMA balancing example again here, which defaults to
> enabling the feature at boot time. IMO that makes sense, as somebody
> would presumably first read through the PSI help text, then decide y
> on that before being asked the second question. A "yes, but
> " for vendor kernels seems more appropriate than
> requiring a double yes for other users to simply get the feature.
> 

That's fair enough. The original NUMA balancing thinking was that it
should be enabled because there is a reasonable expectation that it
would improve performance regardless of user awareness. PSI is not
necessarily the same as it requires a consumer but I accept that a
distro maintainer should read the Kconfig text and figure it out.

I'll make sure the updated version gets tested, thanks.

-- 
Mel Gorman
SUSE Labs


Re: Hackbench pipes regression bisected to PSI

2018-11-26 Thread Johannes Weiner
On Mon, Nov 26, 2018 at 04:54:47PM +, Mel Gorman wrote:
> On Mon, Nov 26, 2018 at 11:07:24AM -0500, Johannes Weiner wrote:
> > @@ -509,6 +509,15 @@ config PSI
> >  
> >   Say N if unsure.
> >  
> > +config PSI_DEFAULT_DISABLED
> > +   bool "Require boot parameter to enable pressure stall information 
> > tracking"
> > +   default n
> > +   depends on PSI
> > +   help
> > + If set, pressure stall information tracking will be disabled
> > + per default but can be enabled through passing psi_enable=1
> > + on the kernel commandline during boot.
> > +
> >  endmenu # "CPU/Task time and stats accounting"
> >  
> 
> Should this default y on the basis that someone only wants the feature if
> they are aware of it? This is not that important as CONFIG_PSI is disabled
> by default and it's up to distribution maintainers to use their brain.

I went with the NUMA balancing example again here, which defaults to
enabling the feature at boot time. IMO that makes sense, as somebody
would presumably first read through the PSI help text, then decide y
on that before being asked the second question. A "yes, but
" for vendor kernels seems more appropriate than
requiring a double yes for other users to simply get the feature.

> > @@ -136,8 +136,18 @@
> >  
> >  static int psi_bug __read_mostly;
> >  
> > -bool psi_disabled __read_mostly;
> > -core_param(psi_disabled, psi_disabled, bool, 0644);
> > +DEFINE_STATIC_KEY_FALSE(psi_disabled);
> > +
> > +#ifdef CONFIG_PSI_DEFAULT_DISABLED
> > +bool psi_enable;
> > +#else
> > +bool psi_enable = true;
> > +#endif
> > +static int __init parse_psi_enable(char *str)
> > +{
> > +   return kstrtobool(str, _enable) == 0;
> > +}
> > +__setup("psi_enable=", parse_psi_enable);
> >  
> 
> Bit late to notice but this switch should be in
> Documentation/admin-guide/kernel-parameters.txt. If you really want to
> match the automatic numa balancing switch then it also should be
> psi=[enable|disable] instead of psi_enable=[1|0]

Done and done, thanks. Updated patch:

---

>From 694ae3d82da06ca57bfaa775140941ac5e8f2e37 Mon Sep 17 00:00:00 2001
From: Johannes Weiner 
Date: Mon, 26 Nov 2018 09:39:23 -0500
Subject: [PATCH] psi: make disabling/enabling easier for vendor kernels

Mel Gorman reports a hackbench regression with psi that would prohibit
shipping the suse kernel with it default-enabled, but he'd still like
users to be able to opt in at little to no cost to others.

With the current combination of CONFIG_PSI and the psi_disabled bool
set from the commandline, this is a challenge. Do the following things
to make it easier:

1. Add a config option CONFIG_PSI_DEFAULT_ENABLED that allows distros
   to enable CONFIG_PSI in their kernel, but leaving the feature
   disabled unless a user requests it at boot-time.

   To avoid double negatives, rename psi_disabled= to psi=.

2. Make psi_disabled a static branch to eliminate any branch costs
   when the feature is disabled.

Reported-by: Mel Gorman 
Signed-off-by: Johannes Weiner 
---
 .../admin-guide/kernel-parameters.txt |  4 +++
 include/linux/psi.h   |  3 +-
 init/Kconfig  |  9 ++
 kernel/sched/psi.c| 30 +--
 kernel/sched/stats.h  |  8 ++---
 5 files changed, 40 insertions(+), 14 deletions(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt 
b/Documentation/admin-guide/kernel-parameters.txt
index 19f4423e70d9..8760a343c6d8 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -3504,6 +3504,10 @@
before loading.
See Documentation/blockdev/ramdisk.txt.
 
+   psi=[KNL] Enable or disable pressure stall information
+   tracking.
+   Format: 
+
psmouse.proto=  [HW,MOUSE] Highest PS2 mouse protocol extension to
probe for; one of (bare|imps|exps|lifebook|any).
psmouse.rate=   [HW,MOUSE] Set desired mouse report rate, in reports
diff --git a/include/linux/psi.h b/include/linux/psi.h
index 8e0725aac0aa..7006008d5b72 100644
--- a/include/linux/psi.h
+++ b/include/linux/psi.h
@@ -1,6 +1,7 @@
 #ifndef _LINUX_PSI_H
 #define _LINUX_PSI_H
 
+#include 
 #include 
 #include 
 
@@ -9,7 +10,7 @@ struct css_set;
 
 #ifdef CONFIG_PSI
 
-extern bool psi_disabled;
+extern struct static_key_false psi_disabled;
 
 void psi_init(void);
 
diff --git a/init/Kconfig b/init/Kconfig
index a4112e95724a..cf5b5a0dcbc2 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -509,6 +509,15 @@ config PSI
 
  Say N if unsure.
 
+config PSI_DEFAULT_DISABLED
+   bool "Require boot parameter to enable pressure stall information 
tracking"
+   default n
+   depends on PSI
+   help
+ If set, pressure stall information tracking will be disabled
+ per default but can be enabled through passing 

Re: Hackbench pipes regression bisected to PSI

2018-11-26 Thread Johannes Weiner
On Mon, Nov 26, 2018 at 04:54:47PM +, Mel Gorman wrote:
> On Mon, Nov 26, 2018 at 11:07:24AM -0500, Johannes Weiner wrote:
> > @@ -509,6 +509,15 @@ config PSI
> >  
> >   Say N if unsure.
> >  
> > +config PSI_DEFAULT_DISABLED
> > +   bool "Require boot parameter to enable pressure stall information 
> > tracking"
> > +   default n
> > +   depends on PSI
> > +   help
> > + If set, pressure stall information tracking will be disabled
> > + per default but can be enabled through passing psi_enable=1
> > + on the kernel commandline during boot.
> > +
> >  endmenu # "CPU/Task time and stats accounting"
> >  
> 
> Should this default y on the basis that someone only wants the feature if
> they are aware of it? This is not that important as CONFIG_PSI is disabled
> by default and it's up to distribution maintainers to use their brain.

I went with the NUMA balancing example again here, which defaults to
enabling the feature at boot time. IMO that makes sense, as somebody
would presumably first read through the PSI help text, then decide y
on that before being asked the second question. A "yes, but
" for vendor kernels seems more appropriate than
requiring a double yes for other users to simply get the feature.

> > @@ -136,8 +136,18 @@
> >  
> >  static int psi_bug __read_mostly;
> >  
> > -bool psi_disabled __read_mostly;
> > -core_param(psi_disabled, psi_disabled, bool, 0644);
> > +DEFINE_STATIC_KEY_FALSE(psi_disabled);
> > +
> > +#ifdef CONFIG_PSI_DEFAULT_DISABLED
> > +bool psi_enable;
> > +#else
> > +bool psi_enable = true;
> > +#endif
> > +static int __init parse_psi_enable(char *str)
> > +{
> > +   return kstrtobool(str, _enable) == 0;
> > +}
> > +__setup("psi_enable=", parse_psi_enable);
> >  
> 
> Bit late to notice but this switch should be in
> Documentation/admin-guide/kernel-parameters.txt. If you really want to
> match the automatic numa balancing switch then it also should be
> psi=[enable|disable] instead of psi_enable=[1|0]

Done and done, thanks. Updated patch:

---

>From 694ae3d82da06ca57bfaa775140941ac5e8f2e37 Mon Sep 17 00:00:00 2001
From: Johannes Weiner 
Date: Mon, 26 Nov 2018 09:39:23 -0500
Subject: [PATCH] psi: make disabling/enabling easier for vendor kernels

Mel Gorman reports a hackbench regression with psi that would prohibit
shipping the suse kernel with it default-enabled, but he'd still like
users to be able to opt in at little to no cost to others.

With the current combination of CONFIG_PSI and the psi_disabled bool
set from the commandline, this is a challenge. Do the following things
to make it easier:

1. Add a config option CONFIG_PSI_DEFAULT_ENABLED that allows distros
   to enable CONFIG_PSI in their kernel, but leaving the feature
   disabled unless a user requests it at boot-time.

   To avoid double negatives, rename psi_disabled= to psi=.

2. Make psi_disabled a static branch to eliminate any branch costs
   when the feature is disabled.

Reported-by: Mel Gorman 
Signed-off-by: Johannes Weiner 
---
 .../admin-guide/kernel-parameters.txt |  4 +++
 include/linux/psi.h   |  3 +-
 init/Kconfig  |  9 ++
 kernel/sched/psi.c| 30 +--
 kernel/sched/stats.h  |  8 ++---
 5 files changed, 40 insertions(+), 14 deletions(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt 
b/Documentation/admin-guide/kernel-parameters.txt
index 19f4423e70d9..8760a343c6d8 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -3504,6 +3504,10 @@
before loading.
See Documentation/blockdev/ramdisk.txt.
 
+   psi=[KNL] Enable or disable pressure stall information
+   tracking.
+   Format: 
+
psmouse.proto=  [HW,MOUSE] Highest PS2 mouse protocol extension to
probe for; one of (bare|imps|exps|lifebook|any).
psmouse.rate=   [HW,MOUSE] Set desired mouse report rate, in reports
diff --git a/include/linux/psi.h b/include/linux/psi.h
index 8e0725aac0aa..7006008d5b72 100644
--- a/include/linux/psi.h
+++ b/include/linux/psi.h
@@ -1,6 +1,7 @@
 #ifndef _LINUX_PSI_H
 #define _LINUX_PSI_H
 
+#include 
 #include 
 #include 
 
@@ -9,7 +10,7 @@ struct css_set;
 
 #ifdef CONFIG_PSI
 
-extern bool psi_disabled;
+extern struct static_key_false psi_disabled;
 
 void psi_init(void);
 
diff --git a/init/Kconfig b/init/Kconfig
index a4112e95724a..cf5b5a0dcbc2 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -509,6 +509,15 @@ config PSI
 
  Say N if unsure.
 
+config PSI_DEFAULT_DISABLED
+   bool "Require boot parameter to enable pressure stall information 
tracking"
+   default n
+   depends on PSI
+   help
+ If set, pressure stall information tracking will be disabled
+ per default but can be enabled through passing 

Re: Hackbench pipes regression bisected to PSI

2018-11-26 Thread Mel Gorman
On Mon, Nov 26, 2018 at 11:07:24AM -0500, Johannes Weiner wrote:
> Hi Mel,
> 
> On Mon, Nov 26, 2018 at 01:34:20PM +, Mel Gorman wrote:
> > Hi Johannes,
> > 
> > PSI is a great idea but it does have overhead and if enabled by Kconfig
> > then it incurs a hit whether the user is aware of the feature or not. I
> > think enabling by default is unnecessary as it should only be enabled if
> > the information is being consumed. While the Kconfig exists, it's all or
> > nothing if distributions want to have the feature available.
> 
> Yes, let's make this easier to pick and choose. Obviously I'd rather
> you shipped it default-disabled than not at all.
> 

Indeed.

> > I've included a bisection report below showing a 6-10% regression on a
> > single socket skylake machine. Would you mind doing one or all of the
> > following to fix it please?
> > 
> > a) disable it by default
> > b) put psi_disable behind a static branch to move the overhead to zero
> >if it's disabled
> > c) optionally enable/disable at runtime (least important as at a glance,
> >this may be problematic)
> 
> For a) I'd suggest we do what we do in other places that face this
> vendor kernel trade-off (NUMA balancing comes to mind): one option to
> build the feature, one option to set whether the default is on or off.
> 

That would be fine and makes sense.

> And b) is pretty straight-forward, let's do that too.
> 

Thanks.

> c) is not possible, as we need the complete task counts to calculate
> pressure, and maintaining those counts are where the sched cost is.
> 

I figured that this would be the case.

> > Last good/First bad commit
> > ==
> > Last good commit: eb414681d5a07d28d2ff90dc05f69ec6b232ebd2
> > First bad commit: 2ce7135adc9ad081aa3c49744144376ac74fea60
> > From 2ce7135adc9ad081aa3c49744144376ac74fea60 Mon Sep 17 00:00:00 2001
> > From: Johannes Weiner 
> > Date: Fri, 26 Oct 2018 15:06:31 -0700
> > Subject: [PATCH] psi: cgroup support
> > On a system that executes multiple cgrouped jobs and independent
> > workloads, we don't just care about the health of the overall system, but
> > also that of individual jobs, so that we can ensure individual job health,
> > fairness between jobs, or prioritize some jobs over others.
> > This patch implements pressure stall tracking for cgroups.  In kernels
> > with CONFIG_PSI=y, cgroup2 groups will have cpu.pressure, memory.pressure,
> > and io.pressure files that track aggregate pressure stall times for only
> > the tasks inside the cgroup.
> 
> It's curious that the cgroup support patch is the offender, not the
> psi patch itself (that adds some cost as per the hackbench results,
> but not as much). What kind of cgroup setup does this code run in?
> 

No cgroup is setup but given that it is an automatic bisection, it's not
very unusual for it to get "close" but not get it exactly right.

> Anyway, how about the following?
> 

I've queued it up setting CONFIG_PSI_DEFAULT_DISABLED in the Kconfig.

> 
>
> diff --git a/init/Kconfig b/init/Kconfig
> index a4112e95724a..cf5b5a0dcbc2 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -509,6 +509,15 @@ config PSI
>  
> Say N if unsure.
>  
> +config PSI_DEFAULT_DISABLED
> + bool "Require boot parameter to enable pressure stall information 
> tracking"
> + default n
> + depends on PSI
> + help
> +   If set, pressure stall information tracking will be disabled
> +   per default but can be enabled through passing psi_enable=1
> +   on the kernel commandline during boot.
> +
>  endmenu # "CPU/Task time and stats accounting"
>  

Should this default y on the basis that someone only wants the feature if
they are aware of it? This is not that important as CONFIG_PSI is disabled
by default and it's up to distribution maintainers to use their brain.

>  config CPU_ISOLATION
> diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
> index 3d7355d7c3e3..9da0af3cd898 100644
> --- a/kernel/sched/psi.c
> +++ b/kernel/sched/psi.c
> @@ -136,8 +136,18 @@
>  
>  static int psi_bug __read_mostly;
>  
> -bool psi_disabled __read_mostly;
> -core_param(psi_disabled, psi_disabled, bool, 0644);
> +DEFINE_STATIC_KEY_FALSE(psi_disabled);
> +
> +#ifdef CONFIG_PSI_DEFAULT_DISABLED
> +bool psi_enable;
> +#else
> +bool psi_enable = true;
> +#endif
> +static int __init parse_psi_enable(char *str)
> +{
> + return kstrtobool(str, _enable) == 0;
> +}
> +__setup("psi_enable=", parse_psi_enable);
>  

Bit late to notice but this switch should be in
Documentation/admin-guide/kernel-parameters.txt. If you really want to
match the automatic numa balancing switch then it also should be
psi=[enable|disable] instead of psi_enable=[1|0]

-- 
Mel Gorman
SUSE Labs


Re: Hackbench pipes regression bisected to PSI

2018-11-26 Thread Mel Gorman
On Mon, Nov 26, 2018 at 11:07:24AM -0500, Johannes Weiner wrote:
> Hi Mel,
> 
> On Mon, Nov 26, 2018 at 01:34:20PM +, Mel Gorman wrote:
> > Hi Johannes,
> > 
> > PSI is a great idea but it does have overhead and if enabled by Kconfig
> > then it incurs a hit whether the user is aware of the feature or not. I
> > think enabling by default is unnecessary as it should only be enabled if
> > the information is being consumed. While the Kconfig exists, it's all or
> > nothing if distributions want to have the feature available.
> 
> Yes, let's make this easier to pick and choose. Obviously I'd rather
> you shipped it default-disabled than not at all.
> 

Indeed.

> > I've included a bisection report below showing a 6-10% regression on a
> > single socket skylake machine. Would you mind doing one or all of the
> > following to fix it please?
> > 
> > a) disable it by default
> > b) put psi_disable behind a static branch to move the overhead to zero
> >if it's disabled
> > c) optionally enable/disable at runtime (least important as at a glance,
> >this may be problematic)
> 
> For a) I'd suggest we do what we do in other places that face this
> vendor kernel trade-off (NUMA balancing comes to mind): one option to
> build the feature, one option to set whether the default is on or off.
> 

That would be fine and makes sense.

> And b) is pretty straight-forward, let's do that too.
> 

Thanks.

> c) is not possible, as we need the complete task counts to calculate
> pressure, and maintaining those counts are where the sched cost is.
> 

I figured that this would be the case.

> > Last good/First bad commit
> > ==
> > Last good commit: eb414681d5a07d28d2ff90dc05f69ec6b232ebd2
> > First bad commit: 2ce7135adc9ad081aa3c49744144376ac74fea60
> > From 2ce7135adc9ad081aa3c49744144376ac74fea60 Mon Sep 17 00:00:00 2001
> > From: Johannes Weiner 
> > Date: Fri, 26 Oct 2018 15:06:31 -0700
> > Subject: [PATCH] psi: cgroup support
> > On a system that executes multiple cgrouped jobs and independent
> > workloads, we don't just care about the health of the overall system, but
> > also that of individual jobs, so that we can ensure individual job health,
> > fairness between jobs, or prioritize some jobs over others.
> > This patch implements pressure stall tracking for cgroups.  In kernels
> > with CONFIG_PSI=y, cgroup2 groups will have cpu.pressure, memory.pressure,
> > and io.pressure files that track aggregate pressure stall times for only
> > the tasks inside the cgroup.
> 
> It's curious that the cgroup support patch is the offender, not the
> psi patch itself (that adds some cost as per the hackbench results,
> but not as much). What kind of cgroup setup does this code run in?
> 

No cgroup is setup but given that it is an automatic bisection, it's not
very unusual for it to get "close" but not get it exactly right.

> Anyway, how about the following?
> 

I've queued it up setting CONFIG_PSI_DEFAULT_DISABLED in the Kconfig.

> 
>
> diff --git a/init/Kconfig b/init/Kconfig
> index a4112e95724a..cf5b5a0dcbc2 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -509,6 +509,15 @@ config PSI
>  
> Say N if unsure.
>  
> +config PSI_DEFAULT_DISABLED
> + bool "Require boot parameter to enable pressure stall information 
> tracking"
> + default n
> + depends on PSI
> + help
> +   If set, pressure stall information tracking will be disabled
> +   per default but can be enabled through passing psi_enable=1
> +   on the kernel commandline during boot.
> +
>  endmenu # "CPU/Task time and stats accounting"
>  

Should this default y on the basis that someone only wants the feature if
they are aware of it? This is not that important as CONFIG_PSI is disabled
by default and it's up to distribution maintainers to use their brain.

>  config CPU_ISOLATION
> diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
> index 3d7355d7c3e3..9da0af3cd898 100644
> --- a/kernel/sched/psi.c
> +++ b/kernel/sched/psi.c
> @@ -136,8 +136,18 @@
>  
>  static int psi_bug __read_mostly;
>  
> -bool psi_disabled __read_mostly;
> -core_param(psi_disabled, psi_disabled, bool, 0644);
> +DEFINE_STATIC_KEY_FALSE(psi_disabled);
> +
> +#ifdef CONFIG_PSI_DEFAULT_DISABLED
> +bool psi_enable;
> +#else
> +bool psi_enable = true;
> +#endif
> +static int __init parse_psi_enable(char *str)
> +{
> + return kstrtobool(str, _enable) == 0;
> +}
> +__setup("psi_enable=", parse_psi_enable);
>  

Bit late to notice but this switch should be in
Documentation/admin-guide/kernel-parameters.txt. If you really want to
match the automatic numa balancing switch then it also should be
psi=[enable|disable] instead of psi_enable=[1|0]

-- 
Mel Gorman
SUSE Labs


Re: Hackbench pipes regression bisected to PSI

2018-11-26 Thread Johannes Weiner
Hi Mel,

On Mon, Nov 26, 2018 at 01:34:20PM +, Mel Gorman wrote:
> Hi Johannes,
> 
> PSI is a great idea but it does have overhead and if enabled by Kconfig
> then it incurs a hit whether the user is aware of the feature or not. I
> think enabling by default is unnecessary as it should only be enabled if
> the information is being consumed. While the Kconfig exists, it's all or
> nothing if distributions want to have the feature available.

Yes, let's make this easier to pick and choose. Obviously I'd rather
you shipped it default-disabled than not at all.

> I've included a bisection report below showing a 6-10% regression on a
> single socket skylake machine. Would you mind doing one or all of the
> following to fix it please?
> 
> a) disable it by default
> b) put psi_disable behind a static branch to move the overhead to zero
>if it's disabled
> c) optionally enable/disable at runtime (least important as at a glance,
>this may be problematic)

For a) I'd suggest we do what we do in other places that face this
vendor kernel trade-off (NUMA balancing comes to mind): one option to
build the feature, one option to set whether the default is on or off.

And b) is pretty straight-forward, let's do that too.

c) is not possible, as we need the complete task counts to calculate
pressure, and maintaining those counts are where the sched cost is.

> Last good/First bad commit
> ==
> Last good commit: eb414681d5a07d28d2ff90dc05f69ec6b232ebd2
> First bad commit: 2ce7135adc9ad081aa3c49744144376ac74fea60
> From 2ce7135adc9ad081aa3c49744144376ac74fea60 Mon Sep 17 00:00:00 2001
> From: Johannes Weiner 
> Date: Fri, 26 Oct 2018 15:06:31 -0700
> Subject: [PATCH] psi: cgroup support
> On a system that executes multiple cgrouped jobs and independent
> workloads, we don't just care about the health of the overall system, but
> also that of individual jobs, so that we can ensure individual job health,
> fairness between jobs, or prioritize some jobs over others.
> This patch implements pressure stall tracking for cgroups.  In kernels
> with CONFIG_PSI=y, cgroup2 groups will have cpu.pressure, memory.pressure,
> and io.pressure files that track aggregate pressure stall times for only
> the tasks inside the cgroup.

It's curious that the cgroup support patch is the offender, not the
psi patch itself (that adds some cost as per the hackbench results,
but not as much). What kind of cgroup setup does this code run in?

Anyway, how about the following?

>From 6ae33455b8083fc9f5d5fbfe971f70253b0dbacd Mon Sep 17 00:00:00 2001
From: Johannes Weiner 
Date: Mon, 26 Nov 2018 09:39:23 -0500
Subject: [PATCH] psi: make disabling/enabling easier for vendor kernels

Mel Gorman reports a hackbench regression with psi that would prohibit
shipping the suse kernel with it default-enabled, but he'd still like
users to be able to opt in at little to no cost to others.

With the current combination of CONFIG_PSI and the psi_disabled bool
set from the commandline, this is a challenge. Do the following things
to make it easier:

1. Add a config option CONFIG_PSI_DEFAULT_ENABLED that allows distros
   to enable CONFIG_PSI in their kernel, but leaving the feature
   disabled unless a user requests it at boot-time.

   To avoid double negatives, rename psi_disabled= to psi_enable=.

2. Make psi_disabled a static branch to eliminate any branch costs
   when the feature is disabled.

Reported-by: Mel Gorman 
Signed-off-by: Johannes Weiner 
---
 include/linux/psi.h  |  3 ++-
 init/Kconfig |  9 +
 kernel/sched/psi.c   | 30 +-
 kernel/sched/stats.h |  8 
 4 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/include/linux/psi.h b/include/linux/psi.h
index 8e0725aac0aa..7006008d5b72 100644
--- a/include/linux/psi.h
+++ b/include/linux/psi.h
@@ -1,6 +1,7 @@
 #ifndef _LINUX_PSI_H
 #define _LINUX_PSI_H
 
+#include 
 #include 
 #include 
 
@@ -9,7 +10,7 @@ struct css_set;
 
 #ifdef CONFIG_PSI
 
-extern bool psi_disabled;
+extern struct static_key_false psi_disabled;
 
 void psi_init(void);
 
diff --git a/init/Kconfig b/init/Kconfig
index a4112e95724a..cf5b5a0dcbc2 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -509,6 +509,15 @@ config PSI
 
  Say N if unsure.
 
+config PSI_DEFAULT_DISABLED
+   bool "Require boot parameter to enable pressure stall information 
tracking"
+   default n
+   depends on PSI
+   help
+ If set, pressure stall information tracking will be disabled
+ per default but can be enabled through passing psi_enable=1
+ on the kernel commandline during boot.
+
 endmenu # "CPU/Task time and stats accounting"
 
 config CPU_ISOLATION
diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
index 3d7355d7c3e3..9da0af3cd898 100644
--- a/kernel/sched/psi.c
+++ b/kernel/sched/psi.c
@@ -136,8 +136,18 @@
 
 static int psi_bug __read_mostly;
 
-bool psi_disabled __read_mostly;
-core_param(psi_disabled, 

Re: Hackbench pipes regression bisected to PSI

2018-11-26 Thread Johannes Weiner
Hi Mel,

On Mon, Nov 26, 2018 at 01:34:20PM +, Mel Gorman wrote:
> Hi Johannes,
> 
> PSI is a great idea but it does have overhead and if enabled by Kconfig
> then it incurs a hit whether the user is aware of the feature or not. I
> think enabling by default is unnecessary as it should only be enabled if
> the information is being consumed. While the Kconfig exists, it's all or
> nothing if distributions want to have the feature available.

Yes, let's make this easier to pick and choose. Obviously I'd rather
you shipped it default-disabled than not at all.

> I've included a bisection report below showing a 6-10% regression on a
> single socket skylake machine. Would you mind doing one or all of the
> following to fix it please?
> 
> a) disable it by default
> b) put psi_disable behind a static branch to move the overhead to zero
>if it's disabled
> c) optionally enable/disable at runtime (least important as at a glance,
>this may be problematic)

For a) I'd suggest we do what we do in other places that face this
vendor kernel trade-off (NUMA balancing comes to mind): one option to
build the feature, one option to set whether the default is on or off.

And b) is pretty straight-forward, let's do that too.

c) is not possible, as we need the complete task counts to calculate
pressure, and maintaining those counts are where the sched cost is.

> Last good/First bad commit
> ==
> Last good commit: eb414681d5a07d28d2ff90dc05f69ec6b232ebd2
> First bad commit: 2ce7135adc9ad081aa3c49744144376ac74fea60
> From 2ce7135adc9ad081aa3c49744144376ac74fea60 Mon Sep 17 00:00:00 2001
> From: Johannes Weiner 
> Date: Fri, 26 Oct 2018 15:06:31 -0700
> Subject: [PATCH] psi: cgroup support
> On a system that executes multiple cgrouped jobs and independent
> workloads, we don't just care about the health of the overall system, but
> also that of individual jobs, so that we can ensure individual job health,
> fairness between jobs, or prioritize some jobs over others.
> This patch implements pressure stall tracking for cgroups.  In kernels
> with CONFIG_PSI=y, cgroup2 groups will have cpu.pressure, memory.pressure,
> and io.pressure files that track aggregate pressure stall times for only
> the tasks inside the cgroup.

It's curious that the cgroup support patch is the offender, not the
psi patch itself (that adds some cost as per the hackbench results,
but not as much). What kind of cgroup setup does this code run in?

Anyway, how about the following?

>From 6ae33455b8083fc9f5d5fbfe971f70253b0dbacd Mon Sep 17 00:00:00 2001
From: Johannes Weiner 
Date: Mon, 26 Nov 2018 09:39:23 -0500
Subject: [PATCH] psi: make disabling/enabling easier for vendor kernels

Mel Gorman reports a hackbench regression with psi that would prohibit
shipping the suse kernel with it default-enabled, but he'd still like
users to be able to opt in at little to no cost to others.

With the current combination of CONFIG_PSI and the psi_disabled bool
set from the commandline, this is a challenge. Do the following things
to make it easier:

1. Add a config option CONFIG_PSI_DEFAULT_ENABLED that allows distros
   to enable CONFIG_PSI in their kernel, but leaving the feature
   disabled unless a user requests it at boot-time.

   To avoid double negatives, rename psi_disabled= to psi_enable=.

2. Make psi_disabled a static branch to eliminate any branch costs
   when the feature is disabled.

Reported-by: Mel Gorman 
Signed-off-by: Johannes Weiner 
---
 include/linux/psi.h  |  3 ++-
 init/Kconfig |  9 +
 kernel/sched/psi.c   | 30 +-
 kernel/sched/stats.h |  8 
 4 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/include/linux/psi.h b/include/linux/psi.h
index 8e0725aac0aa..7006008d5b72 100644
--- a/include/linux/psi.h
+++ b/include/linux/psi.h
@@ -1,6 +1,7 @@
 #ifndef _LINUX_PSI_H
 #define _LINUX_PSI_H
 
+#include 
 #include 
 #include 
 
@@ -9,7 +10,7 @@ struct css_set;
 
 #ifdef CONFIG_PSI
 
-extern bool psi_disabled;
+extern struct static_key_false psi_disabled;
 
 void psi_init(void);
 
diff --git a/init/Kconfig b/init/Kconfig
index a4112e95724a..cf5b5a0dcbc2 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -509,6 +509,15 @@ config PSI
 
  Say N if unsure.
 
+config PSI_DEFAULT_DISABLED
+   bool "Require boot parameter to enable pressure stall information 
tracking"
+   default n
+   depends on PSI
+   help
+ If set, pressure stall information tracking will be disabled
+ per default but can be enabled through passing psi_enable=1
+ on the kernel commandline during boot.
+
 endmenu # "CPU/Task time and stats accounting"
 
 config CPU_ISOLATION
diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
index 3d7355d7c3e3..9da0af3cd898 100644
--- a/kernel/sched/psi.c
+++ b/kernel/sched/psi.c
@@ -136,8 +136,18 @@
 
 static int psi_bug __read_mostly;
 
-bool psi_disabled __read_mostly;
-core_param(psi_disabled,