From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3E18242B4B; Fri, 19 May 2023 18:23:53 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 104DF40E25; Fri, 19 May 2023 18:23:53 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mails.dpdk.org (Postfix) with ESMTP id C4B8D40E09; Fri, 19 May 2023 18:23:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684513431; x=1716049431; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=U039e5aXB1ENmf5MiqO64MFtAaJ8tUAH2QlV9Yba4xs=; b=XigXu2rBTZVjI5B0BpGyi16uXkTGDngBkkqiXrBjVzxhyG3PdNS8t9NU DB72mJTN4NCK187ObxPJ27kZ1diyJMGK5+ZjpiXEkpvWECe1hNXUNygoN YYf+YdBwEzcUoQqmY1RmXhajvMe0X0tjlq+uOakgfvTcexJT1xpwcoZRl Ee2U5q+ktgfoB4ToNDcRg25INM6/U+Goump8v0kXAEALkFvkKcWW8XClT zsxInqkMiU0cabdPKp3m76BnAx83j1EZCb8lb/KgJFhW5zXFjGBWV099l KoNeUSSPVXGEw2ixl5qWiZVdTmZ4DrbGoM3A5cpuEdRxMxhh/8Z+Ziq7n A==; X-IronPort-AV: E=McAfee;i="6600,9927,10715"; a="332779524" X-IronPort-AV: E=Sophos;i="6.00,177,1681196400"; d="scan'208";a="332779524" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 May 2023 09:23:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10715"; a="735562650" X-IronPort-AV: E=Sophos;i="6.00,177,1681196400"; d="scan'208";a="735562650" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga001.jf.intel.com with ESMTP; 19 May 2023 09:23:39 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 19 May 2023 09:23:39 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 19 May 2023 09:23:39 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23 via Frontend Transport; Fri, 19 May 2023 09:23:39 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.103) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.23; Fri, 19 May 2023 09:23:39 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iGuSk7KYMQuhF1hg0u0uTdfvNRpGRUnPTcvEZ3hk+XhxJeiVH0jBKaM6ZkLDp/zldxo7ttBw9qENKYOKCaEqLm/sQbm+pl+/GM0hVlSWPGkSBPWpwFjav7qlYLPS4Tnc1nvR4Y/cd7LoIKoaWlWZxU6slcd1Y1afsdcREc7/hNpKVwM/vdtWKknVMN68nD0AuPOdVvOfTNC8EafYKmMpHJMKVsG0vgWgfFXVCJ6NCagqWprcAo/8DyKWJYdboKlPo8jBv6RdYWzJ9OX4vLsQ+1W1t7nITkeqQF3vXk9u8imasTFN1btCUl0vk3GmN9Xu6hdM7Lo5tJI2qFQqQ0KIIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dXh0f5PubsXdWc5bFF8TTisFqXOLnSxfdv20hbL/bag=; b=U9zK2MAl4VqxjD0MHfDHB7yb4OJQaiwUzq2fBFiLtwfQsfBMIGrZ93IyMaH98kbGob8+OTRpRqCwOxqiKrMo6oIDJ6jPsZNeZftZW3xHFI6ibyEK0GWRULIP36V9T3oVrW0i1lq1iUgm02DYSjX7jSdwlBe3Bm18ImrND1YoEXzxFR7yHQX52xnr9AerlwvTcZu11YYjKv97XMf2SJeLOkOnVGk/1Xyv1fdQJsNlIrjHtwOoeG/v2MabhsVLMjuh1PxPc2ro/PEXW+jS99Mw+so3j9tcNZjiDxaR7PNol8guVuFQRxxgVXiVZJYRTasK++P/wHAu7404HtAVzmoACw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DM4PR11MB6502.namprd11.prod.outlook.com (2603:10b6:8:89::7) by SA2PR11MB4924.namprd11.prod.outlook.com (2603:10b6:806:113::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19; Fri, 19 May 2023 16:23:35 +0000 Received: from DM4PR11MB6502.namprd11.prod.outlook.com ([fe80::49c0:aa4c:e5b4:e718]) by DM4PR11MB6502.namprd11.prod.outlook.com ([fe80::49c0:aa4c:e5b4:e718%5]) with mapi id 15.20.6411.021; Fri, 19 May 2023 16:23:34 +0000 Message-ID: <72a9fc9c-8bb7-bab8-c5c6-bd1cab010fc4@intel.com> Date: Fri, 19 May 2023 17:23:27 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0 Thunderbird/102.11.0 Subject: Re: [PATCH 1/2] Memory Allocation: Fixes ignore_msk during find_next_n() in fb_array library Content-Language: en-US To: Vipin P R CC: , References: <1673615669-21011-1-git-send-email-vipinp@vmware.com> <1673615669-21011-2-git-send-email-vipinp@vmware.com> From: "Burakov, Anatoly" In-Reply-To: <1673615669-21011-2-git-send-email-vipinp@vmware.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: DUZPR01CA0026.eurprd01.prod.exchangelabs.com (2603:10a6:10:46b::20) To DM4PR11MB6502.namprd11.prod.outlook.com (2603:10b6:8:89::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR11MB6502:EE_|SA2PR11MB4924:EE_ X-MS-Office365-Filtering-Correlation-Id: 16d4afc5-4d1f-4eab-ac10-08db58856486 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: av6Z9nfysqOixg2rJ/s9VQlOAYkYi5JOS/11+1Hjmzq56ihbLuAcO9SHqtLv3jOb6NFDDnDKGX5sZOPpQyOHuEtikc5WbyIocD04B/0X1wVZuF8maCJcmpO4X8jcb0VMaInSqbeEcJWIMXc+VEMRu32pnklbmsvYjSvcIadGHxrTdDvE281jUmEbWzCdaqNd2KiPaswdCyHApRE9XNxAHodSq8nL3lNNWbTAWfOSTXkvfTHnJZo98UH36+OMXnbKc4j4SyLyqVuMDJ0lVNDF+1NqSuislEkgtIFrXYXyAW3xl37OOKe2LJ5Xn1wysWrV/JvU7dKn6zORL82KcXzf7dboMN2PdgHvnB1PeibidFyxhpilzbbyPtir9x9hKQLybikrBXDPQdctSrL30Z6CNWUA8NFh/EvBRVVQt4fT0lsap9eh6FlvqGJ9phnXLFJKETqJAcnQAHlua77urBaKcutkVIYGppe9S4X8lgMtjItqxQKvBIDY2zkECqU3qjL+roDT1AkUrLHfgESobeQZXLjmupBHQFUjxtSCgJAZ3HuKwE8kmYAUsSsKCdHSVgxcXT+UIT529eKucnqfE+96Cg9EnmUQFaMNa0wLBQcIcaoOfbLVHp5St6+IUetcYCGH3BHbQdIUZBiw0OYsOjq5rw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM4PR11MB6502.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(39860400002)(366004)(346002)(376002)(396003)(136003)(451199021)(6512007)(53546011)(86362001)(6506007)(26005)(83380400001)(38100700002)(2616005)(31696002)(36756003)(82960400001)(186003)(478600001)(2906002)(8936002)(31686004)(316002)(8676002)(41300700001)(5660300002)(66476007)(4326008)(66556008)(66946007)(6916009)(6666004)(6486002)(43740500002)(45980500001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?ajJjZEtUSjA4c25UazlEMGZjSDFZUTRhRDRSOTcxb3VKcTdkSW81bzBVRnJa?= =?utf-8?B?ZkY5WnBJUUNIaDFlMHlkanFYWklvL3NnL3BtQXFabklWYkphYkhLMWpNci9y?= =?utf-8?B?eEQxTENMSkhnTHZ6SVJqU1FzbnQwN1p1ODVZZnlIZ0pKbEpaYkNiQkN5dXdU?= =?utf-8?B?VWtKRXBwZlJWbzl2MU9HbVZRaEtONms1Q3ZCZkZTNyt6NHYwUHNobktQM0Qx?= =?utf-8?B?QVYrV2RLLytYeTFOaUVkVkNlb0ZzYk9LcTJOQVlEbTFWZklETjVTSGZGZ1JZ?= =?utf-8?B?cDd3a042NWdoT3dXbGRxd2c2W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2YlFt?= =?utf-8?B?NFVOOVNnclZlbjZQaEFkNzBONm41WE1aZ0xQeThwWUo5ZFRGc2NxdUZLbXFi?= =?utf-8?B?cHc9PQ==?= X-MS-Exchange-CrossTenant-Network-Message-Id: 16d4afc5-4d1f-4eab-ac10-08db58856486 X-MS-Exchange-CrossTenant-AuthSource: DM4PR11MB6502.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2023 16:23:34.6126 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ctVj6Xo32tEoo55pbZkucLTciKnKA3yseHa0hQ3JukB+gFgkXdqwFCsPZndnXIifk1p5cXL1xpg81U9/cU4jiDBxQ0OjDSnLyBvdyDb3CIQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR11MB4924 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 > Acked-by: Kumara Parameshwaran > --- > 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 -- Thanks, Anatoly