[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <623c315b-b64a-4bb0-a5d6-e3a2011aa55a@redhat.com>
Date: Tue, 5 Aug 2025 15:37:43 +0200
From: David Hildenbrand <david@...hat.com>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Alex Williamson <alex.williamson@...hat.com>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"lizhe.67@...edance.com" <lizhe.67@...edance.com>,
Jason Gunthorpe <jgg@...dia.com>
Subject: Re: [GIT PULL] VFIO updates for v6.17-rc1
On 05.08.25 15:28, Linus Torvalds wrote:
> On Tue, 5 Aug 2025 at 16:20, David Hildenbrand <david@...hat.com> wrote:
>>
>> I think that would work, and we could limit the section check to the
>> problematic case only (sparsemem without VMEMMAP).
>
> We really don't need to, because unlike the nth_page() thing, the
> compiler can see the logic and see "it's always zero".
Yeah, realized that later.
>
> And in the complex case (ie actual sparsemem without VMEMMAP), the
> page_section() test is at least trivial, unlike the whole "turn it
> into a pfn and back".
>
> Because that "turn it into a pfn and back" is actually a really quite
> complicated operation (and the compiler won't be able to optimize that
> one much, so I'm pretty sure it generates horrific code).
Yes, that's why I hate folio_page_idx() so much on !VMEMMAP
#define folio_page_idx(folio, p) (page_to_pfn(p) - folio_pfn(folio))
>
> I wish we didn't have nth_page() at all. I really don't think it's a
> valid operation. It's been around forever, but I think it was broken
> as introduced, exactly because I don't think you can validly even have
> allocations that cross section boundaries.
Ordinary buddy allocations cannot exceed a memory section, but hugetlb and
dax can with gigantic folios ... :(
We had some weird bugs with that, because people keep forgetting that you
cannot just use page++ unconditionally with such folios.
Anyhow, thanks Linus!
--
Cheers,
David / dhildenb
Powered by blists - more mailing lists