On Wed, May 29, 2024 at 09:58:35AM +0000, Christophe Leroy wrote:
Yes I now have :
+#define _PAGE_HSIZE_MSK (_PAGE_U0 | _PAGE_U1 | _PAGE_U2 | _PAGE_U3)
+#define _PAGE_HSIZE_SHIFT 14
+#define _PAGE_HSIZE_SHIFT_OFFSET 20
and have added a helper to avoid doing the calculation at several places:
+static inline unsigned long pte_huge_size(pte_t pte)
+{
+ pte_basic_t val = pte_val(pte);
+
+ return 1UL << (((val & _PAGE_HSIZE_MSK) >> _PAGE_HSIZE_SHIFT) +
_PAGE_HSIZE_SHIFT_OFFSET);
+}
Great, this looks much better.
That's what I did before but it didn't work. The problem is that
pte_advance_pfn() takes a long not a long long:
static inline pte_t pte_advance_pfn(pte_t pte, unsigned long nr)
{
return __pte(pte_val(pte) + (nr << PFN_PTE_SHIFT));
}
And when I called it with nr = PMD_SIZE / PAGE_SIZE = 2M / 4k = 512, as
we have PFN_PTE_SHIFT = 24, I got 512 << 24 = 0
Ah, I missed that trickery with the types.
Thanks!
--
Oscar Salvador
SUSE Labs