From patchwork Mon Mar 6 01:57:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 659220 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp1593921wrb; Sun, 5 Mar 2023 17:58:35 -0800 (PST) X-Google-Smtp-Source: AK7set/6NDroMSi6qh32sNdB1wFjyz8vV93VZtC/wVewGpAhYZSmLG7NCZNVzNNzqJkT9DFe7geE X-Received: by 2002:ac8:7f01:0:b0:3ae:189c:7455 with SMTP id f1-20020ac87f01000000b003ae189c7455mr12935278qtk.47.1678067915258; Sun, 05 Mar 2023 17:58:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678067915; cv=none; d=google.com; s=arc-20160816; b=kbcoCz+c4KqUJpdRflm761n8RzmAnQyo7gv3bsGFFUlyaOPo0dTgDRkxGoxq+mK5AX copUdHsdC5i5bRQ0IW2gEx0Hz4ildw8bjHvUZlu939JuLa9uoTEgcuSd8dJaezp8hrW8 8QdsjwpDUCgGbPXClJeRNkyM0CBXz+CdM41SSLb/Pg3jdH9HNIdqGhrA/pkK40la/0XG ZUG6fvjRJKOEAea9p7gCeCLoO/U30C42WawrVxjiLsp6hTpb1JGlgRvwAmRl5/hGa4gw yNlAhAnW7I3Y6J6bB7XXM/ZSvJbD/E58i3Gtltsq8WQdxazAdkllFotSjBouMmudDNLg 8I/A== 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=+/1/w+4tCdZdhSP9X+tt6DrDGtiinyr2Hzdz5vlpulU=; b=H6Uac5hPp5m/FoG1dpZ/C6xwxUv6Ac2ne3VdxCHG3xJDFxidyvrW+hyvM7xWgkwOmW vmg4+SeyoZEpxFehwXcOsZQKXsGXNr823FKn3J5hBks2TtnHtJ+JLMWcuVsJfNctlQv/ QEq0RbYcsjjthlIWSKrCNTm/rBoV11aYPz4KKce0nmFY4Ia0/bKg4VjVtAfh73yaLfPN pzNsoa6hQwC4EquLKmtggReb1lb9EbpjIxy3wR0mtiUH821idRKAmOHt2aWqKFSO7Y7t v3idQWbPQa5/IOPnaWShyspCVEe0GPvSD/UnWj+jqJpXuZXWODiGnaglebDTTHDGZIpV TgGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mcF5GPkM; 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 69-20020a370548000000b006fcacb194efsi6171933qkf.53.2023.03.05.17.58.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 05 Mar 2023 17:58:35 -0800 (PST) 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=mcF5GPkM; 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 1pZ06L-00048c-MY; Sun, 05 Mar 2023 20:57:21 -0500 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 1pZ06G-00046N-1F for qemu-devel@nongnu.org; Sun, 05 Mar 2023 20:57:16 -0500 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZ06E-0003IB-GY for qemu-devel@nongnu.org; Sun, 05 Mar 2023 20:57:15 -0500 Received: by mail-pg1-x536.google.com with SMTP id 132so4596372pgh.13 for ; Sun, 05 Mar 2023 17:57:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678067833; 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=+/1/w+4tCdZdhSP9X+tt6DrDGtiinyr2Hzdz5vlpulU=; b=mcF5GPkMR+E18ihieGu5KHIdv49TWmzsHj/+e1nCFODTvepOamAp+HI+jcVywrOanW LVP13pl6WPlPaQ95a2Bx0wdf3YkDe9kTmykyDWX4qboMKW7BXOqjlx+x2ijlA3OAWI/a DYVCC912KvoGRLJKqP+f92lnt6hod4Dctl6rGbJNcom0zepzD/oJr9lIITAyPPJgy2m4 VPeeOwbsyDXEaZzuwm47MqmfNmMUs6VHAihoLvhKpZxtVRabbtRwZoT1EsHU3h2XchqI eTusr+6+8tfRyrxxP/b7GQgEhF9+yXv+3q4PayDTzB5YwyDkOy6CloQm4fEoZgT2V0gr bD9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678067833; 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=+/1/w+4tCdZdhSP9X+tt6DrDGtiinyr2Hzdz5vlpulU=; b=PFp6eBQXQ5Hcoab4fIRtT9zxyc639JB14ux6AELluGXySuX1lN5XczkATEhPLZA6XW e8t/CaeZ+yovIQcgrgSdgpShFMWoT3mLME+qjB+SiTSMqB61XXk1pp3yrK+mFhft12qa NCEvKirZzTmlyNDcW4TBgKg5cV3CmwRbc9Kr/cHwzac+XJAzCqoLay/rk33wpEWFIeND zQFxCFMo3JCzNTmRGym6t1SUnwRu0axWDWlMkBqiWm9I1J7SwzjFR2K46iWoV31GvM3n b7DaJG1T02/43h9dzz07GcE4yBIgVm9bGpD3Ja+IB0BZtM/H/kgw2mUna7hSwiiWNLds 3f6g== X-Gm-Message-State: AO0yUKWEdzsJ/d/K+lV/WHaFiqdbWVvjdxEJUB17FsV7x1+9oCXZNU9x pInSLnlR2SRylcCly//KyKQTZ0H7BsBCUhoKof/K0g== X-Received: by 2002:aa7:9525:0:b0:5a8:ab87:eda with SMTP id c5-20020aa79525000000b005a8ab870edamr7615732pfp.20.1678067833237; Sun, 05 Mar 2023 17:57:13 -0800 (PST) Received: from stoup.. ([2602:ae:154a:9f01:87cc:49bb:2900:c08b]) by smtp.gmail.com with ESMTPSA id g23-20020aa78197000000b0061949fe3beasm2921056pfi.22.2023.03.05.17.57.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Mar 2023 17:57:12 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com Subject: [PATCH v2 2/5] tcg: Elide memory barriers implied by the host memory model Date: Sun, 5 Mar 2023 17:57:07 -0800 Message-Id: <20230306015710.1868853-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306015710.1868853-1-richard.henderson@linaro.org> References: <20230306015710.1868853-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::536; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x536.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 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 Reduce the set of required barriers to those needed by the host right from the beginning. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- tcg/tcg-op.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 75fdcdaac7..2721c1cab9 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -107,8 +107,13 @@ void tcg_gen_mb(TCGBar mb_type) * (i.e. !(cflags & CF_PARALLEL)), however, even with a single cpu * we have i/o threads running in parallel, and lack of memory order * can result in e.g. virtio queue entries being read incorrectly. + * + * That said, we can elide anything which the host provides for free. */ - tcg_gen_op1(INDEX_op_mb, mb_type); + mb_type &= ~TCG_TARGET_DEFAULT_MO; + if (mb_type & TCG_MO_ALL) { + tcg_gen_op1(INDEX_op_mb, mb_type); + } } /* 32 bit ops */