Hi Zi,
Thanks for the patch.
I have a nit suggestion to centralize some of the macro definitions for better consistency and reusability.
On [Date of patch], Zi Yan wrote:
diff --git a/tools/testing/selftests/mm/vm_util.c b/tools/testing/selftests/mm/vm_util.c ... +#define PGMAP_PRESENT (1UL << 63) +#define KPF_COMPOUND_HEAD (1UL << 15) +#define KPF_COMPOUND_TAIL (1UL << 16) +#define KPF_THP (1UL << 22) +#define PFN_MASK ((1UL<<55)-1)
Currently, these macros and `PGMAP_PRESENT` are defined locally in `vm_util.c`. It would be cleaner to move them to the shared header `vm_util.h`.
This would also allow us to consistently use `PM_PRESENT` (from the header) instead of the local `PGMAP_PRESENT` duplicate. I noticed the patch is already moving in this direction, and we can complete this cleanup.
How about a change like this?
--- a/tools/testing/selftests/mm/vm_util.c +++ b/tools/testing/selftests/mm/vm_util.c @@ -17,17 +17,6 @@ #define STATUS_FILE_PATH "/proc/self/status" #define MAX_LINE_LENGTH 500
-#define PGMAP_PRESENT (1UL << 63) -#define KPF_COMPOUND_HEAD (1UL << 15) -#define KPF_COMPOUND_TAIL (1UL << 16) -#define KPF_THP (1UL << 22) -#define PFN_MASK ((1UL<<55)-1) - unsigned int __page_size; unsigned int __page_shift;
@@ -360,7 +349,7 @@ static int get_page_flags(uint64_t vpn, int pagemap_file, int kpageflags_file, * Treat non-present page as a page without any flag, so that * gather_folio_orders() just record the current folio order. */ - if (!(pfn & PGMAP_PRESENT)) { + if (!(pfn & PM_PRESENT)) { *flags = 0; return 0; } --- a/tools/testing/selftests/mm/vm_util.h +++ b/tools/testing/selftests/mm/vm_util.h @@ -17,6 +17,11 @@ #define PM_FILE BIT_ULL(61) #define PM_SWAP BIT_ULL(62) #define PM_PRESENT BIT_ULL(63) +#define KPF_COMPOUND_HEAD (1UL << 15) +#define KPF_COMPOUND_TAIL (1UL << 16) +#define KPF_THP (1UL << 22) +#define PFN_MASK ((1UL<<55)-1)
extern unsigned int __page_size; extern unsigned int __page_shift;
Best regards, wang lian