From patchwork Fri Oct 4 22:01:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 832772 Delivered-To: patch@linaro.org Received: by 2002:adf:8b52:0:b0:367:895a:4699 with SMTP id v18csp989408wra; Fri, 4 Oct 2024 15:02:48 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVa2E3w5La+PUpoucJPLDxyfKF/821F+JB2qclDcy7/9R/UiLdQ63C+ecqKAYwRdXiyNJ5QFQ==@linaro.org X-Google-Smtp-Source: AGHT+IHktYIo6pkbm3VGwERyyZAQlP6UKVJWVeLRpryCVYfnUFewFyu4rV9yFrQVmUtf2A2oEz/n X-Received: by 2002:a05:622a:2992:b0:458:3d1b:8de4 with SMTP id d75a77b69052e-45d9bad188fmr66061101cf.39.1728079368618; Fri, 04 Oct 2024 15:02:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728079368; cv=none; d=google.com; s=arc-20240605; b=EBV76FRw7cEmr6UtPLo0A7TtGrWUmZqf2L8YMEk/RJqgA5fZ0Iy9MvL22S+XExWzlC PdVhLwfHPf5B0BQHtDUx9KpKx0AdgquJz0nRISjW1g4UBtsms/jeeUShqkroOiKslzOj I8sRcwpch46oAWLm9CrWH5ynUXFUMIPmOKlUqilYl0CuvxJDvpeyyS7qiyy5kIPzv1xT UNp5WC6q5tn//pX0IIBgMPCgsD3MU2ftJq3s3HaOT1RUBvtQuukAIUa23hH9gOSKF1oV +3C/E9oYAQiIXC0pn7tgZKcgfOzcbjGW7aKHROjr2Q5NhBAEfGHR1zNP+9zGMKCO51hS Of0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=B9aeWbyilAxD5P5/MJ59HQbUx4/6MyklNnTK3nyBp6g=; fh=bOQPglbSCzp47jhhsqGEJIaVQrbufQK//IH1paXjWYk=; b=J54suvbNmEY/ti9qcN499VXGK9EBdlJpqaEwPkWr041xnW1ZnvBCgSDqdbBtsQQpvl dunjHgOCzLIQoUhq5kOlyQPqj8VFIBZ62AhI4ZhpKAGKae33jXhrU2KDNjHOEkikUx3L URLlpM5saI/IKYknZW7ltHo6N6b7RCWdri+ZjsIfRnXnEcgHc3qy35JMv6CGiaO8VV81 slTcsFoDKMPHxWS+4TSByqXB37j2Jg60Zoly0KIO/BInV0ukMRM4lGXsNXcQg1+Ypk0D pgG1zUizFJghYPpYHQ5GoNvd4YnFEXbCmAON+stgQwnYcM0CWeOebJxiJof18LfH8LZh Q1Dg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NIhZjziw; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-45da76b94d6si7076331cf.650.2024.10.04.15.02.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Oct 2024 15:02:48 -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=NIhZjziw; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1swqMn-000501-KR; Fri, 04 Oct 2024 18:01:41 -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 1swqMj-0004z1-Ge for qemu-devel@nongnu.org; Fri, 04 Oct 2024 18:01:37 -0400 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1swqMh-0000f3-S3 for qemu-devel@nongnu.org; Fri, 04 Oct 2024 18:01:37 -0400 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-20ba8d92af9so20390485ad.3 for ; Fri, 04 Oct 2024 15:01:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728079294; x=1728684094; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=B9aeWbyilAxD5P5/MJ59HQbUx4/6MyklNnTK3nyBp6g=; b=NIhZjziwqJSP3jHvZ9PvgZSRCf15qWrgnqBFMZljQX6QZIx3lMizBFEiiQQ7ifDl8V pUUAVgcWbRhISr9GvMt6ZHeGp1qQqX4FoV61ah2tUDACO441lEB4PZJg1b3/zsea3GyK 1QVvkUqewT0mJWVZxj2O5oN65401jJzLR92QJZeoA/G+UOi4lWVTEnSJcCDIQG7T3yy+ cHNb0EN4bktUHdLaKr6Y7lhT1zTPaGn1RRkzwYeoX+g/PqhRyXzyMwi69UwNw7mjUTb0 usajmkEyUGwxKU0BseEf8HRYSy8Kbp1Ulzny1npR6X78naGsf+4OG95fo6HDJ0XDOPQD I0tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728079294; x=1728684094; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=B9aeWbyilAxD5P5/MJ59HQbUx4/6MyklNnTK3nyBp6g=; b=ApVNKr7CF0YkXetKrrac/9pAKZm/zrdjsknjKXSQQAro/Hj1I8zI3Y/RPnF0OjjjpY a6qyUD1L22I6xIGOlF8W+NR0mi0ISVklBkSTAFgPs+J5fa5IGFJWqzVZgtADPpTSGKs3 3bc6DAL51GU1McIce3nHn+Om/tqnmgDO0sJxaqdbz6IE0/uINrH+O5sPM7deTjnljZJH A+IO7UQ02ez4YlfQ+7U5fuhMPqCQEty5c2J2q0GpBxDVqZeg9lbI0PoGO8JF0s6LDeWd EBjKnaJPF0pyawaqA2sGkGJIvqtqqsOCttvPit4hnsrRTRJAeMYCvMM08124FW0L+yeh GfWg== X-Gm-Message-State: AOJu0YyYRq6Af0cdhrV6lew09myxTKQZSqN/qnFHD+pWaQ1zDAmJIYqC dv4dS1jtWp9/sqKkWEfGl8lPbWnOlKmvW1T+BzUN9IxY2HmGdpHfO6xVQdctXvOUR4yW+OoNnx7 h4pU= X-Received: by 2002:a17:902:d491:b0:20c:15d:c328 with SMTP id d9443c01a7336-20c015dc480mr43687355ad.56.1728079293787; Fri, 04 Oct 2024 15:01:33 -0700 (PDT) Received: from linaro.. (216-180-64-156.dyn.novuscom.net. [216.180.64.156]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c13968ca8sm3054375ad.210.2024.10.04.15.01.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 15:01:33 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: alex.bennee@linaro.org, Paolo Bonzini , richard.henderson@linaro.org, =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Phil?= =?utf-8?q?ippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH] meson: ensure we enable CMPXCHG128 on x86_64 Date: Fri, 4 Oct 2024 15:01:23 -0700 Message-Id: <20241004220123.978938-1-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62d; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-x62d.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 Alex discovered that CMPXCHG128 was not enabled when building for x86_64, resulting in slow execution for wide atomic instructions, creating a huge contention when combined with a high number of cpus (found while booting android aarch64 guest on x86_64 host). The problem is that even though we enable -mcx16 option for x86_64, this is not used when testing for CMPXCHG128. Thus, we silently turn it off. x86_64 is the only architecture adding machine flags for now, so the problem is limited to this host architecture. Meson compiler tests are supposed to be independent of environment flags (https://mesonbuild.com/Reference-manual_returned_compiler.html#returned-by). However, CFLAGS are used anyway, thus masking the problem when using something like CFLAGS='-march=native'. This is a meson bug and was reported: https://github.com/mesonbuild/meson/issues/13757 Signed-off-by: Pierrick Bouvier --- meson.build | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index b18c2a54ab5..af2ce595dcc 100644 --- a/meson.build +++ b/meson.build @@ -2867,6 +2867,13 @@ if has_int128_type config_host_data.set('CONFIG_ATOMIC128_OPT', has_atomic128_opt) if not has_atomic128_opt + + host_flags = [] + if host_arch == 'x86_64' + # for x86_64, x86_version must be >= 1, and we always enable cmpxchg16 + # in this case. + host_flags += ['-mcx16'] + endif config_host_data.set('CONFIG_CMPXCHG128', cc.links(''' int main(void) { @@ -2874,7 +2881,8 @@ if has_int128_type __sync_val_compare_and_swap_16(&x, y, x); return 0; } - ''')) + ''', + args: host_flags)) endif endif endif