[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CADrL8HUmAuez9Zighe21DVB6KxvUMUx6ONvwEyxovOq0vMHeJw@mail.gmail.com>
Date: Thu, 5 Jan 2023 01:51:19 +0000
From: James Houghton <jthoughton@...gle.com>
To: Peter Xu <peterx@...hat.com>
Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org,
Mike Kravetz <mike.kravetz@...cle.com>,
Muchun Song <songmuchun@...edance.com>,
Nadav Amit <nadav.amit@...il.com>,
Andrea Arcangeli <aarcange@...hat.com>,
David Hildenbrand <david@...hat.com>,
Axel Rasmussen <axelrasmussen@...gle.com>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH 2/3] mm/mprotect: Use long for page accountings and retval
On Wed, Jan 4, 2023 at 10:52 PM Peter Xu <peterx@...hat.com> 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.
>
> 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.
>
> Signed-off-by: Peter Xu <peterx@...hat.com>
> ---
> include/linux/hugetlb.h | 4 ++--
> include/linux/mm.h | 2 +-
> mm/hugetlb.c | 4 ++--
> mm/mempolicy.c | 2 +-
> mm/mprotect.c | 26 +++++++++++++-------------
> 5 files changed, 19 insertions(+), 19 deletions(-)
Acked-by: James Houghton <jthoughton@...gle.com>
Powered by blists - more mailing lists