From nobody Wed Oct 22 06:35:01 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1518797882783884.0333628364583; Fri, 16 Feb 2018 08:18:02 -0800 (PST) Received: from localhost ([::1]:36586 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emii2-00082J-0J for importer@patchew.org; Fri, 16 Feb 2018 11:18:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emiZH-0000us-2q for qemu-devel@nongnu.org; Fri, 16 Feb 2018 11:09:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1emiZD-00009Y-UN for qemu-devel@nongnu.org; Fri, 16 Feb 2018 11:08:59 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:34438 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1emiZD-00009C-N9 for qemu-devel@nongnu.org; Fri, 16 Feb 2018 11:08:55 -0500 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1GG81Y1141486 for ; Fri, 16 Feb 2018 11:08:55 -0500 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 2g603bem2w-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 16 Feb 2018 11:08:54 -0500 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 16 Feb 2018 16:08:53 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 16 Feb 2018 16:08:49 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w1GG8n2p42467478; Fri, 16 Feb 2018 16:08:49 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C0DD6A4055; Fri, 16 Feb 2018 16:02:05 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6FC78A4040; Fri, 16 Feb 2018 16:02:05 +0000 (GMT) Received: from bradbury.ibm.com (unknown [9.152.222.92]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 16 Feb 2018 16:02:05 +0000 (GMT) From: Viktor Mihajlovski To: qemu-devel@nongnu.org Date: Fri, 16 Feb 2018 17:08:41 +0100 X-Mailer: git-send-email 1.9.1 In-Reply-To: <1518797321-28356-1-git-send-email-mihajlov@linux.vnet.ibm.com> References: <1518797321-28356-1-git-send-email-mihajlov@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18021616-0040-0000-0000-0000043483C7 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18021616-0041-0000-0000-000020D6889D Message-Id: <1518797321-28356-6-git-send-email-mihajlov@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-16_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802160192 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCHv5 5/5] 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: ehabkost@redhat.com, david@redhat.com, cohuck@redhat.com, armbru@redhat.com, agraf@suse.de, borntraeger@de.ibm.com, qemu-s390x@nongnu.org, pbonzini@redhat.com, dgilbert@redhat.com, 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" 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 Reviewed-by: Cornelia Huck Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Eric Blake --- hmp.c | 41 +++++++---------------------------------- monitor.c | 13 ++++++++++--- 2 files changed, 17 insertions(+), 37 deletions(-) diff --git a/hmp.c b/hmp.c index 7870d6a..ae86bfb 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 f499250..db57241 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 1.9.1