From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755976AbdJJLuk (ORCPT ); Tue, 10 Oct 2017 07:50:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:17807 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755221AbdJJLuj (ORCPT ); Tue, 10 Oct 2017 07:50:39 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6255B820EE Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=oleg@redhat.com Date: Tue, 10 Oct 2017 13:50:35 +0200 From: Oleg Nesterov To: Andrew Morton Cc: Gargi Sharma , linux-kernel@vger.kernel.org, riel@surriel.com, julia.lawall@lip6.fr, mingo@kernel.org, pasha.tatashin@oracle.com, ktkhai@virtuozzo.com, ebiederm@xmission.com, hch@infradead.org Subject: Re: [PATCH v4 1/2] pid: Replace pid bitmap implementation with IDR API Message-ID: <20171010115034.GA28545@redhat.com> References: <1507583624-22146-1-git-send-email-gs051095@gmail.com> <1507583624-22146-2-git-send-email-gs051095@gmail.com> <20171009161737.ea8c62441cc12dfd909ee0b2@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171009161737.ea8c62441cc12dfd909ee0b2@linux-foundation.org> 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.26]); Tue, 10 Oct 2017 11:50:39 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/09, Andrew Morton wrote: > > > @@ -240,17 +230,11 @@ 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(); > > - > > - task = pid_task(find_vpid(nr), PIDTYPE_PID); > > + nr = 2; > > + 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); > > Especially here. I don't think pidmap_lock is held. Is that IDR > iteration safe? Yes, this doesn't look right, we need rcu_read_lock() or pidmap_lock. And, we also need rcu_read_lock() for another reason, to protect "struct pid". Gargi, I suggested to use idr_for_each_entry_continue(), but now I am wondering if we should use idr_for_each() instead. IIUC this would be a bit faster? Not that I think this is really important... Oleg.