[Devel] [PATCH RHEL8 COMMIT] kernel/cgroup: rename css_get_local_root
Konstantin Khorenko
khorenko at virtuozzo.com
Tue Jul 20 12:34:53 MSK 2021
The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.59
------>
commit 6ec28f0bf1e63002eac534b3f67ef17e5c7543d6
Author: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
Date: Tue Jul 20 12:34:53 2021 +0300
kernel/cgroup: rename css_get_local_root
css functions with _get_ wording usually take reference counters.
Rename to css_local_root() to comply. Change all uses accordingly.
To_merge: 849dc660c95a ("ve/device_cgroup: Show all devices allowed in ct to
fool docker")
https://jira.sw.ru/browse/PSBM-131253
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
Reviewed-by: Kirill Tkhai <ktkhai at virtuozzo.com>
==========================
mm/writeback: Adopt cgroup-v2 writeback (limit per-memcg dirty memory)
In cgroup-v1 all writeback IO is accounted to root blkcg by design. With
cgroup-v2 it became possible to link memcg and blkcg, so writeback code
was enhanced to
1) consider balancing dirty pages per memory cgroup
2) account writeback generated IO to blkcg
In vz7 writeback was balancing by means of beancounter cgroup. However we
dropped it.
In vz8 @aryabinin tried to enable cgroup-v2 writeback with 5cc286c98ee20
("mm, cgroup, writeback: Enable per-cgroup writeback for v1 cgroup."),
but cgroup_get_e_css(), which is used to find blkcg based on memcg,
does not work well with cgroup-v1 and always returns root blkcg.
However we can implement a new function to associate blkcg with memcg via
ve css_set.
Test results with 256M container without patch:
===============================================
# echo "253:22358 100000000" > /sys/fs/cgroup/blkio/machine.slice/1/blkio.throttle.write_bps_device
# vzctl exec 1 dd if=/dev/zero of=/test bs=1M count=1000
# 1048576000 bytes (1.0 GB, 1000 MiB) copied, 1.35522 s, 774 MB/s
Since dirty balancing is global, Container can dirty more than it's RAM
and blkio limits are not respected.
With patch:
===========
# echo "253:22765 100000000" > /sys/fs/cgroup/blkio/machine.slice/1/blkio.throttle.write_bps_device
# vzctl exec 1 dd if=/dev/zero of=/test bs=1M count=1000
# 1048576000 bytes (1.0 GB, 1000 MiB) copied, 10.2267 s, 103 MB/s
Per-ve dirty balancing and throttling work as expected.
v2:
Since ve->ve_ns is pointing to task nsproxy, it can be changed during ve
lifetime. We already have a helper ve_get_init_css() that handles this
case, so I decided to reuse it's code in new cgroup_get_e_ve_css().
Additionally I have added two patches that improve current code:
1) drop 'get' from css_get_local_root() name since get with css functions
usually results in taking reference
2) drop duplicate code and reuse css_local_root() helper in
ve_get_init_css()
Andrey Zhadchenko (4):
kernel/cgroup: rename css_get_local_root
kernel/ve: simplify ve_get_init_css
kernel/cgroup: implement cgroup_get_e_ve_css
mm/backing-dev: associate writeback with correct blkcg
---
include/linux/cgroup.h | 2 +-
kernel/cgroup/cgroup.c | 2 +-
security/device_cgroup.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 7cf6e1e69242..1223bc8d4b36 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -874,7 +874,7 @@ void cgroup1_release_agent(struct work_struct *work);
#ifdef CONFIG_VE
int cgroup_mark_ve_roots(struct ve_struct *ve);
void cgroup_unmark_ve_roots(struct ve_struct *ve);
-struct cgroup_subsys_state *css_get_local_root(struct cgroup_subsys_state *css);
+struct cgroup_subsys_state *css_local_root(struct cgroup_subsys_state *css);
struct ve_struct *cgroup_get_ve_owner(struct cgroup *cgrp);
#endif
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 1bc15fb9802c..57ff462c551a 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -329,7 +329,7 @@ struct cgroup *cgroup_get_local_root(struct cgroup *cgrp)
return cgrp;
}
-struct cgroup_subsys_state *css_get_local_root(struct cgroup_subsys_state *css)
+struct cgroup_subsys_state *css_local_root(struct cgroup_subsys_state *css)
{
/*
* Find css for nearest "root" cgroup, which might be
diff --git a/security/device_cgroup.c b/security/device_cgroup.c
index 98bbd9561cd7..5b64765621ea 100644
--- a/security/device_cgroup.c
+++ b/security/device_cgroup.c
@@ -328,7 +328,7 @@ static int devcgroup_seq_show(struct seq_file *m, void *v)
* as in ve root cgroup - show as if we allow everyting
*/
if (!ve_is_super(get_exec_env())) {
- root_css = css_get_local_root(seq_css(m));
+ root_css = css_local_root(seq_css(m));
root_cgrp = css_to_devcgroup(root_css);
if (dev_exceptions_equal(&devcgroup->exceptions,
More information about the Devel
mailing list