Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1831949rda; Tue, 24 Oct 2023 04:59:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGfKiopNniJU2yYKKukGhzzuNUS7QOezoA82PKroP+A3cGV1qJxO49LGw26lytIVwQeo/PC X-Received: by 2002:a05:6a21:1cad:b0:16b:74db:8fde with SMTP id sf45-20020a056a211cad00b0016b74db8fdemr1995309pzb.61.1698148755455; Tue, 24 Oct 2023 04:59:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698148755; cv=none; d=google.com; s=arc-20160816; b=WB2NgFnvWUblj0YUZf7x3oIvVjQYoxvDGe/ZDN9nommb1mb279etkt/pFaq378eSVu nzuXwhJ/wAr3z0KzvqUCSC949GWcGXs5G5NnFnxy5EtF0mVsOW+MjlWerDB0YLCs5YsK efDr/pUfGEE+rGtS7UM7P/mSm1UuJ0CiADiT78RY1zwsAXzfvd+kLWSf/+9xIz2cnV2W gdCB9G4d8u8ffCnbeXBgmdEhSjoZT0Ylf7ZM/7OSqT2O43hH+8LOHv2adglwH+iFAuFD gkc/rhkjjX0z9VLxlHpjyXeYzG2ka9vUlhMp69FmBlpv255nM6OrkLLGqIuAU6SP4HcZ srxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:cc:user-agent:mime-version :date:message-id:dkim-signature; bh=Gj1ccyXIRhvjYMNUtFTw4EvO7oMijupG1TopvsKjjsw=; fh=5Xjc7TpdM1a2TKnM0Fb+tSsJaUydXQgEgpi9oV3fwYg=; b=0lPGLwAEo2p52VXwmdKjocOxnyaNSEn90FOqBKVlTCScIywPnA/h3/N6WeyrtqAhDh 0OAPa9L0WL6c62fUAGkVfyB/gYWm+K7yrY3dYVcxB/63oxUb2bICspqRqlZoOCpcFOiv QoXGuWhiZuZEFuoFbTwdUyqDGjdZ7mJn0p5ieLitJ/++04ywaFBSw7MOKG8ZRcv8OjF+ lXYXFMDZF0uRBRT/jUDCjTX5Be/4B+DTrkxz7GNOTSRJyuSKjsUhntRkDLFtJ5hVUUaq Q1VA1qep+Nve2ae+hxfMqO7KqhkjEVP5R1RLJ+e6/jspldA47l+nRrD7aAYD8UNOBv+Y llrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eI42qC9x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id s3-20020a637703000000b005b8a18ec2dbsi5398366pgc.303.2023.10.24.04.59.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 04:59:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eI42qC9x; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 89B1F80AEE3E; Tue, 24 Oct 2023 04:59:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232469AbjJXL67 (ORCPT + 99 others); Tue, 24 Oct 2023 07:58:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230150AbjJXL66 (ORCPT ); Tue, 24 Oct 2023 07:58:58 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82B2510C3; Tue, 24 Oct 2023 04:58:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698148736; x=1729684736; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=pnGRnp7vVwZkr643r1FTOWjeVjSHpkg1wCabNnnRz1c=; b=eI42qC9xxW9le2qbJRZ68okZz0idtCni5i7vydUlNQZm+kYz+C34fYKh OImE1KOxrAj7HpFl3HevNGdf2ljq6hsy0Z2xLwaCbCqgqQcEgPIfxojb7 IDdEVEk3uy1Rjo50oQXP1iYtMOmXPyP9ogiqw+fCx4heJ0/2x5AhCdoit bpzldo6yFgLA8avObmgZsGnSXQhTxaoTvzRmZCQn4uQW7tTMw8ZP5b7Dj +AgpEZVN8o75uwjMgK38xIYEy/DdrbWsuibw9SfZwyECOyd4Nwvf9KOt2 vihzYlZhFfF4KPe7pSp033Ywj+lnjuv4r9qxMloN0UYzoF5TQOJgkD1we g==; X-IronPort-AV: E=McAfee;i="6600,9927,10872"; a="384239196" X-IronPort-AV: E=Sophos;i="6.03,247,1694761200"; d="scan'208";a="384239196" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Oct 2023 04:58:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.03,247,1694761200"; d="scan'208";a="6153680" Received: from qiangfu1-mobl1.ccr.corp.intel.com (HELO [10.254.212.47]) ([10.254.212.47]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Oct 2023 04:57:35 -0700 Message-ID: <5a4c169d-8e42-4609-87db-8b68f04bb0fe@linux.intel.com> Date: Tue, 24 Oct 2023 19:58:50 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: baolu.lu@linux.intel.com, jacob.jun.pan@linux.intel.com, kevin.tian@intel.com, yi.y.sun@intel.com, kvm@vger.kernel.org Subject: Re: [PATCH 1/2] iommu: Introduce a rb_tree for looking up device Content-Language: en-US To: Huang Jiaqing , joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, dwmw2@infradead.org, linux-kernel@vger.kernel.org, iommu@lists.linux.dev References: <20231024084124.11155-1-jiaqing.huang@intel.com> From: Baolu Lu In-Reply-To: <20231024084124.11155-1-jiaqing.huang@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 24 Oct 2023 04:59:12 -0700 (PDT) On 2023/10/24 16:41, Huang Jiaqing wrote: > The existing IO page fault handler locates the PCI device by calling > pci_get_domain_bus_and_slot(), which searches the list of all PCI > devices until the desired PCI device is found. This is inefficient > because the algorithm efficiency of searching a list is O(n). In the > critical path of handling an IO page fault, this is not performance > friendly given that I/O page fault handling patch is performance > critical, and parallel heavy dsa_test may cause cpu stuck due to > the low efficiency and lock competition in current path. > > To improve the performance of the IO page fault handler, replace > pci_get_domain_bus_and_slot() with a local red-black tree. A red-black > tree is a self-balancing binary search tree, which means that the > average time complexity of searching a red-black tree is O(log(n)). This > is significantly faster than O(n), so it can significantly improve the > performance of the IO page fault handler. > > In addition, we can only insert the affected devices (those that have IO > page fault enabled) into the red-black tree. This can further improve > the performance of the IO page fault handler. > > This series depends on "deliver page faults to user space" patch-set: > https://lore.kernel.org/linux-iommu/20230928042734.16134-1-baolu.lu@linux.intel.com/ The note above is not part of the commit message, and should be placed below the tear line or in the cover letter, if there is one. > > Signed-off-by: Huang Jiaqing > --- > drivers/iommu/io-pgfault.c | 104 ++++++++++++++++++++++++++++++++++++- > include/linux/iommu.h | 16 ++++++ > 2 files changed, 118 insertions(+), 2 deletions(-) Best regards, baolu