From patchwork Mon Oct 24 23:24:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617894 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp3036071pvb; Mon, 24 Oct 2022 16:26:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7CWu3yStMfSsz27FM/fZkAYIXFwGGcu7dOsJQvWx/3Cr8lYMYfg8O8ovvOOjppvOTsHGoH X-Received: by 2002:a05:622a:591:b0:39c:f3c8:117c with SMTP id c17-20020a05622a059100b0039cf3c8117cmr29835489qtb.270.1666653980638; Mon, 24 Oct 2022 16:26:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666653980; cv=none; d=google.com; s=arc-20160816; b=U7Xx3PrcvEPr1g878ofpTgFzD7NEwEykqmDWv4NuwU+zFczqvo/GPcB7lgqnDZG+R+ 7ukT98D1dI0OXJjtgofvRF6agmFRmh8Y/XVi1388YIibnEPx9q+ML3yIY2qB0Q9FS1mj tDnJIpCGhRVE18IlHsEPUcExTgbu1g75/Kl40eAEBzK7RHD9KfPYNgOAi2d0yoCilxjl XuAgQTtRDcvP0mjkiCdApTHKX5iQk9Ld2xzyZuZmoHKPhhNlWhCZ3kIWi35LTCV2dYw4 ewPR1WZpNyjxQc739gppnZDIUtrT0eRQwEDkuF4R4ajrd+e2aJqVptFADngK5WskluMx i/tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=LJ+JQv3dsaa9WWtb7Vu+unKKfyu5T/tcB60KushyFxs=; b=RsEIfxD+OlYFT9OI+wvS42/nayZLR/Rh+gxaS68HxWbiL1MA5iLuq5W78eR4BYxMX3 blDENveRJRM7wNBnCdpbavY6a6NlcM0P+o5QpSlktTLgi7VNUZJ93bilzSpgdBaOfXTE lc92ztgO5BI/2Mny67ZPrJRT1bm5jNscaxBSUI3ArUCz7Eb0CwUgkeCbp/MkhzpW99Y/ ZPMHjs3DW+YRDvQRXIZ2ATlC7TDwjeIMqHp0iMWVgZp0oKWKFXCoZyzZqRyNubFCH1AK 2aIxZVTy2t11bBDs3jPcfhVhbKGos4F30FPxT+8ktEEIaeh0Uk3f5O4cDvPNx361oes2 MeNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=th02GPJz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r13-20020a056214212d00b004b799333465si812050qvc.482.2022.10.24.16.26.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Oct 2022 16:26:20 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=th02GPJz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1on6oS-0000fi-S1; Mon, 24 Oct 2022 19:24:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1on6oP-00008D-UI for qemu-devel@nongnu.org; Mon, 24 Oct 2022 19:24:53 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1on6oL-0000F4-AV for qemu-devel@nongnu.org; Mon, 24 Oct 2022 19:24:53 -0400 Received: by mail-pl1-x635.google.com with SMTP id j12so9742762plj.5 for ; Mon, 24 Oct 2022 16:24:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=LJ+JQv3dsaa9WWtb7Vu+unKKfyu5T/tcB60KushyFxs=; b=th02GPJzxhvyjQqh/DI514LqgLPG5l5afg+cE66ZxkF58AfCb46aBuVzv2VWzlEw0y JmcGlI9XiNTrgVZtG8x7hd4aCuqTGIZkTCC0+SLgDOToRD9LiDKM899xcH5TbJ7FDVId GhlkITIP/jdTDM1Zc6ZVPffekqc8Mg+W1daqdMzw2g3NqNyrm1NI1f9z0VonwYwkjrer fy2UMYrTK6CnyoEbC2yQnbVDTH7o3gAeHoc72u/BogW60jOQtw9xrOAq1SdCkB2YXF30 oV47tRWq4xWcnLjdMuP366+Wr36USKMQ3qdZyTBTZX74r0WWO1qlPpmIrZCkFSjzqsle rXjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LJ+JQv3dsaa9WWtb7Vu+unKKfyu5T/tcB60KushyFxs=; b=K2CVuuBiPH9ErDh0CXmpJ8YMBs6RgohbMHDMEo1fOpKy7vMHvj02u/PvuPIfcEUWPM 3yGabhgaX1E0CH00rRuv4eQhFjg0/Q+k7pdJCgOZNnSczqHNbRYGteTKJcZEDE6OpDsX 3G/tMO9uXrJTER7jSV8gv96q8pnWSUCVqDk3PYQ46nIioqcMHiyzxy3cacqx5T7I5jHT RMrHuTQp5DBdbHeYXXorhia5Ny/0zLhjj7ViaLu1knJEPU2HXH1NhWFCagFF6tDa6vLp soh8Kj8zVMn2HTelpwIOPkL6Ci1Vd5hBDZeWxD2DWNBOKRQQvCCf3o8LmiH9dzlIQ+d3 XPIA== X-Gm-Message-State: ACrzQf33SRy/RHThIrxo3VFfjuX4PVqYTInUuVQlgdUmuhct9zjGQIuW gReKIy+U9npCuxRhztIaDOvln/cUvliDIQ== X-Received: by 2002:a17:902:d484:b0:17f:7437:565d with SMTP id c4-20020a170902d48400b0017f7437565dmr35518531plg.154.1666653887892; Mon, 24 Oct 2022 16:24:47 -0700 (PDT) Received: from stoup.. ([103.100.225.182]) by smtp.gmail.com with ESMTPSA id k3-20020aa79983000000b0056bfa2cf517sm324788pfh.3.2022.10.24.16.24.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 16:24:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 3/4] include/qemu/thread: Use qatomic_* functions Date: Tue, 25 Oct 2022 09:24:34 +1000 Message-Id: <20221024232435.3334600-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221024232435.3334600-1-richard.henderson@linaro.org> References: <20221024232435.3334600-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Use qatomic_*, which expands to __atomic_* in preference to the "legacy" __sync_* functions. Signed-off-by: Richard Henderson --- include/qemu/thread.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/qemu/thread.h b/include/qemu/thread.h index af19f2b3fc..976e1ab995 100644 --- a/include/qemu/thread.h +++ b/include/qemu/thread.h @@ -227,7 +227,7 @@ struct QemuSpin { static inline void qemu_spin_init(QemuSpin *spin) { - __sync_lock_release(&spin->value); + qatomic_set(&spin->value, 0); #ifdef CONFIG_TSAN __tsan_mutex_create(spin, __tsan_mutex_not_static); #endif @@ -246,7 +246,7 @@ static inline void qemu_spin_lock(QemuSpin *spin) #ifdef CONFIG_TSAN __tsan_mutex_pre_lock(spin, 0); #endif - while (unlikely(__sync_lock_test_and_set(&spin->value, true))) { + while (unlikely(qatomic_xchg(&spin->value, true))) { while (qatomic_read(&spin->value)) { cpu_relax(); } @@ -261,7 +261,7 @@ static inline bool qemu_spin_trylock(QemuSpin *spin) #ifdef CONFIG_TSAN __tsan_mutex_pre_lock(spin, __tsan_mutex_try_lock); #endif - bool busy = __sync_lock_test_and_set(&spin->value, true); + bool busy = qatomic_xchg(&spin->value, true); #ifdef CONFIG_TSAN unsigned flags = __tsan_mutex_try_lock; flags |= busy ? __tsan_mutex_try_lock_failed : 0; @@ -280,7 +280,7 @@ static inline void qemu_spin_unlock(QemuSpin *spin) #ifdef CONFIG_TSAN __tsan_mutex_pre_unlock(spin, 0); #endif - __sync_lock_release(&spin->value); + qatomic_store_release(&spin->value, 0); #ifdef CONFIG_TSAN __tsan_mutex_post_unlock(spin, 0); #endif