|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
diff --git a/src/condor_procd/proc_family.cpp b/src/condor_procd/proc_family.cpp
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
index d35ffcc..29d9471 100644
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
--- a/src/condor_procd/proc_family.cpp
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+++ b/src/condor_procd/proc_family.cpp
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
@@ -54,7 +54,9 @@ ProcFamily::ProcFamily(ProcFamilyMonitor* monitor,
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
m_member_list(NULL)
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
#if defined(HAVE_EXT_LIBCGROUP)
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
, m_cgroup_string(""),
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
- m_cm(CgroupManager::getInstance())
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ m_cm(CgroupManager::getInstance()),
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ m_initial_user_cpu(0),
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ m_initial_sys_cpu(0)
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
#endif
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
{
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
#if !defined(WIN32)
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
@@ -188,6 +190,7 @@ after_migrate:
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
cgroup_free(&orig_cgroup);
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
}
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
after_restore:
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
if (orig_cgroup_string != NULL) {
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
free(orig_cgroup_string);
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
@@ -231,6 +234,27 @@ ProcFamily::set_cgroup(const std::string &cgroup_string)
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
member = member->m_next;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
}
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ // Record the amount of pre-existing CPU usage here.
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ m_initial_user_cpu = 0;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ m_initial_sys_cpu = 0;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ get_cpu_usage_cgroup(m_initial_user_cpu, m_initial_sys_cpu);
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ // Reset block IO controller
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ if (m_cm.isMounted(CgroupManager::BLOCK_CONTROLLER)) {
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ struct cgroup *tmp_cgroup = cgroup_new_cgroup(m_cgroup_string.c_str());
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ struct cgroup_controller *blkio_controller = cgroup_add_controller(tmp_cgroup, BLOCK_CONTROLLER_STR);
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ ASSERT (blkio_controller != NULL); // Block IO controller should already exist.
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ cgroup_add_value_uint64(blkio_controller, "blkio.reset_stats", 0);
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ int err;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ if ((err = cgroup_modify_cgroup(tmp_cgroup))) {
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ // Not allowed to reset stats?
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ dprintf(D_ALWAYS,
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ "Unable to reset cgroup %s block IO statistics. "
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ "Some block IO accounting will be inaccurate (ProcFamily %u): %u %s\n",
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ m_cgroup_string.c_str(), m_root_pid, err, cgroup_strerror(err));
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ }
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ }
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
return 0;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
}
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
@@ -486,6 +510,40 @@ ProcFamily::aggregate_usage_cgroup_blockio(ProcFamilyUsage* usage)
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
return 0;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
}
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+int ProcFamily::get_cpu_usage_cgroup(long &user_time, long &sys_time) {
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ if (!m_cm.isMounted(CgroupManager::CPUACCT_CONTROLLER)) {
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ return 1;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ }
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ void * handle = NULL;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ u_int64_t tmp = 0;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ struct cgroup_stat stats;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ int err = cgroup_read_stats_begin(CPUACCT_CONTROLLER_STR, m_cgroup_string.c_str(), &handle, &stats);
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ while (err != ECGEOF) {
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ if (err > 0) {
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ dprintf(D_PROCFAMILY,
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ "Unable to read cgroup %s cpuacct stats (ProcFamily %u): %s.\n",
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ m_cgroup_string.c_str(), m_root_pid, cgroup_strerror(err));
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ break;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ }
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ if (_check_stat_uint64(stats, "user", &tmp)) {
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ user_time = tmp/clock_tick-m_initial_user_cpu;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ } else if (_check_stat_uint64(stats, "system", &tmp)) {
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ sys_time = tmp/clock_tick-m_initial_sys_cpu;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ }
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ err = cgroup_read_stats_next(&handle, &stats);
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ }
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ if (handle != NULL) {
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ cgroup_read_stats_end(&handle);
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ }
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ if (err != ECGEOF) {
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ dprintf(D_ALWAYS, "Internal cgroup error when retrieving CPU statistics: %s\n", cgroup_strerror(err));
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ return 1;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ }
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ return 0;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+}
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
int
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
ProcFamily::aggregate_usage_cgroup(ProcFamilyUsage* usage)
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
{
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
@@ -496,16 +554,13 @@ ProcFamily::aggregate_usage_cgroup(ProcFamilyUsage* usage)
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
int err;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
struct cgroup_stat stats;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
- void **handle;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ void *handle = NULL;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
u_int64_t tmp = 0, image = 0;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
bool found_rss = false;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
// Update memory
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
- handle = (void **)malloc(sizeof(void*));
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
- ASSERT (handle != NULL);
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
- *handle = NULL;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
- err = cgroup_read_stats_begin(MEMORY_CONTROLLER_STR, m_cgroup_string.c_str(), handle, &stats);
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ err = cgroup_read_stats_begin(MEMORY_CONTROLLER_STR, m_cgroup_string.c_str(), &handle, &stats);
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
while (err != ECGEOF) {
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
if (err > 0) {
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
dprintf(D_PROCFAMILY,
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
@@ -522,10 +577,10 @@ ProcFamily::aggregate_usage_cgroup(ProcFamilyUsage* usage)
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
} else if (_check_stat_uint64(stats, "total_swap", &tmp)) {
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
image += tmp;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
}
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
- err = cgroup_read_stats_next(handle, &stats);
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ err = cgroup_read_stats_next(&handle, &stats);
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
}
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
- if (*handle != NULL) {
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
- cgroup_read_stats_end(handle);
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ if (handle != NULL) {
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ cgroup_read_stats_end(&handle);
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
}
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
if (found_rss) {
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
usage->total_image_size = image/1024;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
@@ -540,29 +595,12 @@ ProcFamily::aggregate_usage_cgroup(ProcFamilyUsage* usage)
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
m_max_image_size = image/1024;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
}
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
// Try updating the max size using cgroups
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
- update_max_image_size_cgroup();
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ // XXX: This is taken out for now - kernel calculates max INCLUDING
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ // the filesystem cache. Not what you want.
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ //update_max_image_size_cgroup();
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
// Update CPU
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
- *handle = NULL;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
- err = cgroup_read_stats_begin(CPUACCT_CONTROLLER_STR, m_cgroup_string.c_str(), handle, &stats);
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
- while (err != ECGEOF) {
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
- if (err > 0) {
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
- dprintf(D_PROCFAMILY,
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
- "Unable to read cgroup %s cpuacct stats (ProcFamily %u): %s.\n",
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
- m_cgroup_string.c_str(), m_root_pid, cgroup_strerror(err));
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
- break;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
- }
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
- if (_check_stat_uint64(stats, "user", &tmp)) {
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
- usage->user_cpu_time = tmp/clock_tick;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
- } else if (_check_stat_uint64(stats, "system", &tmp)) {
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
- usage->sys_cpu_time = tmp/clock_tick;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
- }
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
- err = cgroup_read_stats_next(handle, &stats);
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
- }
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
- if (*handle != NULL) {
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
- cgroup_read_stats_end(handle);
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
- }
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
- free(handle);
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ get_cpu_usage_cgroup(usage->user_cpu_time, usage->sys_cpu_time);
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
aggregate_usage_cgroup_blockio(usage);
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
--- a/src/condor_procd/proc_family.h
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+++ b/src/condor_procd/proc_family.h
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
@@ -181,6 +181,11 @@ private:
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
std::string m_cgroup_string;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
CgroupManager &m_cm;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
static long clock_tick;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ // Sometimes Condor doesn't successfully clear out the cgroup from the
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ // previous run. Hence, we subtract off any CPU usage found at the
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ // start of the job.
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ long m_initial_user_cpu;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ long m_initial_sys_cpu;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
static bool have_warned_about_memsw;
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
int count_tasks_cgroup();
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
@@ -190,6 +195,7 @@ private:
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
int spree_cgroup(int);
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
int migrate_to_cgroup(pid_t);
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
void update_max_image_size_cgroup();
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
+ int get_cpu_usage_cgroup(long &user_cpu, long &sys_cpu);
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
#endif
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
};
|
|
![](https://seccdn.libravatar.org/avatar/7953a9093903b1598d828463f294c39ff77c20e7530429a55b48be9a3c3c0f35?s=16&d=retro) |
b3fe293 |
|