From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by sourceware.org (Postfix) with ESMTP id 35A30387085D for ; Tue, 2 Jun 2020 03:36:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 35A30387085D Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-176-iOZOg33IOjikxOSDQKIJCg-1; Mon, 01 Jun 2020 23:36:25 -0400 X-MC-Unique: iOZOg33IOjikxOSDQKIJCg-1 Received: by mail-qv1-f71.google.com with SMTP id y2so2212164qvp.1 for ; Mon, 01 Jun 2020 20:36:25 -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=JSI/dR7WYSC9Q/NTjqaiic8AoHLSR1dAA3YhKIrF+oI=; b=RUgHFnJeknP6eFWI4jgunAmGGSjVGou+Q8i7elub0/gz9BXzfN5fcu4GnalMB6WX9Z zqzIKjFMlPHAzTdHUG2NlkQw0y5FPS1wI1JA4q9LpWbbpuIDs5jBg2tyLwfAQQSNlz75 dRplH78tz40NSgpiRxv2r/JqqskCp4ZAdCZFoHK5WaVBwxfJ4M4yf/9TckC3VKmBCJaK H+iI+euK0v9OVbIbE2sWComWoiN6pC2mAOK9n+n0ie642xToZFUOsSYxzut65ERDSpLf vfLCk0UfPhedswZQu/u4/JChn3j2ASpVWpVGsG12El13LjOJuSFiJfRi4JZ7vodf2k9B 0sAg== X-Gm-Message-State: AOAM532OxxvZSySUFeHnEwzJ6p1ciDDKVx/gBAzXIweMGyV9Nplkn/p5 rG4xgKZ3q24AdB5aPoH8Q5J38WIjUmN9dy55g1TJuiNfsqsqSVUd6rmTCbqTcH29VdIPr/vI1D8 6tjvPNQ9i4/8RcPWYapsj X-Received: by 2002:a37:4b17:: with SMTP id y23mr11211457qka.73.1591068984747; Mon, 01 Jun 2020 20:36:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzC/3lCwoetfR+/FULKAMByb16rhy5jex0gvG7WYeY30ohMQRlUUlr6Pi3w2rPkDWCh6zXkfg== X-Received: by 2002:a37:4b17:: with SMTP id y23mr11211443qka.73.1591068984491; Mon, 01 Jun 2020 20:36:24 -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 o6sm1374785qtd.59.2020.06.01.20.36.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 01 Jun 2020 20:36:23 -0700 (PDT) Subject: Re: [PATCH 13/19] nptl: Use __pthread_attr_setaffinity_np in pthread_getattr_np To: Florian Weimer , libc-alpha@sourceware.org References: <97d4eaaccdee458f469942064acb202b09a82df4.1589884403.git.fweimer@redhat.com> From: Carlos O'Donell Organization: Red Hat Message-ID: <2864983e-afaa-93c8-38c3-b84babc44a56@redhat.com> Date: Mon, 1 Jun 2020 23:36:22 -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: <97d4eaaccdee458f469942064acb202b09a82df4.1589884403.git.fweimer@redhat.com> 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-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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: Tue, 02 Jun 2020 03:36:28 -0000 On 5/19/20 6:44 AM, Florian Weimer via Libc-alpha wrote: > This avoids duplicating the code for the affinity mask allocation > handling. OK for master. Reviewed-by: Carlos O'Donell > --- > nptl/pthread_getattr_np.c | 30 ++++++++++++++---------------- > 1 file changed, 14 insertions(+), 16 deletions(-) > > diff --git a/nptl/pthread_getattr_np.c b/nptl/pthread_getattr_np.c > index 0e8911346d..ce437205e4 100644 > --- a/nptl/pthread_getattr_np.c > +++ b/nptl/pthread_getattr_np.c > @@ -33,8 +33,13 @@ int > __pthread_getattr_np (pthread_t thread_id, pthread_attr_t *attr) > { > struct pthread *thread = (struct pthread *) thread_id; > + > + /* Prepare the new thread attribute. */ > + int ret = __pthread_attr_init (attr); > + if (ret != 0) > + return ret; > + OK. > struct pthread_attr *iattr = (struct pthread_attr *) attr; > - int ret = 0; > > lll_lock (thread->lock, LLL_PRIVATE); > > @@ -187,25 +192,18 @@ __pthread_getattr_np (pthread_t thread_id, pthread_attr_t *attr) > while (ret == EINVAL && size < 1024 * 1024); > > if (ret == 0) > - { > - iattr->cpuset = cpuset; > - iattr->cpusetsize = size; > - } > - else > - { > - free (cpuset); > - if (ret == ENOSYS) > - { > - /* There is no such functionality. */ > - ret = 0; > - iattr->cpuset = NULL; > - iattr->cpusetsize = 0; > - } > - } > + ret = __pthread_attr_setaffinity_np (attr, size, cpuset); OK. Handled all in pthread_attr_setaffinity_np. > + else if (ret == ENOSYS) > + /* There is no such functionality. */ > + ret = 0; > + free (cpuset); OK. > } > > lll_unlock (thread->lock, LLL_PRIVATE); > > + if (ret != 0) > + __pthread_attr_destroy (attr); OK. Destory the attribute if things failed. > + > return ret; > } > versioned_symbol (libc, __pthread_getattr_np, pthread_getattr_np, GLIBC_2_32); > -- Cheers, Carlos.