mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 06:44:00 -04:00
Pull MM updates from Andrew Morton: - "maple_tree: Replace big node with maple copy" (Liam Howlett) Mainly prepararatory work for ongoing development but it does reduce stack usage and is an improvement. - "mm, swap: swap table phase III: remove swap_map" (Kairui Song) Offers memory savings by removing the static swap_map. It also yields some CPU savings and implements several cleanups. - "mm: memfd_luo: preserve file seals" (Pratyush Yadav) File seal preservation to LUO's memfd code - "mm: zswap: add per-memcg stat for incompressible pages" (Jiayuan Chen) Additional userspace stats reportng to zswap - "arch, mm: consolidate empty_zero_page" (Mike Rapoport) Some cleanups for our handling of ZERO_PAGE() and zero_pfn - "mm/kmemleak: Improve scan_should_stop() implementation" (Zhongqiu Han) A robustness improvement and some cleanups in the kmemleak code - "Improve khugepaged scan logic" (Vernon Yang) Improve khugepaged scan logic and reduce CPU consumption by prioritizing scanning tasks that access memory frequently - "Make KHO Stateless" (Jason Miu) Simplify Kexec Handover by transitioning KHO from an xarray-based metadata tracking system with serialization to a radix tree data structure that can be passed directly to the next kernel - "mm: vmscan: add PID and cgroup ID to vmscan tracepoints" (Thomas Ballasi and Steven Rostedt) Enhance vmscan's tracepointing - "mm: arch/shstk: Common shadow stack mapping helper and VM_NOHUGEPAGE" (Catalin Marinas) Cleanup for the shadow stack code: remove per-arch code in favour of a generic implementation - "Fix KASAN support for KHO restored vmalloc regions" (Pasha Tatashin) Fix a WARN() which can be emitted the KHO restores a vmalloc area - "mm: Remove stray references to pagevec" (Tal Zussman) Several cleanups, mainly udpating references to "struct pagevec", which became folio_batch three years ago - "mm: Eliminate fake head pages from vmemmap optimization" (Kiryl Shutsemau) Simplify the HugeTLB vmemmap optimization (HVO) by changing how tail pages encode their relationship to the head page - "mm/damon/core: improve DAMOS quota efficiency for core layer filters" (SeongJae Park) Improve two problematic behaviors of DAMOS that makes it less efficient when core layer filters are used - "mm/damon: strictly respect min_nr_regions" (SeongJae Park) Improve DAMON usability by extending the treatment of the min_nr_regions user-settable parameter - "mm/page_alloc: pcp locking cleanup" (Vlastimil Babka) The proper fix for a previously hotfixed SMP=n issue. Code simplifications and cleanups ensued - "mm: cleanups around unmapping / zapping" (David Hildenbrand) A bunch of cleanups around unmapping and zapping. Mostly simplifications, code movements, documentation and renaming of zapping functions - "support batched checking of the young flag for MGLRU" (Baolin Wang) Batched checking of the young flag for MGLRU. It's part cleanups; one benchmark shows large performance benefits for arm64 - "memcg: obj stock and slab stat caching cleanups" (Johannes Weiner) memcg cleanup and robustness improvements - "Allow order zero pages in page reporting" (Yuvraj Sakshith) Enhance free page reporting - it is presently and undesirably order-0 pages when reporting free memory. - "mm: vma flag tweaks" (Lorenzo Stoakes) Cleanup work following from the recent conversion of the VMA flags to a bitmap - "mm/damon: add optional debugging-purpose sanity checks" (SeongJae Park) Add some more developer-facing debug checks into DAMON core - "mm/damon: test and document power-of-2 min_region_sz requirement" (SeongJae Park) An additional DAMON kunit test and makes some adjustments to the addr_unit parameter handling - "mm/damon/core: make passed_sample_intervals comparisons overflow-safe" (SeongJae Park) Fix a hard-to-hit time overflow issue in DAMON core - "mm/damon: improve/fixup/update ratio calculation, test and documentation" (SeongJae Park) A batch of misc/minor improvements and fixups for DAMON - "mm: move vma_(kernel|mmu)_pagesize() out of hugetlb.c" (David Hildenbrand) Fix a possible issue with dax-device when CONFIG_HUGETLB=n. Some code movement was required. - "zram: recompression cleanups and tweaks" (Sergey Senozhatsky) A somewhat random mix of fixups, recompression cleanups and improvements in the zram code - "mm/damon: support multiple goal-based quota tuning algorithms" (SeongJae Park) Extend DAMOS quotas goal auto-tuning to support multiple tuning algorithms that users can select - "mm: thp: reduce unnecessary start_stop_khugepaged()" (Breno Leitao) Fix the khugpaged sysfs handling so we no longer spam the logs with reams of junk when starting/stopping khugepaged - "mm: improve map count checks" (Lorenzo Stoakes) Provide some cleanups and slight fixes in the mremap, mmap and vma code - "mm/damon: support addr_unit on default monitoring targets for modules" (SeongJae Park) Extend the use of DAMON core's addr_unit tunable - "mm: khugepaged cleanups and mTHP prerequisites" (Nico Pache) Cleanups to khugepaged and is a base for Nico's planned khugepaged mTHP support - "mm: memory hot(un)plug and SPARSEMEM cleanups" (David Hildenbrand) Code movement and cleanups in the memhotplug and sparsemem code - "mm: remove CONFIG_ARCH_ENABLE_MEMORY_HOTREMOVE and cleanup CONFIG_MIGRATION" (David Hildenbrand) Rationalize some memhotplug Kconfig support - "change young flag check functions to return bool" (Baolin Wang) Cleanups to change all young flag check functions to return bool - "mm/damon/sysfs: fix memory leak and NULL dereference issues" (Josh Law and SeongJae Park) Fix a few potential DAMON bugs - "mm/vma: convert vm_flags_t to vma_flags_t in vma code" (Lorenzo Stoakes) Convert a lot of the existing use of the legacy vm_flags_t data type to the new vma_flags_t type which replaces it. Mainly in the vma code. - "mm: expand mmap_prepare functionality and usage" (Lorenzo Stoakes) Expand the mmap_prepare functionality, which is intended to replace the deprecated f_op->mmap hook which has been the source of bugs and security issues for some time. Cleanups, documentation, extension of mmap_prepare into filesystem drivers - "mm/huge_memory: refactor zap_huge_pmd()" (Lorenzo Stoakes) Simplify and clean up zap_huge_pmd(). Additional cleanups around vm_normal_folio_pmd() and the softleaf functionality are performed. * tag 'mm-stable-2026-04-13-21-45' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (369 commits) mm: fix deferred split queue races during migration mm/khugepaged: fix issue with tracking lock mm/huge_memory: add and use has_deposited_pgtable() mm/huge_memory: add and use normal_or_softleaf_folio_pmd() mm: add softleaf_is_valid_pmd_entry(), pmd_to_softleaf_folio() mm/huge_memory: separate out the folio part of zap_huge_pmd() mm/huge_memory: use mm instead of tlb->mm mm/huge_memory: remove unnecessary sanity checks mm/huge_memory: deduplicate zap deposited table call mm/huge_memory: remove unnecessary VM_BUG_ON_PAGE() mm/huge_memory: add a common exit path to zap_huge_pmd() mm/huge_memory: handle buggy PMD entry in zap_huge_pmd() mm/huge_memory: have zap_huge_pmd return a boolean, add kdoc mm/huge: avoid big else branch in zap_huge_pmd() mm/huge_memory: simplify vma_is_specal_huge() mm: on remap assert that input range within the proposed VMA mm: add mmap_action_map_kernel_pages[_full]() uio: replace deprecated mmap hook with mmap_prepare in uio_info drivers: hv: vmbus: replace deprecated mmap hook with mmap_prepare mm: allow handling of stacked mmap_prepare hooks in more drivers ...
226 lines
5.8 KiB
C
226 lines
5.8 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _ASM_POWERPC_PGTABLE_H
|
|
#define _ASM_POWERPC_PGTABLE_H
|
|
|
|
#ifndef __ASSEMBLER__
|
|
#include <linux/mmdebug.h>
|
|
#include <linux/mmzone.h>
|
|
#include <asm/processor.h> /* For TASK_SIZE */
|
|
#include <asm/mmu.h>
|
|
#include <asm/page.h>
|
|
#include <asm/tlbflush.h>
|
|
|
|
struct mm_struct;
|
|
|
|
#endif /* !__ASSEMBLER__ */
|
|
|
|
#ifdef CONFIG_PPC_BOOK3S
|
|
#include <asm/book3s/pgtable.h>
|
|
#else
|
|
#include <asm/nohash/pgtable.h>
|
|
#endif /* !CONFIG_PPC_BOOK3S */
|
|
|
|
/* Make modules code happy. We don't set RO yet */
|
|
#define PAGE_KERNEL_EXEC PAGE_KERNEL_X
|
|
|
|
/* Advertise special mapping type for AGP */
|
|
#define PAGE_AGP (PAGE_KERNEL_NC)
|
|
#define HAVE_PAGE_AGP
|
|
|
|
#ifndef __ASSEMBLER__
|
|
|
|
#define PFN_PTE_SHIFT PTE_RPN_SHIFT
|
|
|
|
void set_ptes(struct mm_struct *mm, unsigned long addr, pte_t *ptep,
|
|
pte_t pte, unsigned int nr);
|
|
#define set_ptes set_ptes
|
|
void set_pte_at_unchecked(struct mm_struct *mm, unsigned long addr,
|
|
pte_t *ptep, pte_t pte);
|
|
#define update_mmu_cache(vma, addr, ptep) \
|
|
update_mmu_cache_range(NULL, vma, addr, ptep, 1)
|
|
|
|
#ifndef MAX_PTRS_PER_PGD
|
|
#define MAX_PTRS_PER_PGD PTRS_PER_PGD
|
|
#endif
|
|
|
|
/* Keep this as a macro to avoid include dependency mess */
|
|
#define pte_page(x) pfn_to_page(pte_pfn(x))
|
|
|
|
static inline unsigned long pte_pfn(pte_t pte)
|
|
{
|
|
return (pte_val(pte) & PTE_RPN_MASK) >> PTE_RPN_SHIFT;
|
|
}
|
|
|
|
/*
|
|
* Select all bits except the pfn
|
|
*/
|
|
#define pte_pgprot pte_pgprot
|
|
static inline pgprot_t pte_pgprot(pte_t pte)
|
|
{
|
|
unsigned long pte_flags;
|
|
|
|
pte_flags = pte_val(pte) & ~PTE_RPN_MASK;
|
|
return __pgprot(pte_flags);
|
|
}
|
|
|
|
#ifdef CONFIG_PPC64
|
|
#define pmd_pgprot pmd_pgprot
|
|
static inline pgprot_t pmd_pgprot(pmd_t pmd)
|
|
{
|
|
return pte_pgprot(pmd_pte(pmd));
|
|
}
|
|
|
|
#define pud_pgprot pud_pgprot
|
|
static inline pgprot_t pud_pgprot(pud_t pud)
|
|
{
|
|
return pte_pgprot(pud_pte(pud));
|
|
}
|
|
#endif /* CONFIG_PPC64 */
|
|
|
|
static inline pgprot_t pgprot_nx(pgprot_t prot)
|
|
{
|
|
return pte_pgprot(pte_exprotect(__pte(pgprot_val(prot))));
|
|
}
|
|
#define pgprot_nx pgprot_nx
|
|
|
|
#ifndef pmd_page_vaddr
|
|
static inline const void *pmd_page_vaddr(pmd_t pmd)
|
|
{
|
|
return __va(pmd_val(pmd) & ~PMD_MASKED_BITS);
|
|
}
|
|
#define pmd_page_vaddr pmd_page_vaddr
|
|
#endif
|
|
|
|
extern pgd_t swapper_pg_dir[];
|
|
|
|
extern void paging_init(void);
|
|
void poking_init(void);
|
|
|
|
extern unsigned long ioremap_bot;
|
|
extern const pgprot_t protection_map[16];
|
|
|
|
/* can we use this in kvm */
|
|
unsigned long vmalloc_to_phys(void *vmalloc_addr);
|
|
|
|
void pgtable_cache_add(unsigned int shift);
|
|
|
|
#ifdef CONFIG_PPC32
|
|
void __init *early_alloc_pgtable(unsigned long size);
|
|
#endif
|
|
pte_t *early_pte_alloc_kernel(pmd_t *pmdp, unsigned long va);
|
|
|
|
#if defined(CONFIG_STRICT_KERNEL_RWX) || defined(CONFIG_PPC32)
|
|
void mark_initmem_nx(void);
|
|
#else
|
|
static inline void mark_initmem_nx(void) { }
|
|
#endif
|
|
|
|
#define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
|
|
int ptep_set_access_flags(struct vm_area_struct *vma, unsigned long address,
|
|
pte_t *ptep, pte_t entry, int dirty);
|
|
|
|
pgprot_t __phys_mem_access_prot(unsigned long pfn, unsigned long size,
|
|
pgprot_t vma_prot);
|
|
|
|
struct file;
|
|
static inline pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
|
|
unsigned long size, pgprot_t vma_prot)
|
|
{
|
|
return __phys_mem_access_prot(pfn, size, vma_prot);
|
|
}
|
|
#define __HAVE_PHYS_MEM_ACCESS_PROT
|
|
|
|
void __update_mmu_cache(struct vm_area_struct *vma, unsigned long address, pte_t *ptep);
|
|
|
|
/*
|
|
* This gets called at the end of handling a page fault, when
|
|
* the kernel has put a new PTE into the page table for the process.
|
|
* We use it to ensure coherency between the i-cache and d-cache
|
|
* for the page which has just been mapped in.
|
|
* On machines which use an MMU hash table, we use this to put a
|
|
* corresponding HPTE into the hash table ahead of time, instead of
|
|
* waiting for the inevitable extra hash-table miss exception.
|
|
*/
|
|
static inline void update_mmu_cache_range(struct vm_fault *vmf,
|
|
struct vm_area_struct *vma, unsigned long address,
|
|
pte_t *ptep, unsigned int nr)
|
|
{
|
|
if ((mmu_has_feature(MMU_FTR_HPTE_TABLE) && !radix_enabled()) ||
|
|
(IS_ENABLED(CONFIG_PPC_E500) && IS_ENABLED(CONFIG_HUGETLB_PAGE)))
|
|
__update_mmu_cache(vma, address, ptep);
|
|
}
|
|
|
|
/*
|
|
* When used, PTE_FRAG_NR is defined in subarch pgtable.h
|
|
* so we are sure it is included when arriving here.
|
|
*/
|
|
#ifdef PTE_FRAG_NR
|
|
static inline void *pte_frag_get(mm_context_t *ctx)
|
|
{
|
|
return ctx->pte_frag;
|
|
}
|
|
|
|
static inline void pte_frag_set(mm_context_t *ctx, void *p)
|
|
{
|
|
ctx->pte_frag = p;
|
|
}
|
|
#else
|
|
#define PTE_FRAG_NR 1
|
|
#define PTE_FRAG_SIZE_SHIFT PAGE_SHIFT
|
|
#define PTE_FRAG_SIZE (1UL << PTE_FRAG_SIZE_SHIFT)
|
|
|
|
static inline void *pte_frag_get(mm_context_t *ctx)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
static inline void pte_frag_set(mm_context_t *ctx, void *p)
|
|
{
|
|
}
|
|
#endif
|
|
|
|
#define pmd_pgtable pmd_pgtable
|
|
static inline pgtable_t pmd_pgtable(pmd_t pmd)
|
|
{
|
|
return (pgtable_t)pmd_page_vaddr(pmd);
|
|
}
|
|
|
|
#ifdef CONFIG_PPC64
|
|
int __meminit vmemmap_populated(unsigned long vmemmap_addr, int vmemmap_map_size);
|
|
bool altmap_cross_boundary(struct vmem_altmap *altmap, unsigned long start,
|
|
unsigned long page_size);
|
|
/*
|
|
* mm/memory_hotplug.c:mhp_supports_memmap_on_memory goes into details
|
|
* some of the restrictions. We don't check for PMD_SIZE because our
|
|
* vmemmap allocation code can fallback correctly. The pageblock
|
|
* alignment requirement is met using altmap->reserve blocks.
|
|
*/
|
|
#define arch_supports_memmap_on_memory arch_supports_memmap_on_memory
|
|
static inline bool arch_supports_memmap_on_memory(unsigned long vmemmap_size)
|
|
{
|
|
if (!radix_enabled())
|
|
return false;
|
|
/*
|
|
* With 4K page size and 2M PMD_SIZE, we can align
|
|
* things better with memory block size value
|
|
* starting from 128MB. Hence align things with PMD_SIZE.
|
|
*/
|
|
if (IS_ENABLED(CONFIG_PPC_4K_PAGES))
|
|
return IS_ALIGNED(vmemmap_size, PMD_SIZE);
|
|
return true;
|
|
}
|
|
|
|
#endif /* CONFIG_PPC64 */
|
|
|
|
#ifndef pmd_user_accessible_page
|
|
#define pmd_user_accessible_page(pmd, addr) false
|
|
#endif
|
|
|
|
#ifndef pud_user_accessible_page
|
|
#define pud_user_accessible_page(pud, addr) false
|
|
#endif
|
|
|
|
#endif /* __ASSEMBLER__ */
|
|
|
|
#endif /* _ASM_POWERPC_PGTABLE_H */
|