From nobody Thu May 9 14:23:05 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=fail(p=none dis=none) header.from=bytedance.com ARC-Seal: i=1; a=rsa-sha256; t=1659426374; cv=none; d=zohomail.com; s=zohoarc; b=ARMILMr/SoCDIUsK9VqFr+DfXw31AxtDMrevjqe5S/NIpVcmLCOi+LFb/S7qN80T3fK91v3mI2aPVEKGxJTOqEFZ4lYvbsDixJKsmnL6twAEErVorEOyLcG/P1pu+p2HE8IRPurkFowvIU3i+1NHU+OFxv6HTIvDH+g4y4Vr2dk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659426374; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+s2f/I9kyvn+CYAYhIKYntc94ugQoOyMWp7qiyL9Zfw=; b=XCuBiqZHPMQqZDYeG704JYH8QyrH/1KvuU7HA/j9/QP0shrrBqD3oC3ng5m1U6qK9XgD372dl09sXzYvnBjEkuYCHAzPvWe2Jx1W17yPc7LE4WDdQsXSmZQNTFgZXS4NPtqlsbleTa3c4XFaD7PYlmcS7DbVtXjNURglTdqZ/8I= 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=fail header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 165942637462346.244577080526255; Tue, 2 Aug 2022 00:46:14 -0700 (PDT) Received: from localhost ([::1]:33396 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oImbV-0002VE-7o for importer@patchew.org; Tue, 02 Aug 2022 03:46:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56248) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oImY4-0008Rw-Vq for qemu-devel@nongnu.org; Tue, 02 Aug 2022 03:42:41 -0400 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]:38530) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oImXy-0004eK-B2 for qemu-devel@nongnu.org; Tue, 02 Aug 2022 03:42:36 -0400 Received: by mail-pj1-x1029.google.com with SMTP id w17-20020a17090a8a1100b001f326c73df6so12888305pjn.3 for ; Tue, 02 Aug 2022 00:42:33 -0700 (PDT) Received: from always-x1.bytedance.net ([61.120.150.72]) by smtp.gmail.com with ESMTPSA id e8-20020a17090301c800b0016dc44459a8sm10996623plh.12.2022.08.02.00.42.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 00:42:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+s2f/I9kyvn+CYAYhIKYntc94ugQoOyMWp7qiyL9Zfw=; b=j0Ts1BxmWSTTOUGY00k4aQqersuOvBgNQ6QGE7cLL3vB+kMwvsTFfF5z1FmxNMDyQK FxHtcmIfZvLZWrghst6B10mVQFuGGSv90a/eRAXQIe1QyIObtx8DuHTlF9LNRBdwQ3rZ pWzW8TUqukY5pPlWBE8bivHwAM++V31aqgCqumHTL19BxcsXScughKNOs27HknRiOVij +HcG08KUWJ5qvS2p3GbGCN5yagYzzxCTJGHLhf7fTLoxGuZslrmtlhFOElOWbmOLvg4+ EL/3OJ8Vd2SSMWMVq4XxL1vK3kwe62sWM9MD5u8OI8y7DKwf36hXCkyrCc/Pk69dEBId 210w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+s2f/I9kyvn+CYAYhIKYntc94ugQoOyMWp7qiyL9Zfw=; b=vUeq+0T6/toKNYH6j0g5MuFEwv4lhazkTYDGkND8yYLKRyMIDKiWCtZ/trFJ34EzH8 44AMAI4K8V3+WNkY/A3BwdBWl4vDVbpce0yrJHp9cLMcGC1SRsqTwOxFnNqTCaVmFf3s wU9EGRDGWpXmvKHmGIgDqsiMo8QzX/4tzPlvdCZv/tBAkcLN6RVYA4AgWOynjeaUoqaW QsjTeeX2/v09qP75eX57AxUiemAO3kwI98RzypVQLSPp5tsork1RSjKhc/l66Uw8KfqH 3cIHNHso+FvJuWe0/bikbWG/tuQRBBjKRgK/kLS02nDbQ92nYnM/f344UF4MMRDdOuKu L1XA== X-Gm-Message-State: ACgBeo2GLe5soH58TPO7avlDbk6GikzW+smV3fBIw7D55UhSuxcDs+lY 0PAq9yQWISF/21hsMIi0JEYStQ== X-Google-Smtp-Source: AA6agR6ZQtJt7NYJ4E5Y24EpWRHOoZznWf2Q+aBOLkXr3NiuTqMMkeQnbhc/Ki3++x2X2ElhJesz/A== X-Received: by 2002:a17:902:8508:b0:16c:46ff:53c8 with SMTP id bj8-20020a170902850800b0016c46ff53c8mr20147469plb.29.1659426152851; Tue, 02 Aug 2022 00:42:32 -0700 (PDT) From: zhenwei pi To: dgilbert@redhat.com, armbru@redhat.com Cc: qemu-devel@nongnu.org, darren.kenny@oracle.com, zhenwei pi Subject: [PATCH v4 1/1] monitor: Support specified vCPU registers Date: Tue, 2 Aug 2022 15:37:20 +0800 Message-Id: <20220802073720.1236988-2-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220802073720.1236988-1-pizhenwei@bytedance.com> References: <20220802073720.1236988-1-pizhenwei@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::1029; envelope-from=pizhenwei@bytedance.com; helo=mail-pj1-x1029.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @bytedance-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1659426375946100001 Content-Type: text/plain; charset="utf-8" Originally we have to get all the vCPU registers and parse the specified one. To improve the performance of this usage, allow user specified vCPU id to query registers. Run a VM with 16 vCPU, use bcc tool to track the latency of 'hmp_info_registers': 'info registers -a' uses about 3ms; 'info registers 12' uses about 150us. Cc: Darren Kenny Reviewed-by: Markus Armbruster Signed-off-by: zhenwei pi Reviewed-by: Darren Kenny Reviewed-by: Dr. David Alan Gilbert --- hmp-commands-info.hx | 8 +++++--- monitor/misc.c | 10 ++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 188d9ece3b..e012035541 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -100,9 +100,11 @@ ERST =20 { .name =3D "registers", - .args_type =3D "cpustate_all:-a", - .params =3D "[-a]", - .help =3D "show the cpu registers (-a: all - show register i= nfo for all cpus)", + .args_type =3D "cpustate_all:-a,vcpu:i?", + .params =3D "[-a|vcpu]", + .help =3D "show the cpu registers (-a: show register info fo= r all cpus;" + " vcpu: specific vCPU to query; show the current CPU= 's registers if" + " no argument is specified)", .cmd =3D hmp_info_registers, }, =20 diff --git a/monitor/misc.c b/monitor/misc.c index 3d2312ba8d..6436a8786b 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -307,6 +307,7 @@ int monitor_get_cpu_index(Monitor *mon) static void hmp_info_registers(Monitor *mon, const QDict *qdict) { bool all_cpus =3D qdict_get_try_bool(qdict, "cpustate_all", false); + int vcpu =3D qdict_get_try_int(qdict, "vcpu", -1); CPUState *cs; =20 if (all_cpus) { @@ -315,13 +316,18 @@ static void hmp_info_registers(Monitor *mon, const QD= ict *qdict) cpu_dump_state(cs, NULL, CPU_DUMP_FPU); } } else { - cs =3D mon_get_cpu(mon); + cs =3D vcpu >=3D 0 ? qemu_get_cpu(vcpu) : mon_get_cpu(mon); =20 if (!cs) { - monitor_printf(mon, "No CPU available\n"); + if (vcpu >=3D 0) { + monitor_printf(mon, "CPU#%d not available\n", vcpu); + } else { + monitor_printf(mon, "No CPU available\n"); + } return; } =20 + monitor_printf(mon, "\nCPU#%d\n", cs->cpu_index); cpu_dump_state(cs, NULL, CPU_DUMP_FPU); } } --=20 2.20.1