Received: by 10.192.165.148 with SMTP id m20csp1712272imm; Thu, 26 Apr 2018 00:48:28 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+trhcadgVEbqJQafrsGCZGQH+BVuOFFQp9M+qtgYqY+8mRmtLUxzmWETkWLLk8W7H+bAJ8 X-Received: by 10.98.92.129 with SMTP id q123mr31290819pfb.252.1524728908914; Thu, 26 Apr 2018 00:48:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524728908; cv=none; d=google.com; s=arc-20160816; b=s74Uy/xhL6t57wHTS/dl8nyDeFNkGKgX5Ce0dV8u9Eitc4sQ0/O1ZaeHe8OP+VvXf1 d1wPKx0byx90KlBPl+4/4bC7MD6Bwy2g2UBlAD/DghrK4Z+dbobvgEU3EeX/k+IIxVHX FfOtGfOKPJ++ZiaH8vQV6rESwMnLBo7osuKH6DOwNgaryy2JhR/ZrncdQkwCOPYfUBx0 Y3Sgb68FcE82oUO8lxsVE815KUH9yMUCo7JnUbY85nXc6hsF0ZIy4ke6mZHw9e8AKnpm 34rA9W0Zacg+kZMs/LHzq10fSDQQWx+TUrnweyooalpIQJMRTWm73e6sXTgzQ7rODuQJ aBGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:arc-authentication-results; bh=aldrjROhYkzbJ4b4wX5rBNoIMf6+42r3F8GTDxZVUGE=; b=VGTuXwrtMEJTn/tkanhPX3IElLDfDwXG6xUsVBazh3EQbudJ8edBu4usUSPtevRpTS U+0lMZS5eVG+WDRDjzMmbXTrsSSBouG2KAn6cRaWL18cNozuZWiUECPbfBZ0ZTKM7fq5 1YDB2sBnDmC8re7KuI3DCNt3X4IqJGYh9C+No/IYTzCGTnoIBaL5AGZyzCyS1W6Xlvb/ UeEcwKLCZi9XdSRM284BVcQcplC80kZFWrrt3zDo3hCyRz7L+D5VOCm/1kW7jroYx9K1 8wGf8tiWyQ8w1Ssqd/dsTOG4CB1wJlCQtalZJwdN5UzMyok0k9IdHR8V7e2UOSkZN/Hx T2+g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j1si10344881pgs.24.2018.04.26.00.48.14; Thu, 26 Apr 2018 00:48:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753996AbeDZHrJ (ORCPT + 99 others); Thu, 26 Apr 2018 03:47:09 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:36792 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752018AbeDZHrH (ORCPT ); Thu, 26 Apr 2018 03:47:07 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E6F19406C742; Thu, 26 Apr 2018 07:47:06 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-141.ams2.redhat.com [10.36.116.141]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EC9D48443C; Thu, 26 Apr 2018 07:47:01 +0000 (UTC) Subject: Re: [PATCH v3 04/12] KVM: arm/arm64: Helper to locate free rdist index To: Christoffer Dall References: <1523607658-9166-1-git-send-email-eric.auger@redhat.com> <1523607658-9166-5-git-send-email-eric.auger@redhat.com> <20180424210704.GG4533@C02W217FHV2R.local> Cc: eric.auger.pro@gmail.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, marc.zyngier@arm.com, cdall@kernel.org, peter.maydell@linaro.org, andre.przywara@arm.com, drjones@redhat.com, wei@redhat.com From: Auger Eric Message-ID: <40978427-0cf7-3a03-f12e-bde73548180e@redhat.com> Date: Thu, 26 Apr 2018 09:47:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20180424210704.GG4533@C02W217FHV2R.local> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 26 Apr 2018 07:47:07 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 26 Apr 2018 07:47:07 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'eric.auger@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Christoffer, On 04/24/2018 11:07 PM, Christoffer Dall wrote: > On Fri, Apr 13, 2018 at 10:20:50AM +0200, Eric Auger wrote: >> We introduce vgic_v3_rdist_free_slot to help identifying >> where we can place a new 2x64KB redistributor. >> >> Signed-off-by: Eric Auger >> --- >> virt/kvm/arm/vgic/vgic-mmio-v3.c | 3 +-- >> virt/kvm/arm/vgic/vgic-v3.c | 17 +++++++++++++++++ >> virt/kvm/arm/vgic/vgic.h | 11 +++++++++++ >> 3 files changed, 29 insertions(+), 2 deletions(-) >> >> diff --git a/virt/kvm/arm/vgic/vgic-mmio-v3.c b/virt/kvm/arm/vgic/vgic-mmio-v3.c >> index d1aab18..49ca176 100644 >> --- a/virt/kvm/arm/vgic/vgic-mmio-v3.c >> +++ b/virt/kvm/arm/vgic/vgic-mmio-v3.c >> @@ -593,8 +593,7 @@ int vgic_register_redist_iodev(struct kvm_vcpu *vcpu) >> * function for all VCPUs when the base address is set. Just return >> * without doing any work for now. >> */ >> - rdreg = list_first_entry(&vgic->rd_regions, >> - struct vgic_redist_region, list); >> + rdreg = vgic_v3_rdist_free_slot(&vgic->rd_regions); >> if (!rdreg) >> return 0; >> >> diff --git a/virt/kvm/arm/vgic/vgic-v3.c b/virt/kvm/arm/vgic/vgic-v3.c >> index 94de6cd..820012a 100644 >> --- a/virt/kvm/arm/vgic/vgic-v3.c >> +++ b/virt/kvm/arm/vgic/vgic-v3.c >> @@ -444,6 +444,23 @@ bool vgic_v3_check_base(struct kvm *kvm) >> return false; >> } >> >> +/** >> + * vgic_v3_rdist_free_slot - Look up registered rdist regions and identify one >> + * which has free space to put a new rdist regions > > Can this structure ever be sparse or do we always find the first empty > one, as we fill them consecutively ? We always find the first empty 2x64kB slot within the region (stride between redistributors = 0). Regions are filled in the index order. The only hole that can exist is at the end of the region if its size is not multiple of 2x64kB. > > I assume there is some mapping between the regions and the VCPUs' > redistributors, so perhaps the wording in this comment can be more > precise. changed into: " A redistributor regions maps n redistributors, n = region size / (2 x 64kB). Stride between redistributors is 0 and regions are filled in the index order. " > >> + * >> + * If any, return this redist region handle, otherwise returns NULL. >> + */ >> +struct vgic_redist_region *vgic_v3_rdist_free_slot(struct list_head *rd_regions) >> +{ >> + struct vgic_redist_region *rdreg; >> + >> + list_for_each_entry(rdreg, rd_regions, list) { >> + if (!vgic_v3_redist_region_full(rdreg)) >> + return rdreg; >> + } >> + return NULL; >> +} >> + >> int vgic_v3_map_resources(struct kvm *kvm) >> { >> int ret = 0; >> diff --git a/virt/kvm/arm/vgic/vgic.h b/virt/kvm/arm/vgic/vgic.h >> index 830e815..fea32cb 100644 >> --- a/virt/kvm/arm/vgic/vgic.h >> +++ b/virt/kvm/arm/vgic/vgic.h >> @@ -251,6 +251,17 @@ static inline int vgic_v3_max_apr_idx(struct kvm_vcpu *vcpu) >> } >> } >> >> +static inline bool >> +vgic_v3_redist_region_full(struct vgic_redist_region *region) >> +{ >> + if (!region->count) >> + return false; >> + >> + return (region->free_index >= region->count); >> +} >> + >> +struct vgic_redist_region *vgic_v3_rdist_free_slot(struct list_head *rdregs); >> + >> int vgic_its_resolve_lpi(struct kvm *kvm, struct vgic_its *its, >> u32 devid, u32 eventid, struct vgic_irq **irq); >> struct vgic_its *vgic_msi_to_its(struct kvm *kvm, struct kvm_msi *msi); >> -- >> 2.5.5 >> > > Asides from the above: > > Reviewed-by: Christoffer Dall Thanks Eric >