mbox series

[V3,0/2] mm/mmap: Drop __SXXX/__PXXX macros from across platforms

Message ID 20220616040924.1022607-1-anshuman.khandual@arm.com (mailing list archive)
Headers show
Series mm/mmap: Drop __SXXX/__PXXX macros from across platforms | expand

Message

Anshuman Khandual June 16, 2022, 4:09 a.m. UTC
__SXXX/__PXXX macros is an unnecessary abstraction layer in creating the
generic protection_map[] array which is used for vm_get_page_prot(). This
abstraction layer can be avoided, if the platforms just define the array
protection_map[] for all possible vm_flags access permission combinations.

This series drops __SXXX/__PXXX macros from across platforms in the tree.
First it makes protection_map[] array private (static) on platforms which
enable ARCH_HAS_VM_GET_PAGE_PROT, later moves protection_map[] array into
arch for all remaining platforms (!ARCH_HAS_VM_GET_PAGE_PROT), dropping
the generic one. In the process __SXXX/__PXXX macros become redundant and
thus get dropped off completely. I understand that the diff stat is large
here, but please do suggest if there is a better way. This series applies
on v5.19-rc1 and has been build tested for multiple platforms.

The CC list for this series has been reduced to just minimum, until there
is some initial agreement.

- Anshuman

Changes in V3:

- Fix build issues on powerpc and riscv

Changes in V2:

https://lore.kernel.org/all/20220613053354.553579-1-anshuman.khandual@arm.com/

- Add 'const' identifier to protection_map[] on powerpc
- Dropped #ifndef CONFIG_ARCH_HAS_VM_GET_PAGE_PROT check from sparc 32
- Dropped protection_map[] init from sparc 64
- Dropped all new platform changes subscribing ARCH_HAS_VM_GET_PAGE_PROT
- Added a second patch which moves generic protection_map[] array into
  all remaining platforms (!ARCH_HAS_VM_GET_PAGE_PROT)

Changes in V1:

https://lore.kernel.org/linux-mm/20220603101411.488970-1-anshuman.khandual@arm.com/

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org

Anshuman Khandual (2):
  mm/mmap: Restrict generic protection_map[] array visibility
  mm/mmap: Drop generic protection_map[] array

 arch/alpha/include/asm/pgtable.h          | 17 -------
 arch/alpha/mm/init.c                      | 21 +++++++++
 arch/arc/include/asm/pgtable-bits-arcv2.h | 18 --------
 arch/arc/mm/mmap.c                        | 19 ++++++++
 arch/arm/include/asm/pgtable.h            | 17 -------
 arch/arm/lib/uaccess_with_memcpy.c        |  2 +-
 arch/arm/mm/mmu.c                         | 19 ++++++++
 arch/arm64/include/asm/pgtable-prot.h     | 18 --------
 arch/arm64/mm/mmap.c                      | 21 +++++++++
 arch/csky/include/asm/pgtable.h           | 18 --------
 arch/csky/mm/init.c                       | 19 ++++++++
 arch/hexagon/include/asm/pgtable.h        | 27 ------------
 arch/hexagon/mm/init.c                    | 41 +++++++++++++++++
 arch/ia64/include/asm/pgtable.h           | 18 --------
 arch/ia64/mm/init.c                       | 27 +++++++++++-
 arch/loongarch/include/asm/pgtable-bits.h | 19 --------
 arch/loongarch/mm/cache.c                 | 45 +++++++++++++++++++
 arch/m68k/include/asm/mcf_pgtable.h       | 54 -----------------------
 arch/m68k/include/asm/motorola_pgtable.h  | 22 ---------
 arch/m68k/include/asm/sun3_pgtable.h      | 17 -------
 arch/m68k/mm/mcfmmu.c                     | 54 +++++++++++++++++++++++
 arch/m68k/mm/motorola.c                   | 19 ++++++++
 arch/m68k/mm/sun3mmu.c                    | 19 ++++++++
 arch/microblaze/include/asm/pgtable.h     | 17 -------
 arch/microblaze/mm/init.c                 | 19 ++++++++
 arch/mips/include/asm/pgtable.h           | 22 ---------
 arch/mips/mm/cache.c                      |  2 +
 arch/nios2/include/asm/pgtable.h          | 16 -------
 arch/nios2/mm/init.c                      | 19 ++++++++
 arch/openrisc/include/asm/pgtable.h       | 18 --------
 arch/openrisc/mm/init.c                   | 19 ++++++++
 arch/parisc/include/asm/pgtable.h         | 18 --------
 arch/parisc/mm/init.c                     | 19 ++++++++
 arch/powerpc/include/asm/pgtable.h        | 18 --------
 arch/powerpc/mm/book3s64/pgtable.c        |  6 +++
 arch/powerpc/mm/pgtable.c                 | 20 +++++++++
 arch/riscv/include/asm/pgtable.h          | 20 ---------
 arch/riscv/mm/init.c                      | 19 ++++++++
 arch/s390/include/asm/pgtable.h           | 17 -------
 arch/s390/mm/mmap.c                       | 19 ++++++++
 arch/sh/include/asm/pgtable.h             | 17 -------
 arch/sh/mm/mmap.c                         | 19 ++++++++
 arch/sparc/include/asm/pgtable_32.h       | 19 --------
 arch/sparc/include/asm/pgtable_64.h       | 19 --------
 arch/sparc/mm/init_32.c                   | 19 ++++++++
 arch/sparc/mm/init_64.c                   |  3 ++
 arch/um/include/asm/pgtable.h             | 17 -------
 arch/um/kernel/mem.c                      | 19 ++++++++
 arch/x86/include/asm/pgtable_types.h      | 19 --------
 arch/x86/mm/pgprot.c                      | 19 ++++++++
 arch/x86/um/mem_32.c                      |  2 +-
 arch/xtensa/include/asm/pgtable.h         | 18 --------
 arch/xtensa/mm/init.c                     | 19 ++++++++
 include/linux/mm.h                        |  2 +
 mm/mmap.c                                 | 19 --------
 55 files changed, 547 insertions(+), 522 deletions(-)

Comments

Christophe Leroy June 16, 2022, 5:22 a.m. UTC | #1
Le 16/06/2022 à 06:09, Anshuman Khandual a écrit :
> __SXXX/__PXXX macros is an unnecessary abstraction layer in creating the
> generic protection_map[] array which is used for vm_get_page_prot(). This
> abstraction layer can be avoided, if the platforms just define the array
> protection_map[] for all possible vm_flags access permission combinations.
> 
> This series drops __SXXX/__PXXX macros from across platforms in the tree.
> First it makes protection_map[] array private (static) on platforms which
> enable ARCH_HAS_VM_GET_PAGE_PROT, later moves protection_map[] array into
> arch for all remaining platforms (!ARCH_HAS_VM_GET_PAGE_PROT), dropping
> the generic one. In the process __SXXX/__PXXX macros become redundant and
> thus get dropped off completely. I understand that the diff stat is large
> here, but please do suggest if there is a better way. This series applies
> on v5.19-rc1 and has been build tested for multiple platforms.

Maybe this patch could be split with one patch per architecture. All you 
have to do for that is to guard the generic protection_map declaration 
with #ifdef __S000 , then the architectures can be migrated one by one.

> 
> The CC list for this series has been reduced to just minimum, until there
> is some initial agreement.

Agreement with who if people don't know this series exists ?

I think you should keep the architecture lists in copy allthough you 
don't include individual maintainers/reviewers for now.

> 
> - Anshuman
> 
> Changes in V3:
> 
> - Fix build issues on powerpc and riscv
> 
> Changes in V2:

I guess V2 was only sent to linux-mm as well ? Too bad.

> 
> https://lore.kernel.org/all/20220613053354.553579-1-anshuman.khandual@arm.com/
> 
> - Add 'const' identifier to protection_map[] on powerpc
> - Dropped #ifndef CONFIG_ARCH_HAS_VM_GET_PAGE_PROT check from sparc 32
> - Dropped protection_map[] init from sparc 64
> - Dropped all new platform changes subscribing ARCH_HAS_VM_GET_PAGE_PROT
> - Added a second patch which moves generic protection_map[] array into
>    all remaining platforms (!ARCH_HAS_VM_GET_PAGE_PROT)
> 
> Changes in V1:
> 
> https://lore.kernel.org/linux-mm/20220603101411.488970-1-anshuman.khandual@arm.com/
> 
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: linux-mm@kvack.org
> Cc: linux-kernel@vger.kernel.org
> 
> Anshuman Khandual (2):
>    mm/mmap: Restrict generic protection_map[] array visibility
>    mm/mmap: Drop generic protection_map[] array
> 
>   arch/alpha/include/asm/pgtable.h          | 17 -------
>   arch/alpha/mm/init.c                      | 21 +++++++++
>   arch/arc/include/asm/pgtable-bits-arcv2.h | 18 --------
>   arch/arc/mm/mmap.c                        | 19 ++++++++
>   arch/arm/include/asm/pgtable.h            | 17 -------
>   arch/arm/lib/uaccess_with_memcpy.c        |  2 +-
>   arch/arm/mm/mmu.c                         | 19 ++++++++
>   arch/arm64/include/asm/pgtable-prot.h     | 18 --------
>   arch/arm64/mm/mmap.c                      | 21 +++++++++
>   arch/csky/include/asm/pgtable.h           | 18 --------
>   arch/csky/mm/init.c                       | 19 ++++++++
>   arch/hexagon/include/asm/pgtable.h        | 27 ------------
>   arch/hexagon/mm/init.c                    | 41 +++++++++++++++++
>   arch/ia64/include/asm/pgtable.h           | 18 --------
>   arch/ia64/mm/init.c                       | 27 +++++++++++-
>   arch/loongarch/include/asm/pgtable-bits.h | 19 --------
>   arch/loongarch/mm/cache.c                 | 45 +++++++++++++++++++
>   arch/m68k/include/asm/mcf_pgtable.h       | 54 -----------------------
>   arch/m68k/include/asm/motorola_pgtable.h  | 22 ---------
>   arch/m68k/include/asm/sun3_pgtable.h      | 17 -------
>   arch/m68k/mm/mcfmmu.c                     | 54 +++++++++++++++++++++++
>   arch/m68k/mm/motorola.c                   | 19 ++++++++
>   arch/m68k/mm/sun3mmu.c                    | 19 ++++++++
>   arch/microblaze/include/asm/pgtable.h     | 17 -------
>   arch/microblaze/mm/init.c                 | 19 ++++++++
>   arch/mips/include/asm/pgtable.h           | 22 ---------
>   arch/mips/mm/cache.c                      |  2 +
>   arch/nios2/include/asm/pgtable.h          | 16 -------
>   arch/nios2/mm/init.c                      | 19 ++++++++
>   arch/openrisc/include/asm/pgtable.h       | 18 --------
>   arch/openrisc/mm/init.c                   | 19 ++++++++
>   arch/parisc/include/asm/pgtable.h         | 18 --------
>   arch/parisc/mm/init.c                     | 19 ++++++++
>   arch/powerpc/include/asm/pgtable.h        | 18 --------
>   arch/powerpc/mm/book3s64/pgtable.c        |  6 +++
>   arch/powerpc/mm/pgtable.c                 | 20 +++++++++
>   arch/riscv/include/asm/pgtable.h          | 20 ---------
>   arch/riscv/mm/init.c                      | 19 ++++++++
>   arch/s390/include/asm/pgtable.h           | 17 -------
>   arch/s390/mm/mmap.c                       | 19 ++++++++
>   arch/sh/include/asm/pgtable.h             | 17 -------
>   arch/sh/mm/mmap.c                         | 19 ++++++++
>   arch/sparc/include/asm/pgtable_32.h       | 19 --------
>   arch/sparc/include/asm/pgtable_64.h       | 19 --------
>   arch/sparc/mm/init_32.c                   | 19 ++++++++
>   arch/sparc/mm/init_64.c                   |  3 ++
>   arch/um/include/asm/pgtable.h             | 17 -------
>   arch/um/kernel/mem.c                      | 19 ++++++++
>   arch/x86/include/asm/pgtable_types.h      | 19 --------
>   arch/x86/mm/pgprot.c                      | 19 ++++++++
>   arch/x86/um/mem_32.c                      |  2 +-
>   arch/xtensa/include/asm/pgtable.h         | 18 --------
>   arch/xtensa/mm/init.c                     | 19 ++++++++
>   include/linux/mm.h                        |  2 +
>   mm/mmap.c                                 | 19 --------
>   55 files changed, 547 insertions(+), 522 deletions(-)
>
Christoph Hellwig June 16, 2022, 6:13 a.m. UTC | #2
On Thu, Jun 16, 2022 at 05:22:23AM +0000, Christophe Leroy wrote:
> I think you should keep the architecture lists in copy allthough you 
> don't include individual maintainers/reviewers for now.

That's what I tend to do for big global changes.
Anshuman Khandual June 17, 2022, 3:07 a.m. UTC | #3
On 6/16/22 10:52, Christophe Leroy wrote:
> 
> 
> Le 16/06/2022 à 06:09, Anshuman Khandual a écrit :
>> __SXXX/__PXXX macros is an unnecessary abstraction layer in creating the
>> generic protection_map[] array which is used for vm_get_page_prot(). This
>> abstraction layer can be avoided, if the platforms just define the array
>> protection_map[] for all possible vm_flags access permission combinations.
>>
>> This series drops __SXXX/__PXXX macros from across platforms in the tree.
>> First it makes protection_map[] array private (static) on platforms which
>> enable ARCH_HAS_VM_GET_PAGE_PROT, later moves protection_map[] array into
>> arch for all remaining platforms (!ARCH_HAS_VM_GET_PAGE_PROT), dropping
>> the generic one. In the process __SXXX/__PXXX macros become redundant and
>> thus get dropped off completely. I understand that the diff stat is large
>> here, but please do suggest if there is a better way. This series applies
>> on v5.19-rc1 and has been build tested for multiple platforms.
> 
> Maybe this patch could be split with one patch per architecture. All you 
> have to do for that is to guard the generic protection_map declaration 
> with #ifdef __S000 , then the architectures can be migrated one by one.
> 
>>
>> The CC list for this series has been reduced to just minimum, until there
>> is some initial agreement.
> 
> Agreement with who if people don't know this series exists ?
> 
> I think you should keep the architecture lists in copy allthough you 
> don't include individual maintainers/reviewers for now.

Sure, will do.

> 
>>
>> - Anshuman
>>
>> Changes in V3:
>>
>> - Fix build issues on powerpc and riscv
>>
>> Changes in V2:
> 
> I guess V2 was only sent to linux-mm as well ? Too bad.

I was in a dilemma, whether to first arrive at something more acceptable or
just engage all stake holders from the beginning. I understand your concern
and hence will copy architecture mailing lists from next time onward.