Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 52320C433F5 for ; Fri, 11 Feb 2022 15:26:48 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.270549.464866 (Exim 4.92) (envelope-from ) id 1nIXof-0001g7-7K; Fri, 11 Feb 2022 15:26:33 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 270549.464866; Fri, 11 Feb 2022 15:26:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nIXof-0001g0-4Q; Fri, 11 Feb 2022 15:26:33 +0000 Received: by outflank-mailman (input) for mailman id 270549; Fri, 11 Feb 2022 15:26:31 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nIXod-0001fp-DO for xen-devel@lists.xenproject.org; Fri, 11 Feb 2022 15:26:31 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nIXoc-0002Eq-Vh; Fri, 11 Feb 2022 15:26:30 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=[192.168.30.126]) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nIXoc-0001eR-Pr; Fri, 11 Feb 2022 15:26:30 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID; bh=KTSoUtgjwSy7gl6uk/Mujrv4cOe4EP/gFFPDHqVbYj0=; b=cEMn2gtqhXpzWVySrQJURQiovT Ozr1I5dupZhL6jadjnIAuj9XxFWip5nnZOqtqXV/IonXlRCYeRsyskFD7SeXXYQKEBFlaALypnMVW 8UccRuIjgZ2aHHxtukuhJP4aadW3z9Cy9/BPKDqSE0trd94ae69xrPXXAIZEpU7esumU=; Message-ID: <81a2f978-9337-2e58-c8b2-86dc7defc2ec@xen.org> Date: Fri, 11 Feb 2022 15:26:28 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: Re: [RFC PATCH] arm/vgic-v3: provide custom callbacks for pend_lpi_tree radix tree To: Luca Fancellu , xen-devel@lists.xenproject.org Cc: wei.chen@arm.com, Stefano Stabellini , Volodymyr Babchuk , Bertrand Marquis References: <20220211150042.11972-1-luca.fancellu@arm.com> From: Julien Grall In-Reply-To: <20220211150042.11972-1-luca.fancellu@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi Luca, On 11/02/2022 15:00, Luca Fancellu wrote: > pend_lpi_tree is a radix tree used to store pending irqs, the tree is > protected by a lock for read/write operations. > > Currently the radix tree default function to free items uses the > RCU mechanism, calling call_rcu and deferring the operation. > > However every access to the structure is protected by the lock so we > can avoid using the default free function that, by using RCU, > increases memory usage and impacts the predictability of the system. I understand goal but looking at the implementation of vgic_v3_lpi_to_pending() (Copied below for convenience). We would release the lock as soon as the look-up finish, yet the element is returned. static struct pending_irq *vgic_v3_lpi_to_pending(struct domain *d, unsigned int lpi) { struct pending_irq *pirq; read_lock(&d->arch.vgic.pend_lpi_tree_lock); pirq = radix_tree_lookup(&d->arch.vgic.pend_lpi_tree, lpi); read_unlock(&d->arch.vgic.pend_lpi_tree_lock); return pirq; } So the lock will not protect us against removal. If you want to drop the RCU, you will need to ensure the structure pending_irq is suitably protected. I haven't check whether there are other locks that may suit us here. Cheers, -- Julien Grall