From nobody Tue Nov 4 15:31:26 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; dkim=fail; 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 1530218071740279.3489935216386; Thu, 28 Jun 2018 13:34:31 -0700 (PDT) Received: from localhost ([::1]:38431 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdcN-0005X0-Fr for importer@patchew.org; Thu, 28 Jun 2018 16:34:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38411) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdB6-0007nb-Jn for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdB5-00018c-Gc for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:04 -0400 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]:39184) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdB5-00017E-9I for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:06:03 -0400 Received: by mail-wr0-x241.google.com with SMTP id b8-v6so6678959wro.6 for ; Thu, 28 Jun 2018 13:06:03 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.06.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:06:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=NaPr4d6wMv8dmWjXdDQYgDuyCuX3DHy+VoxoQ0J/GnY=; b=ih7Wiyl5uNIN3nz4iXcE9emSfQpkT1GdIo+UgesZvEmZaPPlBBlOEeQcaGIpMWqgMN 3pdKs6ku+Mz39yJ1LpG/6AgSB9Vfc1WVBH105ZXyDHNrdV5kvkiF56SOXT0P/dwNS0bJ F03Fc9am9teUi68vJ5+Ac0BjPW/vLyQvOoWfFgxZ3TlnnNNQxGhfSGY40bOThHR7yJII WCabjX3q+TFww+mSSGhgLLyrdvMWRYRs1sFybPKs7XrViFIiKDERZoSxMrG99bChdkwC 2W4g2uejbwOTXx3MbKAIxE6jLKFcs5vig3U/vAlQzJblWCu/WOwlM7zJ5ndU8e8K66oA zJFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=NaPr4d6wMv8dmWjXdDQYgDuyCuX3DHy+VoxoQ0J/GnY=; b=EiAoKNhUpKsu0nok2NCtPCB4/p7AL1RIQh8GNU4SAvwmEIibGwL/78O3tghsQo4bE0 IY/ek1quDb91abMxyxQaPaaVmi7NXKrLNCUG0NtD5vlRr6/oVGTOOZPm8zKmWEA1K7vF IlEeELJWt8eeVVvjtNadO9EO5DvbwpRHRaijlllIYrHTyu9BQEMEgP3QWLL2/zfkjBuL ozC4tq+5f2P6fAEcLzraRm6oEMysuBsUM4UoGWjKhIywtsrtiOVC3r4782YXjnHwbRjL /mltrmPlXTFXy0PC5DrCs0pA8LXt3D8gGQOjW7831LO5qU2PIg04fzO2TCOVc59NOs6Z QLEA== X-Gm-Message-State: APt69E2XQ4RyFPjNsPJsApmFXCL0jx2DwBIbN3R5kiZw1KicZO/GsvhX k9irpN0D5FCNzbkfKpBqIHyXNNNU X-Google-Smtp-Source: AAOMgpdBG0D95BHBY6BKlxfga0t1EtI6UIezhQLGTfiePHSTiu3hgH/slq5tTBVcN7ke3MQT4PU/+Q== X-Received: by 2002:adf:fb43:: with SMTP id c3-v6mr10216085wrs.32.1530216362001; Thu, 28 Jun 2018 13:06:02 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:59 +0200 Message-Id: <1530216310-52873-50-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::241 Subject: [Qemu-devel] [PULL 49/60] ioapic: support "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: Peter Xu Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Peter Xu This include both userspace and in-kernel ioapic. Note that the numbers can be inaccurate for kvm-ioapic. One reason is the same with kvm-i8259, that when irqfd is used, irqs can be delivered all inside kernel without our notice. Meanwhile, kvm-ioapic is specially treated when irq numbers Message-Id: <20171229073104.3810-5-peterx@redhat.com> Signed-off-by: Paolo Bonzini --- hw/i386/kvm/ioapic.c | 2 ++ hw/intc/ioapic.c | 1 + hw/intc/ioapic_common.c | 23 +++++++++++++++++++++++ include/hw/i386/ioapic_internal.h | 3 +++ 4 files changed, 29 insertions(+) diff --git a/hw/i386/kvm/ioapic.c b/hw/i386/kvm/ioapic.c index 646f624..5274dc7 100644 --- a/hw/i386/kvm/ioapic.c +++ b/hw/i386/kvm/ioapic.c @@ -132,8 +132,10 @@ static void kvm_ioapic_reset(DeviceState *dev) static void kvm_ioapic_set_irq(void *opaque, int irq, int level) { KVMIOAPICState *s =3D opaque; + IOAPICCommonState *common =3D IOAPIC_COMMON(s); int delivered; =20 + ioapic_stat_update_irq(common, irq, level); delivered =3D kvm_set_irq(kvm_state, s->kvm_gsi_base + irq, level); apic_report_irq_delivered(delivered); } diff --git a/hw/intc/ioapic.c b/hw/intc/ioapic.c index c45f073..222f3f7 100644 --- a/hw/intc/ioapic.c +++ b/hw/intc/ioapic.c @@ -148,6 +148,7 @@ static void ioapic_set_irq(void *opaque, int vector, in= t level) * the cleanest way of doing it but it should work. */ =20 trace_ioapic_set_irq(vector, level); + ioapic_stat_update_irq(s, vector, level); if (vector =3D=3D 0) { vector =3D 2; } diff --git a/hw/intc/ioapic_common.c b/hw/intc/ioapic_common.c index a02c135..692dc37 100644 --- a/hw/intc/ioapic_common.c +++ b/hw/intc/ioapic_common.c @@ -35,6 +35,28 @@ */ int ioapic_no; =20 +void ioapic_stat_update_irq(IOAPICCommonState *s, int irq, int level) +{ + if (level !=3D s->irq_level[irq]) { + s->irq_level[irq] =3D level; + if (level =3D=3D 1) { + s->irq_count[irq]++; + } + } +} + +static bool ioapic_get_statistics(InterruptStatsProvider *obj, + uint64_t **irq_counts, + unsigned int *nb_irqs) +{ + IOAPICCommonState *s =3D IOAPIC_COMMON(obj); + + *irq_counts =3D s->irq_count; + *nb_irqs =3D IOAPIC_NUM_PINS; + + return true; +} + static void ioapic_irr_dump(Monitor *mon, const char *name, uint32_t bitma= p) { int i; @@ -176,6 +198,7 @@ static void ioapic_common_class_init(ObjectClass *klass= , void *data) dc->realize =3D ioapic_common_realize; dc->vmsd =3D &vmstate_ioapic_common; ic->print_info =3D ioapic_print_info; + ic->get_statistics =3D ioapic_get_statistics; } =20 static const TypeInfo ioapic_common_type =3D { diff --git a/include/hw/i386/ioapic_internal.h b/include/hw/i386/ioapic_int= ernal.h index a11d86d..9848f39 100644 --- a/include/hw/i386/ioapic_internal.h +++ b/include/hw/i386/ioapic_internal.h @@ -109,10 +109,13 @@ struct IOAPICCommonState { uint64_t ioredtbl[IOAPIC_NUM_PINS]; Notifier machine_done; uint8_t version; + uint64_t irq_count[IOAPIC_NUM_PINS]; + int irq_level[IOAPIC_NUM_PINS]; }; =20 void ioapic_reset_common(DeviceState *dev); =20 void ioapic_print_redtbl(Monitor *mon, IOAPICCommonState *s); +void ioapic_stat_update_irq(IOAPICCommonState *s, int irq, int level); =20 #endif /* QEMU_IOAPIC_INTERNAL_H */ --=20 1.8.3.1