From nobody Wed Oct 22 13:02:48 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151991078598072.72208701112959; Thu, 1 Mar 2018 05:26:25 -0800 (PST) Received: from localhost ([::1]:56470 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1erOE4-0007in-1z for importer@patchew.org; Thu, 01 Mar 2018 08:26:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59043) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1erNrt-0004jl-69 for qemu-devel@nongnu.org; Thu, 01 Mar 2018 08:03:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1erNrs-0007jE-4A for qemu-devel@nongnu.org; Thu, 01 Mar 2018 08:03:29 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:48298 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1erNrr-0007iu-Vg; Thu, 01 Mar 2018 08:03:28 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7CE4F80AD238; Thu, 1 Mar 2018 13:03:27 +0000 (UTC) Received: from localhost (ovpn-117-50.ams2.redhat.com [10.36.117.50]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 957A62026E04; Thu, 1 Mar 2018 13:03:24 +0000 (UTC) From: Cornelia Huck To: peter.maydell@linaro.org Date: Thu, 1 Mar 2018 14:01:57 +0100 Message-Id: <20180301130201.24666-24-cohuck@redhat.com> In-Reply-To: <20180301130201.24666-1-cohuck@redhat.com> References: <20180301130201.24666-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 01 Mar 2018 13:03:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 01 Mar 2018 13:03:27 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'cohuck@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL v2 23/27] hmp: change hmp_info_cpus to use query-cpus-fast X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, david@redhat.com, Cornelia Huck , qemu-devel@nongnu.org, agraf@suse.de, borntraeger@de.ibm.com, qemu-s390x@nongnu.org, Viktor Mihajlovski , rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Viktor Mihajlovski Changing the implementation of hmp_info_cpus() to call qmp_query_cpus_fast() instead of qmp_query_cpus. This has the following consequences: o No further code change required for qmp_query_cpus deprecation o HMP profits from the less disruptive cpu information retrieval o HMP 'info cpus' won't display architecture specific data anymore, which should be tolerable in the light of the deprecation of query-cpus. In order to allow 'info cpus' to be executed completely on the fast path, monitor_get_cpu_index() has been adapted to not synchronize the cpu state. Signed-off-by: Viktor Mihajlovski Message-Id: <1518797321-28356-6-git-send-email-mihajlov@linux.vnet.ibm.com> Reviewed-by: Cornelia Huck Reviewed-by: Eric Blake Signed-off-by: Cornelia Huck --- hmp.c | 41 +++++++---------------------------------- monitor.c | 13 ++++++++++--- 2 files changed, 17 insertions(+), 37 deletions(-) diff --git a/hmp.c b/hmp.c index 7870d6a300..ae86bfbade 100644 --- a/hmp.c +++ b/hmp.c @@ -360,50 +360,23 @@ void hmp_info_migrate_cache_size(Monitor *mon, const = QDict *qdict) =20 void hmp_info_cpus(Monitor *mon, const QDict *qdict) { - CpuInfoList *cpu_list, *cpu; + CpuInfoFastList *cpu_list, *cpu; =20 - cpu_list =3D qmp_query_cpus(NULL); + cpu_list =3D qmp_query_cpus_fast(NULL); =20 for (cpu =3D cpu_list; cpu; cpu =3D cpu->next) { int active =3D ' '; =20 - if (cpu->value->CPU =3D=3D monitor_get_cpu_index()) { + if (cpu->value->cpu_index =3D=3D monitor_get_cpu_index()) { active =3D '*'; } =20 - monitor_printf(mon, "%c CPU #%" PRId64 ":", active, cpu->value->CP= U); - - switch (cpu->value->arch) { - case CPU_INFO_ARCH_X86: - monitor_printf(mon, " pc=3D0x%016" PRIx64, cpu->value->u.x86.p= c); - break; - case CPU_INFO_ARCH_PPC: - monitor_printf(mon, " nip=3D0x%016" PRIx64, cpu->value->u.ppc.= nip); - break; - case CPU_INFO_ARCH_SPARC: - monitor_printf(mon, " pc=3D0x%016" PRIx64, - cpu->value->u.q_sparc.pc); - monitor_printf(mon, " npc=3D0x%016" PRIx64, - cpu->value->u.q_sparc.npc); - break; - case CPU_INFO_ARCH_MIPS: - monitor_printf(mon, " PC=3D0x%016" PRIx64, cpu->value->u.q_mip= s.PC); - break; - case CPU_INFO_ARCH_TRICORE: - monitor_printf(mon, " PC=3D0x%016" PRIx64, cpu->value->u.trico= re.PC); - break; - default: - break; - } - - if (cpu->value->halted) { - monitor_printf(mon, " (halted)"); - } - - monitor_printf(mon, " thread_id=3D%" PRId64 "\n", cpu->value->thre= ad_id); + monitor_printf(mon, "%c CPU #%" PRId64 ":", active, + cpu->value->cpu_index); + monitor_printf(mon, " thread-id=3D%" PRId64 "\n", cpu->value->thre= ad_id); } =20 - qapi_free_CpuInfoList(cpu_list); + qapi_free_CpuInfoFastList(cpu_list); } =20 static void print_block_info(Monitor *mon, BlockInfo *info, diff --git a/monitor.c b/monitor.c index 373bb8d1c3..308a3d9b78 100644 --- a/monitor.c +++ b/monitor.c @@ -1055,7 +1055,7 @@ int monitor_set_cpu(int cpu_index) return 0; } =20 -CPUState *mon_get_cpu(void) +static CPUState *mon_get_cpu_sync(bool synchronize) { CPUState *cpu; =20 @@ -1074,10 +1074,17 @@ CPUState *mon_get_cpu(void) monitor_set_cpu(first_cpu->cpu_index); cpu =3D first_cpu; } - cpu_synchronize_state(cpu); + if (synchronize) { + cpu_synchronize_state(cpu); + } return cpu; } =20 +CPUState *mon_get_cpu(void) +{ + return mon_get_cpu_sync(true); +} + CPUArchState *mon_get_cpu_env(void) { CPUState *cs =3D mon_get_cpu(); @@ -1087,7 +1094,7 @@ CPUArchState *mon_get_cpu_env(void) =20 int monitor_get_cpu_index(void) { - CPUState *cs =3D mon_get_cpu(); + CPUState *cs =3D mon_get_cpu_sync(false); =20 return cs ? cs->cpu_index : UNASSIGNED_CPU_INDEX; } --=20 2.13.6