• Peter Xu's avatar
    mm/mprotect: use long for page accountings and retval · a79390f5
    Peter Xu authored
    Switch to use type "long" for page accountings and retval across the whole
    procedure of change_protection().
    
    The change should have shrinked the possible maximum page number to be
    half comparing to previous (ULONG_MAX / 2), but it shouldn't overflow on
    any system either because the maximum possible pages touched by change
    protection should be ULONG_MAX / PAGE_SIZE.
    
    Two reasons to switch from "unsigned long" to "long":
    
      1. It suites better on count_vm_numa_events(), whose 2nd parameter takes
         a long type.
    
      2. It paves way for returning negative (error) values in the future.
    
    Currently the only caller that consumes this retval is change_prot_numa(),
    where the unsigned long was converted to an int.  Since at it, touching up
    the numa code to also take a long, so it'll avoid any possible overflow
    too during the int-size convertion.
    
    Link: https://lkml.kernel.org/r/20230104225207.1066932-3-peterx@redhat.comSigned-off-by: default avatarPeter Xu <peterx@redhat.com>
    Acked-by: default avatarMike Kravetz <mike.kravetz@oracle.com>
    Acked-by: default avatarJames Houghton <jthoughton@google.com>
    Cc: Andrea Arcangeli <aarcange@redhat.com>
    Cc: Axel Rasmussen <axelrasmussen@google.com>
    Cc: David Hildenbrand <david@redhat.com>
    Cc: Muchun Song <songmuchun@bytedance.com>
    Cc: Nadav Amit <nadav.amit@gmail.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    a79390f5
hugetlb.c 208 KB