From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63D13227565 for ; Thu, 26 Feb 2026 12:46:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772110001; cv=none; b=RsbT24VznV0vLJ70GRczdAoxQ50x/+WN/szMpHuQ4ONYDPQTWiCyQ5FxzeT8MmSTOtlIbyHaN9bhksLPx7ciu74W6Z5D5jq6WU1GoCc3ZP2yHgOhDovqN2kmhUSxY3BQnv6V1ksMsRw320NQqr7oqLoQsgqvx4/KY2EJpHQtMes= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772110001; c=relaxed/simple; bh=seXsmfnMZNDGmNdk2vBCcSLMIeHdG+faWBeJUj9rB/4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nXFQ6jwoqzNe4PgL9gUUCPUWD/DnDanU8DoEH4REE8VZjMu52/c5/KCAACAYO0DfMGNQNKH4Qrwmz2/Xj8uqQlOsn1KIhwW9pW9eQwnX7GHUaNJFbAX2v9DrkJ8jHdUywPNtkfWhBOYqe8j6Dvqivga5CPZom2yGtxUNCmJYrLo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=P8kyxFzj; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="P8kyxFzj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772109998; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=REu4C5gEnD9lCrQ0u+aojk+enYm0J/YBvFh4w0Tt6ow=; b=P8kyxFzj/1ifTNGKXfpS/T2vGF46rXFHHlMuVGl5ib9KSoO7BOFM150BtMP6G55y4Xy4Yz fQ38D4QDryQ3G19SZvNyvZDmocaX9SEig+OnxUWzMZto+KfcsSVVBB2WXN60GCADmf0KsP 5a+Gt+zfT0foxEYc//47WZPfZjnlAOg= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-575-KHvnGr7SPuCRykxddpXmIg-1; Thu, 26 Feb 2026 07:46:35 -0500 X-MC-Unique: KHvnGr7SPuCRykxddpXmIg-1 X-Mimecast-MFC-AGG-ID: KHvnGr7SPuCRykxddpXmIg_1772109992 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D73DF19560A3; Thu, 26 Feb 2026 12:46:31 +0000 (UTC) Received: from fedora (unknown [10.44.32.38]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id 5E75419560B8; Thu, 26 Feb 2026 12:46:25 +0000 (UTC) Received: by fedora (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Thu, 26 Feb 2026 13:46:31 +0100 (CET) Date: Thu, 26 Feb 2026 13:46:23 +0100 From: Oleg Nesterov To: Andrei Vagin Cc: Pavel Tikhomirov , Christian Brauner , Shuah Khan , Kees Cook , Andrew Morton , David Hildenbrand , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Jan Kara , Aleksa Sarai , Andrei Vagin , Kirill Tkhai , Alexander Mikhalitsyn , Adrian Reber , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH v3 2/4] pid: check init is created first after idr alloc Message-ID: References: <20260224164852.306583-1-ptikhomirov@virtuozzo.com> <20260224164852.306583-3-ptikhomirov@virtuozzo.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 On 02/25, Oleg Nesterov wrote: > > On 02/24, Andrei Vagin wrote: > > > > This isn't directly related to this patch, but why do we check > > "ns->pid_allocated & PIDNS_ADDING" after allocating all pids? Wouldn't > > it be more reasonable to do that right after taking the pidmap_lock? > > Perhaps, but alloc_pid() can drop pidmap_lock and retry, so we will > need to re-check PIDNS_ADDING. Now that I look at this code again... Why do we bother to check "pid_allocated & PIDNS_ADDING" at all? copy_process() does /* Don't start children in a dying pid namespace */ if (unlikely(!(ns_of_pid(pid)->pid_allocated & PIDNS_ADDING))) { retval = -ENOMEM; goto bad_fork_core_free; } I am going to send the patch which removes this check from alloc_pid... Need to recheck. Oleg.