Skip to contentSkip to conversation

mm: consolidate pte_index() and pte_offset_*() definitions

PATCH Guenter Roeck 2 participants 2 messages Jun 10, 2020

lore
Share & tools
lore
#0 lore raw
Quoted 35 lines · Mike Rapoport

All architectures define pte_index() as

	(address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)

and all architectures define pte_offset_kernel() as an entry in the array of PTEs indexed by the pte_index().

For the most architectures the pte_offset_kernel() implementation relies on the availability of pmd_page_vaddr() that converts a PMD entry value to the virtual address of the page containing PTEs array.

Let's move x86 definitions of the PTE accessors to the generic place in <linux/pgtable.h> and then simply drop the respective definitions from the other architectures.

The architectures that didn't provide pmd_page_vaddr() are updated to have that defined.

The generic implementation of pte_offset_kernel() can be overridden by an architecture and alpha makes use of this because it has special ordering requirements for its version of pte_offset_kernel().

[ ... ]

Quoted 3 lines

---

Building sparc32:defconfig ... failed
--------------
Error log:
<stdin>:1511:2: warning: #warning syscall clone3 not implemented [-Wcpp] In file included from include/linux/mm.h:32,

                 from include/linux/memblock.h:13,
                 from arch/sparc/mm/srmmu.c:14:
include/linux/pgtable.h:74:27: error: redefinition of 'pte_offset_kernel'
   74 | #define pte_offset_kernel pte_offset_kernel
      |                           ^~~~~~~~~~~~~~~~~
arch/sparc/mm/srmmu.c:144:8: note: in expansion of macro 'pte_offset_kernel'
  144 | pte_t *pte_offset_kernel(pmd_t *dir, unsigned long address)
      |        ^~~~~~~~~~~~~~~~~
include/linux/pgtable.h:70:22: note: previous definition of 'pte_offset_kernel' was here
   70 | static inline pte_t *pte_offset_kernel(pmd_t *pmd, unsigned long address)
      |                      ^~~~~~~~~~~~~~~~~

Bisct log attached.

Guenter

---
# bad: [5b14671be58d0084e7e2d1cc9c2c36a94467f6e0] Merge tag 'fuse-update-5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse
# good: [abfbb29297c27e3f101f348dc9e467b0fe70f919] Merge tag 'rproc-v5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/andersson/remoteproc
git bisect start 'HEAD' 'abfbb29297c2'
# bad: [595a56ac1b0d5f0a16a89589ef55ffd35c1967a2] Merge tag 'linux-kselftest-kunit-5.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
git bisect bad 595a56ac1b0d5f0a16a89589ef55ffd35c1967a2
# bad: [d8ed45c5dcd455fc5848d47f86883a1b872ac0d0] mmap locking API: use coccinelle to convert mmap_sem rwsem call sites
git bisect bad d8ed45c5dcd455fc5848d47f86883a1b872ac0d0
# good: [2deebe4d56d638269a4a728086d64de5734b460a] sh: add loglvl to printk_address()
git bisect good 2deebe4d56d638269a4a728086d64de5734b460a
# good: [77819daf247aad16beaeb537ae77d1d6d0697ca2] kdb: don't play with console_loglevel
git bisect good 77819daf247aad16beaeb537ae77d1d6d0697ca2
# good: [e73240be691e1b081190125da67cd38822b8d5f8] m68k/mm/motorola: move comment about page table allocation funcitons
git bisect good e73240be691e1b081190125da67cd38822b8d5f8
# bad: [974b9b2c68f3d35a65e80af9657fe378d2439b60] mm: consolidate pte_index() and pte_offset_*() definitions
git bisect bad 974b9b2c68f3d35a65e80af9657fe378d2439b60
# good: [88107d330de4f175705a3ea03147feb0d7e68499] x86/mm: simplify init_trampoline() and surrounding logic
git bisect good 88107d330de4f175705a3ea03147feb0d7e68499
# good: [e05c7b1f2bc4b7b28199b9a7572f73436d97317e] mm: pgtable: add shortcuts for accessing kernel PMD and PTE
git bisect good e05c7b1f2bc4b7b28199b9a7572f73436d97317e

# first bad commit: [974b9b2c68f3d35a65e80af9657fe378d2439b60] mm: consolidate pte_index() and pte_offset_*() definitions
#1 lore raw

Hi Guenter,

Quoted 6 lines · On Wed, 10 Jun 2020 13:42:12 -0700 Guenter Roeck <[email protected]> wrote:

Building sparc32:defconfig ... failed
--------------
Error log:
<stdin>:1511:2: warning: #warning syscall clone3 not implemented [-Wcpp] In file included from include/linux/mm.h:32,

Quoted 11 lines
                 from include/linux/memblock.h:13,
                 from arch/sparc/mm/srmmu.c:14:
include/linux/pgtable.h:74:27: error: redefinition of 'pte_offset_kernel'
   74 | #define pte_offset_kernel pte_offset_kernel
      |                           ^~~~~~~~~~~~~~~~~
arch/sparc/mm/srmmu.c:144:8: note: in expansion of macro 'pte_offset_kernel'
  144 | pte_t *pte_offset_kernel(pmd_t *dir, unsigned long address)
      |        ^~~~~~~~~~~~~~~~~
include/linux/pgtable.h:70:22: note: previous definition of 'pte_offset_kernel' was here
   70 | static inline pte_t *pte_offset_kernel(pmd_t *pmd, unsigned long address)
      |                      ^~~~~~~~~~~~~~~~~

This was reported on Tuesday (by me among others) and is fixed in Linus' tree now.

Signature · 2 lines
Cheers,
Stephen Rothwell