From: David Christensen <drc@linux.vnet.ibm.com>
To: Anatoly Burakov <anatoly.burakov@intel.com>, dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH 1/2] test/malloc: run realloc tests on external heap
Date: Wed, 1 Apr 2020 19:40:24 -0700 [thread overview]
Message-ID: <2cca0eba-e3bc-c89b-01bb-cc37d906d867@linux.vnet.ibm.com> (raw)
In-Reply-To: <156a0627fb472087aad43d9279ab0f684a2367ce.1585746650.git.anatoly.burakov@intel.com>
On 4/1/20 6:11 AM, Anatoly Burakov wrote:
> Due to the fact that the rte_realloc() test depends on the layout of
> underlying memory, it can sometimes fail due to fragmentation of the
> memory. To address this, make it so that the realloc autotests are run
> using a newly created external memory heap instead of main memory.
>
> Bugzilla ID: 424
>
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
...
> +static int
> +test_realloc(void)
> +{
> + const char *heap_name = "realloc_heap";
> + int realloc_heap_socket;
> + unsigned int mem_sz = 1U << 13; /* 8K */
> + unsigned int page_sz = sysconf(_SC_PAGESIZE);
> + void *mem;
> + int ret;
> +
> + /*
> + * the realloc tests depend on specific layout of underlying memory, so
> + * to prevent accidental failures to do fragmented main heap, we will
> + * do all of our tests on an artificially created memory.
> + */
> + if (rte_malloc_heap_create(heap_name) != 0) {
> + printf("Failed to create external heap\n");
> + ret = -1;
> + goto end;
> + }
> + realloc_heap_socket = rte_malloc_heap_get_socket(heap_name);
> +
> + mem = mmap(NULL, mem_sz, PROT_READ | PROT_WRITE,
> + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
> + if (mem == MAP_FAILED) {
> + printf("Failed to allocate memory for external heap\n");
> + ret = -1;
> + goto heap_destroy;
> + }
> +
> + if (rte_malloc_heap_memory_add(
> + heap_name, mem, mem_sz, NULL, 0, page_sz) != 0) {
> + printf("Failed to add memory to external heap\n");
> + ret = -1;
> + goto mem_free;
> + }
> +
> + /* run the socket-bound tests */
> + ret = test_realloc_socket(realloc_heap_socket);
> +
> + if (ret != 0)
> + goto mem_remove;
> +
> + /* now, run the NUMA node tests */
> + ret = test_realloc_numa();
> +
> +mem_remove:
> + rte_malloc_heap_memory_remove(heap_name, mem, mem_sz);
> +mem_free:
> + munmap(mem, mem_sz);
> +heap_destroy:
> + rte_malloc_heap_destroy(heap_name);
> +end:
> return ret;
> }
>
Works on an x86_64 Lenovo server which was previously failing. Still
fails on a Power 9 system but with a new error:
RTE>>malloc_autotest
test_str_to_size() passed
test_zero_aligned_alloc() passed
test_malloc_bad_params() passed
Failed to add memory to external heap
test_realloc() failed
Test Failed
I'm guessing page_sz is the problem:
(gdb) s
rte_malloc_heap_memory_add (heap_name=0x11bceda0 "realloc_heap",
va_addr=0x7ffff4c80000, len=8192, iova_addrs=0x0, n_pages=0, page_sz=65536)
at ../lib/librte_eal/common/rte_malloc.c:358
358 struct malloc_heap *heap = NULL;
(gdb) n
363 if (heap_name == NULL || va_addr == NULL ||
(gdb) n
364 page_sz == 0 || !rte_is_power_of_2(page_sz) ||
(gdb) n
365 RTE_ALIGN(len, page_sz) != len ||
(gdb) n
364 page_sz == 0 || !rte_is_power_of_2(page_sz) ||
(gdb) n
371 rte_errno = EINVAL;
When I change page_sz to 4K the test succeeds.
Dave
next prev parent reply other threads:[~2020-04-02 2:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-01 13:11 Anatoly Burakov
2020-04-01 13:11 ` [dpdk-dev] [PATCH 2/2] test/malloc: add bad parameter tests for realloc Anatoly Burakov
2020-04-02 2:43 ` David Christensen
2020-04-02 2:40 ` David Christensen [this message]
2020-04-02 9:02 ` [dpdk-dev] [PATCH v2 1/2] test/malloc: run realloc tests on external heap Anatoly Burakov
2020-04-02 19:54 ` David Christensen
2020-04-21 16:16 ` David Marchand
2020-04-10 11:19 ` David Marchand
2020-04-17 12:12 ` Burakov, Anatoly
2020-04-02 9:02 ` [dpdk-dev] [PATCH v2 2/2] test/malloc: add bad parameter tests for realloc Anatoly Burakov
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=2cca0eba-e3bc-c89b-01bb-cc37d906d867@linux.vnet.ibm.com \
--to=drc@linux.vnet.ibm.com \
--cc=anatoly.burakov@intel.com \
--cc=dev@dpdk.org \
/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).