[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z6-djlOXYTDU12mc@casper.infradead.org>
Date: Fri, 14 Feb 2025 19:46:22 +0000
From: Matthew Wilcox <willy@...radead.org>
To: Alex Williamson <alex.williamson@...hat.com>
Cc: kvm@...r.kernel.org, linux-kernel@...r.kernel.org, peterx@...hat.com,
mitchell.augustin@...onical.com, clg@...hat.com,
akpm@...ux-foundation.org, linux-mm@...ck.org
Subject: Re: [PATCH 5/5] vfio/type1: Use mapping page mask for pfnmaps
On Wed, Feb 05, 2025 at 04:17:21PM -0700, Alex Williamson wrote:
> + if (is_invalid_reserved_pfn(*pfn)) {
> + unsigned long epfn;
> +
> + epfn = (((*pfn << PAGE_SHIFT) + ~pgmask + 1)
> + & pgmask) >> PAGE_SHIFT;
> + ret = min_t(int, npages, epfn - *pfn);
You've really made life hard for yourself by passing around a page mask
instead of an order (ie 0/PMD_ORDER/PUD_ORDER). Why not:
epfn = round_up(*pfn + 1, 1 << order);
Although if you insist on passing around a mask, this could be:
unsigned long sz = (~pgmask >> PAGE_SHIFT) + 1;
unsigned long epfn = round_up(*pfn + 1, sz)
Powered by blists - more mailing lists