Documentation/translations/zh_CN/mm/split_page_table_lock.rst
Source file repositories/reference/linux-study-clean/Documentation/translations/zh_CN/mm/split_page_table_lock.rst
File Facts
- System
- Linux kernel
- Corpus path
Documentation/translations/zh_CN/mm/split_page_table_lock.rst- Extension
.rst- Size
- 3591 bytes
- Lines
- 97
- Domain
- Support Tooling And Documentation
- Bucket
- Documentation
- Inferred role
- Support Tooling And Documentation: documentation
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
:Original: Documentation/mm/split_page_table_lock.rst
:翻译:
司延腾 Yanteng Si <siyanteng@loongson.cn>
:校译:
=================================
分页表锁(split page table lock)
=================================
最初,mm->page_table_lock spinlock保护了mm_struct的所有页表。但是这种方
法导致了多线程应用程序的缺页异常可扩展性差,因为对锁的争夺很激烈。为了提高可扩
展性,我们引入了分页表锁。
有了分页表锁,我们就有了单独的每张表锁来顺序化对表的访问。目前,我们对PTE和
PMD表使用分页锁。对高层表的访问由mm->page_table_lock保护。
有一些辅助工具来锁定/解锁一个表和其他访问器函数:
- pte_offset_map_lock()
映射pte并获取PTE表锁,返回所取锁的指针;
- pte_unmap_unlock()
解锁和解映射PTE表;
- pte_alloc_map_lock()
如果需要的话,分配PTE表并获取锁,如果分配失败,返回已获取的锁的指针
或NULL;
- pte_lockptr()
返回指向PTE表锁的指针;
- pmd_lock()
取得PMD表锁,返回所取锁的指针。
- pmd_lockptr()
返回指向PMD表锁的指针;
如果CONFIG_SPLIT_PTLOCK_CPUS(通常为4)小于或等于NR_CPUS,则在编译
时启用PTE表的分页表锁。如果分页锁被禁用,所有的表都由mm->page_table_lock
来保护。
如果PMD表启用了分页锁,并且架构支持它,那么PMD表的分页锁就会被启用(见
下文)。
Hugetlb 和分页表锁
==================
Hugetlb可以支持多种页面大小。我们只对PMD级别使用分页锁,但不对PUD使用。
Hugetlb特定的辅助函数:
- huge_pte_lock()
对PMD_SIZE页面采取pmd分割锁,否则mm->page_table_lock;
- huge_pte_lockptr()
返回指向表锁的指针。
架构对分页表锁的支持
====================
没有必要特别启用PTE分页表锁:所有需要的东西都由pagetable_pte_ctor()
和pagetable_pte_dtor()完成,它们必须在PTE表分配/释放时被调用。
确保架构不使用slab分配器来分配页表:slab使用page->slab_cache来分配其页
面。这个区域与page->ptl共享存储。
PMD分页锁只有在你有两个以上的页表级别时才有意义。
启用PMD分页锁需要在PMD表分配时调用pagetable_pmd_ctor(),在释放时调
用pagetable_pmd_dtor()。
分配通常发生在pmd_alloc_one()中,释放发生在pmd_free()和pmd_free_tlb()
Annotation
- Atlas domain: Support Tooling And Documentation / Documentation.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.