From patchwork Fri Mar 23 10:36:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Hao X-Patchwork-Id: 10302585 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 36DD5600CC for ; Fri, 23 Mar 2018 02:19:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 24F5B28B12 for ; Fri, 23 Mar 2018 02:19:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 199F028B18; Fri, 23 Mar 2018 02:19:34 +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 95DA228B12 for ; Fri, 23 Mar 2018 02:19:33 +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=krwA4ZWUY1vsbtch1O8TBIFIN1w5/iXE93Tr7C9R5O4=; b=t/W oc9gDSe5wSKAcQuQTf4eD6wsb4H3AQhnnMhAFu439+ewGcPqe4aRhNqFARw/EOy3NPGi+S3N2GZBy J7NLH0YiXkKnC9KfhL1uiatoDGus3IyVTDyvcZkB6qi2QSm4ImGIrIbFg65iqDsUJUu3iv1mMe73O 4RAqrUixXYTC5VDTBcAmFLmiIyuwaW0SfLGyd3Q29ibVp0czD2UUVHM6sKZ01OuDDlKlEY744nxV2 qPM4b8NrRIn8JGbEcU4zKbfpV3FA6NsFtaWwvf2y/VwHG6YKlOn1pgk5RCOXX3zrxMvH64jAMbD3T Kuy2o8YcJdtNebxIJcl2t98zvNShgKg==; 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 1ezCIi-0006hf-G3; Fri, 23 Mar 2018 02:19:28 +0000 Received: from out1.zte.com.cn ([202.103.147.172] helo=mxct.zte.com.cn) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ezCId-0006eT-Hp for linux-arm-kernel@lists.infradead.org; Fri, 23 Mar 2018 02:19:26 +0000 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id B1E3683FCF46621FDBD4; Fri, 23 Mar 2018 10:19:01 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id w2N2IlkE086135; Fri, 23 Mar 2018 10:18:47 +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 2018032310185488-3007080 ; Fri, 23 Mar 2018 10:18:54 +0800 From: Peng Hao To: christoffer.dall@linaro.org, marc.zyngier@arm.com Subject: [PATCH] KVM: arm/arm64 : add lpi info in vgic-debug Date: Fri, 23 Mar 2018 18:36:05 +0800 Message-Id: <1521801365-63266-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 10:18:54, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2018-03-23 10:18:31, Serialize complete at 2018-03-23 10:18:31 X-MAIL: mse01.zte.com.cn w2N2IlkE086135 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180322_191923_865995_1D88FACD X-CRM114-Status: GOOD ( 16.97 ) 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 | 61 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 5 deletions(-) diff --git a/virt/kvm/arm/vgic/vgic-debug.c b/virt/kvm/arm/vgic/vgic-debug.c index 10b3817..444115e 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,40 @@ 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; + +again: + 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); + if (iter->nr_lpis != dist->lpi_list_count) { + kfree(lpi_irqs); + spin_unlock(&dist->lpi_list_lock); + goto again; + } + + list_for_each_entry(irq, &dist->lpi_list_head, lpi_list) { + vgic_get_irq_kref(irq); + lpi_irqs[i++] = irq; + } + 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 +101,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 +112,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 +171,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 +196,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 = "S/LPI "; if (vcpu) { hdr = "VCPU"; @@ -162,7 +204,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 +219,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 +267,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 +279,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); + if (iter->intid >= VGIC_MIN_LPI) + vgic_put_irq(kvm, irq); return 0; }