Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751300AbdISKHN (ORCPT ); Tue, 19 Sep 2017 06:07:13 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:48122 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750747AbdISKHM (ORCPT ); Tue, 19 Sep 2017 06:07:12 -0400 Subject: Re: [PATCH v2 3/4] iommu/iova: Extend rbtree node caching To: "Leizhen (ThunderTown)" , Nate Watterson , joro@8bytes.org Cc: iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dwmw2@infradead.org, lorenzo.pieralisi@arm.com, ard.biesheuvel@linaro.org, Jonathan.Cameron@huawei.com, ray.jui@broadcom.com References: <23972edc-e59e-3a43-59a9-d776e64af4d7@codeaurora.org> <59C0E694.6080508@huawei.com> From: Robin Murphy Message-ID: Date: Tue, 19 Sep 2017 11:07:05 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <59C0E694.6080508@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1102 Lines: 39 On 19/09/17 10:42, Leizhen (ThunderTown) wrote: [...] >>>> static void >>>> __cached_rbnode_delete_update(struct iova_domain *iovad, struct iova >>>> *free) >>>> { >>>> struct iova *cached_iova; >>>> - struct rb_node *curr; >>>> + struct rb_node **curr = NULL; >>>> - if (!iovad->cached32_node) >>>> - return; >>>> - curr = iovad->cached32_node; >>>> - cached_iova = rb_entry(curr, struct iova, node); > > ----------------------------- >>>> + if (free->pfn_hi < iovad->dma_32bit_pfn) >>>> + curr = &iovad->cached32_node; >>>> + if (!curr) >>>> + curr = &iovad->cached_node; >> >> + if (!*curr) >> + return; > Is it necessary for us to try the following adjustment? > + if (free->pfn_hi < iovad->dma_32bit_pfn) > + curr = &iovad->cached32_node; > + else > + curr = &iovad->cached_node; > + > + if (!*curr) { > + *curr = rb_next(&free->node); > + return; > + } Yeah, I spotted that this looked a bit wonky after I posted it. It's already cleaned up in v3, which I'll be posting shortly after I write up some cover letters. Thanks, Robin.