From patchwork Tue Jul 30 01:12:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 815270 Delivered-To: patch@linaro.org Received: by 2002:a5d:4acf:0:b0:367:895a:4699 with SMTP id y15csp111858wrs; Mon, 29 Jul 2024 19:26:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVXl/bG5Vo9hL82HaLWg+5mMbOyfniCGgIH55lKJTc+3OgV6QSn7gd7NzsXPyyF5QhEnE0EN9XHULwPHDZvD1lJ X-Google-Smtp-Source: AGHT+IH2kiNgeRfXKAl/1lpN5F+wWTO0OgpArJVB01ZDAjjoHHQZvWxRofoEUJn24d/8ks3zOLo3 X-Received: by 2002:a05:6358:5988:b0:19f:801a:44fa with SMTP id e5c5f4694b2df-1adce43fa44mr1726786655d.29.1722306390806; Mon, 29 Jul 2024 19:26:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722306390; cv=none; d=google.com; s=arc-20160816; b=S/ATwfA+ObMsBq+74XUY3e0avUOUz0c6l5dznRPhF3F3B7CQkqd6bY831j/h+SLX9c 0N6/h3zUVo77G4D7lFMuxAiERBtLSvl5G4BJHAtouazCLVxMfCmG8/+EgKFg012Yq8oP vKGlKRDs9EYptocxhfP/m7zdWeStEyrVAk0rweywnpJyp2v8V2F0hvYBlmh37HIuACY8 hjoIxntO+WCMsdvkFISsw78lPbL1hmaMNHc6FuZ1TGv8EchYgkkmFk1Se5dl9Q9BozWM VaSqKGJ3qAImidktLYypABaNK2pMpPubkq+/8YfnZqW/FHNO2CIB917daAzsEgypGO6W 9W/Q== 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=+xjo9tP3yEe4cBC1QG8qcYKpejenHpZvG1UA2aTLnj0=; fh=lonxpbI4rXSYWLTxWUP2SvazuCiyxK0bo2kbn9ImMrM=; b=JZMkjaku02MuIRIkd4BEnfwunYmiQoYn3nfMlseJlMsqF5GMgHffFazri8x/neI5OJ DFgdLVGz6Z0fZzAE025bNFuth/gPtA/pO4tsgPBq0DurUpcZMl/4ucQJqJcWHqBqKNsr ppN5INoLfNsTSIuHxL9KMG4UxjDbE7W8Zn/wU0OciRtfD3H/A7/z03sOoV7NLX9DAKe9 TfwdXIEepy/iLJ26c6o4i/EYbaI1wzJUVW11GPHTrsEaTiLLU0ywO+wgdVHsIpj4Rlfh H2XpzaSqzALdps5C2fdr+fnYq9jetSKBmey6xkueb9JrSovz86VKSQKVl0oEn7mieeaa EYcA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fJqWXfgi; 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 6a1803df08f44-6bb3f8cbfb9si120020896d6.16.2024.07.29.19.26.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 29 Jul 2024 19:26:30 -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=fJqWXfgi; 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 1sYcZ5-0000aR-Uv; Mon, 29 Jul 2024 22:26:15 -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 1sYcZ4-0000Qk-H8 for qemu-devel@nongnu.org; Mon, 29 Jul 2024 22:26:14 -0400 Received: from mail-yb1-xb2d.google.com ([2607:f8b0:4864:20::b2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sYcZ2-0007Y1-It for qemu-devel@nongnu.org; Mon, 29 Jul 2024 22:26:13 -0400 Received: by mail-yb1-xb2d.google.com with SMTP id 3f1490d57ef6-e05f4c63de6so2942855276.0 for ; Mon, 29 Jul 2024 19:26:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722306371; x=1722911171; darn=nongnu.org; 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=+xjo9tP3yEe4cBC1QG8qcYKpejenHpZvG1UA2aTLnj0=; b=fJqWXfgis+sfm/FmFl9g+1ND1mMrLW3SWCcqs7D6jSYgzf/FFEub0sPp+ReZSbjbyM UOLyyHfJFAQM7KpAOMxeT4yrPUUfUZJ/ZQkxZctBM+KuVKByIix0Xye0bGYW8mTzmISy gNsM6aYB1u3suxnoQEPrimKL+NtEnP5jr97tptu3Zcif1h7U9HlLhfauGZygWUoCN4Nx aTZSVgF4Z55pjAiBVhBhFnce+Q/ISgnhk4HPSY98kPqrLwr1kludRoSVqEH92YaRwtcj Tsj4fzSo+kn9wVxP8Bs5r6qdLIv/DRG9PRzU/bB4zf8vM6mBoqPtx/o2ax+KpUjmDtDB wNoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722306371; x=1722911171; 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=+xjo9tP3yEe4cBC1QG8qcYKpejenHpZvG1UA2aTLnj0=; b=INMKRPXLtIHWL85kirYRORXvclShvj04ZVJcx/AEa/vw3nzYMi/AXa+6OR6Yum6a+/ K2CFS8P9sorKwbOROhL7A+x0XDl8Ia6sjkOuDQZKT/VQGzS4Za14hkcm3bS3/GgGS1mt QA/JKbQQcVqJeZjOhgIBroEHONevp8UdIUOmEqqcZvZqBsc9bVt4ulz1YAR6ccrZ7kAc su/KWH0zY6RWnWx2oVWkvuY9uqbQqwljq+zWixITMa1nodNDXP6nOTWDr92dpybpqm90 75ri0+Hm5WbEpg8j+z9KbQGTH+Lu4EWLRgcItMXMc50dpIG4sMTsoYRbGr8SNGRHQ8kL n4YQ== X-Gm-Message-State: AOJu0YypV6wVVaswB/8IJqnxfiqYYc4v+TtE5GvTBTXFNom/grMwbwYD U6xXWxZdZHLIBP37t3yrcBrsDo7pYKYb13fXSlvA3TXJXHcsQeGWZmfu+zeV6JOccqLPfoGto/f AN8E= X-Received: by 2002:a05:6e02:b42:b0:382:3c83:6acb with SMTP id e9e14a558f8ab-39aec2dcf52mr108891715ab.8.1722301942009; Mon, 29 Jul 2024 18:12:22 -0700 (PDT) Received: from stoup.. ([203.56.128.103]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7a9f7c6ff4bsm6750206a12.4.2024.07.29.18.12.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 18:12:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Fabio D'Urso , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PULL 5/5] linux-user: open_self_stat: Implement num_threads Date: Tue, 30 Jul 2024 11:12:02 +1000 Message-ID: <20240730011202.480829-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240730011202.480829-1-richard.henderson@linaro.org> References: <20240730011202.480829-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::b2d; envelope-from=richard.henderson@linaro.org; helo=mail-yb1-xb2d.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 From: Fabio D'Urso The num_threads field reports the total number of threads in the process. In QEMU, this is equal to the number of CPU instances. Signed-off-by: Fabio D'Urso Reviewed-by: Alex Bennée Message-ID: <20240619194109.248066-1-fdurso@google.com> Signed-off-by: Richard Henderson --- linux-user/syscall.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b8c278b91d..9d5415674d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8168,6 +8168,16 @@ static int open_self_stat(CPUArchState *cpu_env, int fd) } else if (i == 3) { /* ppid */ g_string_printf(buf, FMT_pid " ", getppid()); + } else if (i == 19) { + /* num_threads */ + int cpus = 0; + WITH_RCU_READ_LOCK_GUARD() { + CPUState *cpu_iter; + CPU_FOREACH(cpu_iter) { + cpus++; + } + } + g_string_printf(buf, "%d ", cpus); } else if (i == 21) { /* starttime */ g_string_printf(buf, "%" PRIu64 " ", ts->start_boottime);