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 910FB423E6; Sun, 15 Jan 2023 21:12:26 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 510BB42D2B; Sun, 15 Jan 2023 21:11:47 +0100 (CET) Received: from CY4PR02CU007-vft-obe.outbound.protection.outlook.com (mail-westcentralusazon11011007.outbound.protection.outlook.com [40.93.199.7]) by mails.dpdk.org (Postfix) with ESMTP id 9016642DF3; Fri, 13 Jan 2023 14:14:50 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d7BHfaDdXaVNCBoaodiWIMZGXkWNudTqhUOlQ9Mpp5vi1V89wTaxXaq0/GoNnedTa2jDEOJxBjYeldKfNS3m/sp93kDnceKf3em6EzaVpApC61FWbN+8zUyFymloelzERX08cjupTVPcgYp7eXr2xgZWE80RArKNF+DgCPkSQA09GYsNGody3DPTHpUoUCAu4kXEUpHuxanJueXggNBGvSXExTmdzB2jMrsvgBpm37TOtDzu2H+NFXDyRCN//6XZWUG+2Dpx3eqOb7l1a9YGqJ4DLolZ++an6Lfp2jr1EfDMRS6yGQPS0gc2eRX4+LUhgHguESYawy5SargTr77FOg== 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=+A/uApqO9Hs4rvc9RW0PBktZgxTQNhNoGjLaXTMsV3w=; b=Pe7U63OF8/0lMUqNRz4rLGq31h+a0/H1AGIP64zgn+aLBQG7A46ik4BgmbduAQJ/V2OGl8SWlGcrqhkkIfqndgB9Y827CLLXBqhF4SzuXqutvDOacg0iuIXPr4G9IUcs34/duC9noRYQvaGIIp0qAqmNSh701v4bQCb8LEgJZzhePbxdhBHlofZRWamtCfSdHium2NsxV4OKAWJdHl57ch8RHhXw2hg5XQSlF2rS9DlkWBCARw5Q1blv4LnX+CFdx+ggd9peTkyNNeide6uRD1FlP+OUCAXhmMQuas2SDG4PvAw5GiUogfEDQkmugSWQAbgf/zMzkGWAPdoyGMysew== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vmware.com; dmarc=pass action=none header.from=vmware.com; dkim=pass header.d=vmware.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vmware.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+A/uApqO9Hs4rvc9RW0PBktZgxTQNhNoGjLaXTMsV3w=; b=pvvvxbxGWjDOav8391ovSYmeeMNWFT60e2UJ9xhqh9Fi5Q7cwOkG3NLcWUjIYn24/OSpCA3PqxsesD8vuWdIOk6+Hu/qrY/9WgiHU94o7ImdJG01Mo9YbOTHPXvQqxdKxoT9bkvkC8X1v1x5mlpHy4vviy3Lxq7dq6wUrzujasQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vmware.com; Received: from DM6PR05MB5577.namprd05.prod.outlook.com (2603:10b6:5:c::16) by CY4PR05MB3431.namprd05.prod.outlook.com (2603:10b6:910:59::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13; Fri, 13 Jan 2023 13:14:48 +0000 Received: from DM6PR05MB5577.namprd05.prod.outlook.com ([fe80::4cbc:cca6:3a16:5023]) by DM6PR05MB5577.namprd05.prod.outlook.com ([fe80::4cbc:cca6:3a16:5023%4]) with mapi id 15.20.5986.018; Fri, 13 Jan 2023 13:14:48 +0000 From: Vipin P R To: anatoly.burakov@intel.com Cc: dev@dpdk.org, Vipin P R , stable@dpdk.org Subject: [PATCH 2/2] Memory Allocation: Alternative fix for ignore_msk during find_next_n() in fb_array library Date: Fri, 13 Jan 2023 13:14:29 +0000 Message-Id: <1673615669-21011-3-git-send-email-vipinp@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1673615669-21011-1-git-send-email-vipinp@vmware.com> References: <1673615669-21011-1-git-send-email-vipinp@vmware.com> Content-Type: text/plain X-ClientProxiedBy: BY5PR13CA0009.namprd13.prod.outlook.com (2603:10b6:a03:180::22) To DM6PR05MB5577.namprd05.prod.outlook.com (2603:10b6:5:c::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR05MB5577:EE_|CY4PR05MB3431:EE_ X-MS-Office365-Filtering-Correlation-Id: 6d32d32d-fc14-45be-8e72-08daf56825b5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ROVVqtV1meaDHcoOnvFDiMjxWN6Ksx9TZazRVRFpGR5mWffbvh+Fn9lWUi7bKnYvht2EEHeEels9XeHAeJ9SkcqsoDIjEXUoBGZEZ2sCtOemHXXm26qPBM6ZF6S+t/Z7exB4UBxDKPoSGVlw2lbAm38xk167X2GHZlmfg9j1LdFqdTNHnOJ9PK66jQcP26N/f2l1mH+TuMWBVNN0UvAXCQTThJnqBHVJdPCsEQxfahhpRQ+mj2/C5g/wDKvLWBojtC4kOmLQKPhD7fANmPN/UdYQs5ZIuG3u/IlIaqgnKr+yqq9vtcidIzvsyWFKONrNw1O8XrI15G9FcLc/uuE9FOzw+Hb9M5+BcUvKYxDHi1w0JEGkv5SJZ/mFnjiIQpqoSoRM6wq457c8YNpz5ll3+vU4/eHn5Y8GXHtYhmYT/iSUnUG/q/HFFlXSJOi74pUg+8b5NyYM/dhpZ2W6AjfztHSwlvkvykUlqstJeHu34wV/meEStzMfc/LnRhg4hzKvqjA19a/7U93yt39R5NnX5MIivfSfYWgMGA1ZROmB++44MeIZf+JeYxnA5uJbT3WDsqeL/fbvtVFM60Fdr06BBG6CYi23aU15XCPJcb50zW3EqQYYFbStqnbESm6b2ORq1u0MilxCbwJDutVdVFPnwsYrq042ZxqhNVlYxyjqUrJ5BSEE+UdwT+mShlxLhkFp X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR05MB5577.namprd05.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(396003)(136003)(346002)(366004)(376002)(39860400002)(451199015)(6506007)(36756003)(6666004)(2906002)(5660300002)(83380400001)(4326008)(6916009)(8936002)(8676002)(38350700002)(6512007)(38100700002)(478600001)(41300700001)(6486002)(26005)(66946007)(52116002)(186003)(66476007)(66556008)(2616005)(86362001)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?17KNNT4vVynP6YsYTETctVnVgc+OmoSBwIq+V8DVZDl69U2kp7gpysGPzPKs?= =?us-ascii?Q?vy0kRQQpjz9d8UIJtpU2CueVxKang3KVR/4TLa7/lbsPOQMeOuRwkT2cbfWD?= =?us-ascii?Q?v0Zk3S8vQYz638O8BZDdf5zQerQvawKh8Gz54SoBmd9DvH/h83dIGzbn/LNH?= =?us-ascii?Q?L9r5aolZZE+bjM0MzRwTH01mdMdkbYABh7zGk6Rvz7slufO4/Hg93PEyctzr?= =?us-ascii?Q?22G1XvxmmgtLXIQPJl2HfDA0Rasp73oVwr0NclbAFOMJPI5TP9JBopCoa3Ng?= =?us-ascii?Q?Q9iA+KtjaJZPHLY/7sicIRkJP2CToM4ae4duKbk/qlRZyAAG0vx5xtafPGs/?= =?us-ascii?Q?UfqOZUBzdajHQwQbFS/XTanyNQWawFTsgCkqQgO3UoT3SZZqRu/9QoWeX7Le?= =?us-ascii?Q?Agn2y1Vnszo8QY7fJv4l1JZ8kfj+eygalcwp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reQSQUPC7r1ATjkWqyyVITx2TVfYPlKadHLtGM78IIQJAAWC7h2uoK?= =?us-ascii?Q?S5jWyuYKKPk8GGuE/AF2jdf3fpFAfBwJCwK3zbUBzPRvIm7/m7epV2alNqOm?= =?us-ascii?Q?7VmZMiJnE/IusqpcBHEXLEsIDvaw1KK2tUX7LcWN6HnmQoaf38Ihfl6OL/wd?= =?us-ascii?Q?kIJJT4nm6FyjDbDSZpSc61NL/xxcohcSHHE1m1zQO1cjw9WG1whJ/loZFhFm?= =?us-ascii?Q?/EycmtfQtvX2VSRVOqcGl9c2/t0C383uYkkalzNX?= X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6d32d32d-fc14-45be-8e72-08daf56825b5 X-MS-Exchange-CrossTenant-AuthSource: DM6PR05MB5577.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2023 13:14:48.5655 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4vwyldnVoC/2vepmz+iAqCxwIYco4nJ8RjthNIFPI/+iGFQGLQhmvVPLKX5OsX2e400OM6uIaNVLbqZbCqwmWA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR05MB3431 X-Mailman-Approved-At: Sun, 15 Jan 2023 21:11:39 +0100 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 Ignore mask ignores essential bits WHICH could have been contiguous. This commit aims to rectify that 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 | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/eal/common/eal_common_fbarray.c b/lib/eal/common/eal_common_fbarray.c index 313681a..29fffb6 100644 --- a/lib/eal/common/eal_common_fbarray.c +++ b/lib/eal/common/eal_common_fbarray.c @@ -138,7 +138,7 @@ find_next_n(const struct rte_fbarray *arr, unsigned int start, unsigned int n, last_msk = ~(UINT64_MAX << last_mod); for (msk_idx = first; msk_idx < msk->n_masks; msk_idx++) { - uint64_t cur_msk, lookahead_msk; + uint64_t cur_msk, lookahead_msk, lookahead_msk_; unsigned int run_start, clz, left; bool found = false; /* @@ -215,12 +215,14 @@ find_next_n(const struct rte_fbarray *arr, unsigned int start, unsigned int n, for (lookahead_idx = msk_idx + 1; lookahead_idx < msk->n_masks; lookahead_idx++) { - unsigned int s_idx, need; + unsigned int s_idx, need, fsb_idx, fcb_idx, ignore_bits; lookahead_msk = msk->data[lookahead_idx]; /* if we're looking for free space, invert the mask */ if (!used) lookahead_msk = ~lookahead_msk; + + lookahead_msk_ = lookahead_msk; /* figure out how many consecutive bits we need here */ need = RTE_MIN(left, MASK_ALIGN); @@ -236,10 +238,23 @@ find_next_n(const struct rte_fbarray *arr, unsigned int start, unsigned int n, * as well, so skip that on next iteration. */ if (!lookahead_msk) { - /* There aren't "need" number of contiguous bits anywhere in the mask. + /* 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); + } else { + /* Find the first clear bit */ + fcb_idx = __builtin_ffsll((~lookahead_msk_)); + /* clear all bits upto the first clear bit in lookahead_msk_. */ + lookahead_msk_ = lookahead_msk_ & ((~0ULL) << fcb_idx); + /* find the first set bit in the modified mask */ + fsb_idx = __builtin_ffsll(lookahead_msk_); + /* number of bits to ignore from the next iteration */ + ignore_bits = fsb_idx - 1; + /* ignore all bits preceding the first set bit after the first clear bit + * starting from LSB of lookahead_msk_. + */ + ignore_msk = ~((1ULL << ignore_bits) - 1); } msk_idx = lookahead_idx - 1; break; -- 2.7.4