lkml.org 
[lkml]   [2021]   [Dec]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 4/9] iommu/amd: Simplify pagetable freeing
On Tue, Nov 23, 2021 at 02:10:39PM +0000, Robin Murphy wrote:
> For reasons unclear, pagetable freeing is an effectively recursive
> method implemented via an elaborate system of templated functions that
> turns out to account for 25% of the object file size. Implementing it
> using regular straightforward recursion makes the code simpler, and
> seems like a good thing to do before we work on it further. As part of
> that, also fix the types to avoid all the needless casting back and
> forth which just gets in the way.

Nice cleanup! The stack of functions came from the fact that recursion
was pretty much discouraged in the kernel. But in this case it looks
well bounded and should be fine.

> +static struct page *free_pt_lvl(u64 *pt, struct page *freelist, int lvl)
> +{
> + u64 *p;
> + int i;
> +
> + for (i = 0; i < 512; ++i) {
> + /* PTE present? */
> + if (!IOMMU_PTE_PRESENT(pt[i]))
> + continue;
> +
> + /* Large PTE? */
> + if (PM_PTE_LEVEL(pt[i]) == 0 ||
> + PM_PTE_LEVEL(pt[i]) == 7)
> + continue;
> +
> + p = IOMMU_PTE_PAGE(pt[i]);
> + if (lvl > 2)

I thinkt this function deserves a couple of comments. It took me a while
to make sense of the 'lvl > 2' comparision. I think it is right, but if
I have think again I'd appreciate a comment :)

Regards,

Joerg

\
 
 \ /
  Last update: 2021-12-06 13:41    [W:0.183 / U:0.256 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site