• Yin Fengwei's avatar
    mm: mlock: update mlock_pte_range to handle large folio · dc68badc
    Yin Fengwei authored
    Current kernel only lock base size folio during mlock syscall.
    Add large folio support with following rules:
      - Only mlock large folio when it's in VM_LOCKED VMA range
        and fully mapped to page table.
    
        fully mapped folio is required as if folio is not fully
        mapped to a VM_LOCKED VMA, if system is in memory pressure,
        page reclaim is allowed to pick up this folio, split it
        and reclaim the pages which are not in VM_LOCKED VMA.
    
      - munlock will apply to the large folio which is in VMA range
        or cross the VMA boundary.
    
        This is required to handle the case that the large folio is
        mlocked, later the VMA is split in the middle of large folio.
    
    Link: https://lkml.kernel.org/r/20230918073318.1181104-4-fengwei.yin@intel.comSigned-off-by: default avatarYin Fengwei <fengwei.yin@intel.com>
    Cc: David Hildenbrand <david@redhat.com>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
    Cc: Ryan Roberts <ryan.roberts@arm.com>
    Cc: Yang Shi <shy828301@gmail.com>
    Cc: Yosry Ahmed <yosryahmed@google.com>
    Cc: Yu Zhao <yuzhao@google.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    dc68badc
mlock.c 21 KB