From nobody Fri May 3 13:48:18 2024 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1512888058296757.6336032663601; Sat, 9 Dec 2017 22:40:58 -0800 (PST) Received: from localhost ([::1]:43628 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eNvI4-0003aS-H2 for importer@patchew.org; Sun, 10 Dec 2017 01:40:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60243) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eNvFx-00026Y-V7 for qemu-devel@nongnu.org; Sun, 10 Dec 2017 01:38:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eNvFw-0005zx-9R for qemu-devel@nongnu.org; Sun, 10 Dec 2017 01:38:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41858) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eNvFw-0005zW-1C for qemu-devel@nongnu.org; Sun, 10 Dec 2017 01:38:32 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3852D81DFE for ; Sun, 10 Dec 2017 06:38:31 +0000 (UTC) Received: from xz-mi.redhat.com (ovpn-12-22.pek2.redhat.com [10.72.12.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D7D65DA7A; Sun, 10 Dec 2017 06:38:28 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Sun, 10 Dec 2017 14:38:15 +0800 Message-Id: <20171210063819.14892-2-peterx@redhat.com> In-Reply-To: <20171210063819.14892-1-peterx@redhat.com> References: <20171210063819.14892-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Sun, 10 Dec 2017 06:38:31 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/5] i8259: convert DPRINTFs into trace 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: Paolo Bonzini , peterx@redhat.com, "Michael S . Tsirkin" 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" One thing to mention is that in pic_set_irq() I need to uncomment a few lines in the macros to make sure IRQ value calculation is correct. Signed-off-by: Peter Xu Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/intc/i8259.c | 26 +++++++++++--------------- hw/intc/trace-events | 7 +++++++ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/hw/intc/i8259.c b/hw/intc/i8259.c index fe9ecd6bd4..f12e0b27f1 100644 --- a/hw/intc/i8259.c +++ b/hw/intc/i8259.c @@ -30,17 +30,11 @@ #include "qemu/log.h" #include "hw/isa/i8259_internal.h" #include "hw/intc/intc.h" +#include "trace.h" =20 /* debug PIC */ //#define DEBUG_PIC =20 -#ifdef DEBUG_PIC -#define DPRINTF(fmt, ...) \ - do { printf("pic: " fmt , ## __VA_ARGS__); } while (0) -#else -#define DPRINTF(fmt, ...) -#endif - //#define DEBUG_IRQ_LATENCY //#define DEBUG_IRQ_COUNT =20 @@ -122,8 +116,7 @@ static void pic_update_irq(PICCommonState *s) =20 irq =3D pic_get_irq(s); if (irq >=3D 0) { - DPRINTF("pic%d: imr=3D%x irr=3D%x padd=3D%d\n", - s->master ? 0 : 1, s->imr, s->irr, s->priority_add); + trace_pic_update_irq(s->master, s->imr, s->irr, s->priority_add); qemu_irq_raise(s->int_out[0]); } else { qemu_irq_lower(s->int_out[0]); @@ -140,9 +133,11 @@ static void pic_set_irq(void *opaque, int irq, int lev= el) defined(DEBUG_IRQ_LATENCY) int irq_index =3D s->master ? irq : irq + 8; #endif + + trace_pic_set_irq(s->master, irq, level); + #if defined(DEBUG_PIC) || defined(DEBUG_IRQ_COUNT) if (level !=3D irq_level[irq_index]) { - DPRINTF("pic_set_irq: irq=3D%d level=3D%d\n", irq_index, level); irq_level[irq_index] =3D level; #ifdef DEBUG_IRQ_COUNT if (level =3D=3D 1) { @@ -223,18 +218,18 @@ int pic_read_irq(DeviceState *d) intno =3D s->irq_base + irq; } =20 -#if defined(DEBUG_PIC) || defined(DEBUG_IRQ_LATENCY) if (irq =3D=3D 2) { irq =3D irq2 + 8; } -#endif + #ifdef DEBUG_IRQ_LATENCY printf("IRQ%d latency=3D%0.3fus\n", irq, (double)(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - irq_time[irq]) * 1000000.0 / NANOSECONDS_PER_SECOND); #endif - DPRINTF("pic_interrupt: irq=3D%d\n", irq); + + trace_pic_interrupt(irq, intno); return intno; } =20 @@ -289,7 +284,8 @@ static void pic_ioport_write(void *opaque, hwaddr addr6= 4, uint32_t val =3D val64; int priority, cmd, irq; =20 - DPRINTF("write: addr=3D0x%02x val=3D0x%02x\n", addr, val); + trace_pic_ioport_write(s->master, addr, val); + if (addr =3D=3D 0) { if (val & 0x10) { pic_init_reset(s); @@ -402,7 +398,7 @@ static uint64_t pic_ioport_read(void *opaque, hwaddr ad= dr, ret =3D s->imr; } } - DPRINTF("read: addr=3D0x%02" HWADDR_PRIx " val=3D0x%02x\n", addr, ret); + trace_pic_ioport_read(s->master, addr, ret); return ret; } =20 diff --git a/hw/intc/trace-events b/hw/intc/trace-events index b298fac7c6..c72b37c5cf 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -1,5 +1,12 @@ # See docs/devel/tracing.txt for syntax documentation. =20 +# hw/intc/i8259.c +pic_update_irq(bool master, uint8_t imr, uint8_t irr, uint8_t padd) "maste= r %d imr %"PRIu8" irr %"PRIu8" padd %"PRIu8 +pic_set_irq(bool master, int irq, int level) "master %d irq %d level %d" +pic_interrupt(int irq, int intno) "irq %d intno %d" +pic_ioport_write(bool master, uint64_t addr, uint64_t val) "master %d addr= 0x%"PRIx64" val 0x%"PRIx64 +pic_ioport_read(bool master, uint64_t addr, int val) "master %d addr 0x%"P= RIx64" val 0x%x" + # hw/intc/apic_common.c cpu_set_apic_base(uint64_t val) "0x%016"PRIx64 cpu_get_apic_base(uint64_t val) "0x%016"PRIx64 --=20 2.14.3 From nobody Fri May 3 13:48:18 2024 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1512888067614540.4262573204187; Sat, 9 Dec 2017 22:41:07 -0800 (PST) Received: from localhost ([::1]:43630 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eNvIA-0003f2-5j for importer@patchew.org; Sun, 10 Dec 2017 01:40:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60269) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eNvFz-00026f-MX for qemu-devel@nongnu.org; Sun, 10 Dec 2017 01:38:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eNvFy-00062j-NS for qemu-devel@nongnu.org; Sun, 10 Dec 2017 01:38:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51312) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eNvFy-000620-HX for qemu-devel@nongnu.org; Sun, 10 Dec 2017 01:38:34 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A934880F90 for ; Sun, 10 Dec 2017 06:38:33 +0000 (UTC) Received: from xz-mi.redhat.com (ovpn-12-22.pek2.redhat.com [10.72.12.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id C691361282; Sun, 10 Dec 2017 06:38:31 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Sun, 10 Dec 2017 14:38:16 +0800 Message-Id: <20171210063819.14892-3-peterx@redhat.com> In-Reply-To: <20171210063819.14892-1-peterx@redhat.com> References: <20171210063819.14892-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sun, 10 Dec 2017 06:38:33 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/5] i8259: use DEBUG_IRQ_COUNT always 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: Paolo Bonzini , peterx@redhat.com, "Michael S . Tsirkin" 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" It's not really scary to even enable it forever. After all it's i8259, and it's even not the kernel one. Then we can remove quite a few of lines to make it cleaner. And "info irq" will always work for it. Signed-off-by: Peter Xu Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/intc/i8259.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/hw/intc/i8259.c b/hw/intc/i8259.c index f12e0b27f1..20c9d0a58b 100644 --- a/hw/intc/i8259.c +++ b/hw/intc/i8259.c @@ -36,7 +36,6 @@ //#define DEBUG_PIC =20 //#define DEBUG_IRQ_LATENCY -//#define DEBUG_IRQ_COUNT =20 #define TYPE_I8259 "isa-i8259" #define PIC_CLASS(class) OBJECT_CLASS_CHECK(PICClass, (class), TYPE_I8259) @@ -52,12 +51,8 @@ typedef struct PICClass { DeviceRealize parent_realize; } PICClass; =20 -#if defined(DEBUG_PIC) || defined(DEBUG_IRQ_COUNT) static int irq_level[16]; -#endif -#ifdef DEBUG_IRQ_COUNT static uint64_t irq_count[16]; -#endif #ifdef DEBUG_IRQ_LATENCY static int64_t irq_time[16]; #endif @@ -128,24 +123,17 @@ static void pic_set_irq(void *opaque, int irq, int le= vel) { PICCommonState *s =3D opaque; int mask =3D 1 << irq; - -#if defined(DEBUG_PIC) || defined(DEBUG_IRQ_COUNT) || \ - defined(DEBUG_IRQ_LATENCY) int irq_index =3D s->master ? irq : irq + 8; -#endif =20 trace_pic_set_irq(s->master, irq, level); =20 -#if defined(DEBUG_PIC) || defined(DEBUG_IRQ_COUNT) if (level !=3D irq_level[irq_index]) { irq_level[irq_index] =3D level; -#ifdef DEBUG_IRQ_COUNT if (level =3D=3D 1) { irq_count[irq_index]++; } -#endif } -#endif + #ifdef DEBUG_IRQ_LATENCY if (level) { irq_time[irq_index] =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); @@ -253,12 +241,8 @@ static bool pic_get_statistics(InterruptStatsProvider = *obj, PICCommonState *s =3D PIC_COMMON(obj); =20 if (s->master) { -#ifdef DEBUG_IRQ_COUNT *irq_counts =3D irq_count; *nb_irqs =3D ARRAY_SIZE(irq_count); -#else - return false; -#endif } else { *irq_counts =3D NULL; *nb_irqs =3D 0; --=20 2.14.3 From nobody Fri May 3 13:48:18 2024 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 151288819271851.320510642988324; Sat, 9 Dec 2017 22:43:12 -0800 (PST) Received: from localhost ([::1]:43644 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eNvKO-0007Ik-DE for importer@patchew.org; Sun, 10 Dec 2017 01:43:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60298) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eNvG6-0002CS-IZ for qemu-devel@nongnu.org; Sun, 10 Dec 2017 01:38:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eNvG3-00065D-DO for qemu-devel@nongnu.org; Sun, 10 Dec 2017 01:38:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41876) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eNvG3-00064w-4X for qemu-devel@nongnu.org; Sun, 10 Dec 2017 01:38:39 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 48BA781DE7 for ; Sun, 10 Dec 2017 06:38:38 +0000 (UTC) Received: from xz-mi.redhat.com (ovpn-12-22.pek2.redhat.com [10.72.12.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 41DCE68B23; Sun, 10 Dec 2017 06:38:33 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Sun, 10 Dec 2017 14:38:17 +0800 Message-Id: <20171210063819.14892-4-peterx@redhat.com> In-Reply-To: <20171210063819.14892-1-peterx@redhat.com> References: <20171210063819.14892-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Sun, 10 Dec 2017 06:38:38 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 3/5] i8259: generalize statistics into common code 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: Paolo Bonzini , peterx@redhat.com, "Michael S . Tsirkin" 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" It was only for userspace i8259. Move it to general code so that kvm-i8259 can also use it in the future. Signed-off-by: Peter Xu --- hw/intc/i8259.c | 37 +------------------------------------ hw/intc/i8259_common.c | 41 +++++++++++++++++++++++++++++++++++++= ++++ include/hw/isa/i8259_internal.h | 7 +++++-- 3 files changed, 47 insertions(+), 38 deletions(-) diff --git a/hw/intc/i8259.c b/hw/intc/i8259.c index 20c9d0a58b..d9b9666aff 100644 --- a/hw/intc/i8259.c +++ b/hw/intc/i8259.c @@ -25,11 +25,9 @@ #include "hw/hw.h" #include "hw/i386/pc.h" #include "hw/isa/isa.h" -#include "monitor/monitor.h" #include "qemu/timer.h" #include "qemu/log.h" #include "hw/isa/i8259_internal.h" -#include "hw/intc/intc.h" #include "trace.h" =20 /* debug PIC */ @@ -51,8 +49,6 @@ typedef struct PICClass { DeviceRealize parent_realize; } PICClass; =20 -static int irq_level[16]; -static uint64_t irq_count[16]; #ifdef DEBUG_IRQ_LATENCY static int64_t irq_time[16]; #endif @@ -126,13 +122,7 @@ static void pic_set_irq(void *opaque, int irq, int lev= el) int irq_index =3D s->master ? irq : irq + 8; =20 trace_pic_set_irq(s->master, irq, level); - - if (level !=3D irq_level[irq_index]) { - irq_level[irq_index] =3D level; - if (level =3D=3D 1) { - irq_count[irq_index]++; - } - } + pic_stat_update_irq(irq_index, level); =20 #ifdef DEBUG_IRQ_LATENCY if (level) { @@ -235,31 +225,6 @@ static void pic_reset(DeviceState *dev) pic_init_reset(s); } =20 -static bool pic_get_statistics(InterruptStatsProvider *obj, - uint64_t **irq_counts, unsigned int *nb_irq= s) -{ - PICCommonState *s =3D PIC_COMMON(obj); - - if (s->master) { - *irq_counts =3D irq_count; - *nb_irqs =3D ARRAY_SIZE(irq_count); - } else { - *irq_counts =3D NULL; - *nb_irqs =3D 0; - } - return true; -} - -static void pic_print_info(InterruptStatsProvider *obj, Monitor *mon) -{ - PICCommonState *s =3D PIC_COMMON(obj); - monitor_printf(mon, "pic%d: irr=3D%02x imr=3D%02x isr=3D%02x hprio=3D%= d " - "irq_base=3D%02x rr_sel=3D%d elcr=3D%02x fnm=3D%d\n", - s->master ? 0 : 1, s->irr, s->imr, s->isr, s->priority_= add, - s->irq_base, s->read_reg_select, s->elcr, - s->special_fully_nested_mode); -} - static void pic_ioport_write(void *opaque, hwaddr addr64, uint64_t val64, unsigned size) { diff --git a/hw/intc/i8259_common.c b/hw/intc/i8259_common.c index 18427b459a..a3caddeefb 100644 --- a/hw/intc/i8259_common.c +++ b/hw/intc/i8259_common.c @@ -25,6 +25,10 @@ #include "qemu/osdep.h" #include "hw/i386/pc.h" #include "hw/isa/i8259_internal.h" +#include "monitor/monitor.h" + +static int irq_level[16]; +static uint64_t irq_count[16]; =20 void pic_reset_common(PICCommonState *s) { @@ -98,6 +102,43 @@ ISADevice *i8259_init_chip(const char *name, ISABus *bu= s, bool master) return isadev; } =20 +void pic_stat_update_irq(int irq, int level) +{ + if (level !=3D irq_level[irq]) { + irq_level[irq] =3D level; + if (level =3D=3D 1) { + irq_count[irq]++; + } + } +} + +bool pic_get_statistics(InterruptStatsProvider *obj, + uint64_t **irq_counts, unsigned int *nb_irqs) +{ + PICCommonState *s =3D PIC_COMMON(obj); + + if (s->master) { + *irq_counts =3D irq_count; + *nb_irqs =3D ARRAY_SIZE(irq_count); + } else { + *irq_counts =3D NULL; + *nb_irqs =3D 0; + } + + return true; +} + +void pic_print_info(InterruptStatsProvider *obj, Monitor *mon) +{ + PICCommonState *s =3D PIC_COMMON(obj); + + monitor_printf(mon, "pic%d: irr=3D%02x imr=3D%02x isr=3D%02x hprio=3D%= d " + "irq_base=3D%02x rr_sel=3D%d elcr=3D%02x fnm=3D%d\n", + s->master ? 0 : 1, s->irr, s->imr, s->isr, s->priority_= add, + s->irq_base, s->read_reg_select, s->elcr, + s->special_fully_nested_mode); +} + static const VMStateDescription vmstate_pic_common =3D { .name =3D "i8259", .version_id =3D 1, diff --git a/include/hw/isa/i8259_internal.h b/include/hw/isa/i8259_interna= l.h index 6954b6ec5f..f742c2a726 100644 --- a/include/hw/isa/i8259_internal.h +++ b/include/hw/isa/i8259_internal.h @@ -28,6 +28,7 @@ #include "hw/hw.h" #include "hw/i386/pc.h" #include "hw/isa/isa.h" +#include "hw/intc/intc.h" =20 typedef struct PICCommonState PICCommonState; =20 @@ -76,8 +77,10 @@ struct PICCommonState { }; =20 void pic_reset_common(PICCommonState *s); - ISADevice *i8259_init_chip(const char *name, ISABus *bus, bool master); - +void pic_stat_update_irq(int irq, int level); +bool pic_get_statistics(InterruptStatsProvider *obj, + uint64_t **irq_counts, unsigned int *nb_irqs); +void pic_print_info(InterruptStatsProvider *obj, Monitor *mon); =20 #endif /* QEMU_I8259_INTERNAL_H */ --=20 2.14.3 From nobody Fri May 3 13:48:18 2024 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 1512888185648939.3691276805695; Sat, 9 Dec 2017 22:43:05 -0800 (PST) Received: from localhost ([::1]:43643 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eNvKI-00076r-Ao for importer@patchew.org; Sun, 10 Dec 2017 01:43:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60300) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eNvG6-0002Cd-P3 for qemu-devel@nongnu.org; Sun, 10 Dec 2017 01:38:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eNvG5-00066E-PA for qemu-devel@nongnu.org; Sun, 10 Dec 2017 01:38:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37016) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eNvG5-00065l-JO for qemu-devel@nongnu.org; Sun, 10 Dec 2017 01:38:41 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BE0E185550 for ; Sun, 10 Dec 2017 06:38:40 +0000 (UTC) Received: from xz-mi.redhat.com (ovpn-12-22.pek2.redhat.com [10.72.12.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id D64945DA7A; Sun, 10 Dec 2017 06:38:38 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Sun, 10 Dec 2017 14:38:18 +0800 Message-Id: <20171210063819.14892-5-peterx@redhat.com> In-Reply-To: <20171210063819.14892-1-peterx@redhat.com> References: <20171210063819.14892-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Sun, 10 Dec 2017 06:38:40 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 4/5] kvm-i8259: support "info pic" and "info irq" 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: Paolo Bonzini , peterx@redhat.com, "Michael S . Tsirkin" 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" Let's leverage the i8259 common code for kvm-i8259 too. I think it's still possible that stats can lost when i8259 is in kernel and meanwhile when irqfd is used, e.g., by vfio or vhost devices. However that should be rare IMHO since they should be using MSIs mostly if they really want performance (that's why people use vhost and device assignment), and no old INTx should be used. As long as the INTx users are emulated in QEMU the stats will be correct. For "info pic", it should be always accurate since we fetch kvm regs before dump. More importantly, it's just too simple to do this now - it's only 10+ LOC to gain this feature. Signed-off-by: Peter Xu Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/i386/kvm/i8259.c | 8 ++++++++ hw/intc/i8259_common.c | 1 + 2 files changed, 9 insertions(+) diff --git a/hw/i386/kvm/i8259.c b/hw/i386/kvm/i8259.c index 11d1b726b6..57abe091b0 100644 --- a/hw/i386/kvm/i8259.c +++ b/hw/i386/kvm/i8259.c @@ -111,6 +111,7 @@ static void kvm_pic_set_irq(void *opaque, int irq, int = level) { int delivered; =20 + pic_stat_update_irq(irq, level); delivered =3D kvm_set_irq(kvm_state, irq, level); apic_report_irq_delivered(delivered); } @@ -139,12 +140,15 @@ static void kvm_i8259_class_init(ObjectClass *klass, = void *data) KVMPICClass *kpc =3D KVM_PIC_CLASS(klass); PICCommonClass *k =3D PIC_COMMON_CLASS(klass); DeviceClass *dc =3D DEVICE_CLASS(klass); + InterruptStatsProviderClass *ic =3D INTERRUPT_STATS_PROVIDER_CLASS(kla= ss); =20 dc->reset =3D kvm_pic_reset; kpc->parent_realize =3D dc->realize; dc->realize =3D kvm_pic_realize; k->pre_save =3D kvm_pic_get; k->post_load =3D kvm_pic_put; + ic->get_statistics =3D pic_get_statistics; + ic->print_info =3D pic_print_info; } =20 static const TypeInfo kvm_i8259_info =3D { @@ -153,6 +157,10 @@ static const TypeInfo kvm_i8259_info =3D { .instance_size =3D sizeof(PICCommonState), .class_init =3D kvm_i8259_class_init, .class_size =3D sizeof(KVMPICClass), + .interfaces =3D (InterfaceInfo[]) { + { TYPE_INTERRUPT_STATS_PROVIDER }, + { } + }, }; =20 static void kvm_pic_register_types(void) diff --git a/hw/intc/i8259_common.c b/hw/intc/i8259_common.c index a3caddeefb..7efd2e8012 100644 --- a/hw/intc/i8259_common.c +++ b/hw/intc/i8259_common.c @@ -132,6 +132,7 @@ void pic_print_info(InterruptStatsProvider *obj, Monito= r *mon) { PICCommonState *s =3D PIC_COMMON(obj); =20 + pic_dispatch_pre_save(s); monitor_printf(mon, "pic%d: irr=3D%02x imr=3D%02x isr=3D%02x hprio=3D%= d " "irq_base=3D%02x rr_sel=3D%d elcr=3D%02x fnm=3D%d\n", s->master ? 0 : 1, s->irr, s->imr, s->isr, s->priority_= add, --=20 2.14.3 From nobody Fri May 3 13:48:18 2024 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 1512888079968662.9122511466464; Sat, 9 Dec 2017 22:41:19 -0800 (PST) Received: from localhost ([::1]:43636 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eNvIY-00041a-EK for importer@patchew.org; Sun, 10 Dec 2017 01:41:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60329) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eNvGH-0002Kb-CG for qemu-devel@nongnu.org; Sun, 10 Dec 2017 01:38:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eNvGE-0006B1-8I for qemu-devel@nongnu.org; Sun, 10 Dec 2017 01:38:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44812) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eNvGD-0006Ad-VT for qemu-devel@nongnu.org; Sun, 10 Dec 2017 01:38:50 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0CCF3C047B75 for ; Sun, 10 Dec 2017 06:38:49 +0000 (UTC) Received: from xz-mi.redhat.com (ovpn-12-22.pek2.redhat.com [10.72.12.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 523195DA7A; Sun, 10 Dec 2017 06:38:41 +0000 (UTC) From: Peter Xu To: qemu-devel@nongnu.org Date: Sun, 10 Dec 2017 14:38:19 +0800 Message-Id: <20171210063819.14892-6-peterx@redhat.com> In-Reply-To: <20171210063819.14892-1-peterx@redhat.com> References: <20171210063819.14892-1-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Sun, 10 Dec 2017 06:38:49 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 5/5] i8259: move TYPE_INTERRUPT_STATS_PROVIDER upper 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: Paolo Bonzini , peterx@redhat.com, "Michael S . Tsirkin" 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" Now both classes (i8259, i8259-kvm) support this. Move this upper to the common class code. Signed-off-by: Peter Xu Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/i386/kvm/i8259.c | 7 ------- hw/intc/i8259.c | 7 ------- hw/intc/i8259_common.c | 7 +++++++ 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/hw/i386/kvm/i8259.c b/hw/i386/kvm/i8259.c index 57abe091b0..b91e98074e 100644 --- a/hw/i386/kvm/i8259.c +++ b/hw/i386/kvm/i8259.c @@ -140,15 +140,12 @@ static void kvm_i8259_class_init(ObjectClass *klass, = void *data) KVMPICClass *kpc =3D KVM_PIC_CLASS(klass); PICCommonClass *k =3D PIC_COMMON_CLASS(klass); DeviceClass *dc =3D DEVICE_CLASS(klass); - InterruptStatsProviderClass *ic =3D INTERRUPT_STATS_PROVIDER_CLASS(kla= ss); =20 dc->reset =3D kvm_pic_reset; kpc->parent_realize =3D dc->realize; dc->realize =3D kvm_pic_realize; k->pre_save =3D kvm_pic_get; k->post_load =3D kvm_pic_put; - ic->get_statistics =3D pic_get_statistics; - ic->print_info =3D pic_print_info; } =20 static const TypeInfo kvm_i8259_info =3D { @@ -157,10 +154,6 @@ static const TypeInfo kvm_i8259_info =3D { .instance_size =3D sizeof(PICCommonState), .class_init =3D kvm_i8259_class_init, .class_size =3D sizeof(KVMPICClass), - .interfaces =3D (InterfaceInfo[]) { - { TYPE_INTERRUPT_STATS_PROVIDER }, - { } - }, }; =20 static void kvm_pic_register_types(void) diff --git a/hw/intc/i8259.c b/hw/intc/i8259.c index d9b9666aff..1602255a87 100644 --- a/hw/intc/i8259.c +++ b/hw/intc/i8259.c @@ -442,13 +442,10 @@ static void i8259_class_init(ObjectClass *klass, void= *data) { PICClass *k =3D PIC_CLASS(klass); DeviceClass *dc =3D DEVICE_CLASS(klass); - InterruptStatsProviderClass *ic =3D INTERRUPT_STATS_PROVIDER_CLASS(kla= ss); =20 k->parent_realize =3D dc->realize; dc->realize =3D pic_realize; dc->reset =3D pic_reset; - ic->get_statistics =3D pic_get_statistics; - ic->print_info =3D pic_print_info; } =20 static const TypeInfo i8259_info =3D { @@ -457,10 +454,6 @@ static const TypeInfo i8259_info =3D { .parent =3D TYPE_PIC_COMMON, .class_init =3D i8259_class_init, .class_size =3D sizeof(PICClass), - .interfaces =3D (InterfaceInfo[]) { - { TYPE_INTERRUPT_STATS_PROVIDER }, - { } - }, }; =20 static void pic_register_types(void) diff --git a/hw/intc/i8259_common.c b/hw/intc/i8259_common.c index 7efd2e8012..c75c880157 100644 --- a/hw/intc/i8259_common.c +++ b/hw/intc/i8259_common.c @@ -178,6 +178,7 @@ static Property pic_properties_common[] =3D { static void pic_common_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); + InterruptStatsProviderClass *ic =3D INTERRUPT_STATS_PROVIDER_CLASS(kla= ss); =20 dc->vmsd =3D &vmstate_pic_common; dc->props =3D pic_properties_common; @@ -189,6 +190,8 @@ static void pic_common_class_init(ObjectClass *klass, v= oid *data) * code. */ dc->user_creatable =3D false; + ic->get_statistics =3D pic_get_statistics; + ic->print_info =3D pic_print_info; } =20 static const TypeInfo pic_common_type =3D { @@ -198,6 +201,10 @@ static const TypeInfo pic_common_type =3D { .class_size =3D sizeof(PICCommonClass), .class_init =3D pic_common_class_init, .abstract =3D true, + .interfaces =3D (InterfaceInfo[]) { + { TYPE_INTERRUPT_STATS_PROVIDER }, + { } + }, }; =20 static void pic_common_register_types(void) --=20 2.14.3