Linux IOMMU Development
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: "Tian, Kevin" <kevin.tian@intel.com>
Cc: "iommu@lists.linux.dev" <iommu@lists.linux.dev>,
	Joerg Roedel <joro@8bytes.org>,
	"Brost, Matthew" <matthew.brost@intel.com>,
	Robin Murphy <robin.murphy@arm.com>,
	Will Deacon <will@kernel.org>,
	"Dugast, Francois" <francois.dugast@intel.com>,
	Joerg Roedel <joerg.roedel@amd.com>,
	"patches@lists.linux.dev" <patches@lists.linux.dev>
Subject: Re: [PATCH rc] iommupt: Only cache flush memory changed by unmap
Date: Mon, 26 Jan 2026 10:14:11 -0400	[thread overview]
Message-ID: <20260126141411.GJ1134360@nvidia.com> (raw)
In-Reply-To: <BN9PR11MB527689AC9554360C2339E7598C93A@BN9PR11MB5276.namprd11.prod.outlook.com>

On Mon, Jan 26, 2026 at 07:33:21AM +0000, Tian, Kevin wrote:
> > From: Jason Gunthorpe <jgg@nvidia.com>
> > Sent: Sunday, January 25, 2026 5:00 AM
> > 
> > The cache flush was happening on every level across the whole range of
> > iteration, even if no leafs or tables were cleared. Instead flush only the
> > sub range that was actually written.
> > 
> > Overflushing isn't a correctness problem but it does impact the
> > performance of unmap.
> > 
> > After this series the performance compared to the original VT-d
> > implementation with cache flushing turned on is:
> > 
> > map_pages
> >    pgsz  ,avg new,old ns, min new,old ns  , min % (+ve is better)
> >      2^12,    253,266   ,     213,227     ,   6.06
> >      2^21,    246,244   ,     221,219     ,   0.00
> >      2^30,    231,240   ,     209,217     ,   3.03
> >  256*2^12,   2604,2668  ,    2415,2540    ,   4.04
> >  256*2^21,   2495,2824  ,    2390,2734    ,  12.12
> >  256*2^30,   2542,2845  ,    2380,2718    ,  12.12
> > 
> > unmap_pages
> >    pgsz  ,avg new,old ns, min new,old ns  , min % (+ve is better)
> >      2^12,    259,292   ,     222,251     ,  11.11
> >      2^21,    255,259   ,     227,236     ,   3.03
> >      2^30,    238,254   ,     217,230     ,   5.05
> >  256*2^12,   2751,2620  ,    2417,2437    ,   0.00
> >  256*2^21,   2461,2526  ,    2377,2423    ,   1.01
> >  256*2^30,   2498,2543  ,    2370,2404    ,   1.01
> > 
> 
> that is great!
> 
> Out of curiosity - why would an optimization in the unmap path also
> lead to better efficiency in the map path (in some cases map improves
> even more than unmap, e.g. with 256 pages)?

I cannot explain this, but it is how the test behaves on my system -
before this patch:

map_pages
   pgsz  ,avg new,old ns, min new,old ns  , min % (+ve is better)
     2^12,    530,237   ,     450,207     , -117.17
     2^21,    417,231   ,     375,208     , -80.80
     2^30,    325,233   ,     275,217     , -26.26
 256*2^12,   3020,2658  ,    2599,2492    ,  -4.04
 256*2^21,   2892,2839  ,    2585,2721    ,   4.04
 256*2^30,   2794,2836  ,    2548,2712    ,   6.06

unmap_pages
   pgsz  ,avg new,old ns, min new,old ns  , min % (+ve is better)
     2^12,    444,257   ,     410,230     , -78.78
     2^21,    378,244   ,     353,225     , -56.56
     2^30,    300,245   ,     281,229     , -22.22
 256*2^12,   2975,2604  ,    2536,2403    ,  -5.05
 256*2^21,   2887,2523  ,    2489,2417    ,  -2.02
 256*2^30,   2799,2525  ,    2471,2397    ,  -3.03

Perhaps it is an artifact of how the test is constructed and
subsequent maps are suffering because the cache for the already
populated levels is in a poor state due to the extra flush?

Mapping requires an atomic on the cache line so maybe that interacts
poorly with a clflush somehow?

Jason

  reply	other threads:[~2026-01-26 14:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-24 21:00 [PATCH rc] iommupt: Only cache flush memory changed by unmap Jason Gunthorpe
2026-01-26  7:33 ` Tian, Kevin
2026-01-26 14:14   ` Jason Gunthorpe [this message]
2026-01-27  7:33     ` Tian, Kevin
2026-01-26 20:07 ` Francois Dugast
2026-01-28  6:08 ` Baolu Lu
2026-01-28 14:14 ` Joerg Roedel

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=20260126141411.GJ1134360@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=francois.dugast@intel.com \
    --cc=iommu@lists.linux.dev \
    --cc=joerg.roedel@amd.com \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=matthew.brost@intel.com \
    --cc=patches@lists.linux.dev \
    --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