Commit 6ef9f2b1 authored by Fang Lijun's avatar Fang Lijun Committed by Zheng Zengkai
Browse files

mm: Check numa node hugepages enough when mmap hugetlb

ascend inclusion
category: Bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4JMLR


CVE: NA

--------------

System cann't use the cdm nodes memory, but it can mmap all nodes huge
pages, so it will cause Bus error when mmap succeed but the huge pages
were not enough.

When set the cdmmask, users will transfer the numa id by mmap flag to
map the specific numa node hugepages, if there was not enough hugepages
on this node, return -ENOMEM.

Dvpp use flags MAP_CHECKNODE to enable check node hugetlb.
The global variable numanode will cause the mmap not be
reenterable, so use the flags BITS[26:31] directly.
v2: fix a compiling error on platforms such as mips

Signed-off-by: default avatarFang Lijun <fanglijun3@huawei.com>
Reviewed-by: default avatarWeilong Chen <chenweilong@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent 208a3120
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@
#define MAP_HUGETLB	0x100000	/* create a huge page mapping */
#define MAP_FIXED_NOREPLACE	0x200000/* MAP_FIXED which doesn't unmap underlying mapping */
#define MAP_PA32BIT	0x400000	/* physical address is within 4G */
#define MAP_CHECKNODE	0x800000	/* hugetlb numa node check */

#define MS_ASYNC	1		/* sync memory asynchronously */
#define MS_SYNC		2		/* synchronous memory sync */
+1 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@
#define MAP_HUGETLB	0x80000		/* create a huge page mapping */
#define MAP_FIXED_NOREPLACE 0x100000	/* MAP_FIXED which doesn't unmap underlying mapping */
#define MAP_PA32BIT	0x400000	/* physical address is within 4G */
#define MAP_CHECKNODE	0x800000	/* hugetlb numa node check */

/*
 * Flags for msync
+1 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
#define MAP_FIXED_NOREPLACE 0x100000	/* MAP_FIXED which doesn't unmap underlying mapping */
#define MAP_UNINITIALIZED 0		/* uninitialized anonymous mmap */
#define MAP_PA32BIT	0x400000	/* physical address is within 4G */
#define MAP_CHECKNODE	0x800000	/* hugetlb numa node check */

#define MS_SYNC		1		/* synchronous memory sync */
#define MS_ASYNC	2		/* sync memory asynchronously */
+1 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#define MCL_FUTURE      0x4000          /* lock all additions to address space */
#define MCL_ONFAULT	0x8000		/* lock all pages that are faulted in */
#define MAP_PA32BIT	0x400000	/* physical address is within 4G */
#define MAP_CHECKNODE	0x800000	/* hugetlb numa node check */

/* Override any generic PKEY permission defines */
#define PKEY_DISABLE_EXECUTE   0x4
+1 −0
Original line number Diff line number Diff line
@@ -22,5 +22,6 @@
#define MCL_FUTURE      0x4000          /* lock all additions to address space */
#define MCL_ONFAULT	0x8000		/* lock all pages that are faulted in */
#define MAP_PA32BIT	0x400000	/* physical address is within 4G */
#define MAP_CHECKNODE	0x800000	/* hugetlb numa node check */

#endif /* _UAPI__SPARC_MMAN_H__ */
Loading