From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x735.google.com (mail-qk1-x735.google.com [IPv6:2607:f8b0:4864:20::735]) by sourceware.org (Postfix) with ESMTPS id A614E385843B for ; Thu, 26 Aug 2021 15:11:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A614E385843B Received: by mail-qk1-x735.google.com with SMTP id a66so3745680qkc.1 for ; Thu, 26 Aug 2021 08:11:37 -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:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=/QGWjEfim/2uVK4tYZ1iU2xceYjVhzH78NWL28OC2ks=; b=UIy1yTO7yOcQdbBDj40yY3EoCKDvzdTVStC7fmnKULH5qblyiGbJ5zV3Mdxu1bm1T6 /FTXnsAYUer67OFleT1LPKjr5ZeCyxQRbix5Q3+r1lUE0YlJFTWIN8ctg6epszBiL2KM dK6/T/kGecSD/L5o+qjMJaYjke0HDhMnckXC2a8apnrAHVH77UiT2tEWQy6A5o/0fJ22 OYrk/L1CoLS1PDbsyQ53icCb6GXl7l48Emiibw+zwZhgyFb3ehpvb0MAGO282Ga2qpBn /m2DqdMRVkIUWQ3Hp0eR8nfk2zKY0pe4su/onn9A6J7wEiio0mYb2/UA+i9ypgrUXSJa mI0w== X-Gm-Message-State: AOAM5338wMwaVDfiiegWHSNOEowXu9dYQwKPYYYFvXvt1al/PwM/QGAS LM4rVlPl4hSS92MrhC+QuJgmLicWzVD+Rg== X-Google-Smtp-Source: ABdhPJw+/WXpwncaVbWZ8EmBKgqdHswsnH9evkCf/wMBS8vd6vnoqtXq+s/GJF8yANZBLe6J3wFW1g== X-Received: by 2002:a37:944:: with SMTP id 65mr4278687qkj.412.1629990696990; Thu, 26 Aug 2021 08:11:36 -0700 (PDT) Received: from ?IPv6:2804:431:c7ca:1a68:4e82:9e7c:b7e4:7f3? ([2804:431:c7ca:1a68:4e82:9e7c:b7e4:7f3]) by smtp.gmail.com with ESMTPSA id g13sm2765761qkk.110.2021.08.26.08.11.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Aug 2021 08:11:36 -0700 (PDT) Subject: Re: [PATCH v2 05/19] nptl: Move setxid flag out of cancelhandling To: Florian Weimer Cc: libc-alpha@sourceware.org References: <20210823195047.543237-1-adhemerval.zanella@linaro.org> <20210823195047.543237-6-adhemerval.zanella@linaro.org> <87tujc783g.fsf@oldenburg.str.redhat.com> From: Adhemerval Zanella Message-ID: Date: Thu, 26 Aug 2021 12:11:34 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <87tujc783g.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-14.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Thu, 26 Aug 2021 15:11:48 -0000 On 26/08/2021 08:34, Florian Weimer wrote: > * Adhemerval Zanella: > >> Now that the thread state is tracked by 'joinstate' field, there is no >> need to keep the setxid flag within the 'cancelhandling'. It simplifies >> the atomic code to set and reset it (since there is no need to handle >> the thread state concurrent update). > > Some of this functionality reimplements the tidlock. > > There is some functionality around thread creation, but I do not know if > the synchronization is entirely correct. This makes it rather difficult > to review changes. > > It's also not clear to me if we need to do anything to prevent early > setxid calls: > >> /* Don't allow setxid until cloned. */ > > I suspect this should just look at the TID instead. We create the > thread with all signals blocked, so once there is a TID (and the thread > has not exited), it is safe to send the signal. I agree that we might improve the setxid code, however what I intended with this changes is to keep its semantic as-is and just decouple it from cancelhandling. I might revise it on a later patch to follow your suggestions. > >> diff --git a/nptl/descr.h b/nptl/descr.h >> index 4b2db6edab..563b152bff 100644 >> --- a/nptl/descr.h >> +++ b/nptl/descr.h > >> + /* Indicate whether thread is supposed to change XID. */ >> + int setxid_flag; > > This should document the possible values. I changed to: /* Indicate whether thread is supposed to change XID, it acts a boolean variable (0 means no operation pending). */