Re: Proof-of-concept: better(?) page-table manipulation API
From: Matthew Wilcox
Date: Mon May 07 2018 - 08:23:55 EST
On Mon, May 07, 2018 at 02:31:25PM +0300, Kirill A. Shutemov wrote:
> > Also, what does lvl == 0 mean? Is it the top or the bottom? I think a
> > comment would be helpful.
>
> It is bottom. But it should be up to architecture to decide.
That's not true because ...
> > > +static inline void ptp_walk(ptp_t *ptp, unsigned long addr)
> > > +{
> > > + ptp->ptr = (unsigned long *)ptp_page_vaddr(ptp);
> > > + ptp->ptr += __pt_index(addr, --ptp->lvl);
> > > +}
> >
> > Can you add a comment that says what this function does?
>
> Okay, I will.
>
> > Why does it not change the level?
>
> It does. --ptp->lvl.
... you've hardcoded that walking down decrements the level by 1.
I don't see that as a defect; it's just part of the API that needs
documenting.