Re: [PATCH 0/3] eldie generated code for folded p4d/pud
On Thu, Oct 10, 2019 at 01:05:56PM -0700, Vineet Gupta wrote: > > Hi Kirill, > > On 10/10/19 1:56 AM, Kirill A. Shutemov wrote: > > On Wed, Oct 09, 2019 at 10:26:55PM +, Vineet Gupta wrote: > >> > >> This series elides extraneous generate code for folded p4d/pud. > >> This came up when trying to remove __ARCH_USE_5LEVEL_HACK from ARC port. > >> The code saving are not a while lot, but still worthwhile IMHO. > > > > Agreed. > > Thx. > > So given we are folding pmd too, it seemed we could do the following as well. > > +#ifndef __PAGETABLE_PMD_FOLDED > void pmd_clear_bad(pmd_t *); > +#else > +#define pmd_clear_bad(pmd)do { } while (0) > +#endif > > +#ifndef __PAGETABLE_PMD_FOLDED > void pmd_clear_bad(pmd_t *pmd) > { > pmd_ERROR(*pmd); > pmd_clear(pmd); > } > +#endif > > I stared at generated code and it seems a bit wrong. > free_pgd_range() -> pgd_none_or_clear_bad() is no longer checking for > unmapped pgd > entries as pgd_none/pgd_bad are all stubs returning 0. > > This whole pmd folding is a bit confusing considering I only revisit it every > few > years :-) Abstraction wise, __PAGETABLE_PMD_FOLDED only has pgd, pte but even > in > this regime bunch of pmd macros are still valid > > pmd_set(pmdp, ptep) { > *pmdp.pud.p4d.pgd = (unsigned long)ptep > } > > Is there a better way to make a mental model of this code folding. I don't have any. PMD folding predates me and have never looked at it closely. Quick look brings more confusion than clarity. :P > In an ideal world pmd folded would have meant pmd_* routines just vanish - > poof. > So in that sense I like your implementation under #[45]LEVEL_HACK where the > level > simply vanishes by code like #define p4d_t pgd_t. Perhaps there is lot of > historic > baggage, proliferated into arch code so hard to untangle. In ideal world all these pgd/p4d/pud/pmd/pte should die and we have something more flexible to begin with. I played with this before: https://lore.kernel.org/lkml/20180424154355.mfjgkf47kdp2b...@black.fi.intel.com/ -- Kirill A. Shutemov ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc
[RFC] asm-generic/tlb: stub out pmd_free_tlb() if __PAGETABLE_PMD_FOLDED
This is inine with similar patches for nopud [1] and nop4d [2] cases. However I'm not really sure I understand clearly how the nopmd code is supposed to work (for a 2 tier paging system) - hence the RFC. Consider free_pmd_range() simplified/annotated below free_pmd_range ... pmd = pmd_offset(pud, addr); do { next = pmd_addr_end(addr, end); if (pmd_none_or_clear_bad(pmd)) => *pmd_bad()/pmd_clear_bad() [a]* continue; free_pte_range(tlb, pmd, addr); } while (pmd++, addr = next, addr != end); ... *pmd_free_tlb(tlb, pmd, start); => [b]* For ARC/nopmd case [a] is actually checking pgd and consequently pmd_clear_bad() can't be stubbed out for PMD_FOLDED case. However it seems case [b] can be stubbed out (hence this patch) along same lines as [1] and [2] | bloat-o-meter2 vmlinux-E-elide-p?d_clear_bad vmlinux-F-elide-pmd_free_tlb | add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-112 (-112) | function old new delta | free_pgd_range 422 310-112 | Total: Before=4137002, After=4136890, chg -1.00% [1] http://lists.infradead.org/pipermail/linux-snps-arc/2019-October/006266.html [2] http://lists.infradead.org/pipermail/linux-snps-arc/2019-October/006265.html Signed-off-by: Vineet Gupta --- include/asm-generic/tlb.h | 4 1 file changed, 4 insertions(+) diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h index f3dad87f4ecc..a1edad7d4170 100644 --- a/include/asm-generic/tlb.h +++ b/include/asm-generic/tlb.h @@ -574,6 +574,7 @@ static inline void tlb_end_vma(struct mmu_gather *tlb, struct vm_area_struct *vm } while (0) #endif +#ifndef __PAGETABLE_PMD_FOLDED #ifndef pmd_free_tlb #define pmd_free_tlb(tlb, pmdp, address) \ do {\ @@ -583,6 +584,9 @@ static inline void tlb_end_vma(struct mmu_gather *tlb, struct vm_area_struct *vm __pmd_free_tlb(tlb, pmdp, address); \ } while (0) #endif +#else +#define pmd_free_tlb(tlb, pmdp, address)do { } while (0) +#endif #ifndef __PAGETABLE_PUD_FOLDED #ifndef pud_free_tlb -- 2.20.1 ___ linux-snps-arc mailing list linux-snps-arc@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-snps-arc