On Mon, Feb 24, 2025 at 11:50:50AM -0500, Steven Sistare wrote:
> > > I can do that, but it would add cycles.  Is this considered a high 
> > > performance
> > > path that may be called frequently?
> > 
> > AFAICT, any vIOMMU mapping isn't high perf path.  In this specific path,
> > the refcount op should be buried in any dma map operations..
> 
> memory_region_ref contains a comment that implies we should avoid taking a
> ref if possible:
>      * Memory regions without an owner are supposed to never go away;
>      * we do not ref/unref them because it slows down DMA sensibly.

That's for internal / permanent MRs that don't have an owner to speed
things up, and that should be orthogonal to this, as that'll automatically
take effect even if we use memory_region_[un]ref() here.

AFAIU we should always suggest using memory_region_[un]ref() in callers
when there's MR references.

I'm also ok without the boosted refcount, but then please document the RCU
implications on referencing the MR, and the MR reference must not be used
after rcu_read_unlock(), in that case.

Thanks,

-- 
Peter Xu


Reply via email to