Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp5820044ioo; Wed, 1 Jun 2022 13:17:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzn9+A3kjwsduH4B8/aEfFF1XAvkcd3zp7CeDGCeVnSvE4v4VlOh+s1XcEOg3fEriV8ymtX X-Received: by 2002:a65:4c44:0:b0:39c:e0b5:cd2a with SMTP id l4-20020a654c44000000b0039ce0b5cd2amr927232pgr.481.1654114655154; Wed, 01 Jun 2022 13:17:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654114655; cv=none; d=google.com; s=arc-20160816; b=sUR98TGFp11PtPSEsn6bVDfWm6e4GKGbNhD2FmtB1CAFJPls3rfAIuWenOEko4qPns ABl/Tsfltj3tFx6xf6D2DoEATxqMyJScp18fit4TXipd6Um4VsVm29dNQVzAyDMpmKdx 5YeTW/baRQYnfzbjomv9/fGyDVqUbh6QbkR79syoMTskAUbIdJec6mL7iZoyJalu2N1q 7bVP5iubl4HMO8cYLGEdOd5zsgaC2w+xxnHOzjtc8QghiO2+Oki3DbYM9HE6jyVW8yk9 nXaAKge3432uLNvoBEfbxhq4Q80m4WlqVe3EciB1HEGLGQcbRO30sNUBTYRqIf99duSJ fdWA== 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:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=GPvxprbaUM5tjsLcI80ybhr/D8S+V4dZBhPb54oXCy4=; b=RS6GaHD3QYg4a8GzxIknUpFHNI0wvyIPH7W7qsLB3vPLPuwkM0L3pLC7vxU/JgTDUW 4kkB3tSpXdwjsfCl8ScvOmu3kmxdnYiBZ7Uy8D6sLWp/fccoqoye4c7+4K7sSKQCCNIG 3/KaPsKKcKR9uPtAdt/97EE5GqenKrZgnIBcF5A6lFCFCl2BUlxt1gFkiJ/Xg/wi299g 4r/C1Z3e+yzZh0gUSdQkiH7qZIjqUcZnhmdFTUatdrDuTMBlrtuTSgBMZyQaLpdksGbP 9g671A/wh/M18I4kmONFgNC0AmvvxzRsrPQxotw2tMK4LTrElg7s0kObfDhFZQyxmjVH IGeQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id b13-20020a170902d88d00b00163f35b2aafsi3259234plz.508.2022.06.01.13.17.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 13:17:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 101F1612B2; Wed, 1 Jun 2022 12:30:57 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351473AbiFAJpC (ORCPT + 99 others); Wed, 1 Jun 2022 05:45:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351373AbiFAJoi (ORCPT ); Wed, 1 Jun 2022 05:44:38 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9CA8685EF2 for ; Wed, 1 Jun 2022 02:44:36 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4F56FED1; Wed, 1 Jun 2022 02:44:36 -0700 (PDT) Received: from [10.57.81.38] (unknown [10.57.81.38]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DBB503F66F; Wed, 1 Jun 2022 02:44:34 -0700 (PDT) Message-ID: <408315d1-9820-65d0-c0a7-cc038bfa9eb1@arm.com> Date: Wed, 1 Jun 2022 10:44:29 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH 10/10] dmapool: improve scalability of dma_pool_free Content-Language: en-GB To: Tony Battersby , Keith Busch Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, kernel-team@fb.com, Matthew Wilcox , Andy Shevchenko , Tony Lindgren References: <9b08ab7c-b80b-527d-9adf-7716b0868fbc@cybernetics.com> <801335ba-00f3-12ae-59e0-119d7d8fd8cd@cybernetics.com> <803feeab-b27b-983d-45da-02a0daf0179a@cybernetics.com> From: Robin Murphy In-Reply-To: <803feeab-b27b-983d-45da-02a0daf0179a@cybernetics.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-05-31 23:10, Tony Battersby wrote: > On 5/31/22 17:54, Keith Busch wrote: >> On Tue, May 31, 2022 at 02:23:44PM -0400, Tony Battersby wrote: >>> dma_pool_free() scales poorly when the pool contains many pages because >>> pool_find_page() does a linear scan of all allocated pages. Improve its >>> scalability by replacing the linear scan with a red-black tree lookup. >>> In big O notation, this improves the algorithm from O(n^2) to O(n * log n). >> The improvement should say O(n) to O(log n), right? > > That would be the improvement for a single call to dma_pool_alloc or > dma_pool_free, but I was going with the improvement for "n" calls > instead, which is consistent with the improvement for the example in the > cover letter for mpt3sas.  I would have to look up the convention to be > sure of the proper notation in a situation like this, but I usually > think "inserting N items takes N^2 time"; to me it makes less sense to > say "inserting 1 item takes N time", because the N seems to come out of > nowhere. No, n represents the size of the set that the algorithm is inserting into (or removing from, searching within, etc.). Hence why constant time is represented by O(1), i.e. not involving the variable at all. Robin.