From: Konstantin Belousov <k...@freebsd.org>

Created with shm_open2(SHM_LARGEPAGE) and then configured with
FIOSSHMLPGCNF ioctl, largepages posix shared memory objects guarantee
that all userspace mappings of it are served by superpage non-managed
mappings.

Only amd64 for now, both 2M and 1G superpages can be requested, the
later requires CPU feature.

Reviewed by:    markj
Tested by:      pho
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D24652
---
 newlib/libc/sys/rtems/include/sys/filio.h |  3 +++
 newlib/libc/sys/rtems/include/sys/mman.h  | 13 ++++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/newlib/libc/sys/rtems/include/sys/filio.h 
b/newlib/libc/sys/rtems/include/sys/filio.h
index c5cf3d443..3eea7a7ac 100644
--- a/newlib/libc/sys/rtems/include/sys/filio.h
+++ b/newlib/libc/sys/rtems/include/sys/filio.h
@@ -70,6 +70,9 @@ struct fiobmap2_arg {
 };
 /* Get the file's bmap info for the logical block bn. */
 #define        FIOBMAP2        _IOWR('f', 99, struct fiobmap2_arg)
+/* POSIX shm largepage set/get config */
+#define        FIOSSHMLPGCNF   _IOW('f', 100, struct shm_largepage_conf)
+#define        FIOGSHMLPGCNF   _IOR('f', 101, struct shm_largepage_conf)
 
 #ifdef _KERNEL
 #ifdef COMPAT_FREEBSD32
diff --git a/newlib/libc/sys/rtems/include/sys/mman.h 
b/newlib/libc/sys/rtems/include/sys/mman.h
index 6d861422d..d726a80d6 100644
--- a/newlib/libc/sys/rtems/include/sys/mman.h
+++ b/newlib/libc/sys/rtems/include/sys/mman.h
@@ -192,6 +192,17 @@
  */
 #define        SHM_ALLOW_SEALING               0x00000001
 #define        SHM_GROW_ON_WRITE               0x00000002
+#define        SHM_LARGEPAGE                   0x00000004
+
+#define        SHM_LARGEPAGE_ALLOC_DEFAULT     0
+#define        SHM_LARGEPAGE_ALLOC_NOWAIT      1
+#define        SHM_LARGEPAGE_ALLOC_HARD        2
+
+struct shm_largepage_conf {
+       int psind;
+       int alloc_policy;
+       int pad[10];
+};
 
 /*
  * Flags for memfd_create().
@@ -199,7 +210,6 @@
 #define        MFD_CLOEXEC                     0x00000001
 #define        MFD_ALLOW_SEALING               0x00000002
 
-/* UNSUPPORTED */
 #define        MFD_HUGETLB                     0x00000004
 
 #define        MFD_HUGE_MASK                   0xFC000000
@@ -279,6 +289,7 @@ int shm_unlink(const char *);
 #endif
 #if __BSD_VISIBLE
 int    memfd_create(const char *, unsigned int);
+int    shm_create_largepage(const char *, int, int, int, mode_t);
 int    shm_rename(const char *, const char *, int);
 #endif
 __END_DECLS
-- 
2.35.3

_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Reply via email to