All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: Tony Battersby <tonyb@cybernetics.com>, Keith Busch <kbusch@kernel.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	iommu@lists.linux-foundation.org, kernel-team@fb.com,
	Matthew Wilcox <willy@infradead.org>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	Tony Lindgren <tony@atomide.com>
Subject: Re: [PATCH 10/10] dmapool: improve scalability of dma_pool_free
Date: Wed, 1 Jun 2022 10:44:29 +0100	[thread overview]
Message-ID: <408315d1-9820-65d0-c0a7-cc038bfa9eb1@arm.com> (raw)
In-Reply-To: <803feeab-b27b-983d-45da-02a0daf0179a@cybernetics.com>

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.

WARNING: multiple messages have this Message-ID (diff)
From: Robin Murphy <robin.murphy@arm.com>
To: Tony Battersby <tonyb@cybernetics.com>, Keith Busch <kbusch@kernel.org>
Cc: Tony Lindgren <tony@atomide.com>,
	iommu@lists.linux-foundation.org,
	Matthew Wilcox <willy@infradead.org>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	kernel-team@fb.com
Subject: Re: [PATCH 10/10] dmapool: improve scalability of dma_pool_free
Date: Wed, 1 Jun 2022 10:44:29 +0100	[thread overview]
Message-ID: <408315d1-9820-65d0-c0a7-cc038bfa9eb1@arm.com> (raw)
In-Reply-To: <803feeab-b27b-983d-45da-02a0daf0179a@cybernetics.com>

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.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

  reply	other threads:[~2022-06-01  9:45 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-31 18:11 [PATCH 00/10] mpt3sas and dmapool scalability Tony Battersby
2022-05-31 18:11 ` Tony Battersby
2022-05-31 18:12 ` [PATCH 01/10] dmapool: remove checks for dev == NULL Tony Battersby
2022-05-31 18:12   ` Tony Battersby
2022-05-31 18:23   ` Robin Murphy
2022-05-31 18:23     ` Robin Murphy
2022-05-31 18:13 ` [PATCH 02/10] dmapool: cleanup integer types Tony Battersby
2022-05-31 18:13   ` Tony Battersby
2022-05-31 18:14 ` [PATCH 03/10] dmapool: fix boundary comparison Tony Battersby
2022-05-31 18:14   ` Tony Battersby
2022-05-31 18:17 ` [PATCH 04/10] dmapool: improve accuracy of debug statistics Tony Battersby
2022-05-31 18:17   ` Tony Battersby
2022-05-31 19:48   ` Robin Murphy
2022-05-31 19:48     ` Robin Murphy
2022-05-31 19:52     ` Tony Battersby
2022-05-31 19:52       ` Tony Battersby
2022-05-31 21:55       ` Robin Murphy
2022-05-31 21:55         ` Robin Murphy
2022-05-31 18:18 ` [PATCH 05/10] dmapool: debug: prevent endless loop in case of corruption Tony Battersby
2022-05-31 18:18   ` Tony Battersby
2022-05-31 18:20 ` [PATCH 06/10] dmapool: ignore init_on_free when DMAPOOL_DEBUG enabled Tony Battersby
2022-05-31 18:20   ` Tony Battersby
2022-05-31 18:21 ` [PATCH 07/10] dmapool: speedup DMAPOOL_DEBUG with init_on_alloc Tony Battersby
2022-05-31 18:21   ` Tony Battersby
2022-05-31 18:22 ` [PATCH 08/10] dmapool: cleanup dma_pool_destroy Tony Battersby
2022-05-31 18:22   ` Tony Battersby
2022-05-31 19:33   ` Robin Murphy
2022-05-31 19:33     ` Robin Murphy
2022-05-31 21:40   ` Keith Busch
2022-05-31 21:40     ` Keith Busch
2022-05-31 18:23 ` [PATCH 09/10] dmapool: improve scalability of dma_pool_alloc Tony Battersby
2022-05-31 18:23   ` Tony Battersby
2022-05-31 18:23 ` [PATCH 10/10] dmapool: improve scalability of dma_pool_free Tony Battersby
2022-05-31 18:23   ` Tony Battersby
2022-05-31 21:54   ` Keith Busch
2022-05-31 21:54     ` Keith Busch
2022-05-31 22:10     ` Tony Battersby
2022-05-31 22:10       ` Tony Battersby
2022-06-01  9:44       ` Robin Murphy [this message]
2022-06-01  9:44         ` Robin Murphy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=408315d1-9820-65d0-c0a7-cc038bfa9eb1@arm.com \
    --to=robin.murphy@arm.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=kbusch@kernel.org \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=tony@atomide.com \
    --cc=tonyb@cybernetics.com \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.