From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by sourceware.org (Postfix) with ESMTPS id 77D1A3858D35 for ; Thu, 4 Nov 2021 14:31:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 77D1A3858D35 Received: by mail-pg1-x532.google.com with SMTP id a9so5564614pgg.7 for ; Thu, 04 Nov 2021 07:31:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Mw9HM1elQJzspLxLXNnZXTEsbctXUyRRRBsrrmWWVgg=; b=Db+4/7OmKjEbhcPGQnG3+bZ05bKyGWFFJPdsKV+jgS2bFB2WuY+E54lClvQ0NsIWmH ku6SajbnPB8zKiwJmj6yA35tPFH02ACQu5gIYk3c96bG6ndWt61dnsemppuZqS4Kpppp zs9qp924YA1EyDw6UzmwXtUqcOsuB40FIbPUZKXBbzXNVf76uzv7MD49Tzz7AQsX7XKb su+4TX+IDi0MQ8nkF/MWZ+wYzzX1QaQ2VphMVy+kM01Lsu/kdJZwwPcE7RFdyyN9jQ8O 7lJexG4avjvJjrwWfURaVz//a9pF+1RGkTpHXm1ulzuJcyhV9V4W89b5xZfw6Yylo/Rs O44w== X-Gm-Message-State: AOAM533S9UeKAQ+6zgTZnRf3prFG1DbH8ocyGbamVfhMgE/EUZLLK5ZB zKc9Idlkmycee6RriWeeqCu1HcMyBCmTaE4g6JOHc7fq44A= X-Google-Smtp-Source: ABdhPJzu3nP+PjWWNiK2sWyi4kk+DuS6gy1lyFSyfH0nP2zxFtJ2bMf+9JFhMReF184uHg64l3EDzMDV5UBZPGqjc7M= X-Received: by 2002:a63:87c1:: with SMTP id i184mr21879482pge.75.1636036299554; Thu, 04 Nov 2021 07:31:39 -0700 (PDT) MIME-Version: 1.0 References: <20211103150415.1211388-1-hjl.tools@gmail.com> <871r3xb3it.fsf@oldenburg.str.redhat.com> <87ee7wi5v8.fsf@oldenburg.str.redhat.com> In-Reply-To: <87ee7wi5v8.fsf@oldenburg.str.redhat.com> From: "H.J. Lu" Date: Thu, 4 Nov 2021 07:31:03 -0700 Message-ID: Subject: Re: [PATCH] x86: Optimize atomic_compare_and_exchange_[val|bool]_acq [BZ #28537] To: Florian Weimer , liuhongt , Hongyu Wang Cc: "H.J. Lu via Libc-alpha" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3024.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Thu, 04 Nov 2021 14:31:42 -0000 On Thu, Nov 4, 2021 at 3:15 AM Florian Weimer wrote: > > * H. J. Lu: > > >> Shouldn't GCC be fixed to generate the appropriate instruction sequence > >> for this architecture? Should we perhaps switch to compiler atomics for > >> x86 instead of defining our own? > > > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103065 > > > > In the meantime, we should help older compilers. > > But wouldn't that extra read persist with fixed compilers, due to the > memory barrier? So that there are two reads? Yes, this could be a problem. > Maybe we need a hint flag for __atomic_compare_exchange_n, encoded in > the memory order? We need a way to identify the fixed compiler. We can add a predefined macro, something like __GCC_HAVE_SYNC_COMPARE_AND_SWAP_LOAD_CHECK. -- H.J.