diff mbox series

[mm,1/2] mm: Define pte_index as macro for x86

Message ID 20200228004657.79943-1-arjunroy.kdev@gmail.com (mailing list archive)
State New, archived
Headers show
Series [mm,1/2] mm: Define pte_index as macro for x86 | expand

Commit Message

Arjun Roy Feb. 28, 2020, 12:46 a.m. UTC
From: Arjun Roy <arjunroy@google.com>

pte_index() is either defined as a macro (e.g. sparc64) or as an
inlined function (e.g. x86). vm_insert_pages() depends on pte_index
but it is not defined on all platforms (e.g. m68k).

To fix compilation of vm_insert_pages() on architectures not providing
pte_index(), we perform the following fix:

0. For platforms where it is meaningful, and defined as a macro, no
   change is needed.
1. For platforms where it is meaningful and defined as an inlined
   function, and we want to use it with vm_insert_pages(), we define
   a degenerate macro of the form:  #define pte_index pte_index
2. vm_insert_pages() checks for the existence of a pte_index macro
   definition. If found, it implements a batched insert. If not found,
   it devolves to calling vm_insert_page() in a loop.

This patch implements step 1 for x86.

Signed-off-by: Arjun Roy <arjunroy@google.com>

---
 arch/x86/include/asm/pgtable.h | 3 +++
 1 file changed, 3 insertions(+)

Comments

Stephen Rothwell Feb. 28, 2020, 12:57 a.m. UTC | #1
Hi Arjun,

On Thu, 27 Feb 2020 16:46:56 -0800 Arjun Roy <arjunroy.kdev@gmail.com> wrote:
>
> diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
> index 7e118660bbd9..6658c04bce83 100644
> --- a/arch/x86/include/asm/pgtable.h
> +++ b/arch/x86/include/asm/pgtable.h
> @@ -823,6 +823,9 @@ static inline unsigned long pmd_index(unsigned long address)
>   */
>  #define mk_pte(page, pgprot)   pfn_pte(page_to_pfn(page), (pgprot))
>  
> +/* Degenerative definition so we can test if pte_index is defined for arch. */
> +#define pte_index pte_index

You should put this definition directly above the static inline function.

i.e.

#define pte_index pte_index
static inline unsigned long pte_index(unsigned long address)
	...
Arjun Roy Feb. 28, 2020, 3:04 a.m. UTC | #2
On Thu, Feb 27, 2020 at 4:57 PM Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>
> Hi Arjun,
>
> On Thu, 27 Feb 2020 16:46:56 -0800 Arjun Roy <arjunroy.kdev@gmail.com> wrote:
> >
> > diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
> > index 7e118660bbd9..6658c04bce83 100644
> > --- a/arch/x86/include/asm/pgtable.h
> > +++ b/arch/x86/include/asm/pgtable.h
> > @@ -823,6 +823,9 @@ static inline unsigned long pmd_index(unsigned long address)
> >   */
> >  #define mk_pte(page, pgprot)   pfn_pte(page_to_pfn(page), (pgprot))
> >
> > +/* Degenerative definition so we can test if pte_index is defined for arch. */
> > +#define pte_index pte_index
>
> You should put this definition directly above the static inline function.
>
> i.e.
>
> #define pte_index pte_index
> static inline unsigned long pte_index(unsigned long address)
>         ...
>
Done.

-Arjun

> --
> Cheers,
> Stephen Rothwell
diff mbox series

Patch

diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index 7e118660bbd9..6658c04bce83 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -823,6 +823,9 @@  static inline unsigned long pmd_index(unsigned long address)
  */
 #define mk_pte(page, pgprot)   pfn_pte(page_to_pfn(page), (pgprot))
 
+/* Degenerative definition so we can test if pte_index is defined for arch. */
+#define pte_index pte_index
+
 /*
  * the pte page can be thought of an array like this: pte_t[PTRS_PER_PTE]
  *