Skip to content
  1. Aug 19, 2023
    • Baoquan He's avatar
      openrisc: mm: convert to GENERIC_IOREMAP · 9b994429
      Baoquan He authored
      By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(),
      generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and
      iounmap() are all visible and available to arch.  Arch needs to provide
      wrapper functions to override the generic versions if there's arch
      specific handling in its ioremap_prot(), ioremap() or iounmap().  This
      change will simplify implementation by removing duplicated code with
      generic_ioremap_prot() and generic_iounmap(), and has the equivalent
      functioality as before.
      
      For openrisc, the current ioremap() and iounmap() are the same as generic
      version.  After taking GENERIC_IOREMAP way, the old ioremap() and
      iounmap() can be completely removed.
      
      Link: https://lkml.kernel.org/r/20230706154520.11257-10-bhe@redhat.com
      
      
      Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarMike Rapoport (IBM) <rppt@kernel.org>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Brian Cain <bcain@quicinc.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Niklas Schnelle <schnelle@linux.ibm.com>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vineet Gupta <vgupta@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      9b994429
    • Baoquan He's avatar
      ia64: mm: convert to GENERIC_IOREMAP · 38d110ab
      Baoquan He authored
      By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(),
      generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and
      iounmap() are all visible and available to arch.  Arch needs to provide
      wrapper functions to override the generic versions if there's arch
      specific handling in its ioremap_prot(), ioremap() or iounmap().  This
      change will simplify implementation by removing duplicated code with
      generic_ioremap_prot() and generic_iounmap(), and has the equivalent
      functioality as before.
      
      Here, add wrapper functions ioremap_prot() and iounmap() for ia64's
      special operation when ioremap() and iounmap().
      
      Link: https://lkml.kernel.org/r/20230706154520.11257-9-bhe@redhat.com
      
      
      Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarMike Rapoport (IBM) <rppt@kernel.org>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Brian Cain <bcain@quicinc.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Niklas Schnelle <schnelle@linux.ibm.com>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vineet Gupta <vgupta@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      38d110ab
    • Baoquan He's avatar
      arc: mm: convert to GENERIC_IOREMAP · 06dfae39
      Baoquan He authored
      By taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(),
      generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and
      iounmap() are all visible and available to arch.  Arch needs to provide
      wrapper functions to override the generic versions if there's arch
      specific handling in its ioremap_prot(), ioremap() or iounmap().  This
      change will simplify implementation by removing duplicated code with
      generic_ioremap_prot() and generic_iounmap(), and has the equivalent
      functioality as before.
      
      Here, add wrapper functions ioremap_prot() and iounmap() for arc's special
      operation when ioremap_prot() and iounmap().
      
      Link: https://lkml.kernel.org/r/20230706154520.11257-8-bhe@redhat.com
      
      
      Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarMike Rapoport (IBM) <rppt@kernel.org>
      Cc: Vineet Gupta <vgupta@kernel.org>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Brian Cain <bcain@quicinc.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Niklas Schnelle <schnelle@linux.ibm.com>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      06dfae39
    • Baoquan He's avatar
      mm/ioremap: add slab availability checking in ioremap_prot · a5f61648
      Baoquan He authored
      Several architectures has done checking if slab if available in
      ioremap_prot().  In fact it should be done in generic ioremap_prot() since
      on any architecutre, slab allocator must be available before
      get_vm_area_caller() and vunmap() are used.
      
      Add the checking into generic_ioremap_prot().
      
      Link: https://lkml.kernel.org/r/20230706154520.11257-7-bhe@redhat.com
      
      
      Suggested-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Reviewed-by: default avatarMike Rapoport (IBM) <rppt@kernel.org>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Brian Cain <bcain@quicinc.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Niklas Schnelle <schnelle@linux.ibm.com>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vineet Gupta <vgupta@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      a5f61648
    • Baoquan He's avatar
      mm: ioremap: allow ARCH to have its own ioremap method definition · dfdc6ba9
      Baoquan He authored
      Architectures can be converted to GENERIC_IOREMAP, to take standard
      ioremap_xxx() and iounmap() way.  But some ARCH-es could have specific
      handling for ioremap_prot(), ioremap() and iounmap(), than standard
      methods.
      
      In oder to convert these ARCH-es to take GENERIC_IOREMAP method, allow
      these architecutres to have their own ioremap_prot(), ioremap() and
      iounmap() definitions.
      
      Link: https://lkml.kernel.org/r/20230706154520.11257-6-bhe@redhat.com
      
      
      Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
      Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Reviewed-by: default avatarMike Rapoport (IBM) <rppt@kernel.org>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Brian Cain <bcain@quicinc.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Niklas Schnelle <schnelle@linux.ibm.com>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vineet Gupta <vgupta@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      dfdc6ba9
    • Christophe Leroy's avatar
      mm/ioremap: define generic_ioremap_prot() and generic_iounmap() · 7613366a
      Christophe Leroy authored
      Define a generic version of ioremap_prot() and iounmap() that
      architectures can call after they have performed the necessary alteration
      to parameters and/or necessary verifications.
      
      Link: https://lkml.kernel.org/r/20230706154520.11257-5-bhe@redhat.com
      
      
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Reviewed-by: default avatarMike Rapoport (IBM) <rppt@kernel.org>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Brian Cain <bcain@quicinc.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Niklas Schnelle <schnelle@linux.ibm.com>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vineet Gupta <vgupta@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      7613366a
    • Baoquan He's avatar
      openrisc: mm: remove unneeded early ioremap code · 53c98e35
      Baoquan He authored
      Under arch/openrisc, there isn't any place where ioremap() is called.  It
      means that there isn't early ioremap handling needed in openrisc, So the
      early ioremap handling code in ioremap() of arch/openrisc/mm/ioremap.c is
      unnecessary and can be removed.
      
      And also remove the special handling in iounmap() since no page is got
      from fixmap pool along with early ioremap code removing in ioremap().
      
      Link: https://lore.kernel.org/linux-mm/YwxfxKrTUtAuejKQ@oscomms1/
      Link: https://lkml.kernel.org/r/20230706154520.11257-4-bhe@redhat.com
      
      
      Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
      Acked-by: default avatarStafford Horne <shorne@gmail.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarMike Rapoport (IBM) <rppt@kernel.org>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Brian Cain <bcain@quicinc.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Niklas Schnelle <schnelle@linux.ibm.com>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vineet Gupta <vgupta@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      53c98e35
    • Baoquan He's avatar
      hexagon: mm: convert to GENERIC_IOREMAP · 5bd2cc56
      Baoquan He authored
      By taking GENERIC_IOREMAP method, the generic ioremap_prot() and iounmap()
      are visible and available to arch.  This change will simplify
      implementation by removing duplicated code with generic ioremap_prot() and
      iounmap(), and has the equivalent functioality.
      
      For hexagon, the current ioremap() and iounmap() are the same as generic
      version.  After taking GENERIC_IOREMAP way, the old ioremap() and
      iounmap() can be completely removed.
      
      Link: https://lkml.kernel.org/r/20230706154520.11257-3-bhe@redhat.com
      
      
      Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
      Cc: Brian Cain <bcain@quicinc.com>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Mike Rapoport (IBM) <rppt@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Niklas Schnelle <schnelle@linux.ibm.com>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vineet Gupta <vgupta@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      5bd2cc56
    • Baoquan He's avatar
      asm-generic/iomap.h: remove ARCH_HAS_IOREMAP_xx macros · 0b1f77e7
      Baoquan He authored
      Patch series "mm: ioremap: Convert architectures to take GENERIC_IOREMAP
      way", v8.
      
      Motivation and implementation:
      ==============================
      Currently, many architecutres have't taken the standard GENERIC_IOREMAP
      way to implement ioremap_prot(), iounmap(), and ioremap_xx(), but make
      these functions specifically under each arch's folder.  Those cause many
      duplicated code of ioremap() and iounmap().
      
      In this patchset, firstly introduce generic_ioremap_prot() and
      generic_iounmap() to extract the generic code for GENERIC_IOREMAP.  By
      taking GENERIC_IOREMAP method, the generic generic_ioremap_prot(),
      generic_iounmap(), and their generic wrapper ioremap_prot(), ioremap() and
      iounmap() are all visible and available to arch.  Arch needs to provide
      wrapper functions to override the generic version if there's arch specific
      handling in its corresponding ioremap_prot(), ioremap() or iounmap(). 
      With these changes, duplicated ioremap/iounmap() code uder ARCH-es are
      removed, and the equivalent functioality is kept as before.
      
      Background info:
      ================
      
      1) The converting more architectures to take GENERIC_IOREMAP way is
         suggested by Christoph in below discussion:
         https://lore.kernel.org/all/Yp7h0Jv6vpgt6xdZ@infradead.org/T/#u
      
      2) In the previous v1 to v3, it's basically further action after arm64
         has converted to GENERIC_IOREMAP way in below patchset.  It's done by
         adding hook ioremap_allowed() and iounmap_allowed() in ARCH to add ARCH
         specific handling the middle of ioremap_prot() and iounmap().
      
      [PATCH v5 0/6] arm64: Cleanup ioremap() and support ioremap_prot()
      https://lore.kernel.org/all/20220607125027.44946-1-wangkefeng.wang@huawei.com/T/#u
      
      Later, during v3 reviewing, Christophe Leroy suggested to introduce
      generic_ioremap_prot() and generic_iounmap() to generic codes, and ARCH
      can provide wrapper function ioremap_prot(), ioremap() or iounmap() if
      needed.  Christophe made a RFC patchset as below to specially demonstrate
      his idea.  This is what v4 and now v5 is doing.
      
      [RFC PATCH 0/8] mm: ioremap: Convert architectures to take GENERIC_IOREMAP way
      https://lore.kernel.org/all/cover.1665568707.git.christophe.leroy@csgroup.eu/T/#u
      
      Testing:
      ========
      In v8, I only applied this patchset onto the latest linus's tree to build
      and run on arm64 and s390.
      
      
      This patch (of 19):
      
      Let's use '#define ioremap_xx' and "#ifdef ioremap_xx" instead.
      
      To remove defined ARCH_HAS_IOREMAP_xx macros in <asm/io.h> of each ARCH,
      the ARCH's own ioremap_wc|wt|np definition need be above "#include
      <asm-generic/iomap.h>.  Otherwise the redefinition error would be seen
      during compiling.  So the relevant adjustments are made to avoid compiling
      error:
      
        loongarch:
        - doesn't include <asm-generic/iomap.h>, defining ARCH_HAS_IOREMAP_WC
          is redundant, so simply remove it.
      
        m68k:
        - selected GENERIC_IOMAP, <asm-generic/iomap.h> has been added in
          <asm-generic/io.h>, and <asm/kmap.h> is included above
          <asm-generic/iomap.h>, so simply remove ARCH_HAS_IOREMAP_WT defining.
      
        mips:
        - move "#include <asm-generic/iomap.h>" below ioremap_wc definition
          in <asm/io.h>
      
        powerpc:
        - remove "#include <asm-generic/iomap.h>" in <asm/io.h> because it's
          duplicated with the one in <asm-generic/io.h>, let's rely on the
          latter.
      
        x86:
        - selected GENERIC_IOMAP, remove #include <asm-generic/iomap.h> in
          the middle of <asm/io.h>. Let's rely on <asm-generic/io.h>.
      
      Link: https://lkml.kernel.org/r/20230706154520.11257-2-bhe@redhat.com
      
      
      Signed-off-by: default avatarBaoquan He <bhe@redhat.com>
      Acked-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
      Reviewed-by: default avatarMike Rapoport (IBM) <rppt@kernel.org>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: David Laight <David.Laight@ACULAB.COM>
      Cc: Helge Deller <deller@gmx.de>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Niklas Schnelle <schnelle@linux.ibm.com>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Brian Cain <bcain@quicinc.com>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: Jonas Bonn <jonas@southpole.se>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Nicholas Piggin <npiggin@gmail.com>
      Cc: Rich Felker <dalias@libc.org>
      Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
      Cc: Sven Schnelle <svens@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vineet Gupta <vgupta@kernel.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      0b1f77e7
    • Andrew Donnellan's avatar
      lib/test_meminit: allocate pages up to order MAX_ORDER · efb78fa8
      Andrew Donnellan authored
      test_pages() tests the page allocator by calling alloc_pages() with
      different orders up to order 10.
      
      However, different architectures and platforms support different maximum
      contiguous allocation sizes.  The default maximum allocation order
      (MAX_ORDER) is 10, but architectures can use CONFIG_ARCH_FORCE_MAX_ORDER
      to override this.  On platforms where this is less than 10, test_meminit()
      will blow up with a WARN().  This is expected, so let's not do that.
      
      Replace the hardcoded "10" with the MAX_ORDER macro so that we test
      allocations up to the expected platform limit.
      
      Link: https://lkml.kernel.org/r/20230714015238.47931-1-ajd@linux.ibm.com
      Fixes: 5015a300
      
       ("lib: introduce test_meminit module")
      Signed-off-by: default avatarAndrew Donnellan <ajd@linux.ibm.com>
      Reviewed-by: default avatarAlexander Potapenko <glider@google.com>
      Cc: Xiaoke Wang <xkernel.wang@foxmail.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      efb78fa8
    • Kemeng Shi's avatar
      mm/page_ext: move functions around for minor cleanups to page_ext · eb0da7f6
      Kemeng Shi authored
      1. move page_ext_get and page_ext_put down to remove forward
         declaration of lookup_page_ext.
      
      2. move page_ext_init_flatmem_late down to existing non SPARS block to
         remove a new non SPARS block and to keep code for non SPARS tight.
      
      Link: https://lkml.kernel.org/r/20230714114749.1743032-4-shikemeng@huaweicloud.com
      
      
      Signed-off-by: default avatarKemeng Shi <shikemeng@huaweicloud.com>
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      eb0da7f6
    • Kemeng Shi's avatar
      mm/page_ext: remove rollback for untouched mem_section in online_page_ext · 3c09be5a
      Kemeng Shi authored
      If init_section_page_ext failed, we only need rollback for mem_section
      before failed mem_section.  Make rollback end point to failed mem_section
      to remove unnecessary rollback.
      
      As pfn += PAGES_PER_SECTION will be executed even if init_section_page_ext
      failed.  So pfn points to mem_section after failed mem_section.  Subtract
      one mem_section from pfn to get failed mem_section.
      
      Link: https://lkml.kernel.org/r/20230714114749.1743032-3-shikemeng@huaweicloud.com
      
      
      Signed-off-by: default avatarKemeng Shi <shikemeng@huaweicloud.com>
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      3c09be5a
    • Kemeng Shi's avatar
      mm/page_ext: remove unused return value of offline_page_ext · 063ff7cd
      Kemeng Shi authored
      Patch series "minor cleanups for page_ext".
      
      This series contains some random minor cleanups for page_ext.  More
      details can be found in respective patches.  
      
      
      This patch (of 3):
      
      offline_page_ext always returns 0 and no caller checks the return value. 
      Just remove unused return value of offline_page_ext.
      
      Link: https://lkml.kernel.org/r/20230714114749.1743032-1-shikemeng@huaweicloud.com
      Link: https://lkml.kernel.org/r/20230714114749.1743032-2-shikemeng@huaweicloud.com
      
      
      Signed-off-by: default avatarKemeng Shi <shikemeng@huaweicloud.com>
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      063ff7cd
    • Matthew Wilcox (Oracle)'s avatar
      buffer: remove set_bh_page() · 5f6d2862
      Matthew Wilcox (Oracle) authored
      With all users converted to folio_set_bh(), remove this function.
      
      Link: https://lkml.kernel.org/r/20230713035512.4139457-8-willy@infradead.org
      
      
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Christian Brauner <brauner@kernel.org>
      Cc: David Sterba <dsterba@suse.com>
      Cc: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Pankaj Raghav <p.raghav@samsung.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Cc: Tom Rix <trix@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      5f6d2862
    • Matthew Wilcox (Oracle)'s avatar
      jbd2: use a folio in jbd2_journal_write_metadata_buffer() · 8147c4c4
      Matthew Wilcox (Oracle) authored
      The primary goal here is removing the use of set_bh_page().  Take the
      opportunity to switch from kmap_atomic() to kmap_local().  This simplifies
      the function as the offset is already added to the pointer.
      
      Link: https://lkml.kernel.org/r/20230713035512.4139457-7-willy@infradead.org
      
      
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Christian Brauner <brauner@kernel.org>
      Cc: David Sterba <dsterba@suse.com>
      Cc: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Pankaj Raghav <p.raghav@samsung.com>
      Cc: Tom Rix <trix@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      8147c4c4
    • Matthew Wilcox (Oracle)'s avatar
      ntfs3: convert ntfs_get_block_vbo() to use a folio · 07811230
      Matthew Wilcox (Oracle) authored
      Remove a user of set_bh_page().
      
      Link: https://lkml.kernel.org/r/20230713035512.4139457-6-willy@infradead.org
      
      
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Cc: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Christian Brauner <brauner@kernel.org>
      Cc: David Sterba <dsterba@suse.com>
      Cc: Jan Kara <jack@suse.com>
      Cc: Pankaj Raghav <p.raghav@samsung.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      07811230
    • Matthew Wilcox (Oracle)'s avatar
      migrate: use folio_set_bh() instead of set_bh_page() · d5db4f9d
      Matthew Wilcox (Oracle) authored
      This function was converted before folio_set_bh() existed.  Catch up to
      the new API.
      
      Link: https://lkml.kernel.org/r/20230713035512.4139457-5-willy@infradead.org
      
      
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Christian Brauner <brauner@kernel.org>
      Cc: David Sterba <dsterba@suse.com>
      Cc: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Pankaj Raghav <p.raghav@samsung.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Cc: Tom Rix <trix@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      d5db4f9d
    • Matthew Wilcox (Oracle)'s avatar
      affs: convert data read and write to use folios · 34113026
      Matthew Wilcox (Oracle) authored
      We still need to convert to/from folios in write_begin & write_end to fit
      the API, but this removes a lot of calls to old page-based functions,
      removing many hidden calls to compound_head().
      
      Link: https://lkml.kernel.org/r/20230713035512.4139457-4-willy@infradead.org
      
      
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Reviewed-by: default avatarPankaj Raghav <p.raghav@samsung.com>
      Acked-by: default avatarDavid Sterba <dsterba@suse.com>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Christian Brauner <brauner@kernel.org>
      Cc: Jan Kara <jack@suse.com>
      Cc: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Cc: Tom Rix <trix@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      34113026
    • Matthew Wilcox (Oracle)'s avatar
      affs: convert affs_symlink_read_folio() to use the folio · 41a638a1
      Matthew Wilcox (Oracle) authored
      Remove use of the old page APIs.  That includes use of setting PageError
      on error; simply not setting the uptodate flag is sufficient.
      
      Link: https://lkml.kernel.org/r/20230713035512.4139457-3-willy@infradead.org
      
      
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Acked-by: default avatarDavid Sterba <dsterba@suse.com>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Christian Brauner <brauner@kernel.org>
      Cc: Jan Kara <jack@suse.com>
      Cc: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Pankaj Raghav <p.raghav@samsung.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Cc: Tom Rix <trix@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      41a638a1
    • Matthew Wilcox (Oracle)'s avatar
      highmem: add memcpy_to_folio() and memcpy_from_folio() · b23d03ef
      Matthew Wilcox (Oracle) authored
      Patch series "More filesystem folio conversions for 6.6".
      
      Remove the only spots in affs which actually use a struct page; there
      are a few places where one is mentioned, but it's part of the interface.
      
      The rest of this is removing the remaining calls to set_bh_page(),
      and then removing the function before any new users show up.
      
      
      This patch (of 7):
      
      These are the folio equivalent of memcpy_to_page() and memcpy_from_page().
      
      [agruenba@redhat.com: use correct chunk size in memcpy()]
        Link: https://lkml.kernel.org/r/20230802144354.1023099-1-agruenba@redhat.com
      Link: https://lkml.kernel.org/r/20230713035512.4139457-1-willy@infradead.org
      Link: https://lkml.kernel.org/r/20230713035512.4139457-2-willy@infradead.org
      
      
      Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Cc: David Sterba <dsterba@suse.com>
      Cc: Jan Kara <jack@suse.com>
      Cc: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
      Cc: Pankaj Raghav <p.raghav@samsung.com>
      Cc: "Theodore Ts'o" <tytso@mit.edu>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Christian Brauner <brauner@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Andreas Gruenbacher <agruenba@redhat.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      b23d03ef
    • Kemeng Shi's avatar
      mm/page_table_check: remove unused parameter in [__]page_table_check_pud_set · 6d144436
      Kemeng Shi authored
      Remove unused addr in __page_table_check_pud_set and
      page_table_check_pud_set.
      
      Link: https://lkml.kernel.org/r/20230713172636.1705415-9-shikemeng@huaweicloud.com
      
      
      Signed-off-by: default avatarKemeng Shi <shikemeng@huaweicloud.com>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      6d144436
    • Kemeng Shi's avatar
      mm/page_table_check: remove unused parameter in [__]page_table_check_pmd_set · a3b83713
      Kemeng Shi authored
      Remove unused addr in __page_table_check_pmd_set and
      page_table_check_pmd_set.
      
      Link: https://lkml.kernel.org/r/20230713172636.1705415-8-shikemeng@huaweicloud.com
      
      
      Signed-off-by: default avatarKemeng Shi <shikemeng@huaweicloud.com>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      a3b83713
    • Kemeng Shi's avatar
      mm/page_table_check: remove unused parameter in [__]page_table_check_pte_set · 1066293d
      Kemeng Shi authored
      Remove unused addr in __page_table_check_pte_set and
      page_table_check_pte_set.
      
      Link: https://lkml.kernel.org/r/20230713172636.1705415-7-shikemeng@huaweicloud.com
      
      
      Signed-off-by: default avatarKemeng Shi <shikemeng@huaweicloud.com>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      1066293d
    • Kemeng Shi's avatar
      mm/page_table_check: remove unused parameter in [__]page_table_check_pud_clear · 931c38e1
      Kemeng Shi authored
      Remove unused addr in __page_table_check_pud_clear and
      page_table_check_pud_clear.
      
      Link: https://lkml.kernel.org/r/20230713172636.1705415-6-shikemeng@huaweicloud.com
      
      
      Signed-off-by: default avatarKemeng Shi <shikemeng@huaweicloud.com>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      931c38e1
    • Kemeng Shi's avatar
      mm/page_table_check: remove unused parameter in [__]page_table_check_pmd_clear · 1831414c
      Kemeng Shi authored
      Remove unused addr in page_table_check_pmd_clear and
      __page_table_check_pmd_clear.
      
      Link: https://lkml.kernel.org/r/20230713172636.1705415-5-shikemeng@huaweicloud.com
      
      
      Signed-off-by: default avatarKemeng Shi <shikemeng@huaweicloud.com>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      1831414c
    • Kemeng Shi's avatar
      mm/page_table_check: remove unused parameter in [__]page_table_check_pte_clear · aa232204
      Kemeng Shi authored
      Remove unused addr in page_table_check_pte_clear and
      __page_table_check_pte_clear.
      
      Link: https://lkml.kernel.org/r/20230713172636.1705415-4-shikemeng@huaweicloud.com
      
      
      Signed-off-by: default avatarKemeng Shi <shikemeng@huaweicloud.com>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      aa232204
    • Kemeng Shi's avatar
      mm/page_table_check: remove unused parameters in page_table_check_set() · 2f933eaf
      Kemeng Shi authored
      Remove unused mm and addr in page_table_check_set().
      
      Link: https://lkml.kernel.org/r/20230713172636.1705415-3-shikemeng@huaweicloud.com
      
      
      Signed-off-by: default avatarKemeng Shi <shikemeng@huaweicloud.com>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      2f933eaf
    • Kemeng Shi's avatar
      mm/page_table_check: remove unused parameters in page_table_check_clear() · 34c876ce
      Kemeng Shi authored
      Patch series "Remove unused parameters in page_table_check".
      
      This series remove unused parameters in functions from page_table_check. 
      The first 2 patches remove unused mm and addr parameters in static common
      functions page_table_check_clear and page_table_check_set.  The last 6
      patches remove unused addr parameter in some externed functions which only
      need addr for cleaned page_table_check_clear or page_table_check_set. 
      There is no intended functional change.  
      
      
      This patch (of 8):
      
      Remove unused mm and addr in function page_table_check_clear().
      
      Link: https://lkml.kernel.org/r/20230713172636.1705415-1-shikemeng@huaweicloud.com
      Link: https://lkml.kernel.org/r/20230713172636.1705415-2-shikemeng@huaweicloud.com
      
      
      Signed-off-by: default avatarKemeng Shi <shikemeng@huaweicloud.com>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      34c876ce
    • Miaohe Lin's avatar
      mm/memcg: fix obsolete comment above MEM_CGROUP_MAX_RECLAIM_LOOPS · f4d005af
      Miaohe Lin authored
      Since commit 5660048c ("mm: move memcg hierarchy reclaim to generic
      reclaim code"), mem_cgroup_hierarchical_reclaim() is already renamed to
      mem_cgroup_soft_reclaim().  Update the corresponding comment.
      
      Link: https://lkml.kernel.org/r/20230713121432.273381-1-linmiaohe@huawei.com
      
      
      Signed-off-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
      Reviewed-by: default avatarMuchun Song <songmuchun@bytedance.com>
      Cc: Johannes Weiner <hannes@cmpxchg.org>
      Cc: Miaohe Lin <linmiaohe@huawei.com>
      Cc: Michal Hocko <mhocko@kernel.org>
      Cc: Muchun Song <muchun.song@linux.dev>
      Cc: Roman Gushchin <roman.gushchin@linux.dev>
      Cc: Shakeel Butt <shakeelb@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      f4d005af
    • Miaohe Lin's avatar
      mm/huge_memory: use RMAP_NONE when calling page_add_anon_rmap() · 5ba72b4d
      Miaohe Lin authored
      It's more convenient and readable to use RMAP_NONE instead of false when
      calling page_add_anon_rmap().  No functional change intended.
      
      Link: https://lkml.kernel.org/r/20230713120557.218592-1-linmiaohe@huawei.com
      
      
      Signed-off-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
      Reviewed-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
      Reviewed-by: default avatarAnshuman Khandual <anshuman.khandual@arm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      5ba72b4d
    • Jiaqi Yan's avatar
      selftests/mm: add tests for HWPOISON hugetlbfs read · ba91e7e5
      Jiaqi Yan authored
      Add tests for the improvement made to read operation on HWPOISON
      hugetlb page with different read granularities. For each chunk size,
      three read scenarios are tested:
      1. Simple regression test on read without HWPOISON.
      2. Sequential read page by page should succeed until encounters the 1st
         raw HWPOISON subpage.
      3. After skip a raw HWPOISON subpage by lseek, read()s always succeed.
      
      Link: https://lkml.kernel.org/r/20230713001833.3778937-5-jiaqiyan@google.com
      
      
      Signed-off-by: default avatarJiaqi Yan <jiaqiyan@google.com>
      Acked-by: default avatarMike Kravetz <mike.kravetz@oracle.com>
      Reviewed-by: default avatarNaoya Horiguchi <naoya.horiguchi@nec.com>
      Cc: James Houghton <jthoughton@google.com>
      Cc: Miaohe Lin <linmiaohe@huawei.com>
      Cc: Muchun Song <songmuchun@bytedance.com>
      Cc: Yang Shi <shy828301@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      ba91e7e5
    • Jiaqi Yan's avatar
      hugetlbfs: improve read HWPOISON hugepage · 38c1ddbd
      Jiaqi Yan authored
      When a hugepage contains HWPOISON pages, read() fails to read any byte of
      the hugepage and returns -EIO, although many bytes in the HWPOISON
      hugepage are readable.
      
      Improve this by allowing hugetlbfs_read_iter returns as many bytes as
      possible.  For a requested range [offset, offset + len) that contains
      HWPOISON page, return [offset, first HWPOISON page addr); the next read
      attempt will fail and return -EIO.
      
      Link: https://lkml.kernel.org/r/20230713001833.3778937-4-jiaqiyan@google.com
      
      
      Signed-off-by: default avatarJiaqi Yan <jiaqiyan@google.com>
      Reviewed-by: default avatarMike Kravetz <mike.kravetz@oracle.com>
      Reviewed-by: default avatarNaoya Horiguchi <naoya.horiguchi@nec.com>
      Cc: James Houghton <jthoughton@google.com>
      Cc: Miaohe Lin <linmiaohe@huawei.com>
      Cc: Muchun Song <songmuchun@bytedance.com>
      Cc: Yang Shi <shy828301@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      38c1ddbd
    • Jiaqi Yan's avatar
      mm/hwpoison: check if a raw page in a hugetlb folio is raw HWPOISON · b79f8eb4
      Jiaqi Yan authored
      Add the functionality, is_raw_hwpoison_page_in_hugepage, to tell if a raw
      page in a hugetlb folio is HWPOISON.  This functionality relies on
      RawHwpUnreliable to be not set; otherwise hugepage's raw HWPOISON list
      becomes meaningless.
      
      is_raw_hwpoison_page_in_hugepage holds mf_mutex in order to synchronize
      with folio_set_hugetlb_hwpoison and folio_free_raw_hwp who iterate,
      insert, or delete entry in raw_hwp_list.  llist itself doesn't ensure
      insertion and removal are synchornized with the llist_for_each_entry used
      by is_raw_hwpoison_page_in_hugepage (unless iterated entries are already
      deleted from the list).  Caller can minimize the overhead of lock cycles
      by first checking HWPOISON flag of the folio.
      
      Exports this functionality to be immediately used in the read operation
      for hugetlbfs.
      
      Link: https://lkml.kernel.org/r/20230713001833.3778937-3-jiaqiyan@google.com
      
      
      Signed-off-by: default avatarJiaqi Yan <jiaqiyan@google.com>
      Reviewed-by: default avatarMike Kravetz <mike.kravetz@oracle.com>
      Reviewed-by: default avatarNaoya Horiguchi <naoya.horiguchi@nec.com>
      Reviewed-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
      Cc: James Houghton <jthoughton@google.com>
      Cc: Muchun Song <songmuchun@bytedance.com>
      Cc: Yang Shi <shy828301@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      b79f8eb4
    • Jiaqi Yan's avatar
      mm/hwpoison: delete all entries before traversal in __folio_free_raw_hwp · 9e130c4b
      Jiaqi Yan authored
      Patch series "Improve hugetlbfs read on HWPOISON hugepages", v4.
      
      Today when hardware memory is corrupted in a hugetlb hugepage, kernel
      leaves the hugepage in pagecache [1]; otherwise future mmap or read will
      suject to silent data corruption.  This is implemented by returning -EIO
      from hugetlb_read_iter immediately if the hugepage has HWPOISON flag set.
      
      Since memory_failure already tracks the raw HWPOISON subpages in a
      hugepage, a natural improvement is possible: if userspace only asks for
      healthy subpages in the pagecache, kernel can return these data.
      
      This patchset implements this improvement.  It consist of three parts. 
      The 1st commit exports the functionality to tell if a subpage inside a
      hugetlb hugepage is a raw HWPOISON page.  The 2nd commit teaches
      hugetlbfs_read_iter to return as many healthy bytes as possible.  The 3rd
      commit properly tests this new feature.
      
      [1] commit 8625147c ("hugetlbfs: don't delete error page from pagecache")
      
      
      This patch (of 4):
      
      Traversal on llist (e.g.  llist_for_each_safe) is only safe AFTER entries
      are deleted from the llist.  Correct the way __folio_free_raw_hwp deletes
      and frees raw_hwp_page entries in raw_hwp_list: first llist_del_all, then
      kfree within llist_for_each_safe.
      
      As of today, concurrent adding, deleting, and traversal on raw_hwp_list
      from hugetlb.c and/or memory-failure.c are fine with each other.  Note
      this is guaranteed partly by the lock-free nature of llist, and partly by
      holding hugetlb_lock and/or mf_mutex.  For example, as llist_del_all is
      lock-free with itself, folio_clear_hugetlb_hwpoison()s from
      __update_and_free_hugetlb_folio and memory_failure won't need explicit
      locking when freeing the raw_hwp_list.  New code that manipulates
      raw_hwp_list must be careful to ensure the concurrency correctness.
      
      Link: https://lkml.kernel.org/r/20230713001833.3778937-1-jiaqiyan@google.com
      Link: https://lkml.kernel.org/r/20230713001833.3778937-2-jiaqiyan@google.com
      
      
      Signed-off-by: default avatarJiaqi Yan <jiaqiyan@google.com>
      Acked-by: default avatarMike Kravetz <mike.kravetz@oracle.com>
      Acked-by: default avatarNaoya Horiguchi <naoya.horiguchi@nec.com>
      Cc: James Houghton <jthoughton@google.com>
      Cc: Miaohe Lin <linmiaohe@huawei.com>
      Cc: Muchun Song <songmuchun@bytedance.com>
      Cc: Yang Shi <shy828301@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      9e130c4b
    • Yu Ma's avatar
      mm/mmap: move vma operations to mm_struct out of the critical section of file mapping lock · 6852c46c
      Yu Ma authored
      UnixBench/Execl represents a class of workload where bash scripts are
      spawned frequently to do some short jobs.  When running multiple parallel
      tasks, hot osq_lock is observed from do_mmap and exit_mmap.  Both of them
      come from load_elf_binary through the call chain
      "execl->do_execveat_common->bprm_execve->load_elf_binary".
      
      In do_mmap,it will call mmap_region to create vma node, initialize it and
      insert it to vma maintain structure in mm_struct and i_mmap tree of the
      mapping file, then increase map_count to record the number of vma nodes
      used.  The hot osq_lock is to protect operations on file's i_mmap tree. 
      For the mm_struct member change like vma insertion and map_count update,
      they do not affect i_mmap tree.  Move those operations out of the lock's
      critical section, to reduce hold time on the lock.
      
      With this change, on Intel Sapphire Rapids 112C/224T platform, based on
      v6.0-rc6, the 160 parallel score improves by 12%.  The patch has no
      obvious performance gain on v6.5-rc1 due to regression of this benchmark
      from this commit f1a79412 (mm: convert
      mm's rss stats into percpu_counter).  Related discussion and conclusion
      can be referred at the mail thread initiated by 0day as below: Link:
      https://lore.kernel.org/linux-mm/a4aa2e13-7187-600b-c628-7e8fb108def0@intel.com/
      
      Link: https://lkml.kernel.org/r/20230712145739.604215-1-yu.ma@intel.com
      
      
      Signed-off-by: default avatarYu Ma <yu.ma@intel.com>
      Reviewed-by: default avatarTim Chen <tim.c.chen@linux.intel.com>
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Dave Hansen <dave.hansen@intel.com>
      Cc: Kirill A . Shutemov <kirill@shutemov.name>
      Cc: Liam R. Howlett <Liam.Howlett@oracle.com>
      Cc: Shakeel Butt <shakeelb@google.com>
      Cc: Zhu, Lipeng <lipeng.zhu@intel.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      6852c46c
    • Xueshi Hu's avatar
      mm: remove clear_page_idle() · 73e791d7
      Xueshi Hu authored
      All callers have now been converted to call folio_clear_idle().
      
      Link: https://lkml.kernel.org/r/20230712134959.145373-1-xueshi.hu@smartx.com
      
      
      Signed-off-by: default avatarXueshi Hu <xueshi.hu@smartx.com>
      Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
      Cc: Charan Teja Kalla <quic_charante@quicinc.com>
      Cc: Michal Hocko <mhocko@suse.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      73e791d7
    • Hugh Dickins's avatar
      mm/pgtable: notes on pte_offset_map[_lock]() · 610d0657
      Hugh Dickins authored
      Add a block of comments on pte_offset_map_lock(), pte_offset_map() and
      pte_offset_map_nolock() to mm/pgtable-generic.c, to help explain them.
      
      Link: https://lkml.kernel.org/r/b791c3b0-25c6-a263-d785-d564344eb644@google.com
      
      
      Signed-off-by: default avatarHugh Dickins <hughd@google.com>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Alistair Popple <apopple@nvidia.com>
      Cc: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Cc: Anshuman Khandual <anshuman.khandual@arm.com>
      Cc: Axel Rasmussen <axelrasmussen@google.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Christoph Hellwig <hch@infradead.org>
      Cc: Claudio Imbrenda <imbrenda@linux.ibm.com>
      Cc: David Hildenbrand <david@redhat.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Huang, Ying <ying.huang@intel.com>
      Cc: Ira Weiny <ira.weiny@intel.com>
      Cc: Jann Horn <jannh@google.com>
      Cc: Jason Gunthorpe <jgg@ziepe.ca>
      Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: Lorenzo Stoakes <lstoakes@gmail.com>
      Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
      Cc: Mel Gorman <mgorman@techsingularity.net>
      Cc: Miaohe Lin <linmiaohe@huawei.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Mike Kravetz <mike.kravetz@oracle.com>
      Cc: Mike Rapoport (IBM) <rppt@kernel.org>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Naoya Horiguchi <naoya.horiguchi@nec.com>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Cc: Peter Xu <peterx@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Qi Zheng <zhengqi.arch@bytedance.com>
      Cc: Ralph Campbell <rcampbell@nvidia.com>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: SeongJae Park <sj@kernel.org>
      Cc: Song Liu <song@kernel.org>
      Cc: Steven Price <steven.price@arm.com>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vishal Moola (Oracle) <vishal.moola@gmail.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yang Shi <shy828301@gmail.com>
      Cc: Yu Zhao <yuzhao@google.com>
      Cc: Zack Rusin <zackr@vmware.com>
      Cc: Zi Yan <ziy@nvidia.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      610d0657
    • Hugh Dickins's avatar
      mm: delete mmap_write_trylock() and vma_try_start_write() · cf95e337
      Hugh Dickins authored
      mmap_write_trylock() and vma_try_start_write() were added just for
      khugepaged, but now it has no use for them: delete.
      
      Link: https://lkml.kernel.org/r/4e6db3d-e8e-73fb-1f2a-8de2dab2a87c@google.com
      
      
      Signed-off-by: default avatarHugh Dickins <hughd@google.com>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Alistair Popple <apopple@nvidia.com>
      Cc: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Cc: Anshuman Khandual <anshuman.khandual@arm.com>
      Cc: Axel Rasmussen <axelrasmussen@google.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Christoph Hellwig <hch@infradead.org>
      Cc: Claudio Imbrenda <imbrenda@linux.ibm.com>
      Cc: David Hildenbrand <david@redhat.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Huang, Ying <ying.huang@intel.com>
      Cc: Ira Weiny <ira.weiny@intel.com>
      Cc: Jann Horn <jannh@google.com>
      Cc: Jason Gunthorpe <jgg@ziepe.ca>
      Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: Lorenzo Stoakes <lstoakes@gmail.com>
      Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
      Cc: Mel Gorman <mgorman@techsingularity.net>
      Cc: Miaohe Lin <linmiaohe@huawei.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Mike Kravetz <mike.kravetz@oracle.com>
      Cc: Mike Rapoport (IBM) <rppt@kernel.org>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Naoya Horiguchi <naoya.horiguchi@nec.com>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Cc: Peter Xu <peterx@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Qi Zheng <zhengqi.arch@bytedance.com>
      Cc: Ralph Campbell <rcampbell@nvidia.com>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: SeongJae Park <sj@kernel.org>
      Cc: Song Liu <song@kernel.org>
      Cc: Steven Price <steven.price@arm.com>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vishal Moola (Oracle) <vishal.moola@gmail.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yang Shi <shy828301@gmail.com>
      Cc: Yu Zhao <yuzhao@google.com>
      Cc: Zack Rusin <zackr@vmware.com>
      Cc: Zi Yan <ziy@nvidia.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      cf95e337
    • Hugh Dickins's avatar
      mm/khugepaged: delete khugepaged_collapse_pte_mapped_thps() · d50791c2
      Hugh Dickins authored
      Now that retract_page_tables() can retract page tables reliably, without
      depending on trylocks, delete all the apparatus for khugepaged to try
      again later: khugepaged_collapse_pte_mapped_thps() etc; and free up the
      per-mm memory which was set aside for that in the khugepaged_mm_slot.
      
      But one part of that is worth keeping: when hpage_collapse_scan_file()
      found SCAN_PTE_MAPPED_HUGEPAGE, that address was noted in the mm_slot to
      be tried for retraction later - catching, for example, page tables where a
      reversible mprotect() of a portion had required splitting the pmd, but now
      it can be recollapsed.  Call collapse_pte_mapped_thp() directly in this
      case (why was it deferred before?  I assume an issue with needing
      mmap_lock for write, but now it's only needed for read).
      
      [hughd@google.com: fix mmap_locked handlng]
        Link: https://lkml.kernel.org/r/bfc6cab2-497f-32bf-dd5-98dc1987e4a9@google.com
      Link: https://lkml.kernel.org/r/a5dce57-6dfa-5559-4698-e817eb2f993@google.com
      
      
      Signed-off-by: default avatarHugh Dickins <hughd@google.com>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Alistair Popple <apopple@nvidia.com>
      Cc: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Cc: Anshuman Khandual <anshuman.khandual@arm.com>
      Cc: Axel Rasmussen <axelrasmussen@google.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Christoph Hellwig <hch@infradead.org>
      Cc: Claudio Imbrenda <imbrenda@linux.ibm.com>
      Cc: David Hildenbrand <david@redhat.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Huang, Ying <ying.huang@intel.com>
      Cc: Ira Weiny <ira.weiny@intel.com>
      Cc: Jann Horn <jannh@google.com>
      Cc: Jason Gunthorpe <jgg@ziepe.ca>
      Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: Lorenzo Stoakes <lstoakes@gmail.com>
      Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
      Cc: Mel Gorman <mgorman@techsingularity.net>
      Cc: Miaohe Lin <linmiaohe@huawei.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Mike Kravetz <mike.kravetz@oracle.com>
      Cc: Mike Rapoport (IBM) <rppt@kernel.org>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Naoya Horiguchi <naoya.horiguchi@nec.com>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Cc: Peter Xu <peterx@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Qi Zheng <zhengqi.arch@bytedance.com>
      Cc: Ralph Campbell <rcampbell@nvidia.com>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: SeongJae Park <sj@kernel.org>
      Cc: Song Liu <song@kernel.org>
      Cc: Steven Price <steven.price@arm.com>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vishal Moola (Oracle) <vishal.moola@gmail.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yang Shi <shy828301@gmail.com>
      Cc: Yu Zhao <yuzhao@google.com>
      Cc: Zack Rusin <zackr@vmware.com>
      Cc: Zi Yan <ziy@nvidia.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      d50791c2
    • Hugh Dickins's avatar
      mm/khugepaged: collapse_pte_mapped_thp() with mmap_read_lock() · 1043173e
      Hugh Dickins authored
      Bring collapse_and_free_pmd() back into collapse_pte_mapped_thp().  It
      does need mmap_read_lock(), but it does not need mmap_write_lock(), nor
      vma_start_write() nor i_mmap lock nor anon_vma lock.  All racing paths are
      relying on pte_offset_map_lock() and pmd_lock(), so use those.
      
      Follow the pattern in retract_page_tables(); and using pte_free_defer()
      removes most of the need for tlb_remove_table_sync_one() here; but call
      pmdp_get_lockless_sync() to use it in the PAE case.
      
      First check the VMA, in case page tables are being torn down: from JannH. 
      Confirm the preliminary find_pmd_or_thp_or_none() once page lock has been
      acquired and the page looks suitable: from then on its state is stable.
      
      However, collapse_pte_mapped_thp() was doing something others don't:
      freeing a page table still containing "valid" entries.  i_mmap lock did
      stop a racing truncate from double-freeing those pages, but we prefer
      collapse_pte_mapped_thp() to clear the entries as usual.  Their TLB flush
      can wait until the pmdp_collapse_flush() which follows, but the
      mmu_notifier_invalidate_range_start() has to be done earlier.
      
      Do the "step 1" checking loop without mmu_notifier: it wouldn't be good
      for khugepaged to keep on repeatedly invalidating a range which is then
      found unsuitable e.g.  contains COWs.  "step 2", which does the clearing,
      must then be more careful (after dropping ptl to do mmu_notifier), with
      abort prepared to correct the accounting like "step 3".  But with those
      entries now cleared, "step 4" (after dropping ptl to do pmd_lock) is kept
      safe by the huge page lock, which stops new PTEs from being faulted in.
      
      [hughd@google.com: don't set mmap_locked = true in madvise_collapse()]
        Link: https://lkml.kernel.org/r/d3d9ff14-ef8-8f84-e160-bfa1f5794275@google.com
      [hughd@google.com: use ptep_clear() instead of pte_clear()]
        Link: https://lkml.kernel.org/r/e0197433-8a47-6a65-534d-eda26eeb78b0@google.com
      Link: https://lkml.kernel.org/r/b53be6a4-7715-51f9-aad-f1347dcb7c4@google.com
      
      
      Signed-off-by: default avatarHugh Dickins <hughd@google.com>
      Reviewed-by: default avatarQi Zheng <zhengqi.arch@bytedance.com>
      Cc: Alexander Gordeev <agordeev@linux.ibm.com>
      Cc: Alistair Popple <apopple@nvidia.com>
      Cc: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
      Cc: Anshuman Khandual <anshuman.khandual@arm.com>
      Cc: Axel Rasmussen <axelrasmussen@google.com>
      Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Christoph Hellwig <hch@infradead.org>
      Cc: Claudio Imbrenda <imbrenda@linux.ibm.com>
      Cc: David Hildenbrand <david@redhat.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Huang, Ying <ying.huang@intel.com>
      Cc: Ira Weiny <ira.weiny@intel.com>
      Cc: Jann Horn <jannh@google.com>
      Cc: Jason Gunthorpe <jgg@ziepe.ca>
      Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: Lorenzo Stoakes <lstoakes@gmail.com>
      Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
      Cc: Mel Gorman <mgorman@techsingularity.net>
      Cc: Miaohe Lin <linmiaohe@huawei.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Mike Kravetz <mike.kravetz@oracle.com>
      Cc: Mike Rapoport (IBM) <rppt@kernel.org>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Naoya Horiguchi <naoya.horiguchi@nec.com>
      Cc: Pavel Tatashin <pasha.tatashin@soleen.com>
      Cc: Peter Xu <peterx@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ralph Campbell <rcampbell@nvidia.com>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: SeongJae Park <sj@kernel.org>
      Cc: Song Liu <song@kernel.org>
      Cc: Steven Price <steven.price@arm.com>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vishal Moola (Oracle) <vishal.moola@gmail.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: Will Deacon <will@kernel.org>
      Cc: Yang Shi <shy828301@gmail.com>
      Cc: Yu Zhao <yuzhao@google.com>
      Cc: Zack Rusin <zackr@vmware.com>
      Cc: Zi Yan <ziy@nvidia.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      1043173e