Bug 393 - rte_zmalloc_socket does not zero memory
Summary: rte_zmalloc_socket does not zero memory
Status: UNCONFIRMED
Alias: None
Product: DPDK
Classification: Unclassified
Component: core (show other bugs)
Version: 19.11
Hardware: x86 Linux
: Normal major
Target Milestone: ---
Assignee: Anatoly Burakov
URL:
Depends on:
Blocks:
 
Reported: 2020-02-07 11:18 CET by xkr
Modified: 2020-02-20 12:46 CET (History)
1 user (show)



Attachments

Description xkr 2020-02-07 11:18:05 CET
Hello,
It seems that rte_zmalloc_socket does not return zeroed memory on some cases. It seems to work OK on all but HP G10 server where I was testing application that tried to create rte fragment table and do IP defragementation where it crashed on some of the structure members. 

I put check into rte_zmalloc_socket to see if the memory was really zeroed and it was not! Also if I zero the memory then the defragmentation works correctly and does not crash.

I see from google that there were problems like this in the past with non zeroed rte_zmalloc_socket. 

I have tested also the 19.02 version and it has same problem.

this is on Centos 7.3 with linux kernel 3.10.0-514.el7.x86_64. Don't know if the linux itself can return non-zeroed memory in some case to dpdk lib.
Comment 1 Anatoly Burakov 2020-02-07 15:32:32 CET
rte_zmalloc does not, by itself, zero memory. This is done for performance reasons - memory is more often allocated than deallocated, and we get zero'ed memory from the kernel when we first hit the page, so DPDK will only zero out memory on rte_free(). This means that in practice rte_zmalloc will still give you zero'ed out memory, because that memory is necessarily either 1) fresh from the kernel and thus doesn't need to be zeroed out, or 2) has been previously freed and thus was zeroed out.

There is a config option to enable this behavior, but normally it is not necessary. If there are circumstances where memory isn't zeroed out properly, that is a bug in rte_free and should be investigated.

What is "degramgentation" that you are referring to?
Comment 2 xkr 2020-02-07 15:45:20 CET
Hi,

defragementation refers to IP defragmentation functions from librte_ip_frag.a

essentially I am saying that librte_ip_frag.a function rte_ip_frag_table_create does not get zeroed memory from rte_zmalloc_socket and program crashes when calling some of the functions from librte_ip_frag.a.
Comment 3 Anatoly Burakov 2020-02-07 15:51:01 CET
Can you reproduce the issue with DPDK's malloc autotest?
Comment 4 xkr 2020-02-07 20:55:10 CET
Hi,
can you tell me where I get it and how to run it?
Comment 5 Anatoly Burakov 2020-02-20 12:46:45 CET
Hi,

If you have compiled DPDK from source, the test app should be in the build tree. If you have got it from a distribution, the test application may or may not be there (i am not very familiar with how DPDK is packaged).

Note You need to log in before you can comment on or make changes to this bug.