欢迎来到 DPDK交流社区 ,有什么问题可以尽管在这里提问,您将会收到社区其他成员的回答;也可以将您的总结写在这里,为社区其他成员提供帮助。 (QQ交流群:127163755)

Cannot mmap memory for rte_config

+2 投票
执行多进程例子simple_mp时,主进程执行./build/simple_mp -c 3 -n 4 --proc-type=primary,从进程执行./build/simple_mp -c 3 -n 4 --proc-type=secondary,主进程正常,从进程概率性报此错误,通过查看代码发现:mmap时,想要映射的地址(mmap函数第一个参数)和映射出来的地址(mmap函数返回值)不相等。为什么会出现不相等情况呢?
最新提问 12月 2, 2015 分类:DPDK sample解惑 | 用户: 不菲男455 (240 分)

3 个回答

0 投票
看看是不是打开了aslr?

另外最好能贴一下所有的错误信息
最新回答 12月 2, 2015 用户: sysight (11,900 分)
麻烦问一下,什么是aslr啊?所有错误信息:
root@ubuntu-zl:/home/zl/Documents/dpdk/dpdk-2.1.0/examples/multi_process/simple_mp# ./build/simple_mp -c 3 -n 4 --proc-type=secondary
EAL: Detected lcore 0 as core 0 on socket 0
EAL: Detected lcore 1 as core 1 on socket 0
EAL: Support maximum 128 logical core(s) by configuration.
EAL: Detected 2 lcore(s)
PANIC in rte_eal_config_reattach():
Cannot mmap memory for rte_config
6: [./build/simple_mp() [0x806bdd5]]
5: [/lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0xb75444d3]]
4: [./build/simple_mp(main+0x1c) [0x806a31c]]
3: [./build/simple_mp() [0x80d939e]]
2: [./build/simple_mp(__rte_panic+0x5c) [0x8065fd1]]
1: [./build/simple_mp(rte_dump_stack+0x28) [0x80de848]]
Aborted (core dumped)
root@ubuntu-zl:/home/zl/Documents/dpdk/dpdk-2.1.0/examples/multi_process/simple_mp#
我查看了一下
root@ubuntu-zl:/home/zl/Documents/dpdk/dpdk-2.1.0/examples/multi_process/simple_mp# cat /proc/sys/kernel/randomize_va_space
2
root@ubuntu-zl:/home/zl/Documents/dpdk/dpdk-2.1.0/examples/multi_process/simple_mp#
就是这个,把它设置为0测试一下。
0 投票
你的这个问题首先是-c后面的3应该是cpu掩码,两个进程绑定cpu的时候需要绑定不同的cpu上,你先把这个改过来,然后再查是不是由于aslr导致的,我系统中的aslr是开启的,没有出现你的这个问题
最新回答 12月 2, 2015 用户: oops (2,170 分)
+2 投票

此问题原因已找到,在这里与大家分享一下:

http://dpdk.org/ml/archives/dev/2014-September/005208.html

Having ASLR enabled will just introduce a small element of uncertainty in the application startup process as you the memory mappings used by your app will move about from run to run. In certain cases we've seen some of the secondary multi-process application examples fail to start at random once every few hundred times (IIRC correctly - this was some time back). Presumably the chances of the secondary failing to start will vary depending on how ASLR has adjusted the memory mappings in the primary. 
So, with ASLR on, we've found occasionally that mappings will fail, in which case the solution is really just to retry the app again and ASLR will re-randomise it differently and it will likely start. Disabling ASLR gives repeatability in this regard - your app will always start successfully - or if there is something blocking the memory maps from being replicated - always fail to start (in which case you try passing EAL parameters to hint the primary process to use different mapping addresses).

In your case, you are not seeing any problems thus far, so likely if secondary process startup failures do occur, they should hopefully work fine by just trying again! Whether this element of uncertainty is acceptable or not is your choice :-). One thing you could try, to find out what the issues might be with your app, is to just try running it repeatedly in a script, killing it after a couple of seconds. This should tell you how often, if ever, initialization failures are to be expected when using ASLR.
 
最新回答 12月 14, 2015 用户: 不菲男455 (240 分)
...