From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 9E72432E151; Mon, 10 Aug 2026 15:54:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786377269; cv=none; b=cDYO1iJIhLhkO1EML2ylN+4H5JWR472S0pls1IRzYTKx7I3GLq7hxHHb5aM3rOy+9c6J/1gAUjf+SsSoArP7ohAgMCTEgDZNRoGR5cmMjUwnrSlVXSm09ql4GNCHUOi7lJVAnouK4T3Ddf4iKhOhkLF9BCQKdgYjw+v3RvLKCfE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786377269; c=relaxed/simple; bh=68hh5Cosl30wQCLF13vgVm7oGGaGuZHIX7zNCKFdcH0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LjpFdXaxJ5EjhMpjWaF2PLinhRVvUdAQ4LAzYR2AcX7X+EBxUfFIV+odyQxEMOS2G+SgqZ4MQ0cer9CVW/DkOsNOThN/zRp8sKLe0P8q0Dn/dXRgJN+XOEUC3qFgrHQmnwmKqOjaYk5Nu89BMGS/gpKb+/rX/rjl4TiZBWbjYqw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=pKxA+yxG; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="pKxA+yxG" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67AFWw2O164656; Mon, 10 Aug 2026 15:54:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=0pQY+b ue84EX3NFlbm2S4C4cOwBixR6ZWjN2DFmSB30=; b=pKxA+yxG8g1AbWpx4y0WUh CBAuUPVJ6hX0TWXyyKgZJpc9TZ9tkMMl6rl0sR/pb7kdAjLlaBKM8KBZbiQCamOn jFaptw9oLc7GDwhIjO+4WKSXp1paoan6+2vzLAMyZl7TNBC0e0DeVHYffu9fxBTw qdn1K2J3iu+iWpKubhOEaGN8J8xvQ2PILHoV72V4LfQ//wMmrg6JV6/ZuHPveJr+ 20xF3QVb9Ur0cwG6jt1fl8LgoFqkbOtEjxf9ebQooYjkd42uwq5H7DouNyy38vu8 arGoAz7HHxc33Jy49T0qRENq4/YP+J+EeRRZrEOYnGZm7Ncks6gW3bZXt40d/JkA == Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4fwvjyrtjd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 10 Aug 2026 15:54:23 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 67AFgVXb016482; Mon, 10 Aug 2026 15:54:22 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4fxg9gwbsn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 10 Aug 2026 15:54:22 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 67AFsICA38076724 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 10 Aug 2026 15:54:18 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8DFC720040; Mon, 10 Aug 2026 15:54:18 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EEBF720049; Mon, 10 Aug 2026 15:54:17 +0000 (GMT) Received: from [192.168.88.52] (unknown [9.111.41.151]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 10 Aug 2026 15:54:17 +0000 (GMT) From: Christoph Schlameuss Date: Mon, 10 Aug 2026 17:53:57 +0200 Subject: [PATCH v2 09/20] KVM: s390: vsie: Replace radix_tree with xarray addr_to_page Precedence: bulk X-Mailing-List: linux-s390@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260810-vsie-sigpi-v2-9-e8d59a2f2f70@linux.ibm.com> References: <20260810-vsie-sigpi-v2-0-e8d59a2f2f70@linux.ibm.com> In-Reply-To: <20260810-vsie-sigpi-v2-0-e8d59a2f2f70@linux.ibm.com> To: kvm@vger.kernel.org, linux-s390@vger.kernel.org Cc: Alexander Gordeev , Christian Borntraeger , Claudio Imbrenda , David Hildenbrand , Eric Farman , Heiko Carstens , Janosch Frank , Nico Boehr , Paolo Bonzini , Shuah Khan , Sven Schnelle , Vasily Gorbik , Christoph Schlameuss X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4133; i=schlameuss@linux.ibm.com; h=from:subject:message-id; bh=68hh5Cosl30wQCLF13vgVm7oGGaGuZHIX7zNCKFdcH0=; b=owGbwMvMwCUmoqVx+bqN+mXG02pJDFmVX5T0jkmf19c9mpX2Iu3/rv3VS44c6/oqK3GSia2kM HOrAse3jlIWBjEuBlkxRZZqceu8qr7WpXMOWl6DmcPKBDKEgYtTACZy0pWR4YJc6Bzlj7M3Mx6/ zuSU8qrk/ub0HeFbfdPXBC14rK79tpaRYUfJqefftu6qP3YsxrJZktvI+t2H2XPzhW6UXsuV+PD hLQsA X-Developer-Key: i=schlameuss@linux.ibm.com; a=openpgp; fpr=0E34A68642574B2253AF4D31EEED6AB388551EC3 X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODEwMDEzNCBTYWx0ZWRfX9gQt7f/LD4Wj qyKHow88DX8db/BomR1V+EUC7MGNEDH47X7eEPCip+0A2GOJlxYZXhisTS7/ttKKtDMU61BkCX1 5JKKJcbvHJnB1O90We5dE/Z2q8dafDvsYsJDfqfotTWJh9TonZscvnM/v7Xwt1wYymvoIt9RHnS eiXb1k9Nj7L15Aa8ACAfBxjxPwlOT2GlypFdYI6rP1BoblwghP/5sW40zyx0xO2vFSZsCnoZK8s THhx11cwO8p1ABMI7mo2s85DdjSxXI26/QHdih7H+vZUlfTNOKUsTKq5MG5yOKv4Ay0SwoecVdo mfKTTMB70eRhgcj+E0Ys9pLgW8aXGeFHg9xAqQxs4Y4utCuNUUZqimeIM47cbxuNlwrZDLKakoY 8qYeH9vq4KPsjnDEmckI/60cQC/wGJm5Bf0ECttvZ8Umr/JuC3kdnER5IEnsU2ETZVpFavJxwh0 n2HIbkriXKuUeaPEPHA== X-Proofpoint-Spam-Info: AW1haW4tMjYwODEwMDEzNCBTYWx0ZWRfXxD2VAjxrqwmW q5AhMMSPnJQm7sf6JSej2K3RUlhkVOVCK88boN6bi/NMq2yRXZCUAyX0d0/2TF1jSxf6wMxxmr8 yyzXfbmbEjgmNYI3Dc5Vq4Du9u6542k= X-Authority-Analysis: v=2.4 cv=RqD16imK c=1 sm=1 tr=0 ts=6a79f42f cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VnNF1IyMAAAA:8 a=F8FVqei25e47uhyEDlAA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-GUID: G9i7XwJgPiWKlkTlEJVTI9rGFNFAFxwG X-Proofpoint-ORIG-GUID: G9i7XwJgPiWKlkTlEJVTI9rGFNFAFxwG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-10_03,2026-08-10_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 suspectscore=0 lowpriorityscore=0 clxscore=1015 adultscore=0 bulkscore=0 malwarescore=0 impostorscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608100134 The underlying implementation of radix_tree is xarray since v4.20. Changing to the xarray API directly relaxes some of the locking obligations and provides more symmetry with the next vsie changes in the series. Signed-off-by: Christoph Schlameuss --- arch/s390/include/asm/kvm_host.h | 2 +- arch/s390/kvm/vsie.c | 40 ++++++++++++++++------------------------ 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h index 6617d1161c68..766bbb053421 100644 --- a/arch/s390/include/asm/kvm_host.h +++ b/arch/s390/include/asm/kvm_host.h @@ -629,7 +629,7 @@ struct vsie_page; struct kvm_s390_vsie { struct mutex mutex; - struct radix_tree_root addr_to_page; + struct xarray addr_to_page; int page_count; int next; struct vsie_page *pages[KVM_MAX_VCPUS]; diff --git a/arch/s390/kvm/vsie.c b/arch/s390/kvm/vsie.c index 20e5fcbe382c..6bde6a3ee850 100644 --- a/arch/s390/kvm/vsie.c +++ b/arch/s390/kvm/vsie.c @@ -56,8 +56,7 @@ struct vsie_page { gpa_t sdnx_gpa; /* 0x0250 */ /* * guest address of the original SCB. Remains set for free vsie - * pages, so we can properly look them up in our addr_to_page - * radix tree. + * pages, so we can properly look them up in our addr_to_page map. */ gpa_t scb_gpa; /* 0x0258 */ /* the shadow gmap in use by the vsie_page */ @@ -1532,19 +1531,15 @@ static struct vsie_page *get_vsie_page(struct kvm *kvm, unsigned long addr) struct vsie_page *vsie_page; int nr_vcpus; - rcu_read_lock(); - vsie_page = radix_tree_lookup(&kvm->arch.vsie.addr_to_page, addr >> SCB_ALIGNMENT_SHIFT); - rcu_read_unlock(); - if (vsie_page) { - if (try_get_vsie_page(vsie_page)) { - if (vsie_page->scb_gpa == addr) - return vsie_page; - /* - * We raced with someone reusing + putting this vsie - * page before we grabbed it. - */ - put_vsie_page(vsie_page); - } + vsie_page = xa_load(&kvm->arch.vsie.addr_to_page, addr >> SCB_ALIGNMENT_SHIFT); + if (vsie_page && try_get_vsie_page(vsie_page)) { + if (vsie_page->scb_gpa == addr) + return vsie_page; + /* + * We raced with someone reusing + putting this vsie + * page before we grabbed it. + */ + put_vsie_page(vsie_page); } /* @@ -1573,15 +1568,15 @@ static struct vsie_page *get_vsie_page(struct kvm *kvm, unsigned long addr) kvm->arch.vsie.next %= nr_vcpus; } if (vsie_page->scb_gpa != ULONG_MAX) - radix_tree_delete(&kvm->arch.vsie.addr_to_page, - vsie_page->scb_gpa >> SCB_ALIGNMENT_SHIFT); + xa_erase(&kvm->arch.vsie.addr_to_page, + vsie_page->scb_gpa >> SCB_ALIGNMENT_SHIFT); /* Mark it as invalid until it resides in the tree. */ vsie_page->scb_gpa = ULONG_MAX; } /* Double use of the same address or allocation failure. */ - if (radix_tree_insert(&kvm->arch.vsie.addr_to_page, addr >> SCB_ALIGNMENT_SHIFT, - vsie_page)) { + if (xa_insert(&kvm->arch.vsie.addr_to_page, addr >> SCB_ALIGNMENT_SHIFT, vsie_page, + GFP_KERNEL_ACCOUNT)) { put_vsie_page(vsie_page); mutex_unlock(&kvm->arch.vsie.mutex); return NULL; @@ -1660,7 +1655,7 @@ int kvm_s390_handle_vsie(struct kvm_vcpu *vcpu) void kvm_s390_vsie_init(struct kvm *kvm) { mutex_init(&kvm->arch.vsie.mutex); - INIT_RADIX_TREE(&kvm->arch.vsie.addr_to_page, GFP_KERNEL_ACCOUNT); + xa_init_flags(&kvm->arch.vsie.addr_to_page, XA_FLAGS_ACCOUNT); } /* Destroy the vsie data structures. To be called when a vm is destroyed. */ @@ -1676,12 +1671,9 @@ void kvm_s390_vsie_destroy(struct kvm *kvm) if (vsie_page->gmap_cache.gmap) release_gmap_shadow(vsie_page); kvm->arch.vsie.pages[i] = NULL; - /* free the radix tree entry */ - if (vsie_page->scb_gpa != ULONG_MAX) - radix_tree_delete(&kvm->arch.vsie.addr_to_page, - vsie_page->scb_gpa >> SCB_ALIGNMENT_SHIFT); free_vsie_page(vsie_page); } + xa_destroy(&kvm->arch.vsie.addr_to_page); kvm->arch.vsie.page_count = 0; mutex_unlock(&kvm->arch.vsie.mutex); } -- 2.55.0