Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752691AbdI0PGA (ORCPT ); Wed, 27 Sep 2017 11:06:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52930 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751974AbdI0PF6 (ORCPT ); Wed, 27 Sep 2017 11:05:58 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 77C3F3A26D Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=oleg@redhat.com Date: Wed, 27 Sep 2017 17:05:55 +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 v2 1/2] pid: Replace pid bitmap implementation with IDR API Message-ID: <20170927150555.GA1412@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.38]); Wed, 27 Sep 2017 15:05:58 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1375 Lines: 51 On 09/27, Gargi Sharma wrote: > > @@ -309,7 +168,22 @@ struct pid *alloc_pid(struct pid_namespace *ns) > tmp = ns; > pid->level = ns->level; > for (i = ns->level; i >= 0; i--) { > - nr = alloc_pidmap(tmp); > + int pid_min = 1; > + idr_preload(GFP_KERNEL); > + spin_lock_irq(&pidmap_lock); > + > + /* > + * init really needs pid 1, but after reaching the maximum > + * wrap back to RESERVED_PIDS > + */ > + if (tmp->idr.idr_next > RESERVED_PIDS) > + pid_min = RESERVED_PIDS; > + > + nr = idr_alloc_cyclic(&tmp->idr, pid, pid_min, > + pid_max, GFP_ATOMIC); > + spin_unlock_irq(&pidmap_lock); > + idr_preload_end(); > + > if (nr < 0) { > retval = nr; > goto out_free; > @@ -346,12 +220,14 @@ struct pid *alloc_pid(struct pid_namespace *ns) > return pid; > > out_unlock: > - spin_unlock_irq(&pidmap_lock); > put_pid_ns(ns); > + spin_unlock_irq(&pidmap_lock); Why? No need to move put_pid_ns() under pidmap_lock, please remove this change... > void __init pidhash_init(void) > { > + unsigned int pidhash_size; > + > pid_hash = alloc_large_system_hash("PID", sizeof(*pid_hash), 0, 18, > HASH_EARLY | HASH_SMALL | HASH_ZERO, > &pidhash_shift, NULL, > 0, 4096); > + pidhash_size = 1U << pidhash_shift; > } Hmm, this change makes no sense. And the next patch kills pidhash_init() altogether. Oleg.