linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Pasha Tatashin <pasha.tatashin@soleen.com>
To: Robin Murphy <robin.murphy@arm.com>
Cc: joro@8bytes.org, will@kernel.org, iommu@lists.linux.dev,
	 linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	rientjes@google.com
Subject: Re: [PATCH] iommu/iova: use named kmem_cache for iova magazines
Date: Fri, 2 Feb 2024 13:04:08 -0500	[thread overview]
Message-ID: <CA+CK2bCFbeRHT172KUci5+8WJNUeo-2A1M=UXsSqqOy64w1LJw@mail.gmail.com> (raw)
In-Reply-To: <84c7e816-f749-48d8-a429-8b0ef799cdbb@arm.com>

> Hmm, I did misspeak slightly (it's late and I really should have left
> this for tomorrow...) - that's 12KB per CPU *per domain*, but still that
> would seem to imply well over 100 domains if you have 242MB of magazine
> allocations while the iommu_iova cache isn't even on the charts... what
> the heck is that driver doing?
>
> (I don't necessarily disagree with the spirit of the patch BTW, I just
> really want to understand the situation that prompted it, and make sure
> we don't actually have a subtle leak somewhere.)

Hi Robin,

The following tracing is without Google TPU, simply upstream kernel:

The iova_domain_init_rcaches is called 159 with the following stack:

 iova_domain_init_rcaches
 iommu_setup_dma_ops
 amd_iommu_probe_finalize
 bus_iommu_probe
 iommu_device_register
 iommu_init_pci
 amd_iommu_init_pci
 state_next
 iommu_go_to_state
 amd_iommu_init
 pci_iommu_init
 do_one_initcall

Each time 1536K is allocated: in total 159 * 1536K = 238.5M

The allocation happens like this:
for (IOVA_RANGE_CACHE_MAX_SIZE)
    for_each_possible_cpu()
        iova_magazine_alloc
        iova_magazine_alloc

IOVA_RANGE_CACHE_MAX_SIZE = 6
ncpu = 128
sizeof (struct iova_magazine) = 1K

6 * 128 * (1K + 1K) = 1536K

Pasha


  parent reply	other threads:[~2024-02-02 18:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-01 19:30 Pasha Tatashin
2024-02-01 20:56 ` Robin Murphy
2024-02-01 21:06   ` Pasha Tatashin
2024-02-01 21:23     ` Robin Murphy
2024-02-01 22:10       ` Pasha Tatashin
2024-02-02 18:04       ` Pasha Tatashin [this message]
2024-02-02 18:27         ` Robin Murphy
2024-02-02 19:14           ` Pasha Tatashin
2024-02-01 22:28 ` Yosry Ahmed
2024-02-02 17:52   ` Pasha Tatashin

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='CA+CK2bCFbeRHT172KUci5+8WJNUeo-2A1M=UXsSqqOy64w1LJw@mail.gmail.com' \
    --to=pasha.tatashin@soleen.com \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rientjes@google.com \
    --cc=robin.murphy@arm.com \
    --cc=will@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox