From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x29.google.com (mail-oa1-x29.google.com [IPv6:2001:4860:4864:20::29]) by sourceware.org (Postfix) with ESMTPS id 5F5023853825 for ; Wed, 31 Aug 2022 18:14:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5F5023853825 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-11f0fa892aeso17755939fac.7 for ; Wed, 31 Aug 2022 11:14:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc; bh=RjJBJUGKXoH3BsEyLdop65HopMIfkiLg42JwayV3bzg=; b=luqXvxUTR0Kdpd0jcOPvd9ghR6k14c+B1c6oiLwBr+n2yDsGI2lbd6Zkfdu7jLJfwG WhYCcu2YPEOJXSxsd1ZaNyQsIhpgJ4Ct2sP936RdYJBL1t9JYVImyCF4+tJ/lW7TGXUH n8yfY9HqAaqq9iE7jdrK8H1uQUNRRoyuMdpAUT74u68w9PIt7sfbLZ4ckXKMyluxyvcj MirMpNNTwnLYbDpfBFRq7BAqoFn2PzufU4B+XEH+Z+MKuZeJfAonV3yjdt/bhqC7zXot 6D7VULt7YJM8Uo8gR0TWP1CwLOzJ3Y+0UbZ1h6NH8bpbvWBv4c0bG4tarRfpGfOjfTJQ xEoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc; bh=RjJBJUGKXoH3BsEyLdop65HopMIfkiLg42JwayV3bzg=; b=q4tnICSHPgeYbcHEmb7Vxqj6T4IhheoJAfYcpOMLany38g6EgZouCz/VJ8/8clLZdP isbxrv5BOG7SsFifHZKMxV2A/1vUSazsyiLifU4GjFhKZYGXpSGUXgdl2CqNF1CLEISz PcqbpWMSaDhryIdLc7ak1EpYmlguSeBPXSXipAMGUFiS8ZMQ6f9unbpPnZR8wpTn2Dpt sX98gHEO+fEETjOFxvo/8qNicQ735oaERZfhTFv6lCzfIXotloWtB0QIDlHluudxtTfJ QdiD4QwjKAunLY1pg4P9V9s9YXDFqC0y3Gr9CyImYlfKF5aDvgf94LadLT8nFIQtEQ/3 XSfg== X-Gm-Message-State: ACgBeo3v2+9T/PKxrkrlIyOP8Vn6yxuIuzNO9/ua0g4i0h0BtN6KvOG0 jEru4N1WPkiq9DqirQ7IH3Irf7cAbf5BaQ== X-Google-Smtp-Source: AA6agR4V10wBjx9G1Rw0TFXGnDhxNBjPZWZy6CQ9xjzCRANLCqxIN2ijkIj6PndLKUfMssrx0rem3w== X-Received: by 2002:a05:6870:40c3:b0:11d:7f61:fc50 with SMTP id l3-20020a05687040c300b0011d7f61fc50mr2048435oal.45.1661969667566; Wed, 31 Aug 2022 11:14:27 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c0:745e:a396:a3e3:72c0:b7c7]) by smtp.gmail.com with ESMTPSA id z4-20020a056830290400b00639749ef262sm8256166otu.9.2022.08.31.11.14.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Aug 2022 11:14:27 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH] elf: Use C11 like atomics on _dl_mcount Date: Wed, 31 Aug 2022 15:14:24 -0300 Message-Id: <20220831181424.3875750-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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: Checked on x86_64-linux-gnu. --- elf/dl-profile.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/elf/dl-profile.c b/elf/dl-profile.c index ec57e3a965..06dbeec4b1 100644 --- a/elf/dl-profile.c +++ b/elf/dl-profile.c @@ -548,7 +548,7 @@ _dl_mcount (ElfW(Addr) frompc, ElfW(Addr) selfpc) size_t newfromidx; to_index = (data[narcs].self_pc / (HASHFRACTION * sizeof (*tos))); - newfromidx = catomic_exchange_and_add (&fromidx, 1) + 1; + newfromidx = atomic_fetch_and_acquire (&fromidx, 1) + 1; froms[newfromidx].here = &data[narcs]; froms[newfromidx].link = tos[to_index]; tos[to_index] = newfromidx; @@ -558,14 +558,14 @@ _dl_mcount (ElfW(Addr) frompc, ElfW(Addr) selfpc) /* If we still have no entry stop searching and insert. */ if (*topcindex == 0) { - unsigned int newarc = catomic_exchange_and_add (narcsp, 1); + unsigned int newarc = atomic_exchange_and_add (narcsp, 1) + 1; /* In rare cases it could happen that all entries in FROMS are occupied. So we cannot count this anymore. */ if (newarc >= fromlimit) goto done; - *topcindex = catomic_exchange_and_add (&fromidx, 1) + 1; + *topcindex = atomic_fetch_and_acquire (&fromidx, 1) + 1; fromp = &froms[*topcindex]; fromp->here = &data[newarc]; @@ -573,7 +573,7 @@ _dl_mcount (ElfW(Addr) frompc, ElfW(Addr) selfpc) data[newarc].self_pc = selfpc; data[newarc].count = 0; fromp->link = 0; - catomic_increment (&narcs); + atomic_fetch_and_acquire (&narcs, 1); break; } @@ -586,7 +586,7 @@ _dl_mcount (ElfW(Addr) frompc, ElfW(Addr) selfpc) } /* Increment the counter. */ - catomic_increment (&fromp->here->count); + atomic_fetch_and_acquire (&fromp->here->count, 1); done: ; -- 2.34.1