From nobody Mon Nov 25 01:47:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1718826164; cv=none; d=zohomail.com; s=zohoarc; b=gCqvTS8LoXVDDTRd+yv90+GvGed7MHqREhYa6BU2EArKyTPS5hRWnuYy3fotucAVVVErVx8eQzZsOz/joUYcUtyC+XHKwcpTyq6yoTY0enukliK8WVV6X31VmnQYQBD04G6TELBEgwtvjgN8L/8dJXsmPk0poPrXbMlUJy7fteE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718826164; h=Content-Type:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=45aR8XKSAshFgZd0VPIUYMSxh9sFB0D+IHfcIJxI7tU=; b=TGHblKiIRv9WG+svlUhqSTWwUwWiq4YToJjZMyfYJNghtRIb9psyeBVcSFiOVI5I7UR1O9BNPwwWWx0HbTv+xmLED9fq1uLTAa4h7alyKReDO7NtEPkgHxq7+8egSAtaqUeucfCIDj6wnnxXHv8mUUCr91BlSg6shNE23EUVaxM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718826164116405.14327305799077; Wed, 19 Jun 2024 12:42:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sK1Bj-0000qF-BQ; Wed, 19 Jun 2024 15:41:47 -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 <3dDRzZgYKCuMKIZWXTLTTLQJ.HTRVJRZ-IJaJQSTSLSZ.TWL@flex--fdurso.bounces.google.com>) id 1sK1Bh-0000q5-GO for qemu-devel@nongnu.org; Wed, 19 Jun 2024 15:41:45 -0400 Received: from mail-wm1-x34a.google.com ([2a00:1450:4864:20::34a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3dDRzZgYKCuMKIZWXTLTTLQJ.HTRVJRZ-IJaJQSTSLSZ.TWL@flex--fdurso.bounces.google.com>) id 1sK1Bf-0004qX-Vt for qemu-devel@nongnu.org; Wed, 19 Jun 2024 15:41:45 -0400 Received: by mail-wm1-x34a.google.com with SMTP id 5b1f17b1804b1-42183fdb37cso1187475e9.3 for ; Wed, 19 Jun 2024 12:41:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1718826101; x=1719430901; darn=nongnu.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=45aR8XKSAshFgZd0VPIUYMSxh9sFB0D+IHfcIJxI7tU=; b=rLiXlL4qLnRXLh6kwje6dc+t6nblxCX9hJHjSarlWDifsiekzQnl7WnS2eYREzNsTR 03xstF6bU5RlbbrboB0QOLqhEryl1I4Yhc7p00VOjrCosV9gbiYbSCjTN9D7CfrEq/8S yWJSdadhiqT45IDyyrrZYy8iZ4YSjxXnN4OAzCmnee+UDyDPRVT68siR2VkquV5qyV2r PDiDmSsNvZAQzFQ0OSm7Jg/SGInqqZJnvM2rxmdLw3PfQGNwjpAcKoWsAcaa0rCQ6RQc iFwgfu6Zo4vMvXM3Ze78iQrfZK+Z+aAVKRAjni0o07Yp31a5oBIcWNJuchEWpYitM9iy bjrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718826101; x=1719430901; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=45aR8XKSAshFgZd0VPIUYMSxh9sFB0D+IHfcIJxI7tU=; b=HQxgkkK97GBkAOpyV6wkG07MFTNenSN11joB0uCMVLh1/qtcjYHM/6akf54+WWW0xC G56vglNhYiPwRuATzZqD2KKoqs3iI8TfGhwswY57xI2QkIsa1q+58SI11PcFFTV4yMML OJ4PYg0lTLRkpklcOwo73Tt0C7g+r8Lw625KtkDL2Lyrjz932N0QwkLhHO0OtV9AvgPO dErTuN14uUmJbB4kohQAyKbLouS2DAVMFrVOm7MZJt6EFqkp30ewX2nf65GCnf/EotVj nQq8h2hv1gOFsqR+7aPJSgin1JgMIHs1H9SBMSpZgP1escxujcgbH7ic1wFEScR/MWPH 1Lbg== X-Gm-Message-State: AOJu0YzuWUf73+EmRA2Ofnx332vp2gOChXjla9aE3QBalUrA9UhBh/zo cWoBFWW6+kkMqTdhjBW4J+fFStBl24j0rElEgW4rH8b/6vFmQ27grK3ijUMmqok1QGog8rHTCOK 6d4WBKDYv9gw5bQC/szNHXPCZWeA3kaduUQPuEjkrskc9vQ4iDUfad25GUmcIb3A9ma2Qj1rw/B jJJCm1oDfbgmOxNLjs1mx118Mr2iGBbs8= X-Google-Smtp-Source: AGHT+IGR5SefKD/4obORiw3HTAuPxsTkcPMe4Ly6xFGl6ski9HXsqQpqe17uivjKiuZYgx1lbUIfQqJN2Q0= X-Received: from fdurso-c.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:24fd]) (user=fdurso job=sendgmr) by 2002:a05:600c:3b0a:b0:421:8143:6217 with SMTP id 5b1f17b1804b1-42475078052mr962905e9.1.1718826100809; Wed, 19 Jun 2024 12:41:40 -0700 (PDT) Date: Wed, 19 Jun 2024 21:41:09 +0200 Mime-Version: 1.0 Message-ID: <20240619194109.248066-1-fdurso@google.com> Subject: [PATCH] linux-user: open_self_stat: Implement num_threads From: "Fabio D'Urso" To: qemu-devel@nongnu.org Cc: Laurent Vivier , "Fabio D'Urso" Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::34a; envelope-from=3dDRzZgYKCuMKIZWXTLTTLQJ.HTRVJRZ-IJaJQSTSLSZ.TWL@flex--fdurso.bounces.google.com; helo=mail-wm1-x34a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, 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, USER_IN_DEF_DKIM_WL=-7.5 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1718826165650100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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=C3=A9e --- linux-user/syscall.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index b9b5a387b3..a47b2eeb65 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8171,6 +8171,16 @@ static int open_self_stat(CPUArchState *cpu_env, int= fd) } else if (i =3D=3D 3) { /* ppid */ g_string_printf(buf, FMT_pid " ", getppid()); + } else if (i =3D=3D 19) { + /* num_threads */ + int cpus =3D 0; + WITH_RCU_READ_LOCK_GUARD() { + CPUState *cpu_iter; + CPU_FOREACH(cpu_iter) { + cpus++; + } + } + g_string_printf(buf, "%d ", cpus); } else if (i =3D=3D 21) { /* starttime */ g_string_printf(buf, "%" PRIu64 " ", ts->start_boottime); --=20 2.45.2.627.g7a2c4fd464-goog