Re: [PATCH 2/3] mm/mprotect: Use long for page accountings and retval

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 04.01.23 23:52, Peter Xu wrote:
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.

Yeah, highly unlikely.


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.

I'm wondering if we should just return the number of changed pages via a separate pointer and later using an int for returning errors -- when touching this interface already.

Only who's actually interested in the number of pages would pass a pointer to an unsigned long (NUMA).

And code that expects that there never ever are failures (mprotect, NUMA) could simply check for WARN_ON_ONCE(ret).

I assume you evaluated that option as well, what was your conclusion?

--
Thanks,

David / dhildenb





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux