mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-20 06:20:41 +00:00

Sergey Senozhatsky improves zram's post-processing selection algorithm. This leads to improved memory savings. - Wei Yang has gone to town on the mapletree code, contributing several series which clean up the implementation: - "refine mas_mab_cp()" - "Reduce the space to be cleared for maple_big_node" - "maple_tree: simplify mas_push_node()" - "Following cleanup after introduce mas_wr_store_type()" - "refine storing null" - The series "selftests/mm: hugetlb_fault_after_madv improvements" from David Hildenbrand fixes this selftest for s390. - The series "introduce pte_offset_map_{ro|rw}_nolock()" from Qi Zheng implements some rationaizations and cleanups in the page mapping code. - The series "mm: optimize shadow entries removal" from Shakeel Butt optimizes the file truncation code by speeding up the handling of shadow entries. - The series "Remove PageKsm()" from Matthew Wilcox completes the migration of this flag over to being a folio-based flag. - The series "Unify hugetlb into arch_get_unmapped_area functions" from Oscar Salvador implements a bunch of consolidations and cleanups in the hugetlb code. - The series "Do not shatter hugezeropage on wp-fault" from Dev Jain takes away the wp-fault time practice of turning a huge zero page into small pages. Instead we replace the whole thing with a THP. More consistent cleaner and potentiall saves a large number of pagefaults. - The series "percpu: Add a test case and fix for clang" from Andy Shevchenko enhances and fixes the kernel's built in percpu test code. - The series "mm/mremap: Remove extra vma tree walk" from Liam Howlett optimizes mremap() by avoiding doing things which we didn't need to do. - The series "Improve the tmpfs large folio read performance" from Baolin Wang teaches tmpfs to copy data into userspace at the folio size rather than as individual pages. A 20% speedup was observed. - The series "mm/damon/vaddr: Fix issue in damon_va_evenly_split_region()" fro Zheng Yejian fixes DAMON splitting. - The series "memcg-v1: fully deprecate charge moving" from Shakeel Butt removes the long-deprecated memcgv2 charge moving feature. - The series "fix error handling in mmap_region() and refactor" from Lorenzo Stoakes cleanup up some of the mmap() error handling and addresses some potential performance issues. - The series "x86/module: use large ROX pages for text allocations" from Mike Rapoport teaches x86 to use large pages for read-only-execute module text. - The series "page allocation tag compression" from Suren Baghdasaryan is followon maintenance work for the new page allocation profiling feature. - The series "page->index removals in mm" from Matthew Wilcox remove most references to page->index in mm/. A slow march towards shrinking struct page. - The series "damon/{self,kunit}tests: minor fixups for DAMON debugfs interface tests" from Andrew Paniakin performs maintenance work for DAMON's self testing code. - The series "mm: zswap swap-out of large folios" from Kanchana Sridhar improves zswap's batching of compression and decompression. It is a step along the way towards using Intel IAA hardware acceleration for this zswap operation. - The series "kasan: migrate the last module test to kunit" from Sabyrzhan Tasbolatov completes the migration of the KASAN built-in tests over to the KUnit framework. - The series "implement lightweight guard pages" from Lorenzo Stoakes permits userapace to place fault-generating guard pages within a single VMA, rather than requiring that multiple VMAs be created for this. Improved efficiencies for userspace memory allocators are expected. - The series "memcg: tracepoint for flushing stats" from JP Kobryn uses tracepoints to provide increased visibility into memcg stats flushing activity. - The series "zram: IDLE flag handling fixes" from Sergey Senozhatsky fixes a zram buglet which potentially affected performance. - The series "mm: add more kernel parameters to control mTHP" from Maíra Canal enhances our ability to control/configuremultisize THP from the kernel boot command line. - The series "kasan: few improvements on kunit tests" from Sabyrzhan Tasbolatov has a couple of fixups for the KASAN KUnit tests. - The series "mm/list_lru: Split list_lru lock into per-cgroup scope" from Kairui Song optimizes list_lru memory utilization when lockdep is enabled. -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQTTMBEPP41GrTpTJgfdBJ7gKXxAjgUCZzwFqgAKCRDdBJ7gKXxA jkeuAQCkl+BmeYHE6uG0hi3pRxkupseR6DEOAYIiTv0/l8/GggD/Z3jmEeqnZaNq xyyenpibWgUoShU2wZ/Ha8FE5WDINwg= =JfWR -----END PGP SIGNATURE----- Merge tag 'mm-stable-2024-11-18-19-27' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Pull MM updates from Andrew Morton: - The series "zram: optimal post-processing target selection" from Sergey Senozhatsky improves zram's post-processing selection algorithm. This leads to improved memory savings. - Wei Yang has gone to town on the mapletree code, contributing several series which clean up the implementation: - "refine mas_mab_cp()" - "Reduce the space to be cleared for maple_big_node" - "maple_tree: simplify mas_push_node()" - "Following cleanup after introduce mas_wr_store_type()" - "refine storing null" - The series "selftests/mm: hugetlb_fault_after_madv improvements" from David Hildenbrand fixes this selftest for s390. - The series "introduce pte_offset_map_{ro|rw}_nolock()" from Qi Zheng implements some rationaizations and cleanups in the page mapping code. - The series "mm: optimize shadow entries removal" from Shakeel Butt optimizes the file truncation code by speeding up the handling of shadow entries. - The series "Remove PageKsm()" from Matthew Wilcox completes the migration of this flag over to being a folio-based flag. - The series "Unify hugetlb into arch_get_unmapped_area functions" from Oscar Salvador implements a bunch of consolidations and cleanups in the hugetlb code. - The series "Do not shatter hugezeropage on wp-fault" from Dev Jain takes away the wp-fault time practice of turning a huge zero page into small pages. Instead we replace the whole thing with a THP. More consistent cleaner and potentiall saves a large number of pagefaults. - The series "percpu: Add a test case and fix for clang" from Andy Shevchenko enhances and fixes the kernel's built in percpu test code. - The series "mm/mremap: Remove extra vma tree walk" from Liam Howlett optimizes mremap() by avoiding doing things which we didn't need to do. - The series "Improve the tmpfs large folio read performance" from Baolin Wang teaches tmpfs to copy data into userspace at the folio size rather than as individual pages. A 20% speedup was observed. - The series "mm/damon/vaddr: Fix issue in damon_va_evenly_split_region()" fro Zheng Yejian fixes DAMON splitting. - The series "memcg-v1: fully deprecate charge moving" from Shakeel Butt removes the long-deprecated memcgv2 charge moving feature. - The series "fix error handling in mmap_region() and refactor" from Lorenzo Stoakes cleanup up some of the mmap() error handling and addresses some potential performance issues. - The series "x86/module: use large ROX pages for text allocations" from Mike Rapoport teaches x86 to use large pages for read-only-execute module text. - The series "page allocation tag compression" from Suren Baghdasaryan is followon maintenance work for the new page allocation profiling feature. - The series "page->index removals in mm" from Matthew Wilcox remove most references to page->index in mm/. A slow march towards shrinking struct page. - The series "damon/{self,kunit}tests: minor fixups for DAMON debugfs interface tests" from Andrew Paniakin performs maintenance work for DAMON's self testing code. - The series "mm: zswap swap-out of large folios" from Kanchana Sridhar improves zswap's batching of compression and decompression. It is a step along the way towards using Intel IAA hardware acceleration for this zswap operation. - The series "kasan: migrate the last module test to kunit" from Sabyrzhan Tasbolatov completes the migration of the KASAN built-in tests over to the KUnit framework. - The series "implement lightweight guard pages" from Lorenzo Stoakes permits userapace to place fault-generating guard pages within a single VMA, rather than requiring that multiple VMAs be created for this. Improved efficiencies for userspace memory allocators are expected. - The series "memcg: tracepoint for flushing stats" from JP Kobryn uses tracepoints to provide increased visibility into memcg stats flushing activity. - The series "zram: IDLE flag handling fixes" from Sergey Senozhatsky fixes a zram buglet which potentially affected performance. - The series "mm: add more kernel parameters to control mTHP" from Maíra Canal enhances our ability to control/configuremultisize THP from the kernel boot command line. - The series "kasan: few improvements on kunit tests" from Sabyrzhan Tasbolatov has a couple of fixups for the KASAN KUnit tests. - The series "mm/list_lru: Split list_lru lock into per-cgroup scope" from Kairui Song optimizes list_lru memory utilization when lockdep is enabled. * tag 'mm-stable-2024-11-18-19-27' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (215 commits) cma: enforce non-zero pageblock_order during cma_init_reserved_mem() mm/kfence: add a new kunit test test_use_after_free_read_nofault() zram: fix NULL pointer in comp_algorithm_show() memcg/hugetlb: add hugeTLB counters to memcg vmstat: call fold_vm_zone_numa_events() before show per zone NUMA event mm: mmap_lock: check trace_mmap_lock_$type_enabled() instead of regcount zram: ZRAM_DEF_COMP should depend on ZRAM MAINTAINERS/MEMORY MANAGEMENT: add document files for mm Docs/mm/damon: recommend academic papers to read and/or cite mm: define general function pXd_init() kmemleak: iommu/iova: fix transient kmemleak false positive mm/list_lru: simplify the list_lru walk callback function mm/list_lru: split the lock to per-cgroup scope mm/list_lru: simplify reparenting and initial allocation mm/list_lru: code clean up for reparenting mm/list_lru: don't export list_lru_add mm/list_lru: don't pass unnecessary key parameters kasan: add kunit tests for kmalloc_track_caller, kmalloc_node_track_caller kasan: change kasan_atomics kunit test as KUNIT_CASE_SLOW kasan: use EXPORT_SYMBOL_IF_KUNIT to export symbols ...
279 lines
6.7 KiB
C
279 lines
6.7 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* S390 version
|
|
* Copyright IBM Corp. 1999, 2000
|
|
* Author(s): Hartmut Penner (hp@de.ibm.com)
|
|
*/
|
|
|
|
#ifndef _S390_PAGE_H
|
|
#define _S390_PAGE_H
|
|
|
|
#include <linux/const.h>
|
|
#include <asm/types.h>
|
|
#include <asm/asm.h>
|
|
|
|
#include <vdso/page.h>
|
|
|
|
#define PAGE_DEFAULT_ACC _AC(0, UL)
|
|
/* storage-protection override */
|
|
#define PAGE_SPO_ACC 9
|
|
#define PAGE_DEFAULT_KEY (PAGE_DEFAULT_ACC << 4)
|
|
|
|
#define HPAGE_SHIFT 20
|
|
#define HPAGE_SIZE (1UL << HPAGE_SHIFT)
|
|
#define HPAGE_MASK (~(HPAGE_SIZE - 1))
|
|
#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
|
|
#define HUGE_MAX_HSTATE 2
|
|
|
|
#define ARCH_HAS_SETCLEAR_HUGE_PTE
|
|
#define ARCH_HAS_HUGE_PTE_TYPE
|
|
#define ARCH_HAS_PREPARE_HUGEPAGE
|
|
#define ARCH_HAS_HUGEPAGE_CLEAR_FLUSH
|
|
|
|
#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
|
|
|
|
#include <asm/setup.h>
|
|
#ifndef __ASSEMBLY__
|
|
|
|
void __storage_key_init_range(unsigned long start, unsigned long end);
|
|
|
|
static inline void storage_key_init_range(unsigned long start, unsigned long end)
|
|
{
|
|
if (PAGE_DEFAULT_KEY != 0)
|
|
__storage_key_init_range(start, end);
|
|
}
|
|
|
|
#define clear_page(page) memset((page), 0, PAGE_SIZE)
|
|
|
|
/*
|
|
* copy_page uses the mvcl instruction with 0xb0 padding byte in order to
|
|
* bypass caches when copying a page. Especially when copying huge pages
|
|
* this keeps L1 and L2 data caches alive.
|
|
*/
|
|
static inline void copy_page(void *to, void *from)
|
|
{
|
|
union register_pair dst, src;
|
|
|
|
dst.even = (unsigned long) to;
|
|
dst.odd = 0x1000;
|
|
src.even = (unsigned long) from;
|
|
src.odd = 0xb0001000;
|
|
|
|
asm volatile(
|
|
" mvcl %[dst],%[src]"
|
|
: [dst] "+&d" (dst.pair), [src] "+&d" (src.pair)
|
|
: : "memory", "cc");
|
|
}
|
|
|
|
#define clear_user_page(page, vaddr, pg) clear_page(page)
|
|
#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
|
|
|
|
#define vma_alloc_zeroed_movable_folio(vma, vaddr) \
|
|
vma_alloc_folio(GFP_HIGHUSER_MOVABLE | __GFP_ZERO, 0, vma, vaddr)
|
|
|
|
/*
|
|
* These are used to make use of C type-checking..
|
|
*/
|
|
|
|
typedef struct { unsigned long pgprot; } pgprot_t;
|
|
typedef struct { unsigned long pgste; } pgste_t;
|
|
typedef struct { unsigned long pte; } pte_t;
|
|
typedef struct { unsigned long pmd; } pmd_t;
|
|
typedef struct { unsigned long pud; } pud_t;
|
|
typedef struct { unsigned long p4d; } p4d_t;
|
|
typedef struct { unsigned long pgd; } pgd_t;
|
|
typedef pte_t *pgtable_t;
|
|
|
|
#define pgprot_val(x) ((x).pgprot)
|
|
#define pgste_val(x) ((x).pgste)
|
|
|
|
static inline unsigned long pte_val(pte_t pte)
|
|
{
|
|
return pte.pte;
|
|
}
|
|
|
|
static inline unsigned long pmd_val(pmd_t pmd)
|
|
{
|
|
return pmd.pmd;
|
|
}
|
|
|
|
static inline unsigned long pud_val(pud_t pud)
|
|
{
|
|
return pud.pud;
|
|
}
|
|
|
|
static inline unsigned long p4d_val(p4d_t p4d)
|
|
{
|
|
return p4d.p4d;
|
|
}
|
|
|
|
static inline unsigned long pgd_val(pgd_t pgd)
|
|
{
|
|
return pgd.pgd;
|
|
}
|
|
|
|
#define __pgste(x) ((pgste_t) { (x) } )
|
|
#define __pte(x) ((pte_t) { (x) } )
|
|
#define __pmd(x) ((pmd_t) { (x) } )
|
|
#define __pud(x) ((pud_t) { (x) } )
|
|
#define __p4d(x) ((p4d_t) { (x) } )
|
|
#define __pgd(x) ((pgd_t) { (x) } )
|
|
#define __pgprot(x) ((pgprot_t) { (x) } )
|
|
|
|
static inline void page_set_storage_key(unsigned long addr,
|
|
unsigned char skey, int mapped)
|
|
{
|
|
if (!mapped)
|
|
asm volatile(".insn rrf,0xb22b0000,%0,%1,8,0"
|
|
: : "d" (skey), "a" (addr));
|
|
else
|
|
asm volatile("sske %0,%1" : : "d" (skey), "a" (addr));
|
|
}
|
|
|
|
static inline unsigned char page_get_storage_key(unsigned long addr)
|
|
{
|
|
unsigned char skey;
|
|
|
|
asm volatile("iske %0,%1" : "=d" (skey) : "a" (addr));
|
|
return skey;
|
|
}
|
|
|
|
static inline int page_reset_referenced(unsigned long addr)
|
|
{
|
|
int cc;
|
|
|
|
asm volatile(
|
|
" rrbe 0,%[addr]\n"
|
|
CC_IPM(cc)
|
|
: CC_OUT(cc, cc)
|
|
: [addr] "a" (addr)
|
|
: CC_CLOBBER);
|
|
return CC_TRANSFORM(cc);
|
|
}
|
|
|
|
/* Bits int the storage key */
|
|
#define _PAGE_CHANGED 0x02 /* HW changed bit */
|
|
#define _PAGE_REFERENCED 0x04 /* HW referenced bit */
|
|
#define _PAGE_FP_BIT 0x08 /* HW fetch protection bit */
|
|
#define _PAGE_ACC_BITS 0xf0 /* HW access control bits */
|
|
|
|
struct page;
|
|
struct folio;
|
|
void arch_free_page(struct page *page, int order);
|
|
void arch_alloc_page(struct page *page, int order);
|
|
|
|
static inline int devmem_is_allowed(unsigned long pfn)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
#define HAVE_ARCH_FREE_PAGE
|
|
#define HAVE_ARCH_ALLOC_PAGE
|
|
|
|
int arch_make_folio_accessible(struct folio *folio);
|
|
#define HAVE_ARCH_MAKE_FOLIO_ACCESSIBLE
|
|
|
|
struct vm_layout {
|
|
unsigned long kaslr_offset;
|
|
unsigned long kaslr_offset_phys;
|
|
unsigned long identity_base;
|
|
unsigned long identity_size;
|
|
};
|
|
|
|
extern struct vm_layout vm_layout;
|
|
|
|
#define __kaslr_offset vm_layout.kaslr_offset
|
|
#define __kaslr_offset_phys vm_layout.kaslr_offset_phys
|
|
#define __identity_base vm_layout.identity_base
|
|
#define ident_map_size vm_layout.identity_size
|
|
|
|
static inline unsigned long kaslr_offset(void)
|
|
{
|
|
return __kaslr_offset;
|
|
}
|
|
|
|
extern int __kaslr_enabled;
|
|
static inline int kaslr_enabled(void)
|
|
{
|
|
if (IS_ENABLED(CONFIG_RANDOMIZE_BASE))
|
|
return __kaslr_enabled;
|
|
return 0;
|
|
}
|
|
|
|
#define __PAGE_OFFSET __identity_base
|
|
#define PAGE_OFFSET __PAGE_OFFSET
|
|
|
|
#ifdef __DECOMPRESSOR
|
|
|
|
#define __pa_nodebug(x) ((unsigned long)(x))
|
|
#define __pa(x) __pa_nodebug(x)
|
|
#define __pa32(x) __pa(x)
|
|
#define __va(x) ((void *)(unsigned long)(x))
|
|
|
|
#else /* __DECOMPRESSOR */
|
|
|
|
static inline unsigned long __pa_nodebug(unsigned long x)
|
|
{
|
|
if (x < __kaslr_offset)
|
|
return x - __identity_base;
|
|
return x - __kaslr_offset + __kaslr_offset_phys;
|
|
}
|
|
|
|
#ifdef CONFIG_DEBUG_VIRTUAL
|
|
|
|
unsigned long __phys_addr(unsigned long x, bool is_31bit);
|
|
|
|
#else /* CONFIG_DEBUG_VIRTUAL */
|
|
|
|
static inline unsigned long __phys_addr(unsigned long x, bool is_31bit)
|
|
{
|
|
return __pa_nodebug(x);
|
|
}
|
|
|
|
#endif /* CONFIG_DEBUG_VIRTUAL */
|
|
|
|
#define __pa(x) __phys_addr((unsigned long)(x), false)
|
|
#define __pa32(x) __phys_addr((unsigned long)(x), true)
|
|
#define __va(x) ((void *)((unsigned long)(x) + __identity_base))
|
|
|
|
#endif /* __DECOMPRESSOR */
|
|
|
|
#define phys_to_pfn(phys) ((phys) >> PAGE_SHIFT)
|
|
#define pfn_to_phys(pfn) ((pfn) << PAGE_SHIFT)
|
|
|
|
#define phys_to_folio(phys) page_folio(phys_to_page(phys))
|
|
#define folio_to_phys(page) pfn_to_phys(folio_pfn(folio))
|
|
|
|
static inline void *pfn_to_virt(unsigned long pfn)
|
|
{
|
|
return __va(pfn_to_phys(pfn));
|
|
}
|
|
|
|
static inline unsigned long virt_to_pfn(const void *kaddr)
|
|
{
|
|
return phys_to_pfn(__pa(kaddr));
|
|
}
|
|
|
|
#define pfn_to_kaddr(pfn) pfn_to_virt(pfn)
|
|
|
|
#define virt_to_page(kaddr) pfn_to_page(virt_to_pfn(kaddr))
|
|
#define page_to_virt(page) pfn_to_virt(page_to_pfn(page))
|
|
|
|
#define virt_addr_valid(kaddr) pfn_valid(phys_to_pfn(__pa_nodebug((unsigned long)(kaddr))))
|
|
|
|
#define VM_DATA_DEFAULT_FLAGS VM_DATA_FLAGS_NON_EXEC
|
|
|
|
#endif /* !__ASSEMBLY__ */
|
|
|
|
#include <asm-generic/memory_model.h>
|
|
#include <asm-generic/getorder.h>
|
|
|
|
#define AMODE31_SIZE (3 * PAGE_SIZE)
|
|
|
|
#define KERNEL_IMAGE_SIZE (512 * 1024 * 1024)
|
|
#define __NO_KASLR_START_KERNEL CONFIG_KERNEL_IMAGE_BASE
|
|
#define __NO_KASLR_END_KERNEL (__NO_KASLR_START_KERNEL + KERNEL_IMAGE_SIZE)
|
|
|
|
#define TEXT_OFFSET 0x100000
|
|
|
|
#endif /* _S390_PAGE_H */
|