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 26BDAA0503 for ; Mon, 21 Mar 2022 10:34:00 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1DF37427ED; Mon, 21 Mar 2022 10:34:00 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 061D141614; Mon, 21 Mar 2022 10:33:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1647855238; x=1679391238; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5400Q8MNleBCRh9HCz6hir7k4dVS3S2iqBWuHlg0NmM=; b=Z1iLFdgKJB2XGzn8oEpl3e4HoDYBmTLBsfzi+EuwCK9adHCfpgvafgfC 8JJNk8xJVREHNuUKr65wdq55GzwyVYqr0xsRGbhlPziWa5bfE6ddFrsTY T+DDaLemdyo6m1Qlr+nX7KAtz/kfXDOKUeLgRiECF7QP8MkYy05LwIGrg 0tpYnC0HFcNDGGbSEPBKzSGoF//Ylyr1FF0KHU40D7yqnPYz55bcs63NA TMtnZ/3HEdLkekbbfARLe6OdZPJfXlLYma0hAlPLW7h0DSmC2VeqGcl80 mg5iZMreoFAD98Lx2DVbSmMkVep5tUMH6Gspli/CemT1G5LAynIF0Jny5 Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10292"; a="257457415" X-IronPort-AV: E=Sophos;i="5.90,198,1643702400"; d="scan'208";a="257457415" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Mar 2022 02:33:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,198,1643702400"; d="scan'208";a="648499553" Received: from silpixa00400214.ir.intel.com (HELO silpixa00400214.ger.corp.intel.com) ([10.237.223.184]) by orsmga004.jf.intel.com with ESMTP; 21 Mar 2022 02:33:54 -0700 From: Shibin Koikkara Reeny To: david.hunt@intel.com Cc: dev@dpdk.org, Shibin Koikkara Reeny , alan.carew@intel.com, stable@dpdk.org Subject: [PATCH v2] examples/vm_power: add support for list_foreach_safe Date: Mon, 21 Mar 2022 09:33:42 +0000 Message-Id: <20220321093342.1223208-1-shibin.koikkara.reeny@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220301145313.560577-1-shibin.koikkara.reeny@intel.com> References: <20220301145313.560577-1-shibin.koikkara.reeny@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Asan tool reported LIST_FOREACH should be replaced with LIST_FOREACH_SAFE. Added support for LIST_FOREACH_SAFE macro in rte_os.h file as Linux header file sys/queue.h don't support LIST_FOREACH_SAFE macro. RTE_LIST_FOREACH_SAFE is alias for LIST_FOREACH_SAFE. Fixes: e8ae9b662506 ("examples/vm_power: channel manager and monitor in host") Cc: alan.carew@intel.com Cc: stable@dpdk.org Signed-off-by: Shibin Koikkara Reeny --- examples/vm_power_manager/channel_manager.c | 9 +++++---- lib/eal/linux/include/rte_os.h | 11 +++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/examples/vm_power_manager/channel_manager.c b/examples/vm_power_manager/channel_manager.c index 838465ab4b..d297b28114 100644 --- a/examples/vm_power_manager/channel_manager.c +++ b/examples/vm_power_manager/channel_manager.c @@ -66,8 +66,8 @@ LIST_HEAD(, virtual_machine_info) vm_list_head; static struct virtual_machine_info * find_domain_by_name(const char *name) { - struct virtual_machine_info *info; - LIST_FOREACH(info, &vm_list_head, vms_info) { + struct virtual_machine_info *info, *t_info; + RTE_LIST_FOREACH_SAFE(info, &vm_list_head, vms_info, t_info) { if (!strncmp(info->name, name, CHANNEL_MGR_MAX_NAME_LEN-1)) return info; } @@ -1005,9 +1005,9 @@ channel_manager_exit(void) { unsigned i; char mask[RTE_MAX_LCORE]; - struct virtual_machine_info *vm_info; + struct virtual_machine_info *vm_info, *t_info; - LIST_FOREACH(vm_info, &vm_list_head, vms_info) { + RTE_LIST_FOREACH_SAFE(vm_info, &vm_list_head, vms_info, t_info) { rte_spinlock_lock(&(vm_info->config_spinlock)); @@ -1024,6 +1024,7 @@ channel_manager_exit(void) LIST_REMOVE(vm_info, vms_info); rte_free(vm_info); + } if (global_hypervisor_available) { diff --git a/lib/eal/linux/include/rte_os.h b/lib/eal/linux/include/rte_os.h index c72bf5b7e6..3acff49360 100644 --- a/lib/eal/linux/include/rte_os.h +++ b/lib/eal/linux/include/rte_os.h @@ -25,6 +25,8 @@ extern "C" { #define RTE_TAILQ_NEXT(elem, field) TAILQ_NEXT(elem, field) #define RTE_STAILQ_HEAD(name, type) STAILQ_HEAD(name, type) #define RTE_STAILQ_ENTRY(type) STAILQ_ENTRY(type) +#define RTE_LIST_FIRST(head) LIST_FIRST(head) +#define RTE_LIST_NEXT(elem, field) LIST_NEXT(elem, field) #ifdef CPU_SETSIZE /* may require _GNU_SOURCE */ typedef cpu_set_t rte_cpuset_t; @@ -46,6 +48,15 @@ typedef cpu_set_t rte_cpuset_t; } while (0) #endif +#ifndef LIST_FOREACH_SAFE +#define LIST_FOREACH_SAFE(var, head, field, tvar) \ + for ((var) = RTE_LIST_FIRST(head); \ + (var) && ((tvar) = RTE_LIST_NEXT((var), field), 1); \ + (var) = (tvar)) +#endif +#define RTE_LIST_FOREACH_SAFE(var, head, field, tvar) \ + LIST_FOREACH_SAFE(var, head, field, tvar) + #ifdef __cplusplus } #endif -- 2.25.1