From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by sourceware.org (Postfix) with ESMTPS id A839E3857371 for ; Thu, 29 Sep 2022 18:52:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A839E3857371 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qt1-x831.google.com with SMTP id f26so1341698qto.11 for ; Thu, 29 Sep 2022 11:52:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=DS8QcaFlYBgvckNnSXm/l4Acve3kIa5zo16S3WjnSSQ=; b=mcvGwCP+/ilZnx1e3mm22OcfyV+kAeBG1BOAtlJDM1j1A+KAMoVf2be02Yz6sOK4S/ dgZjW8kH+1j8FMG0aLN1KZisUK9DA+1lW3IJZy101wCM1S077B2rRJKPykeBO3cKlj+n zaWePY3Hm0NFl2hSJ3m98d96q8O9fVnkjQ3h5ByyheOjHNTHEs0+wuImmcmxi0XizSe3 j7BnYJlFvzEbW8yzIhElTeBtsX2RfqDMMU1eBUBCYWW1XabItg29CL6a87bJ17+pz6G1 2d5GOD2GPYutZot/FgTQyRpB8ibS6HhOmrdf6EsVAk92rqS4SOro/pk9bm9RzE0Y+KHd fZNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=DS8QcaFlYBgvckNnSXm/l4Acve3kIa5zo16S3WjnSSQ=; b=H1LlE6R46FHG7sZvVTxFqKTdCT/ZRyQbdB1MoytAEZmqRgA24XNayYPdl17AdLftIK tLC1UpkYDST1sXbDLJ08DTGrNk/i7PjgD3vQQjQxk3gLCYkjf34DJNp3aZRzI2DLA/NC G8mr7N+8vcIOe9thl08dPLKUg76zy4vJXpVemmB95za9BRiTAjIynoA56/8hk1bSrip6 EYX6X8w7LU6wKe8Yx9JH4g9S1F+ViHeriZIdHA7KmiqJCqYNnMiBgCTpdmB6D5NfTQXe BkdcaBKzO3qSHQ0pNZ2AIs9FHoNWP6NzqAevBZhXFyqVaS5TJrAVjUvz41AR2Y8eVZrc +Zdg== X-Gm-Message-State: ACrzQf3eHeLV/opVWvZb8YqMpt5ERt4GfqZoTsoXyaKf+RBL5LNd2vKd OCloGd7ZlRUUuCHSdbeWwsRZK2aAAg1fxe+UALc= X-Google-Smtp-Source: AMsMyM6jP/Aad4X2RSlRbBcODrw+fsT06IbzA1zdtL75V4Tmi5XSOzrrAygw1snKusFZPUDk+G2OhjDH7cgwmcqw10U= X-Received: by 2002:a05:622a:510:b0:35d:50dd:3062 with SMTP id l16-20020a05622a051000b0035d50dd3062mr3704761qtx.437.1664477536071; Thu, 29 Sep 2022 11:52:16 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: "H.J. Lu" Date: Thu, 29 Sep 2022 11:51:39 -0700 Message-ID: Subject: Re: [PATCH v1 2/4] nptl: Continue use arch prefered atomic exchange in spinlock loop To: Noah Goldstein Cc: Wilco Dijkstra , GNU C Library Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3018.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,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 Thu, Sep 29, 2022 at 11:40 AM Noah Goldstein via Libc-alpha wrote: > > On Thu, Sep 29, 2022 at 9:35 AM Wilco Dijkstra wrote: > > > > Hi Noah, > > > > Did you try building it both ways? I don't think this could ever compile: > > > > + if (__glibc_likely (pthread_spin_lock_grab_lock (lock, &val, 1))) > > > > and: > > > > +# define pthread_spin_lock_grab_lock(mem, val, c) \ > > + atomic_compare_exchange_weak_acquire (lock, &val, 1)) > > > > The define uses 'lock' and 'mem' inconsistently and the use of the macro > > expands into &&val... > > > > Apart from that there is the question whether we should keep the weird > > ATOMIC_EXCHANGE_USES_CAS setting - I have removed it in my atomic > > patch series since most targets appear confused as to what it means (so > > are likely to have the wrong setting). Also there is no evidence it is actually > > faster. So using exchange in both cases is easier (and less error prone!). > > > > Also you do realize that no matter how much you change this code, it > > won't make a difference on x86, right? > > Why's that? x86-64 uses sysdeps/x86_64/nptl/pthread_spin_lock.S -- H.J.