From patchwork Tue May 23 13:47:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 684923 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1728678wrt; Tue, 23 May 2023 06:48:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5M5la4dBqp+G9VA8uRzjSXbKQdOBSXHaW78d6TBITB/AxNKrDUbFOIqInAZvO/voUM8bhZ X-Received: by 2002:a05:622a:184:b0:3f4:fa05:ff61 with SMTP id s4-20020a05622a018400b003f4fa05ff61mr23397094qtw.59.1684849709423; Tue, 23 May 2023 06:48:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684849709; cv=none; d=google.com; s=arc-20160816; b=sozsjUqBnr71rS0ugPiA/JRrLgPaCJtjWRkyuVnKyJ/QNIgt7IWKZUuDA8Y7NYkI8A vNfBm6wC1QS/XIP2MzS10Ne3/PtORttB6XhYRbgrdGJpYGGqrrX9N/i2O7V5/U0bwk42 9OTXKJFe80065OHnk5HYlndSmHBueROzChiX0h8IYnWHnR52e8TOzW0gZ6/VupAKjMXZ eGUPXN0n87GHtCF25a6FU6Zw2/1x6mQzx4uopobo5PBWlSw3cw9hfG1JoSocB+xKQLiA 9POukvGYniWWdyfiMFB544DcFmpFtxydsc8MD9Xn5FNllPAn17jaclhf/HLzjgsntr0z wLXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=6WXDf+ZM8xKRR3ok9Sko5lUMigoP5WIzPelyBaHT6/A=; b=WurQrU6OnSuOeCTQXj/n5SEm98qV22mTZwF086eg5yvaqy7WAl2jyXPIph2VN1CDqv QWgy88pizkDJDsMlO0mRa/l/1mtpHR3p+zhc9tq5y7z7wXqny8cZOWkSJUUZBYEf56p6 SiUWi/K3Iz6LkEqjxY2aDXd5X20u4/4xGRt9xjphe25VX0b6nrXi4ssw9KScljMROSty 0JVB75uSK8EVj0ciyUUkfZmIWaMpIUfAfe4aGS4j6UugCpVzOc5a+aIqwuSXltxcirhL 2weWNAAgvQUOAxTyu7ANEj6MI2z35L3p78zbup6Tb+KU9G3PchRexyBdqZ8QnP3flAO7 OeiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LHzBkzOP; 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 h9-20020a0562140da900b005ef56e4f61esi5227474qvh.90.2023.05.23.06.48.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 May 2023 06:48:29 -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=LHzBkzOP; 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 1q1SMs-00019b-SH; Tue, 23 May 2023 09:48:02 -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 1q1SMq-00010Q-Bx for qemu-devel@nongnu.org; Tue, 23 May 2023 09:48:00 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q1SMn-00016c-RI for qemu-devel@nongnu.org; Tue, 23 May 2023 09:48:00 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-64d5b4c3ffeso2141962b3a.2 for ; Tue, 23 May 2023 06:47:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684849677; x=1687441677; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6WXDf+ZM8xKRR3ok9Sko5lUMigoP5WIzPelyBaHT6/A=; b=LHzBkzOPg1fzTGbJrq0pBhfshleqDI0+hu8H7iD9HEW+ugZuYghdycyGcJQjySw1jK 2zA8HTOdLgfHB9JKYMCXrdzWlGNW3wT4PKLawoMFFmRXuRExFMcS6jwm2H3qwQCJfTqm thELLd3qTDWHwkcGAGZ8SSHtRPqD4RxwILVrrYppBAKMeBvZfkJCsQGIyRXzr3TH22Lz 8dh0/J4BJw27MVs/Ghj4Xo85E580kBg5HIqqIfsOEd7q+NgdTgZmbSsIFOjEfMC2AbK7 QweU1tILIy3CnluGMoFti2zdWgxwosEys0DQTrgq+YNsqmd0x8MVCaPQzNbIbjMXt3z0 OeHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684849677; x=1687441677; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6WXDf+ZM8xKRR3ok9Sko5lUMigoP5WIzPelyBaHT6/A=; b=MiN47GiT+3cM9yy95J8zrUyhDZqoMLrhpshRFou/vuVF97GykF8kQJjLYdqZ02/Qew SkWxO6/yHAKUiFoYjzx8SZskUAXpZ0PIJzNnuFDbI2QMnM/fodAtNb7fdiM/FChQc6rO JQkapiIulpZP4wsq4wROkWphPDG8uAeupO9KilflqEpMs9HUoW1YHQSt7DJeqeMZZev5 rhhq4gNXpEgoZrgDJaCznUbvW9IEnTL/L7dHdFiIAA1gTYmNron3/T1Fa5jMHFfRckTk jkvWtZSTLnlgY7OZSTsEWjCt+s1rnIPeWVP5n6n39eRtDT+CjxGXZWB8+ZZFlWkkqnTZ 2k+A== X-Gm-Message-State: AC+VfDx5c4gKuKabP04OLp28RffN2m0DOTbYtzfSrKi29XzaqTrshQ1w 2WS5snjfGMs8x5cjXl2wCSwJUB80cQKW1NmLhXc= X-Received: by 2002:a05:6a00:804:b0:64c:c841:4e8a with SMTP id m4-20020a056a00080400b0064cc8414e8amr19532639pfk.22.1684849676811; Tue, 23 May 2023 06:47:56 -0700 (PDT) Received: from stoup.. ([2602:ae:1598:4c01:c13a:d73:4f88:3654]) by smtp.gmail.com with ESMTPSA id j4-20020aa79284000000b0064d1349dc31sm5737122pfa.199.2023.05.23.06.47.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 May 2023 06:47:56 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org Subject: [PATCH v2 25/27] qemu/atomic128: Improve cmpxchg fallback for atomic16_set Date: Tue, 23 May 2023 06:47:31 -0700 Message-Id: <20230523134733.678646-26-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230523134733.678646-1-richard.henderson@linaro.org> References: <20230523134733.678646-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Use __sync_bool_compare_and_swap_16 to control the loop, rather than a separate comparison. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- host/include/generic/host/atomic128-ldst.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/host/include/generic/host/atomic128-ldst.h b/host/include/generic/host/atomic128-ldst.h index 79d208b7a4..80fff0643a 100644 --- a/host/include/generic/host/atomic128-ldst.h +++ b/host/include/generic/host/atomic128-ldst.h @@ -58,11 +58,14 @@ atomic16_read_rw(Int128 *ptr) static inline void ATTRIBUTE_ATOMIC128_OPT atomic16_set(Int128 *ptr, Int128 val) { - Int128 old = *ptr, cmp; + __int128_t *ptr_align = __builtin_assume_aligned(ptr, 16); + __int128_t old; + Int128Alias new; + + new.s = val; do { - cmp = old; - old = atomic16_cmpxchg(ptr, cmp, val); - } while (int128_ne(old, cmp)); + old = *ptr_align; + } while (!__sync_bool_compare_and_swap_16(ptr_align, old, new.i)); } #else