* [PATCH] define vmemmap before pfn_to_page calls
@ 2019-12-17 13:15 David Abdurachmanov
2019-12-18 3:46 ` Anup Patel
2019-12-18 8:30 ` Andreas Schwab
0 siblings, 2 replies; 4+ messages in thread
From: David Abdurachmanov @ 2019-12-17 13:15 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Anup Patel,
Greentime Hu, Mike Rapoport, David Abdurachmanov, Yash Shah,
Alexandre Ghiti, Logan Gunthorpe, Thomas Gleixner, linux-riscv,
linux-kernel
Cc: david.abdurachmanov
pfn_to_page call depends on `vmemmap` being available before the call.
This caused compilation errors in Fedora/RISCV with 5.5-rc2 and was caused
by NOMMU changes which moved declarations after functions definitions.
Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
Fixes: 6bd33e1ece52 ("riscv: add nommu support")
---
arch/riscv/include/asm/pgtable.h | 34 ++++++++++++++++----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
index 7ff0ed4f292e..d8c89e6e6b3d 100644
--- a/arch/riscv/include/asm/pgtable.h
+++ b/arch/riscv/include/asm/pgtable.h
@@ -90,6 +90,23 @@ extern pgd_t swapper_pg_dir[];
#define __S110 PAGE_SHARED_EXEC
#define __S111 PAGE_SHARED_EXEC
+#define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1)
+#define VMALLOC_END (PAGE_OFFSET - 1)
+#define VMALLOC_START (PAGE_OFFSET - VMALLOC_SIZE)
+
+/*
+ * Roughly size the vmemmap space to be large enough to fit enough
+ * struct pages to map half the virtual address space. Then
+ * position vmemmap directly below the VMALLOC region.
+ */
+#define VMEMMAP_SHIFT \
+ (CONFIG_VA_BITS - PAGE_SHIFT - 1 + STRUCT_PAGE_MAX_SHIFT)
+#define VMEMMAP_SIZE BIT(VMEMMAP_SHIFT)
+#define VMEMMAP_END (VMALLOC_START - 1)
+#define VMEMMAP_START (VMALLOC_START - VMEMMAP_SIZE)
+
+#define vmemmap ((struct page *)VMEMMAP_START)
+
static inline int pmd_present(pmd_t pmd)
{
return (pmd_val(pmd) & (_PAGE_PRESENT | _PAGE_PROT_NONE));
@@ -400,23 +417,6 @@ static inline int ptep_clear_flush_young(struct vm_area_struct *vma,
#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
-#define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1)
-#define VMALLOC_END (PAGE_OFFSET - 1)
-#define VMALLOC_START (PAGE_OFFSET - VMALLOC_SIZE)
-
-/*
- * Roughly size the vmemmap space to be large enough to fit enough
- * struct pages to map half the virtual address space. Then
- * position vmemmap directly below the VMALLOC region.
- */
-#define VMEMMAP_SHIFT \
- (CONFIG_VA_BITS - PAGE_SHIFT - 1 + STRUCT_PAGE_MAX_SHIFT)
-#define VMEMMAP_SIZE BIT(VMEMMAP_SHIFT)
-#define VMEMMAP_END (VMALLOC_START - 1)
-#define VMEMMAP_START (VMALLOC_START - VMEMMAP_SIZE)
-
-#define vmemmap ((struct page *)VMEMMAP_START)
-
#define PCI_IO_SIZE SZ_16M
#define PCI_IO_END VMEMMAP_START
#define PCI_IO_START (PCI_IO_END - PCI_IO_SIZE)
--
2.23.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] define vmemmap before pfn_to_page calls
2019-12-17 13:15 [PATCH] define vmemmap before pfn_to_page calls David Abdurachmanov
@ 2019-12-18 3:46 ` Anup Patel
2019-12-18 5:08 ` David Abdurachmanov
2019-12-18 8:30 ` Andreas Schwab
1 sibling, 1 reply; 4+ messages in thread
From: Anup Patel @ 2019-12-18 3:46 UTC (permalink / raw)
To: David Abdurachmanov
Cc: Albert Ou, Alexandre Ghiti, David Abdurachmanov,
linux-kernel@vger.kernel.org List, Mike Rapoport, Yash Shah,
Palmer Dabbelt, Paul Walmsley, Greentime Hu, Thomas Gleixner,
Logan Gunthorpe, linux-riscv
On Tue, Dec 17, 2019 at 6:45 PM David Abdurachmanov
<david.abdurachmanov@gmail.com> wrote:
>
> pfn_to_page call depends on `vmemmap` being available before the call.
> This caused compilation errors in Fedora/RISCV with 5.5-rc2 and was caused
> by NOMMU changes which moved declarations after functions definitions.
>
> Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
> Fixes: 6bd33e1ece52 ("riscv: add nommu support")
> ---
> arch/riscv/include/asm/pgtable.h | 34 ++++++++++++++++----------------
> 1 file changed, 17 insertions(+), 17 deletions(-)
>
> diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
> index 7ff0ed4f292e..d8c89e6e6b3d 100644
> --- a/arch/riscv/include/asm/pgtable.h
> +++ b/arch/riscv/include/asm/pgtable.h
> @@ -90,6 +90,23 @@ extern pgd_t swapper_pg_dir[];
> #define __S110 PAGE_SHARED_EXEC
> #define __S111 PAGE_SHARED_EXEC
>
> +#define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1)
> +#define VMALLOC_END (PAGE_OFFSET - 1)
> +#define VMALLOC_START (PAGE_OFFSET - VMALLOC_SIZE)
> +
> +/*
> + * Roughly size the vmemmap space to be large enough to fit enough
> + * struct pages to map half the virtual address space. Then
> + * position vmemmap directly below the VMALLOC region.
> + */
> +#define VMEMMAP_SHIFT \
> + (CONFIG_VA_BITS - PAGE_SHIFT - 1 + STRUCT_PAGE_MAX_SHIFT)
> +#define VMEMMAP_SIZE BIT(VMEMMAP_SHIFT)
> +#define VMEMMAP_END (VMALLOC_START - 1)
> +#define VMEMMAP_START (VMALLOC_START - VMEMMAP_SIZE)
> +
> +#define vmemmap ((struct page *)VMEMMAP_START)
> +
> static inline int pmd_present(pmd_t pmd)
> {
> return (pmd_val(pmd) & (_PAGE_PRESENT | _PAGE_PROT_NONE));
> @@ -400,23 +417,6 @@ static inline int ptep_clear_flush_young(struct vm_area_struct *vma,
> #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
> #define __swp_entry_to_pte(x) ((pte_t) { (x).val })
>
> -#define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1)
> -#define VMALLOC_END (PAGE_OFFSET - 1)
> -#define VMALLOC_START (PAGE_OFFSET - VMALLOC_SIZE)
> -
> -/*
> - * Roughly size the vmemmap space to be large enough to fit enough
> - * struct pages to map half the virtual address space. Then
> - * position vmemmap directly below the VMALLOC region.
> - */
> -#define VMEMMAP_SHIFT \
> - (CONFIG_VA_BITS - PAGE_SHIFT - 1 + STRUCT_PAGE_MAX_SHIFT)
> -#define VMEMMAP_SIZE BIT(VMEMMAP_SHIFT)
> -#define VMEMMAP_END (VMALLOC_START - 1)
> -#define VMEMMAP_START (VMALLOC_START - VMEMMAP_SIZE)
> -
> -#define vmemmap ((struct page *)VMEMMAP_START)
> -
> #define PCI_IO_SIZE SZ_16M
> #define PCI_IO_END VMEMMAP_START
> #define PCI_IO_START (PCI_IO_END - PCI_IO_SIZE)
> --
> 2.23.0
>
Can you add a comment for "#define vmemmap" about your findings ?
Otherwise looks good to me.
Reviewed-by: Anup Patel <anup@brainfault.org>
Regards,
Anup
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] define vmemmap before pfn_to_page calls
2019-12-18 3:46 ` Anup Patel
@ 2019-12-18 5:08 ` David Abdurachmanov
0 siblings, 0 replies; 4+ messages in thread
From: David Abdurachmanov @ 2019-12-18 5:08 UTC (permalink / raw)
To: Anup Patel
Cc: Albert Ou, Alexandre Ghiti, David Abdurachmanov,
linux-kernel@vger.kernel.org List, Mike Rapoport, Yash Shah,
Palmer Dabbelt, Paul Walmsley, Greentime Hu, Thomas Gleixner,
Logan Gunthorpe, linux-riscv
On Wed, Dec 18, 2019 at 5:46 AM Anup Patel <anup@brainfault.org> wrote:
>
> On Tue, Dec 17, 2019 at 6:45 PM David Abdurachmanov
> <david.abdurachmanov@gmail.com> wrote:
> >
> > pfn_to_page call depends on `vmemmap` being available before the call.
> > This caused compilation errors in Fedora/RISCV with 5.5-rc2 and was caused
> > by NOMMU changes which moved declarations after functions definitions.
> >
> > Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
> > Fixes: 6bd33e1ece52 ("riscv: add nommu support")
> > ---
> > arch/riscv/include/asm/pgtable.h | 34 ++++++++++++++++----------------
> > 1 file changed, 17 insertions(+), 17 deletions(-)
> >
> > diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
> > index 7ff0ed4f292e..d8c89e6e6b3d 100644
> > --- a/arch/riscv/include/asm/pgtable.h
> > +++ b/arch/riscv/include/asm/pgtable.h
> > @@ -90,6 +90,23 @@ extern pgd_t swapper_pg_dir[];
> > #define __S110 PAGE_SHARED_EXEC
> > #define __S111 PAGE_SHARED_EXEC
> >
> > +#define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1)
> > +#define VMALLOC_END (PAGE_OFFSET - 1)
> > +#define VMALLOC_START (PAGE_OFFSET - VMALLOC_SIZE)
> > +
> > +/*
> > + * Roughly size the vmemmap space to be large enough to fit enough
> > + * struct pages to map half the virtual address space. Then
> > + * position vmemmap directly below the VMALLOC region.
> > + */
> > +#define VMEMMAP_SHIFT \
> > + (CONFIG_VA_BITS - PAGE_SHIFT - 1 + STRUCT_PAGE_MAX_SHIFT)
> > +#define VMEMMAP_SIZE BIT(VMEMMAP_SHIFT)
> > +#define VMEMMAP_END (VMALLOC_START - 1)
> > +#define VMEMMAP_START (VMALLOC_START - VMEMMAP_SIZE)
> > +
> > +#define vmemmap ((struct page *)VMEMMAP_START)
> > +
> > static inline int pmd_present(pmd_t pmd)
> > {
> > return (pmd_val(pmd) & (_PAGE_PRESENT | _PAGE_PROT_NONE));
> > @@ -400,23 +417,6 @@ static inline int ptep_clear_flush_young(struct vm_area_struct *vma,
> > #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
> > #define __swp_entry_to_pte(x) ((pte_t) { (x).val })
> >
> > -#define VMALLOC_SIZE (KERN_VIRT_SIZE >> 1)
> > -#define VMALLOC_END (PAGE_OFFSET - 1)
> > -#define VMALLOC_START (PAGE_OFFSET - VMALLOC_SIZE)
> > -
> > -/*
> > - * Roughly size the vmemmap space to be large enough to fit enough
> > - * struct pages to map half the virtual address space. Then
> > - * position vmemmap directly below the VMALLOC region.
> > - */
> > -#define VMEMMAP_SHIFT \
> > - (CONFIG_VA_BITS - PAGE_SHIFT - 1 + STRUCT_PAGE_MAX_SHIFT)
> > -#define VMEMMAP_SIZE BIT(VMEMMAP_SHIFT)
> > -#define VMEMMAP_END (VMALLOC_START - 1)
> > -#define VMEMMAP_START (VMALLOC_START - VMEMMAP_SIZE)
> > -
> > -#define vmemmap ((struct page *)VMEMMAP_START)
> > -
> > #define PCI_IO_SIZE SZ_16M
> > #define PCI_IO_END VMEMMAP_START
> > #define PCI_IO_START (PCI_IO_END - PCI_IO_SIZE)
> > --
> > 2.23.0
> >
>
> Can you add a comment for "#define vmemmap" about your findings ?
I send v2 in a few hours with extra comment. I will mention that this
is needed if CONFIG_SPARSEMEM_VMEMMAP=y
See https://github.com/torvalds/linux/blob/master/include/asm-generic/memory_model.h
>
> Otherwise looks good to me.
>
> Reviewed-by: Anup Patel <anup@brainfault.org>
>
> Regards,
> Anup
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] define vmemmap before pfn_to_page calls
2019-12-17 13:15 [PATCH] define vmemmap before pfn_to_page calls David Abdurachmanov
2019-12-18 3:46 ` Anup Patel
@ 2019-12-18 8:30 ` Andreas Schwab
1 sibling, 0 replies; 4+ messages in thread
From: Andreas Schwab @ 2019-12-18 8:30 UTC (permalink / raw)
To: David Abdurachmanov
Cc: Albert Ou, Alexandre Ghiti, David Abdurachmanov, Anup Patel,
linux-kernel, Mike Rapoport, Yash Shah, Palmer Dabbelt,
Paul Walmsley, Greentime Hu, Thomas Gleixner, Logan Gunthorpe,
linux-riscv
On Dez 17 2019, David Abdurachmanov wrote:
> pfn_to_page call depends on `vmemmap` being available before the call.
Only if CONFIG_SPARSEMEM_VMEMMAP, as it seems.
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-12-18 8:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-17 13:15 [PATCH] define vmemmap before pfn_to_page calls David Abdurachmanov
2019-12-18 3:46 ` Anup Patel
2019-12-18 5:08 ` David Abdurachmanov
2019-12-18 8:30 ` Andreas Schwab
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).