cgroup: fix psi monitor for root cgroup
Subsystems (2)
v2 cover cgroup: fix psi monitor for root cgroup
This patchset fixes PSI monitors on the root cgroup, as they currently only works on the non-root cgroups. Reading works for all, since that was fixed when adding support for the root PSI files. It also contains a doc update to reflect the current implementation.
Changes since v1:
- Added Reviewed-by tag on the original patch (Suren)
- Updated patch title
- Added a separate patch to update doc
Odin Ugedal (2):
cgroup: fix psi monitor for root cgroup
cgroup: update PSI file description in docs
Documentation/admin-guide/cgroup-v2.rst | 6 +++--- kernel/cgroup/cgroup.c | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-)
Signature · 1 line
2.30.0
PATCH v2 1/2 cgroup: fix psi monitor for root cgroup
Fix NULL pointer dereference when adding new psi monitor to the root cgroup. PSI files for root cgroup was introduced in df5ba5be742 by using system wide psi struct when reading, but file write/monitor was not properly fixed. Since the PSI config for the root cgroup isn't initialized, the current implementation tries to lock a NULL ptr, resulting in a crash.
Can be triggered by running this as root:
$ tee /sys/fs/cgroup/cpu.pressure <<< "some 10000 1000000"
--- kernel/cgroup/cgroup.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/cgroup/cgroup.c +3 -1
@@ -3564,6 +3564,7 @@ static ssize_t cgroup_pressure_write(struct kernfs_open_file *of, char *buf, {struct psi_trigger *new;struct cgroup *cgrp; +struct psi_group *psi; cgrp =cgroup_kn_lock_live (of->kn, false);if (!cgrp)
@@ -3572,7 +3573,8 @@ static ssize_t cgroup_pressure_write(struct kernfs_open_file *of, char *buf,cgroup_get (cgrp);cgroup_kn_unlock (of->kn); - new =psi_trigger_create (&cgrp->psi, buf, nbytes, res); + psi =cgroup_ino (cgrp) ==1 ? &psi_system : &cgrp->psi; + new =psi_trigger_create (psi, buf, nbytes, res);if (IS_ERR (new)) {cgroup_put (cgrp);return PTR_ERR (new);
Signature · 1 line
2.30.0
Quoted 7 lines · Odin Ugedal
Fix NULL pointer dereference when adding new psi monitor to the root cgroup. PSI files for root cgroup was introduced in
df5ba5be742by using system wide psi struct when reading, but file write/monitor was not properly fixed. Since the PSI config for the root cgroup isn't initialized, the current implementation tries to lock a NULL ptr, resulting in a crash.
Quoted 5 lines
Can be triggered by running this as root:
$ tee /sys/fs/cgroup/cpu.pressure <<< "some 10000 1000000"Signed-off-by Odin Ugedal <[email protected]>Reviewed-by Suren Baghdasaryan <[email protected]>
Since this is a userspace-triggerable NULL ptr crash, we should probably also
PATCH v2 2/2 cgroup: update PSI file description in docs
In reply to Odin UgedalUpdate PSI file description in cgroup-v2 docs to reflect the current implementation.
--- Documentation/admin-guide/cgroup-v2.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Documentation/admin-guide/cgroup-v2.rst +3 -3
@@ -1029,7 +1029,7 @@ All time durations are in microseconds. one number is written, $MAX is updated. cpu.pressure - A read-only nested-key file which exists on non-root cgroups. + A read-only nested-keyed file. Shows pressure stall information for CPU. See :ref:`Documentation/accounting/psi.rst <psi>` for details.
@@ -1475,7 +1475,7 @@ PAGE_SIZE multiple when read back. reduces the impact on the workload and memory management. memory.pressure - A read-only nested-key file which exists on non-root cgroups. + A read-only nested-keyed file. Shows pressure stall information for memory. See :ref:`Documentation/accounting/psi.rst <psi>` for details.
@@ -1714,7 +1714,7 @@ IO Interface Files 8:16 rbps=2097152 wbps=max riops=max wiops=max io.pressure - A read-only nested-key file which exists on non-root cgroups. + A read-only nested-keyed file. Shows pressure stall information for IO. See :ref:`Documentation/accounting/psi.rst <psi>` for details.
Signature · 1 line
2.30.0
Re: [PATCH v2 2/2] cgroup: update PSI file description in docs
Quoted 13 lines · Odin Ugedal
Update PSI file description in cgroup-v2 docs to reflect the current implementation.
Signed-off-by Odin Ugedal <[email protected]>--- Documentation/admin-guide/cgroup-v2.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)Documentation/admin-guide/cgroup-v2.rst +0
-0
Documentation/admin-guide/cgroup-v2.rst All time durations are in microseconds. · line 1032
Quoted 5 lines
Documentation/admin-guide/cgroup-v2.rst +1
-1@@ -1029,7 +1029,7 @@ All time durations are in microseconds. one number is written, $MAX is updated. cpu.pressure - A read-only nested-key file which exists on non-root cgroups. + A read-only nested-keyed file.
Could you please also change the 'read-only' to 'read-write'?
With that, please feel free to add:
Tejun Heo
maintainerRe: [PATCH v2 2/2] cgroup: update PSI file description in docs
Quoted 16 lines · Johannes Weiner
Quoted 15 lines · Odin Ugedal
Update PSI file description in cgroup-v2 docs to reflect the current implementation.
Signed-off-by Odin Ugedal <[email protected]>--- Documentation/admin-guide/cgroup-v2.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)Documentation/admin-guide/cgroup-v2.rst +0
-0@@ -1029,7 +1029,7 @@ All time durations are in microseconds. one number is written, $MAX is updated.
Quoted 8 lines
Documentation/admin-guide/cgroup-v2.rst All time durations are in microseconds. · line 1032
Quoted 3 lines
Documentation/admin-guide/cgroup-v2.rst +1
-1cpu.pressure - A read-only nested-key file which exists on non-root cgroups. + A read-only nested-keyed file.Could you please also change the 'read-only' to 'read-write'?
With that, please feel free to add:
Acked-by Johannes Weiner <[email protected]>
Applied w/ the suggested change.
Thanks.
Signature · 1 line
tejun
Quoted 11 lines
This patchset fixes PSI monitors on the root cgroup, as they currently only works on the non-root cgroups. Reading works for all, since that was fixed when adding support for the root PSI files. It also contains a doc update to reflect the current implementation.
Changes since v1:
- Added Reviewed-by tag on the original patch (Suren)
- Updated patch title
- Added a separate patch to update doc
Quoted 7 lines
Odin Ugedal (2):
cgroup: fix psi monitor for root cgroup
cgroup: update PSI file description in docsDocumentation/admin-guide/cgroup-v2.rst | 6 +++--- kernel/cgroup/cgroup.c | 4 +++-
2 files changed, 6 insertions(+), 4 deletions(-)
Both patches look good.
Quoted 4 lines · Odin Ugedal
This patchset fixes PSI monitors on the root cgroup, as they currently only works on the non-root cgroups. Reading works for all, since that was fixed when adding support for the root PSI files. It also contains a doc update to reflect the current implementation.
Applied to cgroup/for-5.11-fixes with acks and stable tag added.
Thanks.
Signature · 1 line
tejun