Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp5748462ioo; Wed, 1 Jun 2022 11:43:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMaO3/3KOwYoq2ZCB3wAplZUKOjkbRvorovpAIJnNaZm9OgVrsy3YylVr+qeM3UQQEIjDj X-Received: by 2002:a17:902:7049:b0:162:962:5b04 with SMTP id h9-20020a170902704900b0016209625b04mr753000plt.167.1654109005525; Wed, 01 Jun 2022 11:43:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654109005; cv=none; d=google.com; s=arc-20160816; b=rccYo2ueNKHO00jDDQadcyylpa7jaUNYVx3i5jk74nalsJSoka9fuFnKpGf11sNJBd 9573TGsEpNlK8nTIHFSfAC32HGYp01cINPAQs3Lpc+dZoj/8zpHAQAdEt2+GLzMUEPBZ QN+UkZEOze8W4dEwd2k32f9MiTMfWIqlSVpsz0Bq7GQG24duB03UfSeQiVnmFZ6qwDLx etxstvDWcorQd5uVJocTfkdgBAMkxYH/Uhzd8MIhvyuENq9xdYrKFmZEchhtTwJHWMZm QHWuOxBkSJ3reLDywbEv5uWkKjb7rua+AImZT+U0SW+YIYh56lowR3kVy+rhfGOLN/aQ Shag== 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:dkim-signature; bh=Pscrfy4zfmI9B2/f3RlaAfD71lZsuhWSoCA2Yk9IIwI=; b=elcBU73UJ+l/QwwC/C6UU9pkWH5fxYqKiVtyo8rwoqexDl90FSoxJoBUX8SKbnWUhv vk5ULJ/xOOXzirgs2TFiYCmd9NJS+AqUWOD/6yZRCRJ/UkDTBdulV+98vjs1FdYWxg6C A6gUtS5ei7lCsBmSQt31AOcuWa56/nXdhpdY8Wyry0N44obxulvW+52NGt0M24+cFfoH GiuAD0zHLlpadV2y7gLjKduQ/3OOjgx+Imt8lhii3USpP7YGQ8UF4iSOjnLjCA957pG0 I1yDzkRkDVb7lxSqICOiJu5WF01n3T7IICZSSpTsri0AkHl5XRG2GfbrWZIwwm6Z7UkY 21dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cybernetics.com header.s=mail header.b=q5PB8adp; 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=pass (p=NONE sp=NONE dis=NONE) header.from=cybernetics.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id a16-20020a170902ecd000b0015cb564e4d5si3703308plh.242.2022.06.01.11.43.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 11:43:25 -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; dkim=pass header.i=@cybernetics.com header.s=mail header.b=q5PB8adp; 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=pass (p=NONE sp=NONE dis=NONE) header.from=cybernetics.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 85571C5E75; Wed, 1 Jun 2022 11:39:10 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348332AbiEaWKs (ORCPT + 99 others); Tue, 31 May 2022 18:10:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348331AbiEaWKq (ORCPT ); Tue, 31 May 2022 18:10:46 -0400 Received: from mail.cybernetics.com (mail.cybernetics.com [173.71.130.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 886EE9CF4F for ; Tue, 31 May 2022 15:10:41 -0700 (PDT) X-ASG-Debug-ID: 1654035038-1cf43917f334d340001-xx1T2L Received: from cybernetics.com ([10.10.4.126]) by mail.cybernetics.com with ESMTP id pi5n3chlKhW5dG70; Tue, 31 May 2022 18:10:38 -0400 (EDT) X-Barracuda-Envelope-From: tonyb@cybernetics.com X-ASG-Whitelist: Client DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=cybernetics.com; s=mail; bh=Pscrfy4zfmI9B2/f3RlaAfD71lZsuhWSoCA2Yk9IIwI=; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From:References:Cc:To: Content-Language:Subject:MIME-Version:Date:Message-ID; b=q5PB8adp564e7QMu+Y67 rqxW9A2//yQphTVtYoOJzENI1mQv1RQmgvsm7Lip7aY8a7rF+htFUguM3OldCVKcojJicdxPHrfCe RfT8TUxLI1Q2o5QHc1BeFYM3K6ctZm0dHzpcsepgcE3x6eZwrBlQGNCsc3NwiuaJ4K8luj2hLA= Received: from [10.157.2.224] (HELO [192.168.200.1]) by cybernetics.com (CommuniGate Pro SMTP 7.1.1) with ESMTPS id 11830524; Tue, 31 May 2022 18:10:38 -0400 Message-ID: <803feeab-b27b-983d-45da-02a0daf0179a@cybernetics.com> Date: Tue, 31 May 2022 18:10:38 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH 10/10] dmapool: improve scalability of dma_pool_free Content-Language: en-US X-ASG-Orig-Subj: Re: [PATCH 10/10] dmapool: improve scalability of dma_pool_free To: 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 , Robin Murphy , Tony Lindgren References: <9b08ab7c-b80b-527d-9adf-7716b0868fbc@cybernetics.com> <801335ba-00f3-12ae-59e0-119d7d8fd8cd@cybernetics.com> From: Tony Battersby In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: UNKNOWN[10.10.4.126] X-Barracuda-Start-Time: 1654035038 X-Barracuda-URL: https://10.10.4.122:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cybernetics.com X-Barracuda-Scan-Msg-Size: 989 X-Barracuda-BRTS-Status: 1 X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,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 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. Tony