• Aneesh Kumar K.V's avatar
    powerpc/mm/iommu: allow migration of cma allocated pages during mm_iommu_do_alloc · 678e174c
    Aneesh Kumar K.V authored
    The current code doesn't do page migration if the page allocated is a
    compound page.  With HugeTLB migration support, we can end up allocating
    hugetlb pages from CMA region.  Also, THP pages can be allocated from
    CMA region.  This patch updates the code to handle compound pages
    correctly.  The patch also switches to a single get_user_pages with the
    right count, instead of doing one get_user_pages per page.  That avoids
    reading page table multiple times.  This is done by using
    get_user_pages_longterm, because that also takes care of DAX backed
    pages.
    
    DAX pages lifetime is dictated by file system rules and as such, we need
    to make sure that we free these pages on operations like truncate and
    punch hole.  If we have long term pin on these pages, which are mostly
    return to userspace with elevated page count, the entity holding the
    long term pin may not be aware of the fact that file got truncated and
    the file system blocks possibly got reused.  That can result in
    corruption.
    
    The patch also converts the hpas member of mm_iommu_table_group_mem_t to
    a union.  We use the same storage location to store pointers to struct
    page.  We cannot update all the code path use struct page *, because we
    access hpas in real mode and we can't do that struct page * to pfn
    conversion in real mode.
    
    [aneesh.kumar@linux.ibm.com: address review feedback, update changelog]
      Link: http://lkml.kernel.org/r/20190227144736.5872-4-aneesh.kumar@linux.ibm.com
    Link: http://lkml.kernel.org/r/20190114095438.32470-5-aneesh.kumar@linux.ibm.comSigned-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
    Reviewed-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
    Cc: Alexey Kardashevskiy <aik@ozlabs.ru>
    Cc: Andrea Arcangeli <aarcange@redhat.com>
    Cc: David Gibson <david@gibson.dropbear.id.au>
    Cc: Michal Hocko <mhocko@kernel.org>
    Cc: Mel Gorman <mgorman@techsingularity.net>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    678e174c
mmu_context_iommu.c 11.2 KB