Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965012AbdIYO7S (ORCPT ); Mon, 25 Sep 2017 10:59:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45746 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964826AbdIYO7Q (ORCPT ); Mon, 25 Sep 2017 10:59:16 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9835381E00 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=oleg@redhat.com Date: Mon, 25 Sep 2017 16:59:14 +0200 From: Oleg Nesterov To: Gargi Sharma Cc: linux-kernel@vger.kernel.org, riel@surriel.com, julia.lawall@lip6.fr, akpm@linux-foundation.org, mingo@kernel.org, pasha.tatashin@oracle.com, ktkhai@virtuozzo.com Subject: Re: [PATCH 1/4] pid: Replace pid bitmap implementation with IDR API Message-ID: <20170925145914.GA11436@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 25 Sep 2017 14:59:16 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1065 Lines: 39 On 09/25, Gargi Sharma wrote: > > 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); > @@ -240,8 +230,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); > @@ -250,7 +240,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); Then you should probably rewrite this code using idr_for_each_entry_continue() ? And why do you need find_vpid(nr) if you already have "pid" ? Oleg.