[RESEND PATCH V3 2/2] riscv: add RISC-V Svpbmt extension supports

Christoph Hellwig hch at lst.de
Mon Nov 1 23:04:24 PDT 2021


On Mon, Oct 25, 2021 at 10:49:11PM +0800, Wei Fu wrote:
> > > +                                             >> _PAGE_PFN_SHIFT);
> >
> > >  static inline unsigned long _pmd_pfn(pmd_t pmd)
> > >  {
> > > -     return pmd_val(pmd) >> _PAGE_PFN_SHIFT;
> > > +     return (pmd_val(pmd) & _PAGE_CHG_MASK) >> _PAGE_PFN_SHIFT;
> > >  }
> >
> > The "(pud_val(pud) & _PAGE_CHG_MASK) >> _PAGE_PFN_SHIFT" expression begs
> > for readable and well-documented helper.
> 
> How about these:
> #define _chg_of_pmd(pmd)  (pmd_val(pmd) & _PAGE_CHG_MASK)
> #define _chg_of_pud(pud)  (pud_val(pud) & _PAGE_CHG_MASK)

I'd use inline functions instead of macros if possible, but otherwise
yes.

> How about :
> 
> extern unsigned long  _svpbmt_mask
> extern unsigned long _svpbmt_mt_pma
> extern unsigned long _svpbmt_mt_nc
> extern unsigned long _svpbmt_mt_io
> 
> #define _PAGE_MT_MASK              _svpbmt_mask
> #define _PAGE_MT_PMA        _svpbmt_mt_pma
> #define _PAGE_MT_NC          _svpbmt_mt_nc
> #define _PAGE_MT_IO           _svpbmt_mt_io

Looks much better.



More information about the linux-riscv mailing list