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 D64EB45FE6; Wed, 29 Jan 2025 01:10:22 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 77C7540268; Wed, 29 Jan 2025 01:10:22 +0100 (CET) Received: from DM5PR21CU001.outbound.protection.outlook.com (mail-centralusazon11021123.outbound.protection.outlook.com [52.101.62.123]) by mails.dpdk.org (Postfix) with ESMTP id 8DAE540265 for ; Wed, 29 Jan 2025 01:10:20 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=OmtqAblowD/pONmcEdjWlHCa6AgfGxtkDjoBtXfeW5WQOWFOE9ssRyEecQI5yqrF/rgUi7+Cs8KEt8OLRXpbtSdvEXMc5Qf8XcF4LqUtQTLEBckb6en0aYWjrqyRAOtMyJ5UEvb2ALt4xu+lqjQUibPRWEdJIerBqKLxnZOTj7VStBqtRNZE2bODbNu9NY52eP8Nehupsi2hOp45HCTe50PFMRBlPZhM2sYmM+UnPGKXsK8X8nC30V9teWKXn7pE+7PAp/QqZqph5T8zkJN9U/p3LyFq/wkzEfpyVjw88tH63IcFy3jMe1AltnaaCfHi5n8+DzDUSACUQRMrYjFxUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=s31C+2ioxruuuoLkhJJY5BdLIDaD+e3FL9NIxzy3EY4=; b=tb8k+plS/UTc8kL5gcyx/spRrpIJdE4anuE+EagnCGUvm2v8Zrj9oUZVzjzu7t1GBgYrwvvDcYz1DAGuOTrjkqXqcoixQMmteX2x+tpPAQtkG0TV6AZoZoSYSVO7mccPI7D7nZHJGqNkGwHeDmpT5u/QVEUSGQuie16vwNKKDLkeN1nSjEhYgHkvdnDzW70dkKyYWL/NJGSRzsYmO5j2pAxAYoOxQWvy881+mTGDjkjwLlLM6EnUZ/KfAjC6RkrrYmkCT4rpNbgcCAP+t2ly3cZt+bsj+Fwwu+AC2Y/Ah72Uylsiqr1m8jmKLS+TSH9tTqlPPylDoqWZASZtkrKLyg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=s31C+2ioxruuuoLkhJJY5BdLIDaD+e3FL9NIxzy3EY4=; b=Y8VZGlOfQoBB9JeZeH6Zj7GtCQ77w1hH+2BwqM9sNlbTfbtZI9+skbuA9kVZDB5HW6yumRJlxYr22+RwsakunQe2oIdoHGQXEItW8PoLckVG5t+23GUPubUCPkFp0DGbI2bX1JkziJHY1oJyIa4t6zH1mImjqiCxbvsy9ztUuy8= Received: from SA6PR21MB4231.namprd21.prod.outlook.com (2603:10b6:806:412::20) by CY5PR21MB3612.namprd21.prod.outlook.com (2603:10b6:930:f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8422.4; Wed, 29 Jan 2025 00:10:13 +0000 Received: from SA6PR21MB4231.namprd21.prod.outlook.com ([fe80::5c62:d7c6:4531:3aff]) by SA6PR21MB4231.namprd21.prod.outlook.com ([fe80::5c62:d7c6:4531:3aff%5]) with mapi id 15.20.8398.014; Wed, 29 Jan 2025 00:10:12 +0000 From: Long Li To: Stephen Hemminger , "longli@linuxonhyperv.com" CC: Ferruh Yigit , Andrew Rybchenko , Wei Hu , "dev@dpdk.org" Subject: RE: [EXTERNAL] Re: [PATCH 4/4] net/netvsc: cache device parameters for hot plug events Thread-Topic: [EXTERNAL] Re: [PATCH 4/4] net/netvsc: cache device parameters for hot plug events Thread-Index: AQHbcce/rc9eOeRySEeaW83iwXBySLMs3iDA Date: Wed, 29 Jan 2025 00:10:12 +0000 Message-ID: References: <1738028106-25239-1-git-send-email-longli@linuxonhyperv.com> <1738028106-25239-4-git-send-email-longli@linuxonhyperv.com> <20250128130056.399a1dd5@hermes.local> In-Reply-To: <20250128130056.399a1dd5@hermes.local> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=156a364a-c2e0-4c4f-811b-70ffdc5b1a77; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=true; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=Internal; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2025-01-29T00:00:45Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Tag=10, 3, 0, 1; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SA6PR21MB4231:EE_|CY5PR21MB3612:EE_ x-ms-office365-filtering-correlation-id: 530c0b13-0ea3-4f54-81e7-08dd3ff94cfe x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|1800799024|10070799003|376014|366016|38070700018; x-microsoft-antispam-message-info: =?us-ascii?Q?V9wjOoaF5/v3vVMgKE31JGPrfF/Ue4Ti1WUVAlNaOA26l0uBQDNxt5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Y9rgFDDsrEtykJQLMHujS9NrqLMNH8?= =?us-ascii?Q?0sMcJJIDOWFIaeFLMACUSel3n7BEzhsWiHGYBBbAadaQQBx+B9kE44giMD/l?= =?us-ascii?Q?SU1r+ouQlK2Ic/d8zVuyyCvEzQtPshuL/k4yZmSksz7X9+GaRHrYXWKbDC0u?= =?us-ascii?Q?HNgj2Nhk+WDyUCrP9fEydU/kFRkLG1aE0siOIG0AEekFktD1N64zQxrXmILj?= =?us-ascii?Q?wYYW0Het340fESaLT399yIhMPOElngagg8NXfdygl8kEtRc9TN5e9FU6pb6B?= =?us-ascii?Q?9+xKfBKVm1UKUog6S6C2XyPMffvEbO2oeKxLZAmSbFh6EYgCvfEPWMYw/orB?= =?us-ascii?Q?MBPjbemUOXZ1Y/JzG777eucd/aUXmVTfzV2LMh6Xm5VSYc+306SZyX7lsD1F?= =?us-ascii?Q?VeRwkjILEULpNM3yOsBXgR+Mng2Jqlb99pA2CSTQ2YVoEIppOf8H52/1Vo4C?= =?us-ascii?Q?N0BYazRLSPt67sReTdrvy6XL0dIACpOqh68n7NHIo3yhJytpO161bYJl+EzC?= =?us-ascii?Q?Mvo6JMRf3YcAHwN4lUrMTGbI7yM5pJiv?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SA6PR21MB4231.namprd21.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(10070799003)(376014)(366016)(38070700018); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?LQbrZEpN41EegFe5IdmpjnGJpdkaklTywJNDBtpLfGX6ZIdPSFXQrzZ4eqS6?= =?us-ascii?Q?GM9POL/CN/SeZ866wKFxnj9FMALm3zz0Twmr5i8gr5UvPtfFMIFSw0W1xLoO?= =?us-ascii?Q?IboGpGCswpAZhAgdsNkKKIxQ+2YetJ5mTqIgymgChHdD5M+tiqS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0UpjexEiULTRdZ5FPCpSoaSJ7NM9y1X9Buo22LkLQ+2H?= =?us-ascii?Q?tBu6Tqx+XAs0DP3L6V8gCNdL0rBs8a8RVAPK4QG+v6Q7jVtZ3AvuS1gvTpcG?= =?us-ascii?Q?o9V2cscV5StbbftvvheQf/b+grxfTmj/y3PHBoWLojnoPSz2BvHPeqlHxVLm?= =?us-ascii?Q?UezieAjfrepEJntHSi5a5vver8WjM3t+IADeB/q0pbcycbGqDeyN0Ie3Le51?= =?us-ascii?Q?mkyjUNDCRObTRXBIXiQz5eseUdSjPuwtvrKwtmzZVPn98aSPjzITJoaTiTlJ?= =?us-ascii?Q?aqnOwb4HjeS1Q9uXSxk5a/FxFoI9Cov5a0HR40I4qUrZyaK5Q5k04gSJDiAn?= =?us-ascii?Q?GrIPPL0qDzyeP/2wPXoeHlL9I0rgap8UVfN8HmGmncqbSFCX6o/5bmXoPqwN?= =?us-ascii?Q?CLFyJo4Xrad3c4TbGM1GIECK8j8lmAWjRovDnkQ9LiQLrJBrjbqi16byyJNg?= =?us-ascii?Q?ASYQvIz4zX03vt73hmW75OsRb9zeW2l0P6wSLKQ3oJzcpwfTftfP/EeSMFRZ?= =?us-ascii?Q?2aDWBoc3XCKmBoiPHyAW5bzbCW7/7JCwFlgY/v5JxuVpWIvkLdZjZM6p3Mvy?= =?us-ascii?Q?EbqlOxSmyu0v0taI2+xA0z7ZOlMOcGoFAVWeWYUszdR5?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SA6PR21MB4231.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 530c0b13-0ea3-4f54-81e7-08dd3ff94cfe X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Jan 2025 00:10:12.7345 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: /UDOv/tGqOmcwtk/kYgyBDGxGXeiMuk9u3M1xVshAA0L32aiicEKMEp5wKM9kbw3oiXlZhViD5+JAMvl05DPfg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR21MB3612 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 > Subject: [EXTERNAL] Re: [PATCH 4/4] net/netvsc: cache device parameters f= or > hot plug events >=20 > On Mon, 27 Jan 2025 17:35:06 -0800 > longli@linuxonhyperv.com wrote: >=20 > > @@ -1409,9 +1424,6 @@ eth_hn_dev_uninit(struct rte_eth_dev *eth_dev) > > ret_stop =3D hn_dev_stop(eth_dev); > > hn_dev_close(eth_dev); > > > > - free(hv->vf_devargs); > > - hv->vf_devargs =3D NULL; > > - > > hn_detach(hv); > > hn_chim_uninit(eth_dev); > > rte_vmbus_chan_close(hv->channels[0]); > > @@ -1423,6 +1435,61 @@ eth_hn_dev_uninit(struct rte_eth_dev *eth_dev) > > return ret_stop; > > } > > > > +static int populate_cache_list(void) > > +{ > > + int ret; > > + struct rte_devargs *da; > > + > > + rte_spinlock_lock(&netvsc_lock); > > + da_cache_usage++; > > + if (da_cache_usage > 1) { > > + ret =3D 0; > > + goto out; > > + } > > + > > + LIST_INIT(&da_cache_list); > > + RTE_EAL_DEVARGS_FOREACH("pci", da) { > > + struct da_cache *cache; > > + > > + cache =3D rte_zmalloc("NETVSC-HOTADD", sizeof(*cache), > rte_mem_page_size()); > > + if (!cache) { > > + ret =3D -ENOMEM; > > + goto out; > > + } > > + > > + strncpy(cache->name, da->name, sizeof(da->name)); > > + cache->drv_str =3D strdup(da->drv_str); > > + if (!cache->drv_str) { > > + rte_free(cache); > > + ret =3D -ENOMEM; > > + goto out; > > + } > > + > > + LIST_INSERT_HEAD(&da_cache_list, cache, list); > > + } >=20 > Why do you need to cache entry to be page aligned, that seems unnecessary > wasteful? You are right it doesn't need to. I'm removing the alignment. > Why does it need to be huge pages? versus normal malloc? I thought it would make it easier to debug memory leaks through EAL. But no= rmal malloc is fine because this data is not shared between primary/seconda= ry. > The string is coming from malloc (strdup) so it can't be used by secondar= y process. >=20 > Since you are allocating a devargs cache entry, you could just as well us= e flexible > array where entry was like: > struct da_cache { > LIST_ENTRY(da_cache) list; > char name[RTE_DEV_NAME_MAX_LEN]; > char drv_str[]; > }; This is difficult as I don't know how big it is for drv_str[]. >=20 >=20 > cache =3D malloc(sizeof(*cache) + strlen(da->drv_str) + 1); ... > strcpy(cache->drv_str, da->drv_str); Another approach is to modify EAL to never delete driver arguments when a d= evice is removed. i.e., It doesn't call rte_devargs_remove() on device remo= val, instead keep those devargs for the lifetime of the process. Do you thi= nk this is a better approach? This will save work if other drivers want to = cache devargs list for device hot plug events. Thanks, Long