Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936330AbdIYRlg (ORCPT ); Mon, 25 Sep 2017 13:41:36 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:37975 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934132AbdIYRlf (ORCPT ); Mon, 25 Sep 2017 13:41:35 -0400 X-Google-Smtp-Source: AOwi7QBFb8XwKRLbwhpe5JS5MwpYbZ92z/tIKBgR7VLZ685d5V/oiJH9NX3Zb9/VK8j1UkqFrBLK5K+cI1RVTC7J2ms= MIME-Version: 1.0 In-Reply-To: <20170925145914.GA11436@redhat.com> References: <20170925145914.GA11436@redhat.com> From: Gargi Sharma Date: Mon, 25 Sep 2017 23:11:03 +0530 Message-ID: Subject: Re: [PATCH 1/4] pid: Replace pid bitmap implementation with IDR API To: Oleg Nesterov Cc: linux-kernel@vger.kernel.org, Rik van Riel , Julia Lawall , akpm@linux-foundation.org, mingo@kernel.org, pasha.tatashin@oracle.com, ktkhai@virtuozzo.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1442 Lines: 47 On Mon, Sep 25, 2017 at 8:29 PM, Oleg Nesterov wrote: > 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() ? Yes, I missed this macro in the idr library. > > And why do you need find_vpid(nr) if you already have "pid" ? Thanks for the feedback! Yes, it is not needed anymore and can be removed. Best, Gargi > > Oleg. >