Re: mmotm 2021-05-12-21-46 uploaded (arch/x86/mm/pgtable.c)

From: Andrew Morton
Date: Thu May 13 2021 - 16:48:00 EST


On Thu, 13 May 2021 19:09:23 +0200 Christophe Leroy <christophe.leroy@xxxxxxxxxx> wrote:

>
>
> > on i386:
> >
> > ../arch/x86/mm/pgtable.c:703:5: error: redefinition of ‘pud_set_huge’
> > int pud_set_huge(pud_t *pud, phys_addr_t addr, pgprot_t prot)
> > ^~~~~~~~~~~~
> > In file included from ../include/linux/mm.h:33:0,
> > from ../arch/x86/mm/pgtable.c:2:
> > ../include/linux/pgtable.h:1387:19: note: previous definition of ‘pud_set_huge’ was here
> > static inline int pud_set_huge(pud_t *pud, phys_addr_t addr, pgprot_t prot)
> > ^~~~~~~~~~~~
> > ../arch/x86/mm/pgtable.c:758:5: error: redefinition of ‘pud_clear_huge’
> > int pud_clear_huge(pud_t *pud)
> > ^~~~~~~~~~~~~~
> > In file included from ../include/linux/mm.h:33:0,
> > from ../arch/x86/mm/pgtable.c:2:
> > ../include/linux/pgtable.h:1391:19: note: previous definition of ‘pud_clear_huge’ was here
> > static inline int pud_clear_huge(pud_t *pud)
> > ^~~~~~~~~~~~~~
>
> Hum ...
>
> Comes from my patch
> https://patchwork.ozlabs.org/project/linuxppc-dev/patch/5ac5976419350e8e048d463a64cae449eb3ba4b0.1620795204.git.christophe.leroy@xxxxxxxxxx/
>
> But, that happens only if x86 defines __PAGETABLE_PUD_FOLDED. And if PUD is folded, then I can't
> understand my it has pud_set_huge() and pud_clear_huge() functions.

Probably because someone messed something up ;)

Let's try this.

--- a/arch/x86/mm/pgtable.c~mm-pgtable-add-stubs-for-pmd-pub_set-clear_huge-fix
+++ a/arch/x86/mm/pgtable.c
@@ -682,6 +682,7 @@ int p4d_clear_huge(p4d_t *p4d)
}
#endif

+#ifndef __PAGETABLE_PUD_FOLDED
/**
* pud_set_huge - setup kernel PUD mapping
*
@@ -721,6 +722,22 @@ int pud_set_huge(pud_t *pud, phys_addr_t
}

/**
+ * pud_clear_huge - clear kernel PUD mapping when it is set
+ *
+ * Returns 1 on success and 0 on failure (no PUD map is found).
+ */
+int pud_clear_huge(pud_t *pud)
+{
+ if (pud_large(*pud)) {
+ pud_clear(pud);
+ return 1;
+ }
+
+ return 0;
+}
+#endif
+
+/**
* pmd_set_huge - setup kernel PMD mapping
*
* See text over pud_set_huge() above.
@@ -751,21 +768,6 @@ int pmd_set_huge(pmd_t *pmd, phys_addr_t
}

/**
- * pud_clear_huge - clear kernel PUD mapping when it is set
- *
- * Returns 1 on success and 0 on failure (no PUD map is found).
- */
-int pud_clear_huge(pud_t *pud)
-{
- if (pud_large(*pud)) {
- pud_clear(pud);
- return 1;
- }
-
- return 0;
-}
-
-/**
* pmd_clear_huge - clear kernel PMD mapping when it is set
*
* Returns 1 on success and 0 on failure (no PMD map is found).
_