代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/systemd 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From d98169555c07668d999ac8ad62718da0ae9eec0f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Date: Wed, 10 Nov 2021 11:37:15 +0100
Subject: [PATCH] core/cgroup: use helper macro for bfq conversion
As suggested in https://github.com/systemd/systemd/pull/20522#discussion_r696699984.
(cherry picked from commit 311822ac28c99e2fb0e25286bdb72c9188314a66)
Conflict:NA
Reference:https://github.com/systemd/systemd/commit/d98169555c07668d999ac8ad62718da0ae9eec0f
---
src/core/cgroup.c | 34 ++++++++++++++++------------------
1 file changed, 16 insertions(+), 18 deletions(-)
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index 8b5b403ae8..6e4780f2f6 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -1200,9 +1200,21 @@ static int cgroup_apply_devices(Unit *u) {
return r;
}
+/* Convert the normal io.weight value to io.bfq.weight */
+#define BFQ_WEIGHT(weight) \
+ (weight <= CGROUP_WEIGHT_DEFAULT ? \
+ CGROUP_BFQ_WEIGHT_DEFAULT - (CGROUP_WEIGHT_DEFAULT - weight) * (CGROUP_BFQ_WEIGHT_DEFAULT - CGROUP_BFQ_WEIGHT_MIN) / (CGROUP_WEIGHT_DEFAULT - CGROUP_WEIGHT_MIN) : \
+ CGROUP_BFQ_WEIGHT_DEFAULT + (weight - CGROUP_WEIGHT_DEFAULT) * (CGROUP_BFQ_WEIGHT_MAX - CGROUP_BFQ_WEIGHT_DEFAULT) / (CGROUP_WEIGHT_MAX - CGROUP_WEIGHT_DEFAULT))
+
+assert_cc(BFQ_WEIGHT(1) == 1);
+assert_cc(BFQ_WEIGHT(50) == 50);
+assert_cc(BFQ_WEIGHT(100) == 100);
+assert_cc(BFQ_WEIGHT(500) == 136);
+assert_cc(BFQ_WEIGHT(5000) == 545);
+assert_cc(BFQ_WEIGHT(10000) == 1000);
+
static void set_io_weight(Unit *u, uint64_t weight) {
char buf[STRLEN("default \n")+DECIMAL_STR_MAX(uint64_t)];
- uint64_t bfq_weight;
assert(u);
@@ -1210,12 +1222,7 @@ static void set_io_weight(Unit *u, uint64_t weight) {
* See also: https://github.com/systemd/systemd/pull/13335 and
* https://github.com/torvalds/linux/commit/65752aef0a407e1ef17ec78a7fc31ba4e0b360f9.
* The range is 1..1000 apparently, and the default is 100. */
- if (weight <= CGROUP_WEIGHT_DEFAULT)
- bfq_weight = CGROUP_BFQ_WEIGHT_DEFAULT - (CGROUP_WEIGHT_DEFAULT - weight) * (CGROUP_BFQ_WEIGHT_DEFAULT - CGROUP_BFQ_WEIGHT_MIN) / (CGROUP_WEIGHT_DEFAULT - CGROUP_WEIGHT_MIN);
- else
- bfq_weight = CGROUP_BFQ_WEIGHT_DEFAULT + (weight - CGROUP_WEIGHT_DEFAULT) * (CGROUP_BFQ_WEIGHT_MAX - CGROUP_BFQ_WEIGHT_DEFAULT) / (CGROUP_WEIGHT_MAX - CGROUP_WEIGHT_DEFAULT);
-
- xsprintf(buf, "%" PRIu64 "\n", bfq_weight);
+ xsprintf(buf, "%" PRIu64 "\n", BFQ_WEIGHT(weight));
(void) set_attribute_and_warn(u, "io", "io.bfq.weight", buf);
xsprintf(buf, "default %" PRIu64 "\n", weight);
@@ -1224,20 +1231,11 @@ static void set_io_weight(Unit *u, uint64_t weight) {
static void set_blkio_weight(Unit *u, uint64_t weight) {
char buf[STRLEN("\n")+DECIMAL_STR_MAX(uint64_t)];
- uint64_t bfq_weight;
assert(u);
- /* FIXME: drop this when distro kernels properly support BFQ through "io.weight"
- * See also: https://github.com/systemd/systemd/pull/13335 and
- * https://github.com/torvalds/linux/commit/65752aef0a407e1ef17ec78a7fc31ba4e0b360f9.
- * The range is 1..1000 apparently, and the default is 100. */
- if (weight <= CGROUP_BLKIO_WEIGHT_DEFAULT)
- bfq_weight = CGROUP_BFQ_WEIGHT_DEFAULT - (CGROUP_BLKIO_WEIGHT_DEFAULT - weight) * (CGROUP_BFQ_WEIGHT_DEFAULT - CGROUP_BFQ_WEIGHT_MIN) / (CGROUP_BLKIO_WEIGHT_DEFAULT - CGROUP_BLKIO_WEIGHT_MIN);
- else
- bfq_weight = CGROUP_BFQ_WEIGHT_DEFAULT + (weight - CGROUP_BLKIO_WEIGHT_DEFAULT) * (CGROUP_BFQ_WEIGHT_MAX - CGROUP_BFQ_WEIGHT_DEFAULT) / (CGROUP_BLKIO_WEIGHT_MAX - CGROUP_BLKIO_WEIGHT_DEFAULT);
-
- xsprintf(buf, "%" PRIu64 "\n", bfq_weight);
+ /* FIXME: see comment in set_io_weight(). */
+ xsprintf(buf, "%" PRIu64 "\n", BFQ_WEIGHT(weight));
(void) set_attribute_and_warn(u, "blkio", "blkio.bfq.weight", buf);
xsprintf(buf, "%" PRIu64 "\n", weight);
--
2.33.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。