Re: [PATCH v3 04/21] arm64: decouple early fixmap init from linear mapping
From: Mark Rutland
Date: Mon Jan 11 2016 - 12:21:36 EST
On Mon, Jan 11, 2016 at 06:15:56PM +0100, Ard Biesheuvel wrote:
> On 11 January 2016 at 18:08, Ard Biesheuvel <ard.biesheuvel@xxxxxxxxxx> wrote:
> > On 11 January 2016 at 17:51, Mark Rutland <mark.rutland@xxxxxxx> wrote:
> >> Sorry, I'm gonig to change my mind on that again. I think using
> >> p?d_offset_kimg is preferable. e.g.
> >>
> >> static inline pud_t * fixmap_pud(unsigned long addr)
> >> {
> >> pgd_t *pgd = pgd_offset_k(addr);
> >>
> >> BUG_ON(pgd_none(*pgd) || pgd_bad(*pgd));
> >>
> >> return pud_offset_kimg(pgd, addr);
> >> }
> >>
> >> static inline pmd_t * fixmap_pmd(unsigned long addr)
> >> {
> >> pud_t *pud = fixmap_pud(addr);
> >>
> >> BUG_ON(pud_none(*pud) || pud_bad(*pud));
> >>
> >> return pmd_offset_kimg(pud, addr);
> >> }
> >>
> >> That avoids having to check CONFIG_PGTABLE_LEVELS check and perform a cast,
> >> avoids duplicating details about bm_{pud,pmd}, and keeps the existing structure
> >> so it's easier to reason about the change. I was wrong about having to pass the
> >> pgd or pud in, so callers don't need upating.
> >>
> >> From my PoV that is preferable.
> >>
> >
> > OK. I think it looks better, indeed.
>
> ... however, this does mean we have to go through a __pa() translation
> and back just to get to the address of bm_pud/bm_pmd
True, but we only do it in the case of a one-off init function, so I
don't think we'll notice the overhead.
Mark.