DPDK patches and discussions
 help / color / mirror / Atom feed
From: Vipin P R <vipinp@vmware.com>
To: anatoly.burakov@intel.com
Cc: dev@dpdk.org, Vipin P R <vipinp@vmware.com>
Subject: [PATCH 0/2] *** Memory Allocation: Fixes ms_idx jump in fb_array library ***
Date: Fri, 13 Jan 2023 13:08:43 +0000	[thread overview]
Message-ID: <1673615325-20624-1-git-send-email-vipinp@vmware.com> (raw)

*** 
The problem :
In the legacy mem mode, when the fb_array is being populated, if there are holes in between, the ms_idx could go backward and there will be an overlap of the region starting from the ms_idx returned later. i.e. it's being mapped to two different physical regions in PA space to a contiguous region in VA space. this would result in the allocator assuming that the memory is contiguous even though there is a hole in between. In legacy mem, allocator assumes that PA contiguous are VA contiguous as well.

Reason for the ms_idx going back :
In the lookahead logic of find_next_n(), if we fail to find contiguous "need" bits, we ignore all masks till the lookahead when we run out of options i.e. the LSB bit is not set or more accurately there are no "need" bits starting from LSB, therefore breaking contiguity.

The optimisation is to avoid repeating this operation and therefore we start from msk_idx = lookahead_idx in the next iter.. However, in the outer loop, we increment msk_idx further, resulting in msk_idx = lookahead_idx + 1, thereby inducing a jump. This problem becomes apparent when we have partially filled bits in the lookahead_msk. Further iterations might find the necessary contiguity from such a lookahead, potentially resulting in the returned ms_idx value to be lower for subsequent iterations.

The assumption was that ms_idx from rte_fbarray_find_next_n_free() is supposed to be incremental in nature, provided that the value of n is always constant.

For a sample input of {1, 1070, 1, 2, 1, 2, 4, 12, 2, 2, 1, 2, 1},

Without the patch :

6358 EAL: ms_idx:1097
6359 EAL: ms_idx:1098
6360 EAL: ms_idx:1099
6361 EAL: ms_idx:1155
6362 EAL: ms_idx:1156
6363 EAL: ms_idx:1158
6364 EAL: ms_idx:1159
6365 EAL: ms_idx:1154
6366 EAL: ms_idx:1161
6367 EAL: ms_idx:1162
6368 EAL: ms_idx:1164

With the patch :

12730 EAL: ms_idx:1096
12731 EAL: ms_idx:1097
12732 EAL: ms_idx:1098
12733 EAL: ms_idx:1099
12734 EAL: ms_idx:1101
12735 EAL: ms_idx:1102
12736 EAL: ms_idx:1104
12737 EAL: ms_idx:1105
12738 EAL: ms_idx:1107
12739 EAL: ms_idx:1109
12740 EAL: ms_idx:1110
12741 EAL: ms_idx:1112

***

Vipin P R (2):
  Memory Allocation: Fixes ms_idx jump (lookahead) during find_next_n()
    in fb_array library
  Memory Allocation: Fixes ms_idx jump (lookbehind) during find_prev_n()
    in fb_array library

 .mailmap                            | 1 +
 lib/eal/common/eal_common_fbarray.c | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

-- 
2.7.4


             reply	other threads:[~2023-01-15 20:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-13 13:08 Vipin P R [this message]
2023-01-13 13:08 ` [PATCH 1/2] Memory Allocation: Fixes ms_idx jump (lookahead) during find_next_n() in fb_array library Vipin P R
2023-05-16 13:49   ` Burakov, Anatoly
2023-01-13 13:08 ` [PATCH 2/2] Memory Allocation: Fixes ms_idx jump (lookbehind) during find_prev_n() " Vipin P R
2023-05-16 14:20   ` Burakov, Anatoly

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=1673615325-20624-1-git-send-email-vipinp@vmware.com \
    --to=vipinp@vmware.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).