From patchwork Fri Mar 23 23:01:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Hao X-Patchwork-Id: 10304929 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 87EC8600F6 for ; Fri, 23 Mar 2018 14:55:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7741C28F1C for ; Fri, 23 Mar 2018 14:55:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6BAEE28F20; Fri, 23 Mar 2018 14:55:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=2.0 tests=BAYES_00, DATE_IN_FUTURE_06_12, DKIM_SIGNED,DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BD10128F1C for ; Fri, 23 Mar 2018 14:55:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=0GAWsUiceh5qw9c6ziWkraxMBNdC0DLnCn0RgQQZuzw=; b=Aiw 0jtnqpB6kEo3cYNWZPV2XNjY/BQSdbDnqnAp56TqJqcQM8pzaonukyPG+q/xilR5+mwVzZQt8LHTq ZrpnIuTgkHAsk/elQqu4CYOdBgo1oQSKP0qgn7jGjalxUtiP6Q8EVsmrCwERsPgrGQ8cpa3wI/fyE bk3w9uoR7ujP8nirprf9ETrGv7zS4HlMA8dC7MnEziBWPvil4ccX2XmyYWgBDenJMoGmYynuI9emH Gcu2BD0j2REbl8w3db+TCJ7vOmQqEuOqjQ3gmMYrzb7JeTkj3xCu0V6Poax97c5oWvnQasxuo1m22 Lx7h5iEyeawWM36JHeGwgyV991wgtzw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1ezO6N-0001Ql-29; Fri, 23 Mar 2018 14:55:31 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ezO6K-0008SC-Bp for linux-arm-kernel@bombadil.infradead.org; Fri, 23 Mar 2018 14:55:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=kgvPRdOwh8d3CNKTzXpW8G5xzQqZKjB2mQyOv3kg1ts=; b=JMfGaY054k4DWlOuwsSYRuWb0 1fE7ZLyAKaqNM4AoW6/SC5y31tIlQF7ZvOdMYaI30BVjZmA+BMgWXqYUGnejT+ublsgx5BcVB3qXB Ol/ejxjzOIFEMR440UZT4ymEb9yk7u3hJsvHltNToxajV/nUKQwpkHkoP6AQwxLUvxt+NJ4p63QCF VyNOz0flsPO+U5Aa97ApPXp81+Anh/dVTiMzrDWtWmUuf0Sv+l0x21gEjrN/wsxg9dd3FJN/qAz1z eOsRtikkDHxYD7y8kAQGCH5+IPWw9vUexWIzlazM/IvT9oWxjRyb5Tj7fuSsdibAnsBu77kEca6iK /urRT3IRQ==; Received: from mxhk.zte.com.cn ([63.217.80.70]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ezNub-0000AH-DS for linux-arm-kernel@lists.infradead.org; Fri, 23 Mar 2018 14:43:23 +0000 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 5FE799D2391AC0A397CA; Fri, 23 Mar 2018 22:42:54 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id w2NEgoIb052298; Fri, 23 Mar 2018 22:42:50 +0800 (GMT-8) (envelope-from peng.hao2@zte.com.cn) Received: from localhost.localdomain.localdomain ([10.74.120.59]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2018032322430003-3093531 ; Fri, 23 Mar 2018 22:43:00 +0800 From: Peng Hao To: christoffer.dall@linaro.org, marc.zyngier@arm.com Subject: [PATCH v2] KVM: arm/arm64 : add lpi info in vgic-debug Date: Sat, 24 Mar 2018 07:01:14 +0800 Message-Id: <1521846074-66914-1-git-send-email-peng.hao2@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2018-03-23 22:43:00, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2018-03-23 22:42:34, Serialize complete at 2018-03-23 22:42:34 X-MAIL: mse01.zte.com.cn w2NEgoIb052298 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180323_144321_756740_5B6D649E X-CRM114-Status: GOOD ( 17.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peng Hao , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add lpi debug info to vgic-stat. the printed info like this: SPI 287 0 000001 0 0 0 160 -1 LPI 8192 2 000100 0 0 0 160 -1 Signed-off-by: Peng Hao --- virt/kvm/arm/vgic/vgic-debug.c | 56 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 5 deletions(-) diff --git a/virt/kvm/arm/vgic/vgic-debug.c b/virt/kvm/arm/vgic/vgic-debug.c index 10b3817..cb85550 100644 --- a/virt/kvm/arm/vgic/vgic-debug.c +++ b/virt/kvm/arm/vgic/vgic-debug.c @@ -36,9 +36,12 @@ struct vgic_state_iter { int nr_cpus; int nr_spis; + int nr_lpis; int dist_id; int vcpu_id; int intid; + int lpi_print_count; + struct vgic_irq **lpi_irqs; }; static void iter_next(struct vgic_state_iter *iter) @@ -52,6 +55,35 @@ static void iter_next(struct vgic_state_iter *iter) if (iter->intid == VGIC_NR_PRIVATE_IRQS && ++iter->vcpu_id < iter->nr_cpus) iter->intid = 0; + + if (iter->intid >= VGIC_NR_PRIVATE_IRQS + iter->nr_spis) { + if (iter->lpi_print_count < iter->nr_lpis) + iter->intid = iter->lpi_irqs[iter->lpi_print_count]->intid; + iter->lpi_print_count++; + } +} + +static void vgic_debug_get_lpis(struct kvm *kvm, struct vgic_state_iter *iter) +{ + struct vgic_dist *dist = &kvm->arch.vgic; + int i = 0; + struct vgic_irq *irq = NULL, **lpi_irqs; + + iter->nr_lpis = dist->lpi_list_count; + lpi_irqs = kmalloc_array(iter->nr_lpis, sizeof(irq), GFP_KERNEL); + if (!lpi_irqs) { + iter->nr_lpis = 0; + return; + } + spin_lock(&dist->lpi_list_lock); + list_for_each_entry(irq, &dist->lpi_list_head, lpi_list) { + vgic_get_irq_kref(irq); + if (i < iter->nr_lpis) + lpi_irqs[i++] = irq; + } + iter->nr_lpis = i; + spin_unlock(&dist->lpi_list_lock); + iter->lpi_irqs = lpi_irqs; } static void iter_init(struct kvm *kvm, struct vgic_state_iter *iter, @@ -64,6 +96,8 @@ static void iter_init(struct kvm *kvm, struct vgic_state_iter *iter, iter->nr_cpus = nr_cpus; iter->nr_spis = kvm->arch.vgic.nr_spis; + if (vgic_supports_direct_msis(kvm) && !pos) + vgic_debug_get_lpis(kvm, iter); /* Fast forward to the right position if needed */ while (pos--) iter_next(iter); @@ -73,7 +107,9 @@ static bool end_of_vgic(struct vgic_state_iter *iter) { return iter->dist_id > 0 && iter->vcpu_id == iter->nr_cpus && - (iter->intid - VGIC_NR_PRIVATE_IRQS) == iter->nr_spis; + (iter->intid - VGIC_NR_PRIVATE_IRQS) >= iter->nr_spis && + ((iter->nr_lpis == 0) || + (iter->lpi_print_count == iter->nr_lpis + 1)); } static void *vgic_debug_start(struct seq_file *s, loff_t *pos) @@ -130,6 +166,7 @@ static void vgic_debug_stop(struct seq_file *s, void *v) mutex_lock(&kvm->lock); iter = kvm->arch.vgic.iter; + kfree(iter->lpi_irqs); kfree(iter); kvm->arch.vgic.iter = NULL; mutex_unlock(&kvm->lock); @@ -154,7 +191,7 @@ static void print_header(struct seq_file *s, struct vgic_irq *irq, struct kvm_vcpu *vcpu) { int id = 0; - char *hdr = "SPI "; + char *hdr = "Global"; if (vcpu) { hdr = "VCPU"; @@ -162,7 +199,10 @@ static void print_header(struct seq_file *s, struct vgic_irq *irq, } seq_printf(s, "\n"); - seq_printf(s, "%s%2d TYP ID TGT_ID PLAEHC HWID TARGET SRC PRI VCPU_ID\n", hdr, id); + if (vcpu) + seq_printf(s, "%s%2d TYP ID TGT_ID PLAEHC HWID TARGET SRC PRI VCPU_ID\n", hdr, id); + else + seq_printf(s, "%s TYP ID TGT_ID PLAEHC HWID TARGET SRC PRI VCPU_ID\n", hdr); seq_printf(s, "---------------------------------------------------------------\n"); } @@ -174,8 +214,10 @@ static void print_irq_state(struct seq_file *s, struct vgic_irq *irq, type = "SGI"; else if (irq->intid < VGIC_NR_PRIVATE_IRQS) type = "PPI"; - else + else if (irq->intid < VGIC_MAX_SPI) type = "SPI"; + else if (irq->intid >= VGIC_MIN_LPI) + type = "LPI"; if (irq->intid ==0 || irq->intid == VGIC_NR_PRIVATE_IRQS) print_header(s, irq, vcpu); @@ -220,7 +262,9 @@ static int vgic_debug_show(struct seq_file *s, void *v) if (!kvm->arch.vgic.initialized) return 0; - if (iter->vcpu_id < iter->nr_cpus) { + if (iter->intid >= VGIC_MIN_LPI) + irq = iter->lpi_irqs[iter->lpi_print_count - 1]; + else if (iter->vcpu_id < iter->nr_cpus) { vcpu = kvm_get_vcpu(kvm, iter->vcpu_id); irq = &vcpu->arch.vgic_cpu.private_irqs[iter->intid]; } else { @@ -230,6 +274,8 @@ static int vgic_debug_show(struct seq_file *s, void *v) spin_lock(&irq->irq_lock); print_irq_state(s, irq, vcpu); spin_unlock(&irq->irq_lock); + + vgic_put_irq(kvm, irq); return 0; }