[PATCH 2/8] pid_namespace: zap_pid_ns_processes: Add IDR implementation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



All allocated pids were searched for in the bitmap and removed to exit
from the processes. The lookup is now done using idr_get_next, which
will find out the next allocated id. nr, the parameter passed to
idr_get_next is set to 2 because idr_get_next() fetches the idr entry
equal to or greater than nr. next_pidmap() fetched the next greater id
so passing 1 as a parameter worked earlier. nr is incremented inside the
loop.

Signed-off-by: Gargi Sharma <gs051095@xxxxxxxxx>
---
 kernel/pid_namespace.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
index 6894109..32c4645 100644
--- a/kernel/pid_namespace.c
+++ b/kernel/pid_namespace.c
@@ -203,10 +203,11 @@ EXPORT_SYMBOL_GPL(put_pid_ns);
 
 void zap_pid_ns_processes(struct pid_namespace *pid_ns)
 {
-	int nr;
+	int nr = 2;
 	int rc;
 	struct task_struct *task, *me = current;
 	int init_pids = thread_group_leader(me) ? 1 : 2;
+	struct pid *pid;
 
 	/* Don't allow any more processes into the pid namespace */
 	disable_pid_allocation(pid_ns);
@@ -234,8 +235,8 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns)
 	 *
 	 */
 	read_lock(&tasklist_lock);
-	nr = next_pidmap(pid_ns, 1);
-	while (nr > 0) {
+	pid = idr_get_next(pid_ns->idr, &nr);
+	while (pid) {
 		rcu_read_lock();
 
 		task = pid_task(find_vpid(nr), PIDTYPE_PID);
@@ -244,7 +245,8 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns)
 
 		rcu_read_unlock();
 
-		nr = next_pidmap(pid_ns, nr);
+		nr++;
+		pid = idr_get_next(pid_ns->idr, &nr);
 	}
 	read_unlock(&tasklist_lock);
 
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux