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 80656432E6; Fri, 10 Nov 2023 12:18:22 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 693D940E5E; Fri, 10 Nov 2023 12:18:22 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id F341640291; Fri, 10 Nov 2023 12:18:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699615101; x=1731151101; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=JllPt3GMteom94crciie+MHUq7OrwoGLbIW72vvTUbo=; b=eSQJgN3TWvrfAIjJO4ljZFoITb/QZiU5oMVTXaJoXKS/0Cqd04Hxv8qq zL698eys8s/2UEukVhBU1nOO/p0J3HkLA/t/YTAha6rN+nB25A9yCh19C jieZ+A2g3uUdxHccrQarp18h8o4oBja8fyMPxlC2HffrvYvnw0sHEtyGe IU3lbzcmA509k5jtQJfXrI729jwrLJaFwnH/42ynILQu+QnC7pCSEOjE1 OaY23+DLyMZN8OtCymwilc6T3ruOn8GGOWaw6zDiL3ujHCTgA0AS1mIEL HotHbL5G2KiGK8CsfYAWInoo5ymrrl613fP4NinP2WkfIwrPXMgnVL1dI A==; X-IronPort-AV: E=McAfee;i="6600,9927,10889"; a="387333483" X-IronPort-AV: E=Sophos;i="6.03,291,1694761200"; d="scan'208";a="387333483" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Nov 2023 03:18:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10889"; a="792839404" X-IronPort-AV: E=Sophos;i="6.03,291,1694761200"; d="scan'208";a="792839404" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by orsmga008.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 10 Nov 2023 03:18:19 -0800 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Fri, 10 Nov 2023 03:18:18 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34 via Frontend Transport; Fri, 10 Nov 2023 03:18:18 -0800 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.100) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.34; Fri, 10 Nov 2023 03:18:16 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bYK/HJ4gDa7oFAGJS0tbrWfHxcPajPP8BU57MfWCFSrBxmbJEmy0/pzZIPFYZvx9Abr+hNGvJhdTs1bUPvISkkBqpRPk1wJH93xNI4kETIV850TSV6FvGVV43/kODjBRRMWWUt9bF+QWbOLI8Vq7+e+9QiFT3GzkgJAQZIremDG3l0KFba30j1N6dufZt++9cyJhukF9+DSDdF1D3ZZDolXEVwJVgbhw7qBMiCVCwunXYjOjoE9qn4Esi5xw2UDBw58Lbhs+FVO8hBpUJ20dq7AVfGG1YYqMn/ECPUxshGAwtncoomlfCewDUAo4kT5p2VHw1/mL8MMNmLeGZ2cjpA== 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=Q/Sn4KgWwjtpq0vRdojnUU1mstIOpuDi5TssgmxgSNM=; b=PoEPzM8itFqsyoMN9s5tQusYoVFh/ETUIzV+VrzMJU4SGxFJpoYGUhzNeZNMsFTR6K5gCi6RAttBOAVVERJa/tcbQyKhPEFiug6Atjw9GFTr6uR2RW1Rh9ot0UZUkjtRvjKROGat9UwUYa+XGLY+RaDbItx8awEPQ91BhkZXA37N+Jy65gJf6S3vKRegZ+a2HkBoOCqHsD++gID7CsucL7b/HgBBVMMkb4vNLooY61VvYicXVPjITmQwzqPWRbOMACuW67+7OZWf0tI6DXva2GmcLCG0U3whmq8KNk3SlVZ4yebB//RUMLXqh59biABmlWH78b9QQe97hSHjv9z5Uw== 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 DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) by IA1PR11MB8176.namprd11.prod.outlook.com (2603:10b6:208:452::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Fri, 10 Nov 2023 11:18:09 +0000 Received: from DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::8645:d921:ce8a:12ba]) by DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::8645:d921:ce8a:12ba%5]) with mapi id 15.20.6954.028; Fri, 10 Nov 2023 11:18:09 +0000 Date: Fri, 10 Nov 2023 11:18:03 +0000 From: Bruce Richardson To: Mingjin Ye CC: , , Subject: Re: [PATCH v5] app/test: secondary process passes allow parameters Message-ID: References: <20230927034204.2279012-1-mingjinx.ye@intel.com> <20231110103013.469430-1-mingjinx.ye@intel.com> Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20231110103013.469430-1-mingjinx.ye@intel.com> X-ClientProxiedBy: DU2PR04CA0346.eurprd04.prod.outlook.com (2603:10a6:10:2b4::33) To DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR11MB7309:EE_|IA1PR11MB8176:EE_ X-MS-Office365-Filtering-Correlation-Id: 8f165089-f43d-41a8-3151-08dbe1deb7fe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SIwSeqrwCPThRgQqwP1FMT6+zls20mDYlFTaB/upCDYVYPDLSDyzjCdU+Jx8pENZiYd4gpY2SS9EJWmT3e7V214LuY9jUE8GZ33kRgbD/5BjZpFNDSh40YVwB0dAnnDwcwsxiTdvKBKtdhPFbP2Jl80YnJgghdrm+mtI74pFxjCsBHQdJW70ok2D4qevG6eaW5+fmg2NqGFKVTmB69S+HTZz6ECBCHj+SCIEzerzyO7LG4x0IOPsjGDn3lh0jtaEfGISNzpVJM0KpjAeNd4Xm5Y/tRn3RWtx1+iFsqXXTWvvyjZ3B3u1C89YWvFQA4sVGXzXYU0ylClVQOcs2LubkOuMcKirg9hxLHryyT6GjzycdoWmuNzljcoK6ZGKRYked7FYtIPPrFkm7J0J4lp8KwBS2kYjm2m23T4dEZ97YDz9S2lR5gBqX3UAako3MkVlNQ2HWKzzra1RNMk8OAgd/vfOsfSQ1vmzn9qnLYFd7IXEZ8Pv0LVjUUGQrukc8Tk/fJFNJrt5HMwk5Vml3T2HlMraV+Kh8yAe9FPnRBfpA/jXYK76XgTBZ8RDkFIt/hou X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS0PR11MB7309.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(136003)(366004)(396003)(39860400002)(376002)(346002)(230922051799003)(64100799003)(451199024)(186009)(1800799009)(2906002)(8676002)(5660300002)(86362001)(6862004)(83380400001)(38100700002)(41300700001)(82960400001)(316002)(6512007)(8936002)(4326008)(44832011)(6636002)(66946007)(66556008)(66476007)(6666004)(6506007)(26005)(6486002)(478600001)(450100002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?QGsRPYAAJgmWB1xKeLqzpXXhsUVkdaMi4SBVoOS98WP+hMUA0uJXtdohUhjk?= =?us-ascii?Q?xRnRrdKR7cpcgH1yKLCR9xekmSXE9QTWp7+Z5Vcn2gGB3DXQ3wxBOalnvqMa?= =?us-ascii?Q?Nm08nnTfNkZM+eKYnFJjo+FNVPcJUYeTPDhGXFapjXcrTG3pBcOItgiEKuCh?= =?us-ascii?Q?hZmdN0w2xJhow30yFuN0SW/OUPuY95JbqMGF5xU0A9z9VpFJaDZq6rKogxvy?= =?us-ascii?Q?y5FLDk3DIGERPBr+APzqbhSTjV7YWvVKbKswNtt4tTKYul3zEJcs1iSb3tuC?= =?us-ascii?Q?HsQRVmkoEbpnxa1zhQM1DSySOshv22ugX9UPL65pQyLJp+CEfvWc1q3VUL+z?= =?us-ascii?Q?Bp+Iusg6yH6rtcq5JDjWTw6c9vALgL4abbYgnsC3GYKLrgvj7bZejBWwou8d?= =?us-ascii?Q?i8+kWcJgQTZ3lElkZfAjlCGfAHYNu1MbeeAQ4R6KntxvbmpB1c/f1cKPsej2?= =?us-ascii?Q?vsGw4jMMi6QtFMEp6cOAjk9WpEWCFLVCbejVNq/QSxWtUAZ4g5ObbQ5Tb549?= =?us-ascii?Q?u1ngYfPuHswQHjvt0xPy3v9kn9DTxOZXsQeIyih+I3ftP/rEGRzyTZ4FSzID?= =?us-ascii?Q?gpDemtZxFb1Yv9jmfZxfp/sKOB1zFv240b8e9r7Ni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GucpgiHPubt2b3jPwGdeALsAifVahApVC/GXI8cKnypPkoAX9WC?= =?us-ascii?Q?i20zD6shSBiFWpXyfwEg9o9gVVPVPwJp6PFtxWZhZQwNb+glbT5fHCHpD5c+?= =?us-ascii?Q?Rw=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 8f165089-f43d-41a8-3151-08dbe1deb7fe X-MS-Exchange-CrossTenant-AuthSource: DS0PR11MB7309.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2023 11:18:09.1121 (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: 6lZKOjebz2tBzd6QUwt9AZLEAXPL2YNVPHYqvNen4RlFLCm98A0+7qAtoDXTmXdz/2yIzdZHUV3PL0f0t3h7FIfzMghIGT9P5r5iYHr04Ps= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR11MB8176 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 On Fri, Nov 10, 2023 at 10:30:12AM +0000, Mingjin Ye wrote: > In EAL related test cases, the allow parameters are not passed to > the secondary process, resulting in unexpected NICs being loaded. > > This patch fixes this issue by appending the allow parameters to > the secondary process. > > Fixes: af75078fece3 ("first public release") > Cc: stable@dpdk.org > > Signed-off-by: Mingjin Ye Some additional comments below. Sorry I missed out on them in my first review. /Bruce > --- > v5: Optimized. > --- > app/test/process.h | 74 +++++++++++++++++++++++++++++++++++++++++++--- > 1 file changed, 70 insertions(+), 4 deletions(-) > > diff --git a/app/test/process.h b/app/test/process.h > index af7bc3e0de..f8beb3c36f 100644 > --- a/app/test/process.h > +++ b/app/test/process.h > @@ -18,6 +18,8 @@ > > #include /* strlcpy */ > > +#include > + > #ifdef RTE_EXEC_ENV_FREEBSD > #define self "curproc" > #define exe "file" > @@ -34,6 +36,57 @@ extern uint16_t flag_for_send_pkts; > #endif > #endif > > +#define PREFIX_ALLOW "--allow=" > + > +static int > +add_parameter_allow(char **argv, int max_capacity) > +{ > + struct rte_devargs *devargs; > + int count = 0; > + char *dev; > + int malloc_size; > + int allow_size = strlen(PREFIX_ALLOW); > + int offset; > + > + RTE_EAL_DEVARGS_FOREACH(NULL, devargs) { > + int name_length = 0; > + int data_length = 0; > + > + if (count >= max_capacity) > + return count; > + > + name_length = strlen(devargs->name); > + if (name_length == 0) > + continue; > + > + if (devargs->data != NULL) > + data_length = strlen(devargs->data); > + else > + data_length = 0; > + > + malloc_size = allow_size + name_length + data_length + 1; > + dev = malloc(malloc_size); > + if (!dev) > + return count; > + > + offset = 0; > + memcpy(dev + offset, PREFIX_ALLOW, allow_size); > + offset += allow_size; > + memcpy(dev + offset, devargs->name, name_length); > + offset += name_length; > + if (data_length > 0) { > + memcpy(dev + offset, devargs->data, data_length); Do we need a comma "," before devargs->data in the output string? > + offset += data_length; > + } > + memset(dev + offset, 0x00, 1); > + > + *(argv + count) = dev; > + count++; > + } > + Sorry for the late feedback, but I believe this whole block can be hugely simplified by using asprintf. RTE_EAL_DEVARGS_FOREACH(NULL, devargs) { if (devargs->data == NULL) { if (asprintf(&argv[count], PREFIX_ALLOW"%s", devargs->name) < 0) break; } else { if (asprintf(&argv[count], PREFIX_ALLOW"%s,%s", devargs->name, devargs->data) < 0) break; } if (++count == max_capacity) break; } This way, the only variables you actually need are devargs and count. > + return count; > +} > + > /* > * launches a second copy of the test process using the given argv parameters, > * which should include argv[0] as the process name. To identify in the > @@ -44,7 +97,9 @@ static inline int > process_dup(const char *const argv[], int numargs, const char *env_value) > { > int num; > - char *argv_cpy[numargs + 1]; > + char **argv_cpy; > + int allow_num; > + int argv_num; > int i, status; > char path[32]; > #ifdef RTE_LIB_PDUMP > @@ -58,12 +113,17 @@ process_dup(const char *const argv[], int numargs, const char *env_value) > if (pid < 0) > return -1; > else if (pid == 0) { > + allow_num = rte_devargs_type_count(RTE_DEVTYPE_ALLOWED); > + argv_num = numargs + allow_num + 1; > + argv_cpy = malloc(argv_num * sizeof(char *)); Check return from malloc. > /* make a copy of the arguments to be passed to exec */ > for (i = 0; i < numargs; i++) > argv_cpy[i] = strdup(argv[i]); > - argv_cpy[i] = NULL; > - num = numargs; > - > + num = add_parameter_allow(&argv_cpy[i], allow_num); > + if (num != allow_num) > + rte_panic("Fill allow parameter incomplete\n"); > + num += numargs; > + argv_cpy[argv_num - 1] = NULL; > #ifdef RTE_EXEC_ENV_LINUX > { > const char *procdir = "/proc/" self "/fd/"; > @@ -131,6 +191,12 @@ process_dup(const char *const argv[], int numargs, const char *env_value) > } > rte_panic("Cannot exec: %s\n", strerror(errno)); > } > + > + for (i = 0; i < num; i++) { > + if (argv_cpy[i] != NULL) > + free(argv_cpy[i]); Free is ok to call with NULl, so you can skip the check and just do for (i = 0; i < num; i++) free(argv_cpy[i]); > + } > + free(argv_cpy); > } > /* parent process does a wait */ > #ifdef RTE_LIB_PDUMP > -- > 2.25.1 >