DPDK-dev Archive on lore.kernel.org
 help / color / Atom feed
* Re: [dpdk-dev]   How *rte_zmalloc_socket* ensure that the memory is zero'd ?
@ 2019-07-17  5:22 He Peng
  0 siblings, 0 replies; 4+ messages in thread
From: He Peng @ 2019-07-17  5:22 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev




2019年7月16日 下午10:19,He Peng <xnhp0320@icloud.com> 写道:


Hi,



2019年7月16日 下午9:51,Stephen Hemminger <stephen@networkplumber.org> 写道:


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.
 

But is it possible that one memory free resulting in two memory elements combined, however 
the code might forget to memset the metadata?




Sorry, check the code, it is done in the *join_elem*.
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev]   How *rte_zmalloc_socket* ensure that the memory is zero'd ?
@ 2019-07-17  5:19 He Peng
  0 siblings, 0 replies; 4+ messages in thread
From: He Peng @ 2019-07-17  5:19 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

Hi,



2019年7月16日 下午9:51,Stephen Hemminger <stephen@networkplumber.org> 写道:


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.
 

But is it possible that one memory free resulting in two memory elements combined, however 
the code might forget to memset the metadata?





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] How *rte_zmalloc_socket* ensure that the memory is zero'd ?
  2019-07-17  2:26 He Peng
@ 2019-07-17  4:51 ` Stephen Hemminger
  0 siblings, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2019-07-17  4:51 UTC (permalink / raw)
  To: He Peng; +Cc: dev

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. 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [dpdk-dev] How *rte_zmalloc_socket* ensure that the memory is zero'd ?
@ 2019-07-17  2:26 He Peng
  2019-07-17  4:51 ` Stephen Hemminger
  0 siblings, 1 reply; 4+ messages in thread
From: He Peng @ 2019-07-17  2:26 UTC (permalink / raw)
  To: dev

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?

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-17  5:22 [dpdk-dev] How *rte_zmalloc_socket* ensure that the memory is zero'd ? He Peng
  -- strict thread matches above, loose matches on Subject: below --
2019-07-17  5:19 He Peng
2019-07-17  2:26 He Peng
2019-07-17  4:51 ` Stephen Hemminger

DPDK-dev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/dpdk-dev/0 dpdk-dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dpdk-dev dpdk-dev/ https://lore.kernel.org/dpdk-dev \
		dev@dpdk.org dpdk-dev@archiver.kernel.org
	public-inbox-index dpdk-dev


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/ public-inbox