yiguolei commented on code in PR #39256:
URL: https://github.com/apache/doris/pull/39256#discussion_r1714193158


##########
be/src/common/cgroup_memory_ctl.cpp:
##########
@@ -0,0 +1,183 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+// This file is copied from
+// 
https://github.com/ClickHouse/ClickHouse/blob/master/src/Common/CgroupsMemoryUsageObserver.cpp
+// and modified by Doris
+
+#include "common/cgroup_memory_ctl.h"
+
+#include <filesystem>
+#include <fstream>
+#include <memory>
+#include <utility>
+
+#include "common/exception.h"
+#include "common/status.h"
+#include "util/cgroup_util.h"
+
+namespace doris {
+
+// Is the memory controller of cgroups v2 enabled on the system?
+// Assumes that cgroupsv2_enable() is enabled.
+bool cgroupsv2_memory_controller_enabled() {
+#if defined(OS_LINUX)
+    assert(cgroupsv2_enable());
+    // According to https://docs.kernel.org/admin-guide/cgroup-v2.html, file 
"cgroup.controllers" defines which controllers are available
+    // for the current + child cgroups. The set of available controllers can 
be restricted from level to level using file
+    // "cgroups.subtree_control". It is therefore sufficient to check the 
bottom-most nested "cgroup.controllers" file.
+    std::string cgroup = CGroupUtil::cgroupv2_of_process();
+    auto cgroup_dir = cgroup.empty() ? default_cgroups_mount : 
(default_cgroups_mount / cgroup);

Review Comment:
   我看这个值是/sys/fs/cgroup"
   如果在k8s 里,在docker 环境下,感觉看不到这个目录



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to