From 18360290e8e1b80638c8cba55267cd652e771a47 Mon Sep 17 00:00:00 2001
From: Tim Wickberg <tim@schedmd.com>
Date: Fri, 8 Sep 2017 11:55:25 -0600
Subject: [PATCH] Remove notify and notify_prog from cgroup code.

Since ReleaseAgent is no longer required, we can strip out
all the supporting logic for it.
---
 src/plugins/task/cgroup/task_cgroup.c        |  5 +--
 src/plugins/task/cgroup/task_cgroup_memory.c | 16 ++------
 src/slurmd/common/slurmd_cgroup.c            | 13 +++----
 src/slurmd/common/xcgroup.c                  | 40 ++------------------
 src/slurmd/common/xcgroup.h                  |  7 ----
 5 files changed, 14 insertions(+), 67 deletions(-)

diff --git a/src/plugins/task/cgroup/task_cgroup.c b/src/plugins/task/cgroup/task_cgroup.c
index e5296a1f90d..71ad6eb1333 100644
--- a/src/plugins/task/cgroup/task_cgroup.c
+++ b/src/plugins/task/cgroup/task_cgroup.c
@@ -325,15 +325,12 @@ extern char* task_cgroup_create_slurm_cg (xcgroup_ns_t* ns) {
 	}
 #endif
 
-	/* create slurm cgroup in the ns (it could already exist)
-	 * disable notify_on_release to avoid the removal/creation
-	 * of this cgroup for each last/first running job on the node */
+	/* create slurm cgroup in the ns (it could already exist) */
 	if (xcgroup_create(ns,&slurm_cg,pre,
 			   getuid(), getgid()) != XCGROUP_SUCCESS) {
 		xfree(pre);
 		return pre;
 	}
-	slurm_cg.notify = 0;
 	if (xcgroup_instantiate(&slurm_cg) != XCGROUP_SUCCESS) {
 		error("unable to build slurm cgroup for ns %s: %m",
 		      ns->subsystems);
diff --git a/src/plugins/task/cgroup/task_cgroup_memory.c b/src/plugins/task/cgroup/task_cgroup_memory.c
index b361ce6d8ea..85a31bf5553 100644
--- a/src/plugins/task/cgroup/task_cgroup_memory.c
+++ b/src/plugins/task/cgroup/task_cgroup_memory.c
@@ -197,9 +197,7 @@ extern int task_cgroup_memory_fini(slurm_cgroup_conf_t *slurm_cgroup_conf)
 	 * After that, try to remove the user memcg. If it fails, it is due
 	 * to jobs that are still running for the same user on the node or
 	 * because of tasks attached directly to the user cg by an other
-	 * component (PAM). The user memcg was created with the
-	 * notify_on_release=1 flag (default) so it will be removed
-	 * automatically after that.
+	 * component (PAM).
 	 * For now, do not try to detect if only externally attached tasks
 	 * are present to see if they can be be moved to an orhpan memcg.
 	 * That could be done in the future, if it is necessary.
@@ -306,7 +304,7 @@ static uint64_t kmem_limit_in_bytes (uint64_t mlb)
 
 static int memcg_initialize (xcgroup_ns_t *ns, xcgroup_t *cg,
 			     char *path, uint64_t mem_limit, uid_t uid,
-			     gid_t gid, uint32_t notify)
+			     gid_t gid)
 {
 	uint64_t mlb = mem_limit_in_bytes (mem_limit, true);
 	uint64_t mlb_soft = mem_limit_in_bytes(mem_limit, false);
@@ -315,8 +313,6 @@ static int memcg_initialize (xcgroup_ns_t *ns, xcgroup_t *cg,
 	if (xcgroup_create (ns, cg, path, uid, gid) != XCGROUP_SUCCESS)
 		return -1;
 
-	cg->notify = notify;
-
 	if (xcgroup_instantiate (cg) != XCGROUP_SUCCESS) {
 		xcgroup_destroy (cg);
 		return -1;
@@ -472,11 +468,9 @@ extern int task_cgroup_memory_create(stepd_step_rec_t *job)
 	/*
 	 * Create job cgroup in the memory ns (it could already exist)
 	 * and set the associated memory limits.
-	 * Disable notify_on_release for this memcg, it will be
-	 * manually removed by the plugin at the end of the step.
 	 */
 	if (memcg_initialize (&memory_ns, &job_memory_cg, job_cgroup_path,
-	                      job->job_mem, getuid(), getgid(), 0) < 0) {
+	                      job->job_mem, getuid(), getgid()) < 0) {
 		xcgroup_destroy (&user_memory_cg);
 		goto error;
 	}
@@ -484,11 +478,9 @@ extern int task_cgroup_memory_create(stepd_step_rec_t *job)
 	/*
 	 * Create step cgroup in the memory ns (it should not exists)
 	 * and set the associated memory limits.
-	 * Disable notify_on_release for the step memcg, it will be
-	 * manually removed by the plugin at the end of the step.
 	 */
 	if (memcg_initialize (&memory_ns, &step_memory_cg, jobstep_cgroup_path,
-	                      job->step_mem, uid, gid, 0) < 0) {
+	                      job->step_mem, uid, gid) < 0) {
 		xcgroup_destroy(&user_memory_cg);
 		xcgroup_destroy(&job_memory_cg);
 		goto error;
diff --git a/src/slurmd/common/slurmd_cgroup.c b/src/slurmd/common/slurmd_cgroup.c
index e76c0080c4a..64d7a33d0e2 100644
--- a/src/slurmd/common/slurmd_cgroup.c
+++ b/src/slurmd/common/slurmd_cgroup.c
@@ -56,14 +56,14 @@
 #include "src/slurmd/slurmd/slurmd.h"
 #include "src/slurmd/slurmstepd/slurmstepd_job.h"
 
-static xcgroup_t system_cpuset_cg = {NULL, NULL, NULL, 0, 0, 0, 0};
-static xcgroup_t system_memory_cg = {NULL, NULL, NULL, 0, 0, 0, 0};
+static xcgroup_t system_cpuset_cg = {NULL, NULL, NULL, 0, 0, 0};
+static xcgroup_t system_memory_cg = {NULL, NULL, NULL, 0, 0, 0};
 
 static bool cpuset_prefix_set = false;
 static char *cpuset_prefix = "";
 
-static xcgroup_ns_t cpuset_ns = {NULL, NULL, NULL, NULL};
-static xcgroup_ns_t memory_ns = {NULL, NULL, NULL, NULL};
+static xcgroup_ns_t cpuset_ns = {NULL, NULL, NULL};
+static xcgroup_ns_t memory_ns = {NULL, NULL, NULL};
 
 char cpuset_meta[PATH_MAX];
 
@@ -328,15 +328,12 @@ static char* _system_cgroup_create_slurm_cg (xcgroup_ns_t* ns)
 	}
 #endif
 
-	/* create slurm cgroup in the ns
-	 * disable notify_on_release to avoid the removal/creation
-	 * of this cgroup for each last/first running job on the node */
+	/* create slurm cgroup in the ns */
 	if (xcgroup_create(ns, &slurm_cg, pre,
 			   getuid(), getgid()) != XCGROUP_SUCCESS) {
 		xfree(pre);
 		return pre;
 	}
-	slurm_cg.notify = 0;
 	if (xcgroup_instantiate(&slurm_cg) != XCGROUP_SUCCESS) {
 		error("system cgroup: unable to build slurm cgroup for "
 		      "ns %s: %m",
diff --git a/src/slurmd/common/xcgroup.c b/src/slurmd/common/xcgroup.c
index 91adbcbbb46..4ff12462b9d 100644
--- a/src/slurmd/common/xcgroup.c
+++ b/src/slurmd/common/xcgroup.c
@@ -87,8 +87,6 @@ int xcgroup_ns_create(slurm_cgroup_conf_t *conf,
 					 conf->cgroup_mountpoint, subsys);
 	cgns->mnt_args = xstrdup(mnt_args);
 	cgns->subsystems = xstrdup(subsys);
-	cgns->notify_prog = xstrdup_printf("%s/release_%s",
-					   conf->cgroup_release_agent, subsys);
 
 	/* check that freezer cgroup namespace is available */
 	if (!xcgroup_ns_is_available(cgns)) {
@@ -121,7 +119,6 @@ void xcgroup_ns_destroy(xcgroup_ns_t* cgns)
 	xfree(cgns->mnt_point);
 	xfree(cgns->mnt_args);
 	xfree(cgns->subsystems);
-	xfree(cgns->notify_prog);
 }
 
 /*
@@ -142,8 +139,6 @@ int xcgroup_ns_mount(xcgroup_ns_t* cgns)
 	char* mnt_point;
 	char* p;
 
-	xcgroup_t cg;
-
 	mode_t cmask;
 	mode_t omask;
 
@@ -205,23 +200,8 @@ int xcgroup_ns_mount(xcgroup_ns_t* cgns)
 		  MS_NOSUID|MS_NOEXEC|MS_NODEV, options))
 #endif
 		return XCGROUP_ERROR;
-	else {
-		/* FIXME: this only gets set when we aren't mounted at
-		   all.  Since we never umount this may only be loaded
-		   at startup the first time.
-		*/
-
-		/* we then set the release_agent if necessary */
-		if (cgns->notify_prog) {
-			if (xcgroup_create(cgns, &cg, "/", 0, 0) ==
-			     XCGROUP_ERROR)
-				return XCGROUP_SUCCESS;
-			xcgroup_set_param(&cg, "release_agent",
-					  cgns->notify_prog);
-			xcgroup_destroy(&cg);
-		}
-		return XCGROUP_SUCCESS;
-	}
+
+	return XCGROUP_SUCCESS;
 }
 
 /*
@@ -341,8 +321,6 @@ int xcgroup_ns_load(slurm_cgroup_conf_t *conf, xcgroup_ns_t *cgns, char *subsys)
 					 conf->cgroup_mountpoint, subsys);
 	cgns->mnt_args = NULL;
 	cgns->subsystems = xstrdup(subsys);
-	cgns->notify_prog = xstrdup_printf("%s/release_%s",
-					   conf->cgroup_release_agent, subsys);
 	return XCGROUP_SUCCESS;
 }
 
@@ -374,7 +352,6 @@ int xcgroup_create(xcgroup_ns_t* cgns, xcgroup_t* cg,
 	cg->path = xstrdup(file_path);
 	cg->uid = uid;
 	cg->gid = gid;
-	cg->notify = 1;
 
 	return XCGROUP_SUCCESS;
 }
@@ -431,18 +408,14 @@ int xcgroup_instantiate(xcgroup_t* cg)
 	mode_t cmask;
 	mode_t omask;
 
-	xcgroup_ns_t* cgns;
 	char* file_path;
 	uid_t uid;
 	gid_t gid;
-	uint32_t notify;
 
 	/* init variables based on input cgroup */
-	cgns = cg->ns;
 	file_path = cg->path;
 	uid = cg->uid;
 	gid = cg->gid;
-	notify = cg->notify;
 
 	/* save current mask and apply working one */
 	cmask = S_IWGRP | S_IWOTH;
@@ -474,10 +447,8 @@ int xcgroup_instantiate(xcgroup_t* cg)
 	fstatus = XCGROUP_SUCCESS;
 
 	/* set notify on release flag */
-	if (notify == 1 && cgns->notify_prog)
-		xcgroup_set_params(cg, "notify_on_release=1");
-	else
-		xcgroup_set_params(cg, "notify_on_release=0");
+	xcgroup_set_params(cg, "notify_on_release=0");
+
 	return fstatus;
 }
 
@@ -509,9 +480,6 @@ int xcgroup_load(xcgroup_ns_t* cgns, xcgroup_t* cg, char* uri)
 	cg->uid = buf.st_uid;
 	cg->gid = buf.st_gid;
 
-	/* read the content of the notify flag */
-	xcgroup_get_uint32_param(cg, "notify_on_release", &(cg->notify));
-
 	return XCGROUP_SUCCESS;
 }
 
diff --git a/src/slurmd/common/xcgroup.h b/src/slurmd/common/xcgroup.h
index 45482bbf733..304b41c3a4e 100644
--- a/src/slurmd/common/xcgroup.h
+++ b/src/slurmd/common/xcgroup.h
@@ -55,26 +55,19 @@
 #endif
 
 typedef struct xcgroup_ns {
-
 	char* mnt_point;  /* mount point to use for the associated cgroup */
 	char* mnt_args;   /* mount args to use in addition */
 
 	char* subsystems; /* list of comma separated subsystems to provide */
-
-	char* notify_prog;/* prog to use with notify on release action */
-
 } xcgroup_ns_t;
 
 typedef struct xcgroup {
-
 	xcgroup_ns_t* ns; /* xcgroup namespace of this xcgroup */
 	char*    name;    /* name of the xcgroup relative to the ns */
 	char*    path;    /* absolute path of the xcgroup in the ns */
 	uid_t    uid;     /* uid of the owner */
 	gid_t    gid;     /* gid of the owner */
 	int      fd;      /* used for locking */
-	uint32_t notify;  /* toggle notify_on_release flag (default=1) */
-
 } xcgroup_t;
 
 /*
-- 
GitLab