From: "Roedel, Joerg" <Joerg.Roedel@amd.com>
To: Ohad Ben-Cohen <ohad@wizery.com>
Cc: "iommu@lists.linux-foundation.org"
<iommu@lists.linux-foundation.org>,
"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>,
Hiroshi DOYU <Hiroshi.DOYU@nokia.com>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
David Woodhouse <dwmw2@infradead.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
David Brown <davidb@codeaurora.org>,
Arnd Bergmann <arnd@arndb.de>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Stepan Moskovchenko <stepanm@codeaurora.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: Re: [PATCH v3 1/6] iommu/core: split mapping to page sizes as supported by the hardware
Date: Tue, 27 Sep 2011 20:14:38 +0200 [thread overview]
Message-ID: <20110927181438.GM2138@amd.com> (raw)
In-Reply-To: <CAK=WgbYG2tpMJ2SikZhm=R9j5kQ6Hm8CGg=q1bko3idzF53Q3Q@mail.gmail.com>
On Tue, Sep 27, 2011 at 09:28:37AM -0400, Ohad Ben-Cohen wrote:
> So you're suggesting to re-implement find_next_bit() using ffs()/fls()
> and shifting ?
No. I suggest a simpler and shorter algorithm using the bit helpers.
Something like that:
min_idx = __ffs(iommu_page_sizes);
while (size) {
/* Max alignment allowed by current physical address */
phys_idx = __ffs(phys);
/* Max alignment allowed by current size */
size_idx = __fls(size);
/* special case: iova == 0 */
if (likely(phys))
idx = min(phys_idx, size_idx);
else
idx = size_idx;
BUG_ON(idx < min_idx);
psize = 1UL << idx;
/* search next smaller page-size supported */
while (psize && !(iommu_page_sizes & psize))
psize >>= 1;
BUG_ON(psize == 0);
iommu_ops->map(domain, iova, phys, get_order(psize), prot);
iova += psize;
phys += psize;
size -= psize;
}
It is only C-style pseudo-code, of course. These __ffs and __fls lines
all translate to a single instruction later. The find_next_bit()
function has a lot more overhead because it needs to take account of
real bitmaps (arrays of ulong). But this complexity is not required
here.
And yes, overhead is important when we implement the generic dma-ops
on-top of the iommu-api because this will make the iommu_map function a
fast-path. So we really care about overhead here.
Joerg
--
AMD Operating System Research Center
Advanced Micro Devices GmbH Einsteinring 24 85609 Dornach
General Managers: Alberto Bozzo, Andrew Bowd
Registration: Dornach, Landkr. Muenchen; Registerger. Muenchen, HRB Nr. 43632
next prev parent reply other threads:[~2011-09-27 18:17 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-16 17:51 [PATCH v3 0/6] iommu: split mapping to page sizes as supported by the hardware Ohad Ben-Cohen
2011-09-16 17:51 ` [PATCH v3 1/6] iommu/core: " Ohad Ben-Cohen
2011-09-27 10:05 ` Roedel, Joerg
2011-09-27 12:26 ` Ohad Ben-Cohen
2011-09-27 13:12 ` Roedel, Joerg
2011-09-27 13:28 ` Ohad Ben-Cohen
2011-09-27 18:14 ` Roedel, Joerg [this message]
2011-10-02 15:58 ` Ohad Ben-Cohen
2011-10-10 7:40 ` Ohad Ben-Cohen
2011-10-10 9:47 ` Roedel, Joerg
2011-10-10 13:59 ` Ohad Ben-Cohen
2011-10-10 15:36 ` Roedel, Joerg
2011-10-10 17:02 ` Ohad Ben-Cohen
2011-10-10 22:01 ` Ohad Ben-Cohen
2011-10-11 10:21 ` Roedel, Joerg
2011-10-11 10:19 ` Roedel, Joerg
2011-10-10 22:49 ` Ohad Ben-Cohen
2011-10-11 10:38 ` Roedel, Joerg
2011-10-11 17:01 ` Ohad Ben-Cohen
2011-10-14 13:35 ` Roedel, Joerg
2011-10-14 17:03 ` Ohad Ben-Cohen
2011-10-14 17:05 ` Ohad Ben-Cohen
2011-10-17 8:05 ` Ohad Ben-Cohen
2011-10-17 9:28 ` Roedel, Joerg
2011-10-17 9:55 ` Ohad Ben-Cohen
2011-10-11 14:59 ` KyongHo Cho
2011-10-11 17:04 ` Ohad Ben-Cohen
2011-10-10 12:52 ` KyongHo Cho
2011-10-10 14:00 ` Ohad Ben-Cohen
2011-09-16 17:51 ` [PATCH v3 2/6] iommu/omap: announce supported page sizes Ohad Ben-Cohen
2011-09-16 17:51 ` [PATCH v3 3/6] iommu/msm: " Ohad Ben-Cohen
2011-09-25 5:03 ` David Brown
2011-09-16 17:51 ` [PATCH v3 4/6] iommu/amd: " Ohad Ben-Cohen
2011-09-16 17:51 ` [PATCH v3 5/6] iommu/intel: " Ohad Ben-Cohen
2011-09-16 17:51 ` [PATCH v3 6/6] iommu/core: remove the temporary register_iommu_pgsize API Ohad Ben-Cohen
2011-09-27 8:56 ` [PATCH v3 0/6] iommu: split mapping to page sizes as supported by the hardware Ohad Ben-Cohen
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=20110927181438.GM2138@amd.com \
--to=joerg.roedel@amd.com \
--cc=Hiroshi.DOYU@nokia.com \
--cc=arnd@arndb.de \
--cc=davidb@codeaurora.org \
--cc=dwmw2@infradead.org \
--cc=iommu@lists.linux-foundation.org \
--cc=kvm@vger.kernel.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=ohad@wizery.com \
--cc=stepanm@codeaurora.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