From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS17314 8.43.84.0/22 X-Spam-Status: No, score=-5.6 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 62DCD1F8C6 for ; Thu, 26 Aug 2021 17:30:12 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4F2433858434 for ; Thu, 26 Aug 2021 17:30:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4F2433858434 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1629999011; bh=nAoY5At35biEm807YrNwkPUxswSmhGHImet3Vp/LGrg=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Q3Q5PmnN4moJBxSSlyGa/rNpx8PZg+/sYHCj9CL4cJT/p5Z31PcAz3gaCcLgiFjIc 2wUOj3mxMpryVsHZ49nWFymqM3SnDYzP6MSCKM5NgK+Gfxkep6EpKndgiMcrQBssUy /Pwxjkv/OHS0QCAATdHCxyHIWcNiWJk9ROgVL0U8= Received: from mail-qv1-xf35.google.com (mail-qv1-xf35.google.com [IPv6:2607:f8b0:4864:20::f35]) by sourceware.org (Postfix) with ESMTPS id 8022D3858402 for ; Thu, 26 Aug 2021 17:29:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8022D3858402 Received: by mail-qv1-xf35.google.com with SMTP id g11so2478050qvd.2 for ; Thu, 26 Aug 2021 10:29:42 -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=nAoY5At35biEm807YrNwkPUxswSmhGHImet3Vp/LGrg=; b=G3p6c/oPVHMytVw5j4Xa76Z+ZrK2ombnKoK3wUABerfvakeswN1M7Ku6VKpMngltAr MZ9oCORQ1dwZ1KWR4NyGVdL4BCXYhFIogW1/t4DZ6CmLoY9Gtr5V2Mb8arMUloppBXXC X6n+LpmWTlC5vIdJ68RZUHjnQLziDHgU9UQBjWk5CT/Z36thMnVqrMD2zciYe9i22yV5 rcvVZjjLQcvcPRG2lYPX527AVK5/1T2j6rbsel8LhBuw0VGv2iaNthgfT2uFSakDJs3B W4L9Vz4/4AWsu3KDWp8nq/DA2I1ME+i2VnEljtvfnZLVXHCbDss+CdKp4lqRhCITdtnG xYLg== X-Gm-Message-State: AOAM533bFddumd/Xqe7I5a6l+V1uRSV6mHMCTMp4vcKnnKjWaoRSY+h/ TL381QHIIPvm2Eo4ztaAtekA7RsiwDx30A== X-Google-Smtp-Source: ABdhPJx4ENdf+1g2A8YfKUMS9tqk04RnG38rmLllaSmu19i++ncX3S2Qm4INdIppSJwxbUerj9OxdQ== X-Received: by 2002:ad4:40d1:: with SMTP id x17mr5251079qvp.7.1629998980856; Thu, 26 Aug 2021 10:29:40 -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 i27sm2922343qkl.111.2021.08.26.10.29.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Aug 2021 10:29:40 -0700 (PDT) Subject: Re: [PATCH v2 10/19] nptl: Use tidlock when accessing TID on pthread_getaffinity_np To: Florian Weimer References: <20210823195047.543237-1-adhemerval.zanella@linaro.org> <20210823195047.543237-11-adhemerval.zanella@linaro.org> <874kbc707x.fsf@oldenburg.str.redhat.com> Message-ID: Date: Thu, 26 Aug 2021 14:29:38 -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: <874kbc707x.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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: , From: Adhemerval Zanella via Libc-alpha Reply-To: Adhemerval Zanella Cc: libc-alpha@sourceware.org Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" On 26/08/2021 11:24, Florian Weimer wrote: > * Adhemerval Zanella: > >> Checked on x86_64-linux-gnu. >> --- >> nptl/pthread_getaffinity.c | 22 +++++++++++++++++----- >> 1 file changed, 17 insertions(+), 5 deletions(-) >> >> diff --git a/nptl/pthread_getaffinity.c b/nptl/pthread_getaffinity.c >> index 18261ddae0..5268d86e6e 100644 >> --- a/nptl/pthread_getaffinity.c >> +++ b/nptl/pthread_getaffinity.c >> @@ -29,12 +29,24 @@ >> int >> __pthread_getaffinity_np (pthread_t th, size_t cpusetsize, cpu_set_t *cpuset) >> { >> - const struct pthread *pd = (const struct pthread *) th; >> + struct pthread *pd = (struct pthread *) th; >> >> - int res = INTERNAL_SYSCALL_CALL (sched_getaffinity, pd->tid, >> - MIN (INT_MAX, cpusetsize), cpuset); >> - if (INTERNAL_SYSCALL_ERROR_P (res)) >> - return INTERNAL_SYSCALL_ERRNO (res); >> + /* Block all signal, since the lock is recursive and used on pthread_cancel >> + (which should be async-signal-safe). */ > > The pthread_cancel reference looks like a cut-and-paste-bug. It is, but I think it is applicable. Maybe: /* Block all signal, since the lock is not recursive and used on async-signal-safe functions. */ > >> + sigset_t oldmask; >> + __libc_signal_block_all (&oldmask); >> + lll_lock (pd->tidlock, LLL_PRIVATE); >> + >> + int res = pd->tid == 0 >> + ? -ESRCH >> + : INTERNAL_SYSCALL_CALL (sched_getaffinity, pd->tid, >> + MIN (INT_MAX, cpusetsize), cpuset); >> + >> + lll_unlock (pd->tidlock, LLL_PRIVATE); >> + __libc_signal_restore_set (&oldmask); >> + >> + if (res < 0) >> + return -res; > > ESRCH doesn't look like the right error code here. Should we return an > affinity mask without any bits set? Why not? Returning anything but an error does not improve things here since the information won't make much sense. Also it follows what other symbols is already doing (such as pthread_cancel()). > > Thanks, > Florian >