From: "Burakov, Anatoly" <anatoly.burakov@intel.com>
To: Vipin P R <vipinp@vmware.com>
Cc: <dev@dpdk.org>, <stable@dpdk.org>
Subject: Re: [PATCH 1/2] Memory Allocation: Fixes ignore_msk during find_next_n() in fb_array library
Date: Fri, 19 May 2023 17:23:27 +0100 [thread overview]
Message-ID: <72a9fc9c-8bb7-bab8-c5c6-bd1cab010fc4@intel.com> (raw)
In-Reply-To: <1673615669-21011-2-git-send-email-vipinp@vmware.com>
Hi Vipin,
On 1/13/2023 1:14 PM, Vipin P R wrote:
> Ignore mask ignores essential bits WHICH could have been contiguous.
> This commit aims to rectify that
Suggested rewording:
fbarray: fix incorrect lookahead ignore mask
Currently, when lookahead reaches a point where we've lost the run, we
set ignore mask to ignore N bits we were looking for for lookahead. The
problem is, because we're only looking at first bit after collapsing
next N bits into it, we end up ignoring bits that could've potentially
started a new run not from the first bit.
To reproduce this issue, we need to do the following:
1) Look for N bits where 64 > N > 1 (to enable lookahead behavior)
2) Set last bit of mask M (to trigger lookahead)
3) Leave first bit of mask M+1 unset (to create incorrect ignore mask)
4) Have next N bits of mask M+1 set
For example:
1) Look for 3 bits
2) Set bit 63 (last bit of first mask)
3) Leave bit 64 unset (first bit of second mask)
4) Set bits 65-67
With current code, we will not find a run starting from bit 65, because
we set ignore mask to ignore first 3 bits of second mask.
Fix this behavior by only setting the ignore mask when we know there
were no bits in the mask at all, so there's no chance in skipping bits
that could've been useful to us.
Fixes: c44d09811b40 ("eal: add shared indexed file-backed array")
>
> Cc: stable@dpdk.org
>
> Signed-off-by: Vipin P R <vipinp@vmware.com>
> Acked-by: Kumara Parameshwaran <kparameshwar@vmware.com>
> ---
> Depends-on: 0001-Memory-Allocation-Fixes-ms_idx-jump-lookahead-during.patch
> Depends-on: 0002-Memory-Allocation-Fixes-ms_idx-jump-lookbehind-durin.patch
> ---
> lib/eal/common/eal_common_fbarray.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/lib/eal/common/eal_common_fbarray.c b/lib/eal/common/eal_common_fbarray.c
> index 90240e8..313681a 100644
> --- a/lib/eal/common/eal_common_fbarray.c
> +++ b/lib/eal/common/eal_common_fbarray.c
> @@ -235,7 +235,12 @@ find_next_n(const struct rte_fbarray *arr, unsigned int start, unsigned int n,
> * no runs in the space we've lookahead-scanned
> * as well, so skip that on next iteration.
> */
> - ignore_msk = ~((1ULL << need) - 1);
> + if (!lookahead_msk) {
> + /* There aren't "need" number of contiguous bits anywhere in the mask.
> + * Ignore these many number of bits from LSB for the next iteration.
> + */
> + ignore_msk = ~((1ULL << need) - 1);
> + }
Great find! Needs a unit test though. I've described in the commit
message how to reproduce this behavior, should be trivial to implement
it as a unit test.
With above changes,
Reviewed-by: Anatoly Burakov <anatoly.burakov@intel.com>
--
Thanks,
Anatoly
next parent reply other threads:[~2023-05-19 16:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1673615669-21011-1-git-send-email-vipinp@vmware.com>
[not found] ` <1673615669-21011-2-git-send-email-vipinp@vmware.com>
2023-05-19 16:23 ` Burakov, Anatoly [this message]
[not found] ` <1673615669-21011-3-git-send-email-vipinp@vmware.com>
2023-05-19 16:45 ` [PATCH 2/2] Memory Allocation: Alternative fix for " Burakov, Anatoly
2023-05-22 5:12 ` Vipin P R
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=72a9fc9c-8bb7-bab8-c5c6-bd1cab010fc4@intel.com \
--to=anatoly.burakov@intel.com \
--cc=dev@dpdk.org \
--cc=stable@dpdk.org \
--cc=vipinp@vmware.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).