Commit c97078bd authored by Arjun Roy's avatar Arjun Roy Committed by Linus Torvalds

mm: define pte_index as macro for x86

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.

v3 of this patch fixes a compilation warning for an unused method.
v2 of this patch moved a macro definition to a more readable location.
Signed-off-by: default avatarArjun Roy <arjunroy@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Cc: David Miller <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Soheil Hassas Yeganeh <soheil@google.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Link: http://lkml.kernel.org/r/20200228054714.204424-1-arjunroy.kdev@gmail.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 251a0ffe
...@@ -860,7 +860,10 @@ static inline unsigned long pmd_index(unsigned long address) ...@@ -860,7 +860,10 @@ static inline unsigned long pmd_index(unsigned long address)
* *
* this function returns the index of the entry in the pte page which would * this function returns the index of the entry in the pte page which would
* control the given virtual address * control the given virtual address
*
* Also define macro so we can test if pte_index is defined for arch.
*/ */
#define pte_index pte_index
static inline unsigned long pte_index(unsigned long address) static inline unsigned long pte_index(unsigned long address)
{ {
return (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1); return (address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment