Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp558313rdb; Sun, 18 Feb 2024 00:47:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVtJ7rnxdRu7T/i715sKlnDGVXV2KSZDICzEEQhnXvKgoIOo/lgM+7KxltcrPbelWDLO3/cE3tvHzgwZ9KrJb2V6F3BuTPE6vmEH5nuGQ== X-Google-Smtp-Source: AGHT+IGbZq/e4n2S5FGfvgfoifmsv/B/wS+Wdm4MdhMj6WWiT9nW+nGmIadQxk8sIF7Al81TajgQ X-Received: by 2002:a17:902:d2c5:b0:1db:701b:33e0 with SMTP id n5-20020a170902d2c500b001db701b33e0mr12329066plc.14.1708246043122; Sun, 18 Feb 2024 00:47:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708246043; cv=pass; d=google.com; s=arc-20160816; b=iUKImH75gJprkWN19HB/5T/Obq8XvGtcG78JaHZicBVe6WSpkNJ3gINgqbWRN8IZb6 w8ZXjytFD347+osGHgX2HW2HCeHkF4tSPxpu7KNuVcfOq+qV2ZzS2RjPSgrGgywOrmgP jNbfIqtS9zJuvtQP2eRaBHQxc9R+JqJhwRYpqhr6UoAUleE6YQdkh8/uVNo2vjyNrVn/ 2ICgC3ErABoEHRElA5dKnQF4Z9M/uK6FoWmt0UjDtB+5Pt2BAUtppgAYQI3RfjRzI+N7 N3tYqUBdeGWBHVJaBoWlgAjTfYNoMeFtVvAimTj4ryM6LSMZlnl5yX40+VnQQSRQI4HA E04A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:user-agent:date :message-id:from:references:cc:to:subject; bh=RpQUFjA6sEjje3mDjuTFJ2VREDnI1PeSU5k9mqtkpwA=; fh=KNd2S/LBDGYi5aai4BMhT9tTb34wd5UmTrjO2cq61gw=; b=jmg42OGmuyKNEd/zEgifbHZTAmy0Edkn4bZbVzdGb3VK6ObSnC31JOPAF52ERxwZSr +3rOkF4u386u3ILIAW7JRAx9SpgWqMb/7DQuBWzFcvR18P7BUB+tmWqRX7mzSVk3GwFC kkYptBR2ZR7GBdDdzKSUH9HLcrVb6bHFaGOFq4yOttCUqny4mAN7TII/v0+VWFjzYzzJ nm205JB5XHTXsASf9Bh7YtmWi9q/Qn7ULraQeZVpi2eYB6Nswi5L2Hd584whpxmHEhs2 s4Lo507NuB6KWjCrx/sJGVKJcACi4gdV1o9v6U5BZSqCjASBCjW4A+C5Xp+HWq6aNI86 mqrw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-70299-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70299-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id o9-20020a170902d4c900b001d94544ed1esi2666910plg.410.2024.02.18.00.47.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Feb 2024 00:47:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70299-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-70299-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70299-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 4EAF2B2163B for ; Sun, 18 Feb 2024 08:47:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C88FF111BB; Sun, 18 Feb 2024 08:47:10 +0000 (UTC) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E2F5A149E17; Sun, 18 Feb 2024 08:47:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708246030; cv=none; b=iWmfsuN8JvvJmX96GKYoxwjx4Y8r5f8Y6YMzoMDA2yBWR4FWqeLQIkcjYQc+CkJJqHVaixia8ZotEkribZWzGSOKYLpjLnISLjbq7U4sZLVCeKyyeG6LpLdrQMUxvtFOT3XSdr7A4UQ2DUfxtKLZk6OwMS+SvFrDGkLAeu3Y3Oc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708246030; c=relaxed/simple; bh=r57VIygo4McbMJy7ObYDVyZ9K85AZDXtGaqReM398zI=; h=Subject:To:CC:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=KNLmmNM+IVYL4We/SG9ry1fHNDdzbBAo1G/yHxbTdGU2FNDYc00yRCEc6bozH+5qYqAaqWUfEXqa1BlESzjXj3YC/9xiMlvhpLrJdrnYbW4hjV39It0A0vT5Z+uKlpzAYrwZBHAZw/94k1rqdNLuh+7ig4MCQ8MyEJcA+tFeU7w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4TczlS4hMQz1xnjr; Sun, 18 Feb 2024 16:45:40 +0800 (CST) Received: from kwepemm600007.china.huawei.com (unknown [7.193.23.208]) by mail.maildlp.com (Postfix) with ESMTPS id E67E51A0172; Sun, 18 Feb 2024 16:46:59 +0800 (CST) Received: from [10.174.185.179] (10.174.185.179) by kwepemm600007.china.huawei.com (7.193.23.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Sun, 18 Feb 2024 16:46:58 +0800 Subject: Re: [PATCH v3 04/10] KVM: arm64: vgic-its: Walk the LPI xarray in vgic_copy_lpi_list() To: Oliver Upton CC: , , Marc Zyngier , James Morse , Suzuki K Poulose , References: <20240216184153.2714504-1-oliver.upton@linux.dev> <20240216184153.2714504-5-oliver.upton@linux.dev> From: Zenghui Yu Message-ID: Date: Sun, 18 Feb 2024 16:46:53 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <20240216184153.2714504-5-oliver.upton@linux.dev> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600007.china.huawei.com (7.193.23.208) On 2024/2/17 2:41, Oliver Upton wrote: > Start iterating the LPI xarray in anticipation of removing the LPI > linked-list. > > Signed-off-by: Oliver Upton > --- > arch/arm64/kvm/vgic/vgic-its.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/kvm/vgic/vgic-its.c b/arch/arm64/kvm/vgic/vgic-its.c > index fb2d3c356984..9ce2edfadd11 100644 > --- a/arch/arm64/kvm/vgic/vgic-its.c > +++ b/arch/arm64/kvm/vgic/vgic-its.c > @@ -335,6 +335,7 @@ static int update_lpi_config(struct kvm *kvm, struct vgic_irq *irq, > int vgic_copy_lpi_list(struct kvm *kvm, struct kvm_vcpu *vcpu, u32 **intid_ptr) > { > struct vgic_dist *dist = &kvm->arch.vgic; > + XA_STATE(xas, &dist->lpi_xa, GIC_LPI_OFFSET); > struct vgic_irq *irq; > unsigned long flags; > u32 *intids; > @@ -353,7 +354,9 @@ int vgic_copy_lpi_list(struct kvm *kvm, struct kvm_vcpu *vcpu, u32 **intid_ptr) > return -ENOMEM; > > raw_spin_lock_irqsave(&dist->lpi_list_lock, flags); > - list_for_each_entry(irq, &dist->lpi_list_head, lpi_list) { > + rcu_read_lock(); > + > + xas_for_each(&xas, irq, INTERRUPT_ID_BITS_ITS) { We should use '1 << INTERRUPT_ID_BITS_ITS - 1' to represent the maximum LPI interrupt ID. > if (i == irq_count) > break; > /* We don't need to "get" the IRQ, as we hold the list lock. */ > @@ -361,6 +364,8 @@ int vgic_copy_lpi_list(struct kvm *kvm, struct kvm_vcpu *vcpu, u32 **intid_ptr) > continue; > intids[i++] = irq->intid; > } > + > + rcu_read_unlock(); > raw_spin_unlock_irqrestore(&dist->lpi_list_lock, flags); > > *intid_ptr = intids; Thanks, Zenghui