[Devel] [PATCH RHEL7 COMMIT] ve: Revert "ve/pid_ns: reap zombies with external parent on container's init exit"

Konstantin Khorenko khorenko at odin.com
Thu Apr 30 06:17:05 PDT 2015


The commit is pushed to "branch-rh7-3.10.0-123.1.2-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-123.1.2.vz7.4.9
------>
commit 3851f54d93e548e5af6ffeb2bb9fa63b09637d43
Author: Kirill Tkhai <ktkhai at odin.com>
Date:   Thu Apr 30 17:17:00 2015 +0400

    ve: Revert "ve/pid_ns: reap zombies with external parent on container's init exit"
    
    Revert commit 4dba4987c61aff42e36aa3c889ba68dab84b0be8 ported from 2.6.32 kernel.
    
    It's unnecessary because the shutdown sequence was reworked by Konstantin
    Khlebnikov earlier in commit b5656165832b19ad628eee2a80a939625d43eab1.
    
    With 4dba4987c61aff42e36aa3c889ba68dab84b0be8 applied we has a problem with
    double task waiting which leads to memory corruption.
    
    https://jira.sw.ru/browse/PSBM-33254
    
    NOTE: vzctl from PCS6 and vz7 does not need functionality like this. The first
    one ignores signals (and child autoreaps), the second waits for its child in-ve
    process exit (and reaps it). So, this was need for versions <= PSBM5.
    
    Signed-off-by: Kirill Tkhai <ktkhai at odin.com>
---
 include/linux/sched.h  |  2 --
 include/linux/ve.h     |  2 --
 kernel/exit.c          | 15 ---------------
 kernel/pid_namespace.c |  2 --
 kernel/ve/ve.c         | 38 --------------------------------------
 5 files changed, 59 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index b5e5a17..7a3b793 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2291,8 +2291,6 @@ extern int allow_signal(int);
 extern void exit_mm(struct task_struct *);
 extern int disallow_signal(int);
 
-extern int reap_zombie(struct task_struct *);
-
 extern int do_execve(const char *,
 		     const char __user * const __user *,
 		     const char __user * const __user *);
diff --git a/include/linux/ve.h b/include/linux/ve.h
index 61f31fd..833a731 100644
--- a/include/linux/ve.h
+++ b/include/linux/ve.h
@@ -208,7 +208,6 @@ static inline int vtty_open_master(int veid, int idx) { return -ENODEV; }
 
 void ve_stop_ns(struct pid_namespace *ns);
 void ve_exit_ns(struct pid_namespace *ns);
-void ve_reap_external(struct pid_namespace *ns);
 int ve_start_container(struct ve_struct *ve);
 
 #else	/* CONFIG_VE */
@@ -226,7 +225,6 @@ static inline int vz_security_protocol_check(struct net *net, int protocol) { re
 
 static inline void ve_stop_ns(struct pid_namespace *ns) { }
 static inline void ve_exit_ns(struct pid_namespace *ns) { }
-static inline void ve_reap_external(struct pid_namespace *s) ( )
 
 #define kthread_create_on_node_ve(ve, threadfn, data, node, namefmt...)	\
 	kthread_create_on_node_ve(threadfn, data, node, namefmt...)
diff --git a/kernel/exit.c b/kernel/exit.c
index 5e43932..56b840c 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -1215,21 +1215,6 @@ static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p)
 	return retval;
 }
 
-int reap_zombie(struct task_struct *p)
-{
-	struct wait_opts wo = {
-		.wo_flags = WEXITED,
-	};
-	int ret = 0;
-
-	if (p->exit_state == EXIT_ZOMBIE && !delay_group_leader(p)) {
-		p->exit_signal = -1;
-		ret = wait_task_zombie(&wo, p);
-	}
-
-	return ret;
-}
-
 static int *task_stopped_code(struct task_struct *p, bool ptrace)
 {
 	if (ptrace) {
diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
index cbff312..173b7df 100644
--- a/kernel/pid_namespace.c
+++ b/kernel/pid_namespace.c
@@ -236,8 +236,6 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns)
 		rc = sys_wait4(-1, NULL, __WALL, NULL);
 	} while (rc != -ECHILD);
 
-	ve_reap_external(pid_ns);
-
 	/*
 	 * sys_wait4() above can't reap the TASK_DEAD children.
 	 * Make sure they all go away, see free_pid().
diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index 1944e23..9a6424e 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -588,44 +588,6 @@ err_kthread:
 }
 EXPORT_SYMBOL_GPL(ve_start_container);
 
-static bool ve_reap_one(struct pid_namespace *pid_ns)
-{
-	struct task_struct *task;
-	int nr;
-	bool reaped = false;
-
-	read_lock(&tasklist_lock);
-	nr = next_pidmap(pid_ns, 1);
-	while (nr > 0) {
-		rcu_read_lock();
-
-		task = pid_task(find_vpid(nr), PIDTYPE_PID);
-		if (task && task != current &&
-		    task->exit_state != EXIT_DEAD &&
-		    !(task->flags & PF_KTHREAD)) {
-			printk(KERN_INFO "VE#%d: found task on stop: %s (pid:"
-				"%d, exit_state: %d)\n", task->task_ve->veid,
-					task->comm, task_pid_nr(task),
-					task->exit_state);
-			reaped = true;
-			if (reap_zombie(task))
-				read_lock(&tasklist_lock);
-		}
-
-		rcu_read_unlock();
-
-		nr = next_pidmap(pid_ns, nr);
-	}
-	read_unlock(&tasklist_lock);
-	return reaped;
-}
-
-void ve_reap_external(struct pid_namespace *pid_ns)
-{
-	while (ve_reap_one(pid_ns))
-		schedule();
-}
-
 void ve_stop_ns(struct pid_namespace *pid_ns)
 {
 	struct ve_struct *ve = current->task_ve;



More information about the Devel mailing list