1 Star 0 Fork 49

YYNA/systemd

forked from src-anolis-os/systemd 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0407-cgroup-Create-UNIT_DEFINE_ANCESTOR_MEMORY_LOOKUP.patch 3.65 KB
一键复制 编辑 原始数据 按行查看 历史
geliwei 提交于 2021-06-16 16:46 . update to systemd-239-45.el8.src.rpm
From a016ef4ab29ed62da547db008866624f75ed6407 Mon Sep 17 00:00:00 2001
From: Chris Down <chris@chrisdown.name>
Date: Tue, 16 Apr 2019 18:14:09 +0100
Subject: [PATCH] cgroup: Create UNIT_DEFINE_ANCESTOR_MEMORY_LOOKUP
This is in preparation for creating unit_get_ancestor_memory_min.
(cherry picked from commit 6264b85e92aeddb74b8d8808a08c9eae8390a6a5)
Related: #1763435
---
src/core/cgroup.c | 55 ++++++++++++++++++++++++++---------------------
1 file changed, 30 insertions(+), 25 deletions(-)
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index f804bf4727..46a89ff5e1 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -372,31 +372,36 @@ int cgroup_add_device_allow(CGroupContext *c, const char *dev, const char *mode)
return 0;
}
-uint64_t unit_get_ancestor_memory_low(Unit *u) {
- CGroupContext *c;
-
- /* 1. Is MemoryLow set in this unit? If so, use that.
- * 2. Is DefaultMemoryLow set in any ancestor? If so, use that.
- * 3. Otherwise, return CGROUP_LIMIT_MIN. */
-
- assert(u);
-
- c = unit_get_cgroup_context(u);
-
- if (c->memory_low_set)
- return c->memory_low;
-
- while (UNIT_ISSET(u->slice)) {
- u = UNIT_DEREF(u->slice);
- c = unit_get_cgroup_context(u);
-
- if (c->default_memory_low_set)
- return c->default_memory_low;
- }
-
- /* We've reached the root, but nobody had DefaultMemoryLow set, so set it to the kernel default. */
- return CGROUP_LIMIT_MIN;
-}
+#define UNIT_DEFINE_ANCESTOR_MEMORY_LOOKUP(entry) \
+ uint64_t unit_get_ancestor_##entry(Unit *u) { \
+ CGroupContext *c; \
+ \
+ /* 1. Is entry set in this unit? If so, use that. \
+ * 2. Is the default for this entry set in any \
+ * ancestor? If so, use that. \
+ * 3. Otherwise, return CGROUP_LIMIT_MIN. */ \
+ \
+ assert(u); \
+ \
+ c = unit_get_cgroup_context(u); \
+ \
+ if (c->entry##_set) \
+ return c->entry; \
+ \
+ while (UNIT_ISSET(u->slice)) { \
+ u = UNIT_DEREF(u->slice); \
+ c = unit_get_cgroup_context(u); \
+ \
+ if (c->default_##entry##_set) \
+ return c->default_##entry; \
+ } \
+ \
+ /* We've reached the root, but nobody had default for \
+ * this entry set, so set it to the kernel default. */ \
+ return CGROUP_LIMIT_MIN; \
+}
+
+UNIT_DEFINE_ANCESTOR_MEMORY_LOOKUP(memory_low);
static int lookup_block_device(const char *p, dev_t *ret) {
struct stat st;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ful9/systemd.git
git@gitee.com:ful9/systemd.git
ful9
systemd
systemd
a8

搜索帮助

0d507c66 1850385 C8b1a773 1850385