Re: [PATCH v6 5/6] tools/mm: make gup_bench a benchmark only tool

Mike Rapoport <[email protected]> Tue, 4 Aug 2026 12:31:20 +0300
Newsgroups gmane.linux.documentation,gmane.linux.kernel.mm,gmane.linux.kernel
Message-ID <[email protected]>
Hi Sarthak,

On Tue, Aug 04, 2026 at 01:04:13PM +0530, Sarthak Sharma wrote:
> Hi Mike!
> 
> On 8/3/26 2:30 PM, Mike Rapoport wrote:
> >  
> > And the limit checks seem wierd all over the place, like if we can loop
> > infinitely, why do we care about INT_MAX?
> 
> INT_MAX checks are there since nr_pages, nthreads and repeats are stored
> as int.
> 
> But yes I can keep the parameters which are not there in the ioctl ABI
> to be unsigned long, so these checks won't be required there.
> > 
> > And what exact limit ULONG_MAX / MB or SIZE_MAX / sizeof(ptread_t) are
> > supposed to express?
> 
> ULONG_MAX / MB prevents size *= MB from overflowing. SIZE_MAX /
> sizeof(ptread_t) prevents thread array allocation size from overflowing.

To me these checks seem overprotective from one side and not actually
serving a real purpose from the other.

Like e.g. requesting INT_MAX - 1 pages passes the check but it means almost 8TB
of memory and that's really wild.

I'd say let's keep things simple and if a user is stupid enough to run this
with peculiar command line just let it crash.

-- 
Sincerely yours,
Mike.