From patchwork Wed Jul 5 09:25:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenjun Wu X-Patchwork-Id: 129277 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EFDB542DCC; Wed, 5 Jul 2023 11:23:01 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EEF2340FAE; Wed, 5 Jul 2023 11:22:59 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id A274B40FAE; Wed, 5 Jul 2023 11:22:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688548978; x=1720084978; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5oufmE4eyZnV6LisqjY+exu9skdq/K5qpe3iT7gArus=; b=PJl/XvN58X9rOcc3NWFjuUiN9vvfhY5UlJN1+hMSbeBwYPsexTSTPYB7 AIP8WE5XbDT9utW/AQAS8ewNY8UCYVEIJgvOO4DHtAhZlvOjl4isKPQHp PSnU/Ylwq8y+p3cayv1J4UoyeVQLIQVLxl4buie3EDcLCm6z8IuInwuL2 OxTw2rFx/Np38gZh2moKcVcMGYqvUY22gGencAFOBRk7ibJsBX1oFM8KV 5kvSSTXyzXHN+dZMl2j7sMVjONRHhNA0N26HU5TbkPYi5URO+62bnukWB 9Ox5beP4tFTQypYEhPTZWZztlsipg/v+pV63rQvtDex6vAR6IAFTBoU6z Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10761"; a="353122495" X-IronPort-AV: E=Sophos;i="6.01,182,1684825200"; d="scan'208";a="353122495" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jul 2023 02:22:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10761"; a="669340944" X-IronPort-AV: E=Sophos;i="6.01,182,1684825200"; d="scan'208";a="669340944" Received: from dpdk-wuwenjun-icelake-ii.sh.intel.com ([10.67.110.188]) by orsmga003.jf.intel.com with ESMTP; 05 Jul 2023 02:22:55 -0700 From: Wenjun Wu To: dev@dpdk.org, anatoly.burakov@intel.com, qi.z.zhang@intel.com Cc: simei.su@intel.com, Wenjun Wu , stable@dpdk.org Subject: [PATCH v1 1/2] bus/vdev: fix memory leak Date: Wed, 5 Jul 2023 17:25:10 +0800 Message-Id: <20230705092511.362484-2-wenjun1.wu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230705092511.362484-1-wenjun1.wu@intel.com> References: <20230705092511.362484-1-wenjun1.wu@intel.com> MIME-Version: 1.0 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 In hotplug usecase, devargs will be allocated in secondary process in the function alloc_devargs. Since it will not be insert into the devarg_list, it will have no chance to be freed. This patch adds additional memory free for device structure member devargs in the secondary process in rte_vdev_uninit. Fixes: f5b2eff0847d ("bus/vdev: fix devargs after multi-process bus scan") Cc: stable@dpdk.org Signed-off-by: Wenjun Wu --- drivers/bus/vdev/vdev.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c index 7974b27295..3f4e6a1b55 100644 --- a/drivers/bus/vdev/vdev.c +++ b/drivers/bus/vdev/vdev.c @@ -373,6 +373,11 @@ rte_vdev_uninit(const char *name) TAILQ_REMOVE(&vdev_device_list, dev, next); rte_devargs_remove(dev->device.devargs); + if (rte_eal_process_type() == RTE_PROC_SECONDARY && + dev->device.devargs != NULL) { + rte_devargs_reset(dev->device.devargs); + free(dev->device.devargs); + } free(dev); unlock: From patchwork Wed Jul 5 09:25:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenjun Wu X-Patchwork-Id: 129278 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8415942DCC; Wed, 5 Jul 2023 11:23:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 70C9B42BDA; Wed, 5 Jul 2023 11:23:16 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id EEF4540150; Wed, 5 Jul 2023 11:23:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688548994; x=1720084994; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LWYgXAhOYkNIE4qVqoANJjnrb9EGKnOvrRfe+x8qssA=; b=QSkL2dn8965lTATNetmf3SMLibNbnnVe3CwEhofkEmmCFaEvqba2KvwU UvdWNNmEvNL6VMTcovB+pFtycrhd22K9onFNctn+beQVr7watVHjNHiOA l+ozu5Delwx8/yeGnAUDyXhWqaoopIhRp5XlytIqifNxe5cZHCZ7RNim5 /K4uF97JgcPjDOMbV3j/aDAkp5+y9k4ZuqznRdqXNIw2eQNq3klTKq5qj Y6/bQ2BkIdrCBtOKjpYWA0JLYxkeqwWWdTGIAkdrPmk1L3IgcTEIfjuLo YpAgEBRGZZzo1cKjBP84tJJ6L2Vx0fKQuy0Sr16cw4zOzkTdXWTvoL5zn w==; X-IronPort-AV: E=McAfee;i="6600,9927,10761"; a="353122550" X-IronPort-AV: E=Sophos;i="6.01,182,1684825200"; d="scan'208";a="353122550" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jul 2023 02:23:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10761"; a="669341067" X-IronPort-AV: E=Sophos;i="6.01,182,1684825200"; d="scan'208";a="669341067" Received: from dpdk-wuwenjun-icelake-ii.sh.intel.com ([10.67.110.188]) by orsmga003.jf.intel.com with ESMTP; 05 Jul 2023 02:23:11 -0700 From: Wenjun Wu To: dev@dpdk.org, anatoly.burakov@intel.com, qi.z.zhang@intel.com Cc: simei.su@intel.com, Wenjun Wu , stable@dpdk.org Subject: [PATCH v1 2/2] examples/multi_process: fix memory leak Date: Wed, 5 Jul 2023 17:25:11 +0800 Message-Id: <20230705092511.362484-3-wenjun1.wu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230705092511.362484-1-wenjun1.wu@intel.com> References: <20230705092511.362484-1-wenjun1.wu@intel.com> MIME-Version: 1.0 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 The device should be detached before quit, otherwise it will cause memory leak. Fixes: 05f1d6842fc3 ("examples/multi_process: add hotplug sample") Cc: stable@dpdk.org Signed-off-by: Wenjun Wu --- examples/multi_process/hotplug_mp/commands.c | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/examples/multi_process/hotplug_mp/commands.c b/examples/multi_process/hotplug_mp/commands.c index 88f44e00a0..143d57eeb6 100644 --- a/examples/multi_process/hotplug_mp/commands.c +++ b/examples/multi_process/hotplug_mp/commands.c @@ -52,6 +52,28 @@ static void cmd_quit_parsed(__rte_unused void *parsed_result, struct cmdline *cl, __rte_unused void *data) { + uint16_t port_id; + char dev_name[RTE_DEV_NAME_MAX_LEN]; + struct rte_devargs da; + + RTE_ETH_FOREACH_DEV(port_id) { + rte_eth_dev_get_name_by_port(port_id, dev_name); + memset(&da, 0, sizeof(da)); + + if (rte_devargs_parsef(&da, "%s", dev_name)) { + cmdline_printf(cl, + "cannot parse devargs for device %s\n", + dev_name); + } + printf("detaching before quit...\n"); + if (!rte_eal_hotplug_remove(rte_bus_name(da.bus), da.name)) + cmdline_printf(cl, "detached device %s\n", + da.name); + else + cmdline_printf(cl, "failed to detach device %s\n", + da.name); + + } cmdline_quit(cl); }