From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 65668 invoked by alias); 28 Jun 2019 17:09:59 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 65656 invoked by uid 89); 28 Jun 2019 17:09:59 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-4.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=H*i:sk:87d0ixm, H*f:sk:87d0ixm X-HELO: mail-qk1-f196.google.com Return-Path: Subject: Re: [PATCH] Linux: Implement per-thread file system attributes To: Florian Weimer Cc: libc-alpha@sourceware.org References: <87d0jpfius.fsf@oldenburg2.str.redhat.com> <8ad787b8-994e-65e9-4f18-1e0d29605de3@redhat.com> <87v9wpn4ft.fsf@oldenburg2.str.redhat.com> <87d0ixmyyv.fsf@oldenburg2.str.redhat.com> From: Carlos O'Donell Message-ID: <1b1730f1-8d90-a0c2-734f-d2f964774cab@redhat.com> Date: Fri, 28 Jun 2019 17:09:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <87d0ixmyyv.fsf@oldenburg2.str.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2019-06/txt/msg00934.txt.bz2 On 6/28/19 12:55 PM, Florian Weimer wrote: > * Carlos O'Donell: > >> The thread_perthreadfs_indirect uses the NULL attribute, >> and not PTHREAD_PER_PROCESS_NP explicitly, and it's an >> implementation detail that this happens to be the same >> code path e.g. we copy the default global attr, then adjust >> the scope flags. This might change in the future and it would >> be nice to catch any breakage in a distinct test for this. >> >> The test would be a basic flag test looking to validate the >> stickyness in a simpler test. >> >> The simpler test should have the parent threads permute over >> [null, per-process, per-thread], and the child iterate over >> [null, per-process, per-thread], and validate the expected >> results. > > Is it sufficient to verify that the thread attribute is set correctly, > or do you want a fully functional test? It is sufficient to verify that the thread attribute is set correctly. > If the latter, I will split the indirect flag into direct, indirect with > default attribute, and indirect with non-default attribute because I > would have to replicate a lot of the other test functionality to verify > per-thread separation or the lack thereof. That sounds reasonable to me if you want to keep the test as a single test. >>> +/* Return true if the thread has per-thread file system >>> + attributes. */ >>> +static bool >>> +perthread_flag (pthread_t thr) >>> +{ >>> + pthread_attr_t attr; >>> + int ret = pthread_getattr_np (thr, &attr); >>> + if (ret != 0) >>> + { >>> + errno = ret; >>> + FAIL_EXIT1 ("pthread_getattr_np: %m"); >>> + } >>> + int flag = -1; >>> + pthread_attr_getperthreadfs_np (&attr, &flag); >>> + if (flag != 0) >>> + TEST_COMPARE (flag, 1); >> >> Magic number. >> >> Please use some intermediate define to call this out. >> >> #define CHECK_PTHREAD_PER_THREAD_FS 1 >> >> ... and use in place of 1. >> >> This way it's grep-able when looking for references to >> the enumerated value. > > Right, I realized that as well. I've now got: > > /* Return true if the thread has per-thread file system > attributes. */ > static bool > perthread_flag (pthread_t thr) > { > pthread_attr_t attr; > int ret = pthread_getattr_np (thr, &attr); > if (ret != 0) > { > errno = ret; > FAIL_EXIT1 ("pthread_getattr_np: %m"); > } > int flag = -1; > pthread_attr_getperthreadfs_np (&attr, &flag); > if (flag != PTHREAD_PER_THREAD_NP) > TEST_COMPARE (flag, PTHREAD_PER_PROCESS_NP); I don't follow why you can't call this unconditionally? > xpthread_attr_destroy (&attr); > return flag == PTHREAD_PER_THREAD_NP; OK. > } > > Thanks, > Florian > -- Cheers, Carlos.