[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210330080856.14940-3-wangyanan55@huawei.com>
Date: Tue, 30 Mar 2021 16:08:48 +0800
From: Yanan Wang <wangyanan55@...wei.com>
To: Paolo Bonzini <pbonzini@...hat.com>,
Andrew Jones <drjones@...hat.com>, <kvm@...r.kernel.org>,
<linux-kselftest@...r.kernel.org>, <linux-kernel@...r.kernel.org>
CC: Ben Gardon <bgardon@...gle.com>,
Sean Christopherson <seanjc@...gle.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Peter Xu <peterx@...hat.com>, "Ingo Molnar" <mingo@...nel.org>,
Adrian Hunter <adrian.hunter@...el.com>,
Jiri Olsa <jolsa@...hat.com>,
Arnaldo Carvalho de Melo <acme@...hat.com>,
Arnd Bergmann <arnd@...db.de>,
Michael Kerrisk <mtk.manpages@...il.com>,
Thomas Gleixner <tglx@...utronix.de>,
<wanghaibin.wang@...wei.com>, <yuzenghui@...wei.com>,
Yanan Wang <wangyanan55@...wei.com>
Subject: [PATCH v6 02/10] mm/hugetlb: Add a macro to get HUGETLB page sizes for mmap
We know that if a system supports multiple hugetlb page sizes,
the desired hugetlb page size can be specified in bits [26:31]
of the mmap() flag arguments. The value in these 6 bits will be
the shift of each hugetlb page size.
So add a macro to get the page size shift and then calculate the
corresponding hugetlb page size, using flag x.
Cc: Ben Gardon <bgardon@...gle.com>
Cc: Ingo Molnar <mingo@...nel.org>
Cc: Adrian Hunter <adrian.hunter@...el.com>
Cc: Jiri Olsa <jolsa@...hat.com>
Cc: Arnaldo Carvalho de Melo <acme@...hat.com>
Cc: Arnd Bergmann <arnd@...db.de>
Cc: Michael Kerrisk <mtk.manpages@...il.com>
Cc: Thomas Gleixner <tglx@...utronix.de>
Suggested-by: Ben Gardon <bgardon@...gle.com>
Signed-off-by: Yanan Wang <wangyanan55@...wei.com>
Reviewed-by: Ben Gardon <bgardon@...gle.com>
---
include/uapi/linux/mman.h | 2 ++
tools/include/uapi/linux/mman.h | 2 ++
2 files changed, 4 insertions(+)
diff --git a/include/uapi/linux/mman.h b/include/uapi/linux/mman.h
index f55bc680b5b0..d72df73b182d 100644
--- a/include/uapi/linux/mman.h
+++ b/include/uapi/linux/mman.h
@@ -41,4 +41,6 @@
#define MAP_HUGE_2GB HUGETLB_FLAG_ENCODE_2GB
#define MAP_HUGE_16GB HUGETLB_FLAG_ENCODE_16GB
+#define MAP_HUGE_PAGE_SIZE(x) (1ULL << ((x >> MAP_HUGE_SHIFT) & MAP_HUGE_MASK))
+
#endif /* _UAPI_LINUX_MMAN_H */
diff --git a/tools/include/uapi/linux/mman.h b/tools/include/uapi/linux/mman.h
index f55bc680b5b0..d72df73b182d 100644
--- a/tools/include/uapi/linux/mman.h
+++ b/tools/include/uapi/linux/mman.h
@@ -41,4 +41,6 @@
#define MAP_HUGE_2GB HUGETLB_FLAG_ENCODE_2GB
#define MAP_HUGE_16GB HUGETLB_FLAG_ENCODE_16GB
+#define MAP_HUGE_PAGE_SIZE(x) (1ULL << ((x >> MAP_HUGE_SHIFT) & MAP_HUGE_MASK))
+
#endif /* _UAPI_LINUX_MMAN_H */
--
2.19.1
Powered by blists - more mailing lists