From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (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 26F4F379990 for ; Fri, 26 Jun 2026 10:34:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782470105; cv=none; b=D1kmCGlaxo6DNbuJrJ+wCwFDXLFZR3yPwrKHgU4pymr5VnvRvWlIlT8vUke2Ie6IQxevCPTqdIm/OwdoeOpPH0MttWaXq33ZZZxt5FT6ZkZ3HK+7dfFKJzo71rbnSRk2EauxQBwk0AAggrdYPUAbpj16qC7MbcXFZGsytn3cYfs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782470105; c=relaxed/simple; bh=0LAfCFigjk2pkH8reI7J4X9T4M/8EOT9+5bL0XpqUDc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=fxABQxtVCYnq/1aL6tCJ7FAcja9WjJay6on+TPbAJ4EV0QyJGPu8NdiTz3a5i9iIpFey+lKINBS9bcp++KCo81AvAvXHq1c6eLbSAYNpeUJcrjgUCz39HP2L2nWZhNgZHkryKD+LoxQ6CCosuICnkWL/98J7VDPZwpOgznG65Oo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=BROBLdNi; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=iYHVe9GX; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="BROBLdNi"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="iYHVe9GX" Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 65QA03sT984399 for ; Fri, 26 Jun 2026 10:34:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= n28v+zrgL+6691cycJAuIiEzsIce2TWx4xB2oYyWdls=; b=BROBLdNiS4D19cMs ZLc9IRdFDh2RxDcd1yPiiAWEB925wrxTZFRO3sOODQbiMvfrzpSrBl1EqgZHwsBa YrTWmTW2Dj1280YLKXhJu3v5FiXPyRrfOMm0UNiJCOxotnmdsklDQXNVz02g6xuv exX80+deKqNxk2BbqderGhRQerqR4fra8972xZT6n/3r/dIofrJDRpAkz2c/aMs9 /HIkcaL5/Ph2hw707kIU+DwdgymKSKNbNqoTA4wfVnntJmTq/p76nH4HMOVl0QcP oapD3kEtr99gPqyZVC6ZXJTqz/FBh3zLAIhSsC0wHmER2bUr6zbdyqMD4dePNKOs 9NyqXQ== Received: from mail-dy1-f197.google.com (mail-dy1-f197.google.com [74.125.82.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4f1fct9y66-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 26 Jun 2026 10:34:54 +0000 (GMT) Received: by mail-dy1-f197.google.com with SMTP id 5a478bee46e88-30c42d96713so634967eec.1 for ; Fri, 26 Jun 2026 03:34:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1782470093; x=1783074893; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=n28v+zrgL+6691cycJAuIiEzsIce2TWx4xB2oYyWdls=; b=iYHVe9GX7QFpmDy3W55WUXmEKpnEu1CMsBmALMqKZaxJZzQ4yLsMTqraq6dBmQo0KG DgSAWmulMUWiJ0IgkSmL5EPjUPtxFdxwd2+6Yrd+I7wat95Cg+OR+L3l7EP1dtYa6c+5 /D6o1I5t7/Zod7h9PRVtapIhxepb7sDsKaZhgj2Q9lX7ZXWD5ZZzCu69i0SjzC0gMKDw U4FBGFTZ5GZWEOiyU/9q3x+CFfJlz9VcRcBNWC3ZMEKDUvDvoXOWC44R36HtrhM4w7tA i0SYNVO/liF+yWe48YCkt4+SlNcc0r9BACQxvO3HLV2dZAE1d2x1SUt8MH/pYHKYDuj4 E8Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782470093; x=1783074893; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=n28v+zrgL+6691cycJAuIiEzsIce2TWx4xB2oYyWdls=; b=p8iwKLbQVg4/7AL06RSS6GzIkBBYHgDGodkssRcwHo2DmCG+f/kAb85cEaCw3R//WS M7L3u33F+1Dffdwz7QqJ+vImiVROcl1ZhlsptfTWU6P/45/BO+uvPJa6C1u90Q0GfhSa hY9UxQkkkZ5uTAFj4A8zi+/UT02/QDbiAupLi4DbnUUa0IKwcrfvWk/jJGxbR947qAzB vrDWnN5eHprMvtwQ4dvl6Qf59GYd6IChPrSrlbmx+xfb0zRPnFGU/cSWbzmPd16Dh8L3 yf6erBdG6Or6DBE400wvVUfv4LfDDfMRTiJo5WDhZonxFfrdeH5ZNlZpjA7ZMwqt+2n+ Z4tg== X-Forwarded-Encrypted: i=1; AHgh+RoskQKRvsEehY5bGC3hZ3sykCyrBoB+EEh2ezK9I6f9kVtwrmi5EQYe/qu8ZWnVrAtFBdR3XYg2jicMK4Q=@vger.kernel.org X-Gm-Message-State: AOJu0Yyqqgj9LiVJTMmLqmWamPWVocPEpR8LchWuN74KKW2314pVNaVc iG6jwiOhZkZkxsUVhdfnxAxMLYy3O4GtUo2UeX0s06kbLK1S3C82BaY0ud7b/r9jh22+GfYSamL PAZdmtLR7a4hwQIVe+/UMPYOAItqVGsNF8oahNdHncnoBdWA3wFXBNdw59rWTGLS5yqQ= X-Gm-Gg: AfdE7clDIx8A1CwXFkvgVHJzL6dnhjHWcEiacnAoJLK+ROqFd/Vz5ANXOtt8WWIM2lL sD+f5JWXT+F6n2eK2ORUXxDCnw2SMdKGjo4TSy+h2dzC9r+u4uqEpf46/QunFt/R7/cHeI5CLUg TI1r9SMH/DjzAT7sZvwzhXmbGEL0B/ul2zGU5iDcc68MjHDXj5nox2hX4VKELXkZM7gOQhrJ00q DUEQ1/lKIdLaVQ9++TdemN9+d0RQRe8nq21nirvn0ztvrMcP2BhOF2JrsoWtZMOVveNHHkoHudc r7ALBjSN97CDvrHCIpCE1m7dMWwpICI9fIXZEXEX0E28wqlMDUI5g9tO/C0gnYBlCKrHOikASPl ULR7uSp479ZjDsSAK7Mq+HTAD+jn05/KJBQWm5d9c X-Received: by 2002:a05:7300:2144:b0:304:13f3:e461 with SMTP id 5a478bee46e88-30c84d0ed61mr6718900eec.3.1782470093515; Fri, 26 Jun 2026 03:34:53 -0700 (PDT) X-Received: by 2002:a05:7300:2144:b0:304:13f3:e461 with SMTP id 5a478bee46e88-30c84d0ed61mr6718867eec.3.1782470092953; Fri, 26 Jun 2026 03:34:52 -0700 (PDT) Received: from [10.218.25.225] ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-30c944999adsm9482228eec.24.2026.06.26.03.34.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 26 Jun 2026 03:34:52 -0700 (PDT) Message-ID: <4b00ec54-6fbb-485a-af9f-a2bd145ddeb6@oss.qualcomm.com> Date: Fri, 26 Jun 2026 16:04:41 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH RFC 00/12] mm/vmalloc: migrate vmap_area indexing from rb-tree to maple-tree Content-Language: en-US To: Matthew Wilcox , Uladzislau Rezki Cc: Andrew Morton , "Liam R. Howlett" , Alice Ryhl , Andrew Ballance , linux-arm-msm@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org, Lorenzo Stoakes , Pranjal Shrivastava , Will Deacon , Suzuki K Poulose , Neil Armstrong , Mostafa Saleh , Balbir Singh , Suren Baghdasaryan , Marco Elver , Dmitry Vyukov , Alexander Potapenko , Shuah Khan , Dev Jain , Brendan Jackman , Puranjay Mohan , Santosh Shukla , Wyes Karny , Sudeep Holla References: <20260613-vmalloc_maple-v1-0-0aa740bb944b@oss.qualcomm.com> From: Pranjal Arya In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Proofpoint-GUID: C7M5dQnfLMhJN8SpJL1YDrGS66gEB4Hs X-Proofpoint-ORIG-GUID: C7M5dQnfLMhJN8SpJL1YDrGS66gEB4Hs X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjI2MDA4NSBTYWx0ZWRfXxKmazEkLxCis 8fi+zQJGmZhk2GeyiMH02OXwV5J9f0kiwe/Xn41KtGt54q5w8NRDe5CKGUNdIKeDn8+uOuj9Nac I1+2o4cNER+63ssny0bfkCzMqYwpPeVFBb5WrA5SZGdxRLU4IJ8bfTswE3nRSnZlVL2gTIw2Vv/ eLEdZcMZm1EpEEQILGsxZYSI1ufvEMpcGrgCukkIt8eukn8aoGPwhv5tDhr/cGCp1DSa9EHTfRP RLG7y2C5mmfF/EUjrDJA9ibNGzTV4KDP+a3L2cbcIRiuZcnh3GgHQM2g3cbZ832qizIhByef8dq jTwIH5yhrMTvCEecL2nbFUx23h53+BWFMTnd+TTo0cH9E1NIFpP6hHnd9EjxwIqd4NvUbNuXVQA cCO2/upTTd0oN0gHV5gj1Xj8tJgiWI2pyNFuRXUvU0qvrFyNKBb0UOnpUpVkRm2nQhNX9ghKxpo 0j4bqyT3Iw6uyQKRzAQ== X-Authority-Analysis: v=2.4 cv=FPkrAeos c=1 sm=1 tr=0 ts=6a3e55ce cx=c_pps a=Uww141gWH0fZj/3QKPojxA==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=FelO9ux0wxsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=qSOC8k_MCT-xwaH91gwA:9 a=QEXdDO2ut3YA:10 a=PxkB5W3o20Ba91AHUih5:22 X-Proofpoint-Spam-Info: AW1haW4tMjYwNjI2MDA4NSBTYWx0ZWRfX9uMY3INHBnDQ x/Ms15qb8fw/OipPEM46rMSYmN/oS6iMtDhuPFdMN4b2kIF4o4QgKiOFJ4AnL/y2E1rdLS80pW7 ubVOLhQZMg29IcHS6ige/7yxOOyyhts= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-26_03,2026-06-24_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 priorityscore=1501 malwarescore=0 adultscore=0 bulkscore=0 impostorscore=0 phishscore=0 suspectscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2606260085 On 6/16/2026 11:37 PM, Matthew Wilcox wrote: > On Mon, Jun 15, 2026 at 11:52:22AM +0200, Uladzislau Rezki wrote: >> On Sun, Jun 14, 2026 at 12:15:28AM +0100, Matthew Wilcox wrote: >>> What I don't understand is why you maintain a separate "free" tree. >>> It should not be necessary any more, but maybe you tried removing it >>> already and found a performance problem? >> >> We maintain it in order to split several entities. That prevents >> interfering between allocated data and vmap-free-space manager. >> So in that case one context can easily access allocated data, for >> example vread iterator, etc., whereas another can do an allocation. >> >> So by splitting parts i minimize lock-contention. > > Sure, but there are many ways to reduce lock contention. One is to not > take locks at all; the maple tree is RCU-safe, so you can read the tree > holding only the RCU read lock, as long as you obey the RCU rules. > > Specifically: > - Write side has to RCU-free the objects that are stored in the tree > - Read side has to trylock the objects it finds (and retry the walk > if the trylock fails) > - Read side can see a mixture of objects if the tree is changed while > it is reading, but for any given index in the tree it is guaranteed > to see one of the objects which has been referred to by that index. > That is, if the write side overwrites an index that referred to > object A with object B, the reader will see either object A or B. > It will not see NULL and it will not see any other object. > - If the write side stores both object C and object D in the tree, > the read side may see neither, both, only C or only D. Acknowledged & I'll implement this approach for find_vmap_area(): Write side: Every vmap_area that was previously freed with kmem_cache_free() will now be freed via call_rcu(&va->rcu, vmap_area_free_rcu). Read side: find_vmap_area() will walk vn->busy.mt under rcu_read_lock() using mas_walk() (RCU safe tree traversal) & will then validate the found object using READ_ONCE before returning it. The maple tree guarantees that for any single index the reader will see either the old or the new object, not NULL. To ensure this, I'll set MT_FLAGS_USE_RCU on vn->busy.mt in the mt_init_flags() call. With these changes, find_vmap_area() which is called on every vfree(), vmalloc_to_page(), vmalloc_to_pfn() will no longer acquire any spinlock on the lookup path. Does it sound like a good plan ? BR, Pranjal