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 2542AA0C43; Thu, 23 Sep 2021 12:21:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9ED0D4125D; Thu, 23 Sep 2021 12:21:44 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id A524341250 for ; Thu, 23 Sep 2021 12:21:42 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10115"; a="220613357" X-IronPort-AV: E=Sophos;i="5.85,316,1624345200"; d="scan'208";a="220613357" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Sep 2021 03:21:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,316,1624345200"; d="scan'208";a="702667655" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by fmsmga006.fm.intel.com with ESMTP; 23 Sep 2021 03:21:40 -0700 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Thu, 23 Sep 2021 03:21:40 -0700 Received: from orsmsx604.amr.corp.intel.com (10.22.229.17) by ORSMSX612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Thu, 23 Sep 2021 03:21:40 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx604.amr.corp.intel.com (10.22.229.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12 via Frontend Transport; Thu, 23 Sep 2021 03:21:40 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.173) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.12; Thu, 23 Sep 2021 03:21:40 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hFBFRiOQha9BOBwawRvy0JLqRBGghV8J1Evzozcr/1JQFvo2JEk9xlRJinIWa8mt3umsrdPcTuKr8TtAhU4jeTRdhma3N9GfWnGvmxXeoAhgYI3ogoyT1eSADmB6t/yu3/lGpGiNO0xnCq6Dp3gEx7MqUmXpMIMuxRO4Svji6MoFY2NociOluspRTmq3NOPzXOviK1rO7rDcnOmDFDFJKGV9vnx9kKLUxAEnZveaIPb+TJzvTiD7ME+a7fVxFPZeOp5/IyW8vBcnquB8sEYoVkdb/jAlwJjQyE5IDnNPCaR/SGkFfapYwCftCq+1hZLPcriwGhRHC58C+A2ugNuWTg== 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; bh=teJ9CMW4vG8IkOhnElDlYNWdQHR3o3OV9B9UrvSz9s8=; b=ZAZb3bS3Mw16vfSu0XVcHszh3ZToFUqHqAkU7oT/5wPfH6yaIvDLF/OZJbuWC4GLw/Kvyc8ejNKwRKfq3Nj/mmtULC2GHppi6bGC8fmR6OlM+VNUreNJZme1gx/PoAyeaiXwhvDLjl0nqMbgLpgW/nSfiMIONqb4VzpEuvCAbOKFeqC/XnU4w0iKDpzZBhnqlFdR+SblmichtyYWapKZpBwb1QEEn7wi9pLCyuM4jRtlDUPKCMB6GTR+vQ/etmqNeZKB+pjd2RBkXG4yVBP1Ioj8O1S2VndOUxDMBZ3ebI+DPDbY0ui9IY8EAa0v7yr9n1dABAvChqe4Wc21Kitv9w== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=teJ9CMW4vG8IkOhnElDlYNWdQHR3o3OV9B9UrvSz9s8=; b=i+p6xD+B5bI9YNaVoiKAZE2UorNp4rZai4BAiZri7uSWynUjnLqzUNXtAIPPirkbs8rX9hXQWWmu9ZLGyjI5oqAF78bYhfrD8SwMhWx0D1l+OWKGlR+lufR+o5PP7AB54/oq2W2+jovTBuXTQNBrESKlTqiQTVpiASCYb8/6fg8= Authentication-Results: monjalon.net; dkim=none (message not signed) header.d=none;monjalon.net; dmarc=none action=none header.from=intel.com; Received: from PH0PR11MB5047.namprd11.prod.outlook.com (2603:10b6:510:3c::18) by PH0PR11MB5014.namprd11.prod.outlook.com (2603:10b6:510:31::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13; Thu, 23 Sep 2021 10:21:38 +0000 Received: from PH0PR11MB5047.namprd11.prod.outlook.com ([fe80::a495:76aa:e576:1281]) by PH0PR11MB5047.namprd11.prod.outlook.com ([fe80::a495:76aa:e576:1281%4]) with mapi id 15.20.4544.014; Thu, 23 Sep 2021 10:21:38 +0000 To: David Marchand CC: dev , Bruce Richardson , "Thomas Monjalon" References: <20210921115015.36442-1-david.hunt@intel.com> <20210922122920.34759-1-david.hunt@intel.com> <20210922122920.34759-2-david.hunt@intel.com> From: David Hunt Message-ID: Date: Thu, 23 Sep 2021 11:21:32 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.14.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-ClientProxiedBy: DB8PR06CA0023.eurprd06.prod.outlook.com (2603:10a6:10:100::36) To PH0PR11MB5047.namprd11.prod.outlook.com (2603:10b6:510:3c::18) MIME-Version: 1.0 Received: from [10.4.11.161] (95.45.23.115) by DB8PR06CA0023.eurprd06.prod.outlook.com (2603:10a6:10:100::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13 via Frontend Transport; Thu, 23 Sep 2021 10:21:36 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 17d1bf6a-fab3-4278-8137-08d97e7bed3e X-MS-TrafficTypeDiagnostic: PH0PR11MB5014: X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1443; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hS1rOTuTQL9vTC1vUsjFq9vs88Wupxes9jd8rJxE34T6GOLqKQZZiEU5Em3DWvr/oCmvawTNtikxHKa2LU2Ji2+SAytsMwc2ykWJQi0iNgfWqnqUZo1rzbp8shxocxz8K6cXy27c4BoWbSmfOWTKTxOp+JpXRgHEFsNU9Gr1KAbte5RkDtSrBa4oU33zbwch9myG8cTf8SdftwI1KbCF4/y6C0rJwIDJGAkqoz0ME7+fQnf01XW9PwrXQKdhCM47qrac4RgmB4NpvXomuv1rFg2utRk0nLuxwVosbpbpf4bdSCvi6oJQZMl7onGvNBlIioNBkL7jSBueV0gwFSJZP/vzGteuv9EVdGsFHkdr8/A2K1CIaY/mRO9DX7MDEHPDLg5tmgD79hj7doTZ0QJ8GylTSci3fDrO9AfiFnzVGHDDpQ7EMJYqJTa+qaxORQF+UVEzDkGDegpHd/6L4z0Y/XlIFRshlgZeg0PELwiYal23t7RpNE4MRd++kNH9RiDDmbo7wVLJE9dFWLA7FnkjFG84JeTswPlYXeDqt0eUHBtjuePwr/tDZ8xGi9pdQnQm36rkynSw7zBzyKdYmquviumSf4F1TpG8IpEBMxpa2AzDvMBmPMQK41hWxTcEByvpJWhWkv0EaSohPGGTrdHklDZ2rvjrY3BaCPUjJ6kHCuhu9j84zMV5glX5VFOwG2L+q0Uohxq5dkl2fPrKqKmH9t0SUzxvYFacUk09Af5WMAyKCwnA7HMB+qXnaqclYGQI X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR11MB5047.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(186003)(53546011)(26005)(8676002)(31686004)(83380400001)(38100700002)(54906003)(6666004)(2906002)(6486002)(6916009)(66556008)(66946007)(16576012)(316002)(508600001)(86362001)(31696002)(36756003)(44832011)(4326008)(66476007)(5660300002)(8936002)(2616005)(956004)(43740500002)(45980500001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?MW1DNUNBOHhpM09XS3JFOXlTODRWQjBHcFRCVU1jczdlSXU3SEhUZHoySzVM?= =?utf-8?B?RTJJL2wzTFoyckoyS1BkcFhzd2g1VGFWWW1UOUU3TGJtcm5RejNuVG1JMDJX?= =?utf-8?B?YWkyM29tUDFVT1lCNkUxSlNqODExRkIxSDRvM09qZS92OUIwblhhc2EyVHVn?= =?utf-8?B?MkFhMUQwRGQwYkhXeXg4MGFpRkUrdTUzRnAyaVFMamJGUnpVY3dwRUhUZEpn?= =?utf-8?B?c0piclZYclIzS2RBZEVDa0ZpcnVOVzF2MU16RmtzZHpKdm0rTE1aQ2FDOE5v?= =?utf-8?B?RWVQN0J2MndQeWJNc3F3UGhKeUYvaGhRV0dU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6QnE1aVAyN1BNdTQ4bWU4bmxyWUVVMFVybzZh?= =?utf-8?B?ME5GUkRQSXdUV09TNlJ6ZkxUM1hwZnBhK0ZWbUJiYmZjbjgvMGhkRGZ5VWQw?= =?utf-8?B?MDJUUHQ2OTRRcEcwQmMrdGYrVHlwODgvN1lFODZmNEp5cDVXcXFjTFpLRzJ2?= =?utf-8?B?bkFLZVpFVThRdTZRNE5HWGlhb1laTERjYmZBWC9BdmlLZU9la08vTEhqdCsv?= =?utf-8?B?SWgzRWpSTndmUzh4eHA3bEgyTktzZFdTMmhMQXhrT1JtUW1haVIvaEgreFkv?= =?utf-8?B?cDhzTExyTFJObWVRRFA2N1ZEZ09pZzdqWXNETGoySnpUS2d1dzVEWEtiNFQ0?= =?utf-8?B?b2NOM1V4QXRTUXJrK2JiTHdxVGM1R2lCOWd4OGtJdTNkUWhpd1NoNWkyRXcz?= =?utf-8?B?WnhaY3UxMXhXWW1ySW5sVGhsR1FLMFl5eVBLdit1OVNJZi9zekQ1Y1JrQTlM?= =?utf-8?B?Q2pJNXlJZkZWRDFwdUw3SW50YlU1bFE0U2FWT0tTWGJyYlAvMzRlY1o0QTZx?= =?utf-8?Q?TFizHcIaSpzTw0v5aXuXZhujpGlISCxQ5Cq/Tix?= X-MS-Exchange-CrossTenant-Network-Message-Id: 17d1bf6a-fab3-4278-8137-08d97e7bed3e X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5047.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2021 10:21:37.9802 (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: W7M4ytvuTqcBkYCedf/dEjPudqCVXnB4XmyB0bMXlVguug8YcneulfaKojU43Q8ptZQILpp0tTZO2nBbblAe+g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB5014 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v4 2/2] eal: add additional info if core mask too long 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 Sender: "dev" On 23/9/2021 9:12 AM, David Marchand wrote: > On Wed, Sep 22, 2021 at 2:29 PM David Hunt wrote: >> >> int i, j, idx; >> int val; >> char c; >> + int lcores[RTE_MAX_LCORE]; >> + char *coremask_copy = NULL; > Contrary to patch 1, coremask_copy is used. > But, coremask is const, we can directly use it in log messages. > > So same as patch 1, please remove coremask_copy. const protects the data being pointed at from being modified, but the pointer itself can still be modified, and the pointer is indeed incremented to cut off leading zeroes and spaces. For example, if I provide "  0x0" as a parameter,coremask prints as "0", where as coremask_copy prints as "  0x0". Similarly, if I provide "0x" as a parameter,coremask prints as "", where as coremask_copy prints as "  0x". Instead of using strdup, I can use "const char *coremask_orig = coremask;", and remove the strdup and the frees... > >> for (idx = 0; idx < RTE_MAX_LCORE; idx++) >> cores[idx] = -1; >> idx = 0; >> >> + coremask_copy = strdup(coremask); >> + if (coremask_copy == NULL) { >> + RTE_LOG(ERR, EAL, "Unable to duplicate coremask\n"); >> + return -ENOMEM; >> + } >> + >> /* Remove all blank characters ahead and after . >> * Remove 0x/0X if exists. >> */ >> @@ -767,30 +775,64 @@ eal_parse_coremask(const char *coremask, int *cores) >> i = strlen(coremask); >> while ((i > 0) && isblank(coremask[i - 1])) >> i--; >> - if (i == 0) >> - return -1; >> + if (i == 0) { >> + RTE_LOG(ERR, EAL, "No lcores in coremask: %s\n", coremask_copy); >> + goto err; >> + } >> >> - for (i = i - 1; i >= 0 && idx < RTE_MAX_LCORE; i--) { >> + for (i = i - 1; i >= 0; i--) { >> c = coremask[i]; >> if (isxdigit(c) == 0) { >> /* invalid characters */ >> - return -1; >> + RTE_LOG(ERR, EAL, "invalid characters in coremask: %s\n", >> + coremask_copy); >> + goto err; >> } >> val = xdigit2val(c); >> - for (j = 0; j < BITS_PER_HEX && idx < RTE_MAX_LCORE; j++, idx++) >> + for (j = 0; j < BITS_PER_HEX; j++, idx++) >> { >> if ((1 << j) & val) { >> - cores[idx] = count; >> - count++; >> + if (count < RTE_MAX_LCORE) { >> + lcores[count++] = idx; >> + } else { >> + RTE_LOG(ERR, EAL, "Too many lcores provided. Cannot exceed %d\n", >> + RTE_MAX_LCORE); >> + goto err; >> + } > You can invert those blocks: > > if (count >= RTE_MAX_LCORE) { > RTE_LOG(); > goto err; > } > > lcores[count] = idx; > count++; > +1 > >> } >> } >> } >> for (; i >= 0; i--) >> - if (coremask[i] != '0') >> - return -1; >> - if (count == 0) >> - return -1; >> + if (coremask[i] != '0') { >> + RTE_LOG(ERR, EAL, "invalid characters in coremask: %s\n", >> + coremask_copy); >> + goto err; >> + } >> + if (count == 0) { >> + RTE_LOG(ERR, EAL, "No lcores in coremask: %s\n", coremask_copy); >> + goto err; >> + } >> + >> + if (check_core_list(lcores, count)) >> + goto err; >> + >> + /* >> + * Now that we've gto a list of cores no longer than >> + * RTE_MAX_LCORE, and no lcore in that list is greater >> + * than RTE_MAX_LCORE, populate the cores >> + * array and return. >> + */ >> + for (k = 0; k < count; k++) >> + cores[lcores[k]] = k; >> + >> + if (coremask_copy) >> + free(coremask_copy); >> + >> return 0; >> +err: >> + if (coremask_copy) >> + free(coremask_copy); >> + return -1; >> } >> >> static int >> -- >> 2.17.1 >> > >