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 4FB48460B1; Tue, 28 Jan 2025 22:01:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E1B2A40268; Tue, 28 Jan 2025 22:01:02 +0100 (CET) Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by mails.dpdk.org (Postfix) with ESMTP id E289C40267 for ; Tue, 28 Jan 2025 22:01:01 +0100 (CET) Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-21669fd5c7cso109604255ad.3 for ; Tue, 28 Jan 2025 13:01:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1738098061; x=1738702861; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=p0h+I3gJLcvjwHzftc0Sntfh7vlGQoThsWp4GJaSfew=; b=DAClyf8RtzdNfglhk1f23Tyv3D2pUlZfYIxRkQA/otPrAv/ujRloP+55eJSQsB/fyC lC1nD9PM3toTs8RdDR+RxiieG6oS1cElUMij2729pRlBa+Cj/ehO4qRT83U4LM2Z916x lCcaZ5zperdKg0+6iL3t3vhKEwUnm3Lv1WFnTkiYpyUqYb1UCH75IZpE+gYkXDUSQqsL AqC0nXDZNbDCtbDomWeh9FEAxCaCbBe+F6UNf7+jVMW5eHwe7rGcneigWyF8fs3haOPC Gr/wYp/HeV29uCMpqDMt9HtKbDreteylx298sfG1VACkHnLnpXlpgEmjw8fNBSRCYEB5 M4Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738098061; x=1738702861; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=p0h+I3gJLcvjwHzftc0Sntfh7vlGQoThsWp4GJaSfew=; b=BUgGlyxA3sDAg8tyAbbTpN0IuYLYWyx4/czSyDugXqKhWaTthDVF/o7voOOs7SkF9Y IwkNyEfd9gBAO64+VpCvznGat09bquE7nOMFYok9GuvB4AcebzwIc955DIM2ggLH2TUh Q4TwjQHAEbxmrGWh5R00BYzAtKS8pMcRYhQ8gFRTz4iYHyzSwHp6U34k7alx2rirTp/P JIrYYHw4g5pvY4acbZS6Xa0KdH9f+SZlQiOr5ion14yA3wV2gAc84hORoJTbsA0luHVf yYByi3U1/2EI7D1PS5i+CiKalYu0tzVUneTZOOX8+LerpHTUmj1Q2ph1X4KiOzTQqDn0 x26A== X-Forwarded-Encrypted: i=1; AJvYcCWm1apQsAZwkqTRMZEPQNVtesq3t9l5cJ9NAqIWtxagnVSn6HDWa2bOnNqss+agQ9TQF9k=@dpdk.org X-Gm-Message-State: AOJu0YyvzE3X9h14Nx4hz2BwkNwYaRfXktvkVyJLcyB4MRTWE/AjNiZ/ fQiS0u71Z7lni0IEZFraOenIXkAe376527eOrX5xYR9dI4Rj1aEclzOH7DN8huk= X-Gm-Gg: ASbGncuZmmaEXvZsrKVpi9eiMdDzuH0ov5BzBO/BhooPQ3VYOEa96uBf1++m+nv4fHs XS8spi93tpPaxHLRVWms9yK2/TEUJRjyQJGW6MxSJ4jb5+AkqHiOWTKuEgIlV3/dQ1rgEqbbe11 nSHr3PCpCjOM+b3nq2qwbtRsMPOBlHjixygXrK60PiwvEN4ByqH/R4z18GxUf6WhbDr0b3Qc/6C w2D1pjAYsL38QRkvNiusgxdA5DwBUkrOfo/5biBQkH8VIKtpGNEJac1WfjiBlFBqdIYdXlvXFox 57BnF4M2vxqhmUr0Mo5+BQw2n54IGS6PSeCBHaGlT09hEYwgJ1bph3pTyPLK8KT4IQWRt98nSPA KzDU= X-Google-Smtp-Source: AGHT+IFe/N6hPJtv6Ih/hXWZ7nXMiHiRI01FS8ijzwVN65axWiWFWM+1KH4tABgJtDR4xxe0TZ/8mg== X-Received: by 2002:a17:902:cf11:b0:215:94e0:17 with SMTP id d9443c01a7336-21dd7c66ed9mr11106475ad.23.1738098060870; Tue, 28 Jan 2025 13:01:00 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21da3ea3b45sm87476565ad.97.2025.01.28.13.01.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jan 2025 13:01:00 -0800 (PST) Date: Tue, 28 Jan 2025 13:00:56 -0800 From: Stephen Hemminger To: longli@linuxonhyperv.com Cc: Ferruh Yigit , Andrew Rybchenko , Wei Hu , dev@dpdk.org, Long Li Subject: Re: [PATCH 4/4] net/netvsc: cache device parameters for hot plug events Message-ID: <20250128130056.399a1dd5@hermes.local> In-Reply-To: <1738028106-25239-4-git-send-email-longli@linuxonhyperv.com> References: <1738028106-25239-1-git-send-email-longli@linuxonhyperv.com> <1738028106-25239-4-git-send-email-longli@linuxonhyperv.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 Mon, 27 Jan 2025 17:35:06 -0800 longli@linuxonhyperv.com wrote: > @@ -1409,9 +1424,6 @@ eth_hn_dev_uninit(struct rte_eth_dev *eth_dev) > ret_stop = hn_dev_stop(eth_dev); > hn_dev_close(eth_dev); > > - free(hv->vf_devargs); > - hv->vf_devargs = 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 = 0; > + goto out; > + } > + > + LIST_INIT(&da_cache_list); > + RTE_EAL_DEVARGS_FOREACH("pci", da) { > + struct da_cache *cache; > + > + cache = rte_zmalloc("NETVSC-HOTADD", sizeof(*cache), rte_mem_page_size()); > + if (!cache) { > + ret = -ENOMEM; > + goto out; > + } > + > + strncpy(cache->name, da->name, sizeof(da->name)); > + cache->drv_str = strdup(da->drv_str); > + if (!cache->drv_str) { > + rte_free(cache); > + ret = -ENOMEM; > + goto out; > + } > + > + LIST_INSERT_HEAD(&da_cache_list, cache, list); > + } Why do you need to cache entry to be page aligned, that seems unnecessary wasteful? Why does it need to be huge pages? versus normal malloc? The string is coming from malloc (strdup) so it can't be used by secondary process. Since you are allocating a devargs cache entry, you could just as well use flexible array where entry was like: struct da_cache { LIST_ENTRY(da_cache) list; char name[RTE_DEV_NAME_MAX_LEN]; char drv_str[]; }; cache = malloc(sizeof(*cache) + strlen(da->drv_str) + 1); ... strcpy(cache->drv_str, da->drv_str);