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 [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id A1F223857033 for ; Fri, 14 May 2021 19:16:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A1F223857033 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-211-0hhtbZPVN9-7WR8c-pVWeA-1; Fri, 14 May 2021 15:16:12 -0400 X-MC-Unique: 0hhtbZPVN9-7WR8c-pVWeA-1 Received: by mail-qt1-f200.google.com with SMTP id o5-20020ac872c50000b02901c32e7e3c21so330347qtp.8 for ; Fri, 14 May 2021 12:16:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=UDTZAk+zg0cjHw14WQ/aRCQQzkV3QLOf3e1cprAVoU8=; b=JdrC3VTXPqTOPI+KXP3QEuDvENQxzKpPIrWuAYuiAxhZKQVRAI1Z3EjghOJVfG+FYY ol7hGFH8zXNz8z+xXNm/sk0d8hcg/YzcmW5BzdhVhUfZBpm35Y4zvtb8O9Ta2NNUjPoz kPjSqPcMXgfCHPLPdxZPeH8mR8k6fgFRzfa6/w0x+BzrhZUwoYrH2S6JZHVmSOWQUQbg 5vBoc1Y7NhRd/SYDMj9aD2iK2SK11J9Sd00eO6m3t/b+85pDEdZgN9XVdmRJ1oNIw+RJ sS5Hf1c4jEADEhHYg95yWPN464NoV9aQT4ixpa/bP7Agjw8em2nl8nfrcq7wIMM2+Laj MQvQ== X-Gm-Message-State: AOAM5335xHlaA1vB7c5miEtDNlHwvQDffyh16NfctBoD0ZddpFR1oat5 aF/YdkRwOLF83jvYKXjXx1EjP18714EL4GtGY21ctKtop6kp6iIOsa+3kfymVlDv+1wUkY104ve xUuCAYSfHeOlj03QL/blH2ZuHzX0MDo7xU9dXBuijBWng3iUDKmej/ZHI657J7c5BS+HXpQ== X-Received: by 2002:ac8:5ec8:: with SMTP id s8mr24682803qtx.348.1621019770900; Fri, 14 May 2021 12:16:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzh19urdQHzSTZNnv5mPwhivJtkdyq7bXspMjrbWl01RYYgbAQYlzn+nWUOkkc2xBCCtfhq8g== X-Received: by 2002:ac8:5ec8:: with SMTP id s8mr24682785qtx.348.1621019770672; Fri, 14 May 2021 12:16:10 -0700 (PDT) Received: from [192.168.1.16] (198-84-214-74.cpe.teksavvy.com. [198.84.214.74]) by smtp.gmail.com with ESMTPSA id n17sm5507168qke.14.2021.05.14.12.16.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 14 May 2021 12:16:10 -0700 (PDT) Subject: Re: [PATCH 12/23] nptl: Introduce __nptl_deferred_init To: Adhemerval Zanella , Florian Weimer Cc: libc-alpha@sourceware.org References: <303f46939bafa347bae62f9740837955ebbf43e9.1620838411.git.fweimer@redhat.com> <71008721-05eb-aa32-4665-e49c1940b57d@linaro.org> <87zgwymk6v.fsf@oldenburg.str.redhat.com> <84c8d06e-e485-fed7-35d9-98d5ac70bb00@linaro.org> <87r1i9mrmu.fsf@oldenburg.str.redhat.com> From: Carlos O'Donell Organization: Red Hat Message-ID: <88276a7c-919b-97ce-9ffc-c2fdc9ecdc06@redhat.com> Date: Fri, 14 May 2021 15:16:08 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, 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: Fri, 14 May 2021 19:16:16 -0000 On 5/14/21 9:29 AM, Adhemerval Zanella via Libc-alpha wrote: > > > On 14/05/2021 09:22, Florian Weimer wrote: >> * Adhemerval Zanella: >> >>> On 13/05/2021 17:51, Florian Weimer wrote: >>>> * Adhemerval Zanella: >>>> >>>>> On 12/05/2021 13:58, Florian Weimer via Libc-alpha wrote: >>>>>> This function is called once by pthread_create, before spawning >>>>>> the first thread, and also within pthread_cancel. Since it sets up >>>>>> cancellation handlers, place it along with the pthread_cancel >>>>>> implementation within libc. >>>>> >>>>> Why does it need to be initialized by pthread_create as well? I think >>>>> moving the initialization to pthread_cancel and only setting once >>>>> when pthread_cancel is called (and not tying to __libc_single_threaded) >>>>> is slight better since it avoids the setup of SIGCANCEL for programs >>>>> that do not use cancellation. >>>> >>>> We need to unblock SIGCANCEL anyway, so that we can send the signal. >>>> This part can't be deferred until pthread_cancel is called. >>> >>> Yes, what it seems to be wrong is unblocking it on both pthread_create >>> *and* on pthread_cancel. >> >> We need to unblock in pthread_cancel too, to support self-cancel in a >> single-threaded process. > > We don't really need in fact, pthread_cancel can call __pthread_exit > directly if the argument is THREAD_SELF. And with my canceltype and > cancelstate refactor we don't even need the whole atomic bit set > support. And POSIX in the RATIONALE says exactly this: ~~~ The special function also means that implementations are not obliged to implement cancellation with signals. ~~~ https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cancel.html >> Do you know if we ever change the signal mask to enable/disable >> asynchronous cancellation? I don't think so. Then we could support >> self-cancel simply by calling the signal handler. (It would not matter >> whether the process is multi-threaded or not.) >> >> If we do that, I think it is simpler to do all the initialization in >> pthread_create. >> >> Thanks, >> Florian >> > -- Cheers, Carlos.