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-Status: No, score=-4.1 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 871691F55B for ; Tue, 2 Jun 2020 03:34:11 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 69088383E829; Tue, 2 Jun 2020 03:34:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 69088383E829 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1591068850; bh=1MSQAtPKFUDHL+QSHtjzOIb9X1Qjhi0uGXHSQVlpAP0=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=GMS3ZClVDYR76VOMYcnScU3aNvNiTWD3PXHT+LmozJvjIysSdSVZdRxA5FOx0nCpG e4rhWFbyb0oHUzfqZCCLPlpaOXKgmbl2GHxr9z4Bqw83FfoOcMvmGOmm3dinmwBw2S FYq6K1s/StvvJNItIvd533gRV/O643jmiTQrx4z4= Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by sourceware.org (Postfix) with ESMTP id C50293870852 for ; Tue, 2 Jun 2020 03:34:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C50293870852 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-98-rZgw3VwVNUCi_LJuD4J2ZQ-1; Mon, 01 Jun 2020 23:34:06 -0400 X-MC-Unique: rZgw3VwVNUCi_LJuD4J2ZQ-1 Received: by mail-qt1-f197.google.com with SMTP id u26so12468988qtj.21 for ; Mon, 01 Jun 2020 20:34:06 -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:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=1MSQAtPKFUDHL+QSHtjzOIb9X1Qjhi0uGXHSQVlpAP0=; b=pP5u3nW6NDzEpZd9/ivbeig2w9yAtaT4oqC5m2eIv01nzA+Uay5lxzeAtLivHGrV7e WD73Rtjq766sT9XYZySWZ0+YECW/nMgG1ZFpDoaZvksk1yKTrsT5K9h1MyvJTa5j+pya +WIrLXW/OuX/AP1JIRx3kAJiWE5E02REoMivPvjWip1EjA6jCncwEBmhpJ8r1NvgZEWP tom8ll8Vs2irEqhmvSEMG6BJA95iCVuJb6fBGXjCzY/kdPrTcwFd9J+J7Uw2LTYo2cav xUaP8SXR7jaPNJa3aozFsx4l4PqoE72zCu9HzYiPGdALfmuAHU4rFe7pZW4l4xnil1qf 8c3Q== X-Gm-Message-State: AOAM531zOkcF5mSXFVekrVsEd9DJk2197d4HgoIKP0mqnl6WbWNa8PCM k2YX7tVZdcjjRKa6fuCXpzvuQMWQBLp/Qf6FcASy41Bwkdeb/ck0gNFQnxiN639Q82o5okEODjU rK2I3vqesjn49W74fEDAg X-Received: by 2002:ae9:f214:: with SMTP id m20mr22978884qkg.232.1591068845312; Mon, 01 Jun 2020 20:34:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYTlV+zTj8etveqPdiZ11Jmf6iD1FrfnI7+eujUkiQuWIRPiYiWMHjcd1NQp35uUZpCpcDNQ== X-Received: by 2002:ae9:f214:: with SMTP id m20mr22978867qkg.232.1591068845079; Mon, 01 Jun 2020 20:34:05 -0700 (PDT) Received: from [192.168.1.4] (198-84-170-103.cpe.teksavvy.com. [198.84.170.103]) by smtp.gmail.com with ESMTPSA id r30sm1382883qtb.87.2020.06.01.20.34.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 01 Jun 2020 20:34:04 -0700 (PDT) Subject: Re: [PATCH 12/19] nptl: Use __pthread_getattr_default_np in pthread_create To: Florian Weimer , libc-alpha@sourceware.org References: Organization: Red Hat Message-ID: <70b5e38d-0f7e-507c-2eb2-be3a902655ea@redhat.com> Date: Mon, 1 Jun 2020 23:34:03 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 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: Carlos O'Donell via Libc-alpha Reply-To: Carlos O'Donell Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" On 5/19/20 6:44 AM, Florian Weimer via Libc-alpha wrote: > This removes another instance of custom attribute copying code. OK for master. Reviewed-by: Carlos O'Donell > --- > nptl/pthread_create.c | 32 +++++++------------------------- > 1 file changed, 7 insertions(+), 25 deletions(-) > > diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c > index a43089065c..347d510707 100644 > --- a/nptl/pthread_create.c > +++ b/nptl/pthread_create.c > @@ -613,32 +613,14 @@ __pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr, > > const struct pthread_attr *iattr = (struct pthread_attr *) attr; > struct pthread_attr default_attr; > - bool free_cpuset = false; > + bool destroy_default_attr = false; OK. > bool c11 = (attr == ATTR_C11_THREAD); > if (iattr == NULL || c11) > { > - lll_lock (__default_pthread_attr_lock, LLL_PRIVATE); > - default_attr = __default_pthread_attr; > - size_t cpusetsize = default_attr.cpusetsize; > - if (cpusetsize > 0) > - { > - cpu_set_t *cpuset; > - if (__glibc_likely (__libc_use_alloca (cpusetsize))) > - cpuset = __alloca (cpusetsize); > - else > - { > - cpuset = malloc (cpusetsize); > - if (cpuset == NULL) > - { > - lll_unlock (__default_pthread_attr_lock, LLL_PRIVATE); > - return ENOMEM; > - } > - free_cpuset = true; > - } > - memcpy (cpuset, default_attr.cpuset, cpusetsize); > - default_attr.cpuset = cpuset; > - } > - lll_unlock (__default_pthread_attr_lock, LLL_PRIVATE); > + int ret = __pthread_getattr_default_np ((pthread_attr_t *) &default_attr); OK. Call internally to get the default attributes. > + if (ret != 0) > + return ret; > + destroy_default_attr = true; > iattr = &default_attr; > } > > @@ -869,8 +851,8 @@ __pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr, > } > > out: > - if (__glibc_unlikely (free_cpuset)) > - free (default_attr.cpuset); > + if (destroy_default_attr) > + __pthread_attr_destroy ((pthread_attr_t *) &default_attr); OK. > > return retval; > } > -- Cheers, Carlos.