From: Shaohua Li <shli-b10kYP2dOMg@public.gmane.org>
To: Jens Axboe <axboe-b10kYP2dOMg@public.gmane.org>
Cc: "iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org"
<iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>,
"jroedel-l3A5Bk7waGM@public.gmane.org"
<jroedel-l3A5Bk7waGM@public.gmane.org>,
"Woodhouse,
David" <david.woodhouse-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
"Kernel-team-b10kYP2dOMg@public.gmane.org"
<Kernel-team-b10kYP2dOMg@public.gmane.org>
Subject: Re: [PATCH 2/4] iommu: add a bitmap based dma address allocator
Date: Wed, 25 Nov 2015 10:57:42 -0800 [thread overview]
Message-ID: <20151125185723.GA247498@devbig084.prn1.facebook.com> (raw)
In-Reply-To: <5655F1F8.9070203-b10kYP2dOMg@public.gmane.org>
On Wed, Nov 25, 2015 at 10:38:00AM -0700, Jens Axboe wrote:
> On 11/25/2015 10:33 AM, Shaohua Li wrote:
> >On Wed, Nov 25, 2015 at 09:43:49AM -0700, Jens Axboe wrote:
> >>On 11/25/2015 09:40 AM, Woodhouse, David wrote:
> >>>On Wed, 2015-11-25 at 15:46 +0100, jroedel-l3A5Bk7waGM@public.gmane.org wrote:
> >>>>On Tue, Nov 24, 2015 at 02:05:12PM -0800, Shaohua Li wrote:
> >>>>>The lib/iommu-common.c uses a bitmap and a lock. This implementation
> >>>>>actually uses a percpu_ida which completely avoids locking. It would be
> >>>>>possible to make lib/iommu-common.c use percpu_ida too if somebody wants
> >>>>>to do it, but I think this shouldn't be a blocker for these patches
> >>>>>giving it has huge performance gain.
> >>>>
> >>>>It doesn't "completely avoids locking", the percpu_ida code uses a lock
> >>>>internally too. Also, what is the memory and device address space
> >>>>overhead per cpu?
> >>>
> >>>A percpu lock doesn't bounce cachelines between CPUs very much, so from
> >>>that point of view it might as well not exist :)
> >>
> >>As long as the address space can remain more than ~50% empty, it is
> >>indeed practically lockless. Are we ever worried about higher
> >>utilization? If so, in my experience percpu_ida fails miserable near
> >>or at exhaustion.
> >
> >The patch uses TASK_RUNNING for tag allocation, so it doesn't wait. I
> >thought it's ok, no?
>
> Even without the waiting it can end up sucking. If you are near
> exhaustion, multiple tasks allocating will end up stealing from each
> other.
>
> Maybe it's not a concern here, if the space is big enough?
There are 128k tags. I think we can double it without problems within
32-bit DMA address space if necessary. But if driver holds the DMA
address space, we will have space shortage. If 64-bit DMA address is on
by default in the future, this will not be a concern.
> In any case, the pathological case isn't any worse than the normal
> case for the current code...
Yep, it should be not worse than current spinlock.
Thanks,
Shaohua
next prev parent reply other threads:[~2015-11-25 18:57 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-24 21:54 [PATCH 0/4] iommu: remove lock contention in iova allocation Shaohua Li
[not found] ` <cover.1448401089.git.shli-b10kYP2dOMg@public.gmane.org>
2015-11-24 21:54 ` [PATCH 1/4] iommu: alloc_iova returns a pfn Shaohua Li
2015-11-24 21:54 ` [PATCH 2/4] iommu: add a bitmap based dma address allocator Shaohua Li
[not found] ` <4c0804c85404be81acfe81fcd402f1af484e9d5f.1448401089.git.shli-b10kYP2dOMg@public.gmane.org>
2015-11-24 21:56 ` Woodhouse, David
[not found] ` <1448402209.44976.109.camel-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2015-11-24 22:05 ` Shaohua Li
[not found] ` <20151124220511.GA2106568-tb7CFzD8y5b7E6g3fPdp/g2O0Ztt9esIQQ4Iyu8u01E@public.gmane.org>
2015-11-25 14:46 ` jroedel-l3A5Bk7waGM
[not found] ` <20151125144613.GA3763-l3A5Bk7waGM@public.gmane.org>
2015-11-25 16:40 ` Woodhouse, David
[not found] ` <1448469599.44976.134.camel-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2015-11-25 16:43 ` Jens Axboe
[not found] ` <5655E545.1010509-b10kYP2dOMg@public.gmane.org>
2015-11-25 17:33 ` Shaohua Li
[not found] ` <20151125173320.GA92074-tb7CFzD8y5b7E6g3fPdp/g2O0Ztt9esIQQ4Iyu8u01E@public.gmane.org>
2015-11-25 17:38 ` Jens Axboe
[not found] ` <5655F1F8.9070203-b10kYP2dOMg@public.gmane.org>
2015-11-25 18:57 ` Shaohua Li [this message]
2015-11-24 21:54 ` [PATCH 3/4] iommu: enable bitmap allocation for intel iommu Shaohua Li
2015-11-24 21:54 ` [PATCH 4/4] iommu: free_iova doesn't need lock twice Shaohua Li
2015-12-07 17:52 ` [PATCH 0/4] iommu: remove lock contention in iova allocation Shaohua Li
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=20151125185723.GA247498@devbig084.prn1.facebook.com \
--to=shli-b10kyp2domg@public.gmane.org \
--cc=Kernel-team-b10kYP2dOMg@public.gmane.org \
--cc=axboe-b10kYP2dOMg@public.gmane.org \
--cc=david.woodhouse-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=jroedel-l3A5Bk7waGM@public.gmane.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