From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id CBB7F3985467 for ; Wed, 9 Jun 2021 13:49:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CBB7F3985467 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-554-ODlRjitnMFisNiNDEOUOCA-1; Wed, 09 Jun 2021 09:49:50 -0400 X-MC-Unique: ODlRjitnMFisNiNDEOUOCA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 741B0107ACF6; Wed, 9 Jun 2021 13:49:49 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-115-60.ams2.redhat.com [10.36.115.60]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8AAEF5D9E2; Wed, 9 Jun 2021 13:49:48 +0000 (UTC) From: Florian Weimer To: Adhemerval Zanella Cc: Adhemerval Zanella via Libc-alpha Subject: Re: [PATCH v3] nptl: Deallocate the thread stack on setup failure (BZ #19511) References: <20210527172823.3461314-3-adhemerval.zanella@linaro.org> <20210602125644.3725112-1-adhemerval.zanella@linaro.org> <87lf7kbp5b.fsf@oldenburg.str.redhat.com> <14ba289b-9168-45bd-4547-ebd3f33f64b2@linaro.org> Date: Wed, 09 Jun 2021 15:49:46 +0200 In-Reply-To: <14ba289b-9168-45bd-4547-ebd3f33f64b2@linaro.org> (Adhemerval Zanella's message of "Tue, 8 Jun 2021 14:01:32 -0300") Message-ID: <871r9b5erp.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Jun 2021 13:49:56 -0000 * Adhemerval Zanella: > THREAD_RAN only signals if whether clone() or thread setup has failed, > there is no synchronization involved and it is already local to > creating thread. I changed the concurrency comment to the following, > to indicate that (c) and (d) are essentially the same as you noted: > > (c) If either a joinable or detached thread setup failed and THREAD_RAN > is true, then the creating thread releases ownership to the new thread, > the created thread sees the failed setup through PD SETUP_FAILED PD->setup_failed (I think this is the GNU convention). > member, releases the PD ownership, and exits. The creating thread will > be responsible for cleanup the allocated resources. The THREAD_RAN is > local to creating thread and indicate whether thread creation or setup > has failed. > > (d) If the thread creation failed and THREAD_RAN is false (meaning > ARCH_CLONE has failed), then the creating thread retains ownership > of PD and must cleanup he allocated resource. No waiting for the new > thread is required because it never started. Yes, that's much better. > I think for such case you will need to set PD->stopped_start to true > before thread creation (similar to what affinity and schedule set do), > add the required initialization after the setup failure check, and > handle potential errors. > > Something like (I removed the comments to simplify): Yeah, that is what I expect as well. > Below it is the updated patch based on your suggestion, including the > concurrency state descriptor regarding THREAD_RAN. Are this version > ok to commit? This version looks okay to me, with the PD->setup_failed change above. Thanks, Florian