Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2942409rdb; Tue, 13 Feb 2024 01:50:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWyjEI322iGeFaJ9jeLLlBpgf8K+74PCoGT1XvaBv8WfpSErpnw+IujAXIbWUH/8sEio45kAsQpAsrAAbG65FFLSbOJXJB9V2QpFXGWUA== X-Google-Smtp-Source: AGHT+IH8Elz/cuL3C6BZBcJ8yYDR6+DrTRYdo6B4aFppQSGmbrRZgXp0mg6K/NcDPSM2rVL2jVkT X-Received: by 2002:a05:6358:9894:b0:177:6dc9:ac1e with SMTP id q20-20020a056358989400b001776dc9ac1emr14704258rwa.8.1707817802047; Tue, 13 Feb 2024 01:50:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707817802; cv=pass; d=google.com; s=arc-20160816; b=a6ZBB0ixpGeidQ7vyjinlxANKCdJG+lCSJbRorTmP7jvvpAAx3EAL2t+05LyV0PCLh Dunj07S8shN2QaAwPer2QnRtH1NZQ6UeInqqe/wcd4cY6jU+So8PdFJiJjTTr+cBy2hW PAW0Ozzomq86T9gE9xQC3kk7Kjh3zVEdpsKAtMnICgk8qqFzdd8X/eNf0NX3eMfn50NX JGfAe6QgcS9cY7EmhSWPX0I9GSPsc8gFQq9xlEiLG0N4NTOsqp0UsoCFf/0cVMVn4183 z2hyG4YshOOenYW6JwtGlEqAtnBnJ5aeKUDIuFqBg27UsyXfhq9Cl0FwDOwIf4/Le5Dr Gpow== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=iVvQT5/XmikRWyk9sSNpoveNMbrL0Bk4ezrgyqLcu50=; fh=YbSlllU3YHHdTaZzoPa+A0c7hQpE13PGM9Aj0pkr2BA=; b=su3qhmmihTD/uVY+rRSi8MZD0OxG8hi3y1Cn7Yvq4XpnxtfaJDC47mZ5SpLMaEGqwN nBh9jsNte/BXZtZ+uWrLWp/+LvFvSJ/Cpr684PCVPSHRbCKKFjPcgfDeOhDmTsMgX8Gk ak5Ftt/c9priPtdWbpny1lPfMxwJvjBcbN/CsCKDWOFdzV/9qznaV5bZ1AzIF1BjOhVV 3akIeoUdRfQufUOhk8OYM280+3Mda//hFVi2/gL+XCnDQrbkxZdbVNQVnRxOKa8wOQ2N 7PXEURZoTwgmq8zSegHErLSyJoVdA2FwomK/tkrWCJLkwgUwEVK9tRlu0SmJ0ljrbBuy 6Ftg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=tspZWTRQ; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-63239-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63239-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev X-Forwarded-Encrypted: i=2; AJvYcCVf3bMYuVIKcacGVlil3aWesW4WyEtd+vdgv4yNOCwxuOxP/ooTvdEF2KfbMLcrDsdtRp7tUu8sJgeEzDck9t4SWQHKeIwzve4DKfr4Zg== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id s13-20020a056a00178d00b006e0ab969a87si4979866pfg.321.2024.02.13.01.50.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 01:50:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-63239-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=tspZWTRQ; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-63239-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-63239-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A5579285139 for ; Tue, 13 Feb 2024 09:44:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D268C22F0A; Tue, 13 Feb 2024 09:40:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="tspZWTRQ" Received: from out-177.mta0.migadu.com (out-177.mta0.migadu.com [91.218.175.177]) (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 4DDA1224E7 for ; Tue, 13 Feb 2024 09:40:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707817208; cv=none; b=toJQPLY64OXzYRql+Qbgm/z0HARN+CJHM7SoF4RAgwFizB7zPjbzdvfAQOq0FlqQkWOPwLGNvizDoZ/pXEcuoPHSX3Wa4RxKT27MU+ThYzTcq3kckgsSrllPNatHpQ5vNcxRijl+dG1P3JhBOTIIbj3zVZkCIcd+S9v5GXn8h0Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707817208; c=relaxed/simple; bh=1X3y/+7kwIA1bPfJOn0Y/WTdRQy52Y2ta/su6GXyAHE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L4rYMITm10FpKs/GPx5JVnDVK0T7r1t0e/2ocCBGrQSjWSqnc1goP7xgNqzx8hDkD29JHH3JGPsflWHV10lmLQT01FjU7SbZKR8EYPz8d4JFhwvECRt1VFwRrLR+q+c7T/xE/CMESdvbO1yR0jCV7KdzxVHMOs+sgDI3O81rzCE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=tspZWTRQ; arc=none smtp.client-ip=91.218.175.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1707817203; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iVvQT5/XmikRWyk9sSNpoveNMbrL0Bk4ezrgyqLcu50=; b=tspZWTRQsY42Ipgi4nXkPCl77D6pxRdd0dv7qUb22qs3s6nvFQYwES8NqQumcyZj8EpM7d iKxxt1GENHJpHFumHr5BW/iasdQ/dj3jNfR6WStKJNTjpZOCt6a9eSUX5s+CGWxAk4tptc 2LrvdkzycAeYPES6xrPyBLmIlqc7/4c= From: Oliver Upton To: kvmarm@lists.linux.dev Cc: kvm@vger.kernel.org, Marc Zyngier , James Morse , Suzuki K Poulose , Zenghui Yu , linux-kernel@vger.kernel.org, Oliver Upton Subject: [PATCH v2 15/23] KVM: arm64: vgic-its: Treat the LPI translation cache as an rculist Date: Tue, 13 Feb 2024 09:39:54 +0000 Message-ID: <20240213093954.3961389-1-oliver.upton@linux.dev> In-Reply-To: <20240213093250.3960069-1-oliver.upton@linux.dev> References: <20240213093250.3960069-1-oliver.upton@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Convert the LPI translation cache to an rculist such that readers can walk it while only holding the RCU read lock. Signed-off-by: Oliver Upton --- arch/arm64/kvm/vgic/vgic-its.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kvm/vgic/vgic-its.c b/arch/arm64/kvm/vgic/vgic-its.c index 99042ecc9c85..55463eb84763 100644 --- a/arch/arm64/kvm/vgic/vgic-its.c +++ b/arch/arm64/kvm/vgic/vgic-its.c @@ -569,7 +569,7 @@ static struct vgic_irq *__vgic_its_check_cache(struct vgic_dist *dist, { struct vgic_translation_cache_entry *cte; - list_for_each_entry(cte, &dist->lpi_translation_cache, entry) { + list_for_each_entry_rcu(cte, &dist->lpi_translation_cache, entry) { /* * If we hit a NULL entry, there is nothing after this * point. @@ -625,7 +625,7 @@ static struct vgic_translation_cache_entry *vgic_its_cache_victim(struct vgic_di * older entries in the case of a tie. Return the max usage count seen * during the scan to initialize the new cache entry. */ - list_for_each_entry(cte, &dist->lpi_translation_cache, entry) { + list_for_each_entry_rcu(cte, &dist->lpi_translation_cache, entry) { tmp = atomic64_read(&cte->usage_count); max = max(max, tmp); @@ -679,7 +679,7 @@ static void vgic_its_cache_translation(struct kvm *kvm, struct vgic_its *its, if (dist->lpi_cache_count >= vgic_its_max_cache_size(kvm)) { victim = vgic_its_cache_victim(dist, &usage); - list_del(&victim->entry); + list_del_rcu(&victim->entry); dist->lpi_cache_count--; } @@ -697,7 +697,7 @@ static void vgic_its_cache_translation(struct kvm *kvm, struct vgic_its *its, rcu_assign_pointer(new->irq, irq); /* Move the new translation to the head of the list */ - list_add(&new->entry, &dist->lpi_translation_cache); + list_add_rcu(&new->entry, &dist->lpi_translation_cache); dist->lpi_cache_count++; out: @@ -734,7 +734,7 @@ void vgic_its_invalidate_cache(struct kvm *kvm) raw_spin_lock_irqsave(&dist->lpi_list_lock, flags); rcu_read_lock(); - list_for_each_entry(cte, &dist->lpi_translation_cache, entry) { + list_for_each_entry_rcu(cte, &dist->lpi_translation_cache, entry) { /* * If we hit a NULL entry, there is nothing after this * point. @@ -1981,7 +1981,7 @@ void vgic_lpi_translation_cache_destroy(struct kvm *kvm) list_for_each_entry_safe(cte, tmp, &dist->lpi_translation_cache, entry) { - list_del(&cte->entry); + list_del_rcu(&cte->entry); kfree(cte); } } -- 2.43.0.687.g38aa6559b0-goog