dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: He Peng <xnhp0320@icloud.com>
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] How *rte_zmalloc_socket* ensure that the memory is zero'd ?
Date: Tue, 16 Jul 2019 21:51:06 -0700	[thread overview]
Message-ID: <20190716215106.2fd8e042@hermes.lan> (raw)
In-Reply-To: <fbe8b807-ccfa-43f6-838f-97ecdd1dde18@me.com>

On Wed, 17 Jul 2019 02:26:57 GMT
He Peng <xnhp0320@icloud.com> wrote:

> Hi,
> 
> In file dpdk/lib/librte_eal/common/rte_malloc.c:
> 
> /*
> * Allocate memory on default heap.
> */
> void *
> rte_malloc(const char *type, size_t size, unsigned align)
> {
>   return rte_malloc_socket(type, size, align, SOCKET_ID_ANY);
> }
> 
> /*
> * Allocate zero'd memory on specified heap.
> */
> void *
> rte_zmalloc_socket(const char *type, size_t size, unsigned align, int socket)
> {
>   return rte_malloc_socket(type, size, align, socket);
> }
> 
> Looks like the *rte_malloc* and *rte_zmalloc_socket* is the same, then, how the latter function ensure the memory allocated by is zeroed?

This is done because touching the memory on free is faster than cache cold memory during allocation.

If you look at recent DPDK the behavior changes slightly if MALLOC_DEBUG is enabled.
If DEBUG is enabled freed memory is clobbered with a 0x6b so that any buggy program
is likely to crash when using freed memory. 

  reply	other threads:[~2019-07-17  4:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-17  2:26 [dpdk-dev] How *rte_zmalloc_socket* ensure that the memory is zero'd ? He Peng
2019-07-17  4:51 ` Stephen Hemminger [this message]
2019-07-17  5:19 He Peng
2019-07-17  5:22 He Peng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190716215106.2fd8e042@hermes.lan \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=xnhp0320@icloud.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).