DPDK patches and discussions
 help / color / mirror / Atom feed
From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
To: Fidaullah Noonari <fidaullah.noonari@emumba.com>
Cc: Anatoly Burakov <anatoly.burakov@intel.com>, dpdk-dev <dev@dpdk.org>
Subject: Re: [PATCH] eal: fixes the bug where rte_malloc() fails to allocates memory
Date: Sat, 18 Jun 2022 14:29:34 +0300	[thread overview]
Message-ID: <CAEYuUWCnRZNwxiOHEeTHw0Gy9aFJRLZtvAG9g=smuUvUEMcFXg@mail.gmail.com> (raw)
In-Reply-To: <20220525051837.247255-1-fidaullah.noonari@emumba.com>

[-- Attachment #1: Type: text/plain, Size: 1207 bytes --]

Hi Fidaullah,

Thanks for the fix,
Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>


Anatoly, I noticed a couple of other things while testing this.

1. Consider:

elt_size = pg_sz - MALLOC_ELEM_OVERHEAD
rte_malloc(align=0) which is converted to align = 1.

Obviously, such an element fits into one page, however:

alloc_sz = RTE_ALIGN_CEIL(1 + pg_sz +
                (MALLOC_ELEM_OVERHEAD - MALLOC_ELEM_OVERHEAD),
                pg_sz) == 2 * pg_sz.

This can unnecessarily hit an allocation limit from the system or EAL.
I suggest, in both places:

alloc_sz = RTE_ALIGN_CEIL(RTE_ALIGN_CEIL(elt_size, align) +
                MALLOC_ELEM_OVERHEAD, pg_sz);

This would be symmetric with malloc_elem_can_hold().

2. Alignment calculation depends on whether we allocated new pages or not:

malloc_heap_alloc_on_heap_id(align = 0) ->
heap_alloc(align = 1) ->
find_suitable_element(align = RTE_CACHE_LINE_ROUNDUP(align))

malloc_heap_alloc_on_heap_id(align = 0) ->
alloc_more_mem_on_socket(align = 1) ->
try_expand_heap() -> ... ->
alloc_pages_on_heap(align = 1) ->
find_suitable_element(align = 1)

Why do we call find_suitable_element() directly and not just return
and repeat the heap_alloc() attempt?

[-- Attachment #2: Type: text/html, Size: 1858 bytes --]

  parent reply	other threads:[~2022-06-18 11:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-25  5:18 Fidaullah Noonari
2022-06-16  7:53 ` David Marchand
2022-06-18 11:29 ` Dmitry Kozlyuk [this message]
2022-06-22 17:03   ` David Marchand
2022-06-22 21:18     ` Dmitry Kozlyuk
2022-07-05  5:04   ` Fidaullah Noonari
2022-06-23  7:50 ` David Marchand

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='CAEYuUWCnRZNwxiOHEeTHw0Gy9aFJRLZtvAG9g=smuUvUEMcFXg@mail.gmail.com' \
    --to=dmitry.kozliuk@gmail.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=fidaullah.noonari@emumba.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).