Comments (4)
Thanks for the reply. I am trying to move some pages inside the same program.
After
madvise(p_map, SZ_16M, MADV_HUGEPAGE);
Could we call some API to migrate some parts of the array?
For example, we try to move the first huge page in this array.
from numactl.
Do you mean the numa_migrate_pages or migrate_pages API?
These API don't care whether transparent hugepages are used or not.
from numactl.
test program:
#include<sys/mman.h>
#include<sys/types.h>
#include<stdio.h>
#include<unistd.h>
#define SZ_16M (16 * 1024 * 1024UL)
#define PAGE_SIZE (4 *1024UL)
int main(void)
{
int i;
char *p_map;
p_map = (char*)mmap(NULL, SZ_16M, PROT_READ|PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1 , 0);
if (p_map == (void *)MAP_FAILED) {
printf("mmap error\n");
return 0;
}
madvise(p_map, SZ_16M, MADV_HUGEPAGE);
for (i = 0; i < SZ_16M; i += PAGE_SIZE) {
p_map[i] = i % 10;
}
getchar();
for (i = 0; i < SZ_16M; i += PAGE_SIZE) {
printf("%u ",p_map[i]);
}
munmap(p_map, SZ_16M);
return 0;
}
gcc test.c
1、run program
2、Observe transparent hugepages use, it uses 14M transparent hugepages
ffff8e329000-ffff8f329000 rw-p 00000000 00:00 0
Size: 16384 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
Rss: 16384 kB
Pss: 16384 kB
...
Private_Dirty: 16384 kB
Referenced: 16384 kB
Anonymous: 16384 kB
LazyFree: 0 kB
AnonHugePages: 14336 kB ##14M transparent hugepages
...
THPeligible: 1
VmFlags: rd wr mr mw me ac hg
3、Observe the corresponding node
[root@euleros-pxe ~]# cat /proc/`pidof a.out`/numa_maps
00400000 default file=/home/csluo/tete/a.out mapped=1 N0=1 kernelpagesize_kB=4
0041f000 default file=/home/csluo/tete/a.out anon=1 dirty=1 active=0 N0=1 kernelpagesize_kB=4
00420000 default file=/home/csluo/tete/a.out anon=1 dirty=1 active=0 N0=1 kernelpagesize_kB=4
2885d000 default heap anon=1 dirty=1 active=0 N0=1 kernelpagesize_kB=4
###transparent hugepages###
ffff8e329000 default anon=4096 dirty=4096 active=0 N0=4096 kernelpagesize_kB=4 ##transparent hugepages uses node0
########
ffff8f329000 default file=/usr/lib64/libc.so.6 mapped=196 mapmax=30 N1=196 kernelpagesize_kB=4
ffff8f4a2000 default file=/usr/lib64/libc.so.6
ffff8f4b6000 default file=/usr/lib64/libc.so.6 anon=3 dirty=3 active=0 N0=3 kernelpagesize_kB=4
ffff8f4b9000 default file=/usr/lib64/libc.so.6 anon=3 dirty=3 active=0 N0=3 kernelpagesize_kB=4
ffff8f4bc000 default anon=4 dirty=4 active=0 N0=4 kernelpagesize_kB=4
ffff8f4c3000 default file=/usr/lib/ld-linux-aarch64.so.1 mapped=35 mapmax=29 N1=35 kernelpagesize_kB=4
ffff8f4fc000 default anon=2 dirty=2 active=0 N0=2 kernelpagesize_kB=4
ffff8f4fe000 default
ffff8f500000 default
ffff8f501000 default file=/usr/lib/ld-linux-aarch64.so.1 anon=2 dirty=2 active=0 N0=2 kernelpagesize_kB=4
ffff8f503000 default file=/usr/lib/ld-linux-aarch64.so.1 anon=2 dirty=2 active=0 N0=2 kernelpagesize_kB=4
ffffe72e2000 default stack anon=3 dirty=3 active=1 N0=3 kernelpagesize_kB=4
4、use migratepages and Observe the corresponding node again, it works.
[root@euleros-pxe ~]# migratepages `pidof a.out` 0 1
[root@euleros-pxe ~]# cat /proc/`pidof a.out`/numa_maps
00400000 default file=/home/csluo/tete/a.out mapped=1 N1=1 kernelpagesize_kB=4
0041f000 default file=/home/csluo/tete/a.out anon=1 dirty=1 active=0 N1=1 kernelpagesize_kB=4
00420000 default file=/home/csluo/tete/a.out anon=1 dirty=1 active=0 N1=1 kernelpagesize_kB=4
2885d000 default heap anon=1 dirty=1 active=0 N1=1 kernelpagesize_kB=4
###transparent hugepages###
ffff8e329000 default anon=4096 dirty=4096 active=0 N1=4096 kernelpagesize_kB=4 ##it works
######
ffff8f329000 default file=/usr/lib64/libc.so.6 mapped=196 mapmax=30 N1=196 kernelpagesize_kB=4
ffff8f4a2000 default file=/usr/lib64/libc.so.6
ffff8f4b6000 default file=/usr/lib64/libc.so.6 anon=3 dirty=3 active=0 N1=3 kernelpagesize_kB=4
ffff8f4b9000 default file=/usr/lib64/libc.so.6 anon=3 dirty=3 active=0 N1=3 kernelpagesize_kB=4
ffff8f4bc000 default anon=4 dirty=4 active=0 N1=4 kernelpagesize_kB=4
ffff8f4c3000 default file=/usr/lib/ld-linux-aarch64.so.1 mapped=35 mapmax=29 N1=35 kernelpagesize_kB=4
ffff8f4fc000 default anon=2 dirty=2 active=0 N1=2 kernelpagesize_kB=4
ffff8f4fe000 default
ffff8f500000 default
ffff8f501000 default file=/usr/lib/ld-linux-aarch64.so.1 anon=2 dirty=2 active=0 N1=2 kernelpagesize_kB=4
ffff8f503000 default file=/usr/lib/ld-linux-aarch64.so.1 anon=2 dirty=2 active=0 N1=2 kernelpagesize_kB=4
ffffe72e2000 default stack anon=3 dirty=3 active=1 N1=3 kernelpagesize_kB=4
from numactl.
You can use numa_move_pages API or mbind MPOL_MF_MOVE flags.
from numactl.
Related Issues (20)
- Interleave/Bind fails for empty memory nodes HOT 5
- Latest release doesn't build with MUSL C run-time HOT 6
- numactl can not move a task onto isolated cpus HOT 3
- numactl: has memory leaks when run with -H
- numa_warn HOT 4
- Can I be the committer of this project? HOT 11
- Reference actions by commit SHA HOT 2
- usage of mbind, "maxnode" argument HOT 2
- Potential Bug: memcpy using msize/2 but using msize for performance calculation HOT 4
- Create next release HOT 6
- EINVAL for numa_set_schedaffinity HOT 2
- Add support for aarch64 clearcache HOT 2
- suppress printing "libnuma.c: Success" HOT 2
- get_mempolicy: Function not implemented HOT 5
- Add MemAvailable per node HOT 4
- better handling of CONFIG_NUMA=n / get_mempolicy: Function not implemented HOT 4
- Compilation errors for __NR_set_mempolicy_home_node HOT 1
- Fallback for `__NR_set_mempolicy_home_node` for architecture `__arm__` is missing HOT 2
- nuamdemo [random2] some result is not show after execute numodemo test HOT 1
- confused about library name in debian HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from numactl.