From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by sourceware.org (Postfix) with ESMTPS id 6DD2F3858D28; Wed, 11 Oct 2023 18:36:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6DD2F3858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=efficios.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1697049368; bh=EwAxC3Q+JEyD0LgZhvzKZ4hglwLjnEbLLBWASWLl2Xs=; h=Date:Subject:To:References:Cc:From:In-Reply-To:From; b=v4LtksSLIz6GfbDvQDr4un6DXqFkbtra6vtN//K0P3SllgadrwI38z0DIZjDfRBjo RJPtxn0Q0KJ27dH4yiqQYeW064yWZsdNn61KEVktypmm1+VxVzgttAieU0g5iLplt0 f6R6QslfxKnHpHgqe6+libu77wmrA5Lt4Cdsyc6nok+T1kkv5ufqilOyL96hC4mxt4 dUn/cQa7cO/yXQmJVY42XdVVVZyQXJUECMiqkUA6QI+iSObVTaQgJJDnHRYMdW4y6V WI5+dS6PaoKD1L9xhi6KSh1V27zy1kt3/At158lFT5mfGv3i5NxXC2u3ZpZhoqqA4F +XjMj9//Z8wCA== Received: from [172.16.0.134] (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4S5M0l6wrNz1X39; Wed, 11 Oct 2023 14:36:07 -0400 (EDT) Message-ID: <51d5d248-3eb0-4c9f-a76b-0a2dd1bdac1d@efficios.com> Date: Wed, 11 Oct 2023 14:36:12 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Dead code in pthread_cond_wait() for spin-wait Content-Language: en-US To: Olivier Dion References: <87a5spvwoi.fsf@laura> Cc: libc-help@sourceware.org, libc-alpha , "carlos@redhat.com" , Florian Weimer From: Mathieu Desnoyers In-Reply-To: <87a5spvwoi.fsf@laura> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 2023-10-11 14:30, Olivier Dion wrote: > Hi, > > Commit ed19993b5b0d05d62cc883571519a67dae481a14 from 2016 introduce "a > new implementation of condition variables". This new implementation > seems to introduce a spin-wait fast-path to avoid taking the underlying > futex when doing a pthread_cond_wait(). Adding libc-alpha, Carlos and Florian in CC. Thanks, Mathieu > > However, looking at the following snippet in nptl/pthread_cond_wait.c: > > static __always_inline int > __pthread_cond_wait_common (pthread_cond_t *cond, pthread_mutex_t *mutex, > clockid_t clockid, const struct __timespec64 *abstime) > { > const int maxspin = 0; > [...] > /* Spin-wait first. [...] */ > unsigned int spin = maxspin; > while (signals == 0 && spin > 0) { > [...] > } > [...] > } > > it seems to me that the try-spinning portion is dead code in > pthread_cond_wait_common(). I was wondering why this was the case? > > I also think that there would maybe some interest in using the Userspace > RCU wait algorithm [0] for this. > > [0] https://github.com/urcu/userspace-rcu/blob/master/src/urcu-wait.h > > Thanks, > > Olivier > -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com