Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753326AbdI0OHC (ORCPT ); Wed, 27 Sep 2017 10:07:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57428 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753126AbdI0OHB (ORCPT ); Wed, 27 Sep 2017 10:07:01 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 69592C014178 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=oleg@redhat.com Date: Wed, 27 Sep 2017 16:06:58 +0200 From: Oleg Nesterov To: Rik van Riel Cc: Gargi Sharma , linux-kernel@vger.kernel.org, julia.lawall@lip6.fr, akpm@linux-foundation.org, mingo@kernel.org, pasha.tatashin@oracle.com, ktkhai@virtuozzo.com Subject: Re: [PATCH v2 1/2] pid: Replace pid bitmap implementation with IDR API Message-ID: <20170927140658.GA28133@redhat.com> References: <1506517794.21121.93.camel@surriel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1506517794.21121.93.camel@surriel.com> 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.31]); Wed, 27 Sep 2017 14:07:01 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1383 Lines: 49 On 09/27, Rik van Riel wrote: > > > @@ -240,17 +230,18 @@ void zap_pid_ns_processes(struct pid_namespace > > *pid_ns) > > ? ?* > > ? ?*/ > > ? read_lock(&tasklist_lock); > > - nr = next_pidmap(pid_ns, 1); > > - while (nr > 0) { > > - rcu_read_lock(); > > + pid = idr_get_next(&pid_ns->idr, &nr); > > + while (pid) { > > ? > > - task = pid_task(find_vpid(nr), PIDTYPE_PID); > > - if (task && !__fatal_signal_pending(task)) > > - send_sig_info(SIGKILL, SEND_SIG_FORCED, > > task); > > + rcu_read_lock(); > > ? > > + idr_for_each_entry_continue(&pid_ns->idr, pid, nr) { > > + task = pid_task(pid, PIDTYPE_PID); > > + if (task && !__fatal_signal_pending(task)) > > + send_sig_info(SIGKILL, > > SEND_SIG_FORCED, task); > > + } > > ? rcu_read_unlock(); > > ? > > - nr = next_pidmap(pid_ns, nr); > > ? } > > ? read_unlock(&tasklist_lock); > > ? > > I believe we should be fine with just the idr_for_each_entry_continue() > surrounding the loop, Yes, and please move "nr = 2" close to idr_for_each_entry_continue() to make it clear why do we use _continue (to skip nr == 1). > and not need the while (pid) around that. > > That should still iterate over all the pids in the namespace, and > simplify the code even more. And make this patch correct ;) because currently it is wrong, zap_pid_ns_processes() won't kill the pid returned by the first idr_get_next(). Oleg.