From patchwork Fri Sep 6 11:47:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Burakov, Anatoly" X-Patchwork-Id: 143692 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 CBDCC4591D; Fri, 6 Sep 2024 13:48:01 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C935042EF2; Fri, 6 Sep 2024 13:47:42 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) by mails.dpdk.org (Postfix) with ESMTP id 8801C42EE2 for ; Fri, 6 Sep 2024 13:47:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1725623261; x=1757159261; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=bmhKROxYL18KwMro6RvOS8EsLPDG9tWk/1orKnHrGkw=; b=RtfpoXhY4Dga3Km7DvKki0OIEHATBjXc03aucPyAIiCEvZgk+9lFD4Ct +51ncYPKwr3m0GU+MY0+U0JWXjInBO0FsyJ5nRPyXevVa2SdMuX5Qbxx0 4p7+DkS2ff+QK8r60vsvlu826HjHdHROanrRjbNGM+71KM8wc73crkxmn 8Wp8nshAljPKU1/kyHrpEJu+u2JhnVJ6GA67CGIWkqmzt2vrRiWME4AI5 Xl/gMAVqOxqNu+aX1GWsUIPEK4IsF89CaRdPESDcaRq5DWsq/c6Z/vNqt 0w8PxJYjQ9xbzhcShEhVSxDjHGhpAch6NxQmLExYsmVHhMm4R6d3uSQpE Q==; X-CSE-ConnectionGUID: mxFA/28wS/anmUTRhKxr4A== X-CSE-MsgGUID: 9+Mqy6luQqO2a12/LKceCw== X-IronPort-AV: E=McAfee;i="6700,10204,11187"; a="13408799" X-IronPort-AV: E=Sophos;i="6.10,207,1719903600"; d="scan'208";a="13408799" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Sep 2024 04:47:40 -0700 X-CSE-ConnectionGUID: 5v5alcsSRhuwI8apVVjwuA== X-CSE-MsgGUID: VS5QLNeITgePuirBQ997rA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.10,207,1719903600"; d="scan'208";a="66162958" Received: from silpixa00401119.ir.intel.com ([10.55.129.167]) by fmviesa010.fm.intel.com with ESMTP; 06 Sep 2024 04:47:38 -0700 From: Anatoly Burakov To: dev@dpdk.org, Tyler Retzlaff , Bruce Richardson , Dmitry Kozlyuk , Pallavi Kadam Subject: [RFC PATCH v1 3/5] eal: rename socket ID to NUMA ID in internal config Date: Fri, 6 Sep 2024 12:47:29 +0100 Message-ID: <7c14609a08b897bd22351e0915e9f6a01cb2be0f.1725622420.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: References: 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 This patch renames socket ID-related fields in internal EAL config structure to refer to NUMA ID instead. No user-facing API's are changed. Signed-off-by: Anatoly Burakov --- lib/eal/common/eal_common_dynmem.c | 14 +++++++------- lib/eal/common/eal_common_options.c | 16 ++++++++-------- lib/eal/common/eal_internal_cfg.h | 10 +++++----- lib/eal/common/malloc_heap.c | 2 +- lib/eal/freebsd/eal.c | 2 +- lib/eal/linux/eal.c | 10 +++++----- lib/eal/linux/eal_memory.c | 22 +++++++++++----------- lib/eal/windows/eal.c | 2 +- 8 files changed, 39 insertions(+), 39 deletions(-) diff --git a/lib/eal/common/eal_common_dynmem.c b/lib/eal/common/eal_common_dynmem.c index b4dc231940..4377af5aab 100644 --- a/lib/eal/common/eal_common_dynmem.c +++ b/lib/eal/common/eal_common_dynmem.c @@ -264,9 +264,9 @@ eal_dynmem_hugepage_init(void) #endif } - /* make a copy of socket_mem, needed for balanced allocation. */ + /* make a copy of numa_mem, needed for balanced allocation. */ for (hp_sz_idx = 0; hp_sz_idx < RTE_MAX_NUMA_NODES; hp_sz_idx++) - memory[hp_sz_idx] = internal_conf->socket_mem[hp_sz_idx]; + memory[hp_sz_idx] = internal_conf->numa_mem[hp_sz_idx]; /* calculate final number of pages */ if (eal_dynmem_calc_num_pages_per_socket(memory, @@ -334,10 +334,10 @@ eal_dynmem_hugepage_init(void) } /* if socket limits were specified, set them */ - if (internal_conf->force_socket_limits) { + if (internal_conf->force_numa_limits) { unsigned int i; for (i = 0; i < RTE_MAX_NUMA_NODES; i++) { - uint64_t limit = internal_conf->socket_limit[i]; + uint64_t limit = internal_conf->numa_limit[i]; if (limit == 0) continue; if (rte_mem_alloc_validator_register("socket-limit", @@ -382,7 +382,7 @@ eal_dynmem_calc_num_pages_per_socket( return -1; /* if specific memory amounts per socket weren't requested */ - if (internal_conf->force_sockets == 0) { + if (internal_conf->force_numa == 0) { size_t total_size; #ifdef RTE_ARCH_64 int cpu_per_socket[RTE_MAX_NUMA_NODES]; @@ -509,10 +509,10 @@ eal_dynmem_calc_num_pages_per_socket( /* if we didn't satisfy all memory requirements per socket */ if (memory[socket] > 0 && - internal_conf->socket_mem[socket] != 0) { + internal_conf->numa_mem[socket] != 0) { /* to prevent icc errors */ requested = (unsigned int)( - internal_conf->socket_mem[socket] / 0x100000); + internal_conf->numa_mem[socket] / 0x100000); available = requested - ((unsigned int)(memory[socket] / 0x100000)); EAL_LOG(ERR, "Not enough memory available on " diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c index f1a5e329a5..73fbb8587b 100644 --- a/lib/eal/common/eal_common_options.c +++ b/lib/eal/common/eal_common_options.c @@ -333,14 +333,14 @@ eal_reset_internal_config(struct internal_config *internal_cfg) internal_cfg->hugepage_dir = NULL; internal_cfg->hugepage_file.unlink_before_mapping = false; internal_cfg->hugepage_file.unlink_existing = true; - internal_cfg->force_sockets = 0; + internal_cfg->force_numa = 0; /* zero out the NUMA config */ for (i = 0; i < RTE_MAX_NUMA_NODES; i++) - internal_cfg->socket_mem[i] = 0; - internal_cfg->force_socket_limits = 0; + internal_cfg->numa_mem[i] = 0; + internal_cfg->force_numa_limits = 0; /* zero out the NUMA limits config */ for (i = 0; i < RTE_MAX_NUMA_NODES; i++) - internal_cfg->socket_limit[i] = 0; + internal_cfg->numa_limit[i] = 0; /* zero out hugedir descriptors */ for (i = 0; i < MAX_HUGEPAGE_SIZES; i++) { memset(&internal_cfg->hugepage_info[i], 0, @@ -2041,7 +2041,7 @@ eal_adjust_config(struct internal_config *internal_cfg) /* if no memory amounts were requested, this will result in 0 and * will be overridden later, right after eal_hugepage_info_init() */ for (i = 0; i < RTE_MAX_NUMA_NODES; i++) - internal_cfg->memory += internal_cfg->socket_mem[i]; + internal_cfg->memory += internal_cfg->numa_mem[i]; return 0; } @@ -2082,12 +2082,12 @@ eal_check_common_options(struct internal_config *internal_cfg) "option"); return -1; } - if (mem_parsed && internal_cfg->force_sockets == 1) { + if (mem_parsed && internal_cfg->force_numa == 1) { EAL_LOG(ERR, "Options -m and --"OPT_SOCKET_MEM" cannot " "be specified at the same time"); return -1; } - if (internal_cfg->no_hugetlbfs && internal_cfg->force_sockets == 1) { + if (internal_cfg->no_hugetlbfs && internal_cfg->force_numa == 1) { EAL_LOG(ERR, "Option --"OPT_SOCKET_MEM" cannot " "be specified together with --"OPT_NO_HUGE); return -1; @@ -2105,7 +2105,7 @@ eal_check_common_options(struct internal_config *internal_cfg) "be specified together with --"OPT_NO_HUGE); return -1; } - if (internal_conf->force_socket_limits && internal_conf->legacy_mem) { + if (internal_conf->force_numa_limits && internal_conf->legacy_mem) { EAL_LOG(ERR, "Option --"OPT_SOCKET_LIMIT " is only supported in non-legacy memory mode"); } diff --git a/lib/eal/common/eal_internal_cfg.h b/lib/eal/common/eal_internal_cfg.h index 167ec501fa..c34a2c3fe7 100644 --- a/lib/eal/common/eal_internal_cfg.h +++ b/lib/eal/common/eal_internal_cfg.h @@ -68,11 +68,11 @@ struct internal_config { */ volatile unsigned create_uio_dev; /**< true to create /dev/uioX devices */ volatile enum rte_proc_type_t process_type; /**< multi-process proc type */ - /** true to try allocating memory on specific sockets */ - volatile unsigned force_sockets; - volatile uint64_t socket_mem[RTE_MAX_NUMA_NODES]; /**< amount of memory per socket */ - volatile unsigned force_socket_limits; - volatile uint64_t socket_limit[RTE_MAX_NUMA_NODES]; /**< limit amount of memory per socket */ + /** true to try allocating memory on specific NUMA nodes */ + volatile unsigned force_numa; + volatile uint64_t numa_mem[RTE_MAX_NUMA_NODES]; /**< amount of memory per socket */ + volatile unsigned force_numa_limits; + volatile uint64_t numa_limit[RTE_MAX_NUMA_NODES]; /**< limit amount of memory per socket */ uintptr_t base_virtaddr; /**< base address to try and reserve memory from */ volatile unsigned legacy_mem; /**< true to enable legacy memory behavior (no dynamic allocation, diff --git a/lib/eal/common/malloc_heap.c b/lib/eal/common/malloc_heap.c index 058aaf4209..f87a947a42 100644 --- a/lib/eal/common/malloc_heap.c +++ b/lib/eal/common/malloc_heap.c @@ -711,7 +711,7 @@ malloc_get_numa_socket(void) /* for control threads, return first socket where memory is available */ for (idx = 0; idx < rte_socket_count(); idx++) { socket_id = rte_socket_id_by_idx(idx); - if (conf->socket_mem[socket_id] != 0) + if (conf->numa_mem[socket_id] != 0) return socket_id; } /* We couldn't quickly find a NUMA node where memory was available, diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c index 1229230063..8c7981645b 100644 --- a/lib/eal/freebsd/eal.c +++ b/lib/eal/freebsd/eal.c @@ -749,7 +749,7 @@ rte_eal_init(int argc, char **argv) } } - if (internal_conf->memory == 0 && internal_conf->force_sockets == 0) { + if (internal_conf->memory == 0 && internal_conf->force_numa == 0) { if (internal_conf->no_hugetlbfs) internal_conf->memory = MEMSIZE_IF_NO_HUGE_PAGE; else diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index d742cc98e2..cf174aeaa3 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -695,26 +695,26 @@ eal_parse_args(int argc, char **argv) } case OPT_SOCKET_MEM_NUM: if (eal_parse_socket_arg(optarg, - internal_conf->socket_mem) < 0) { + internal_conf->numa_mem) < 0) { EAL_LOG(ERR, "invalid parameters for --" OPT_SOCKET_MEM); eal_usage(prgname); ret = -1; goto out; } - internal_conf->force_sockets = 1; + internal_conf->force_numa = 1; break; case OPT_SOCKET_LIMIT_NUM: if (eal_parse_socket_arg(optarg, - internal_conf->socket_limit) < 0) { + internal_conf->numa_limit) < 0) { EAL_LOG(ERR, "invalid parameters for --" OPT_SOCKET_LIMIT); eal_usage(prgname); ret = -1; goto out; } - internal_conf->force_socket_limits = 1; + internal_conf->force_numa_limits = 1; break; case OPT_VFIO_INTR_NUM: @@ -1137,7 +1137,7 @@ rte_eal_init(int argc, char **argv) } } - if (internal_conf->memory == 0 && internal_conf->force_sockets == 0) { + if (internal_conf->memory == 0 && internal_conf->force_numa == 0) { if (internal_conf->no_hugetlbfs) internal_conf->memory = MEMSIZE_IF_NO_HUGE_PAGE; } diff --git a/lib/eal/linux/eal_memory.c b/lib/eal/linux/eal_memory.c index 45879ca743..45776ed33d 100644 --- a/lib/eal/linux/eal_memory.c +++ b/lib/eal/linux/eal_memory.c @@ -282,7 +282,7 @@ map_all_hugepages(struct hugepage_file *hugepg_tbl, struct hugepage_info *hpi, oldpolicy = MPOL_DEFAULT; } for (i = 0; i < RTE_MAX_NUMA_NODES; i++) - if (internal_conf->socket_mem[i]) + if (internal_conf->numa_mem[i]) maxnode = i + 1; } #endif @@ -301,7 +301,7 @@ map_all_hugepages(struct hugepage_file *hugepg_tbl, struct hugepage_info *hpi, if (j == maxnode) { node_id = (node_id + 1) % maxnode; - while (!internal_conf->socket_mem[node_id]) { + while (!internal_conf->numa_mem[node_id]) { node_id++; node_id %= maxnode; } @@ -1269,9 +1269,9 @@ eal_legacy_hugepage_init(void) huge_register_sigbus(); - /* make a copy of socket_mem, needed for balanced allocation. */ + /* make a copy of numa_mem, needed for balanced allocation. */ for (i = 0; i < RTE_MAX_NUMA_NODES; i++) - memory[i] = internal_conf->socket_mem[i]; + memory[i] = internal_conf->numa_mem[i]; /* map all hugepages and sort them */ for (i = 0; i < (int)internal_conf->num_hugepage_sizes; i++) { @@ -1339,7 +1339,7 @@ eal_legacy_hugepage_init(void) huge_recover_sigbus(); - if (internal_conf->memory == 0 && internal_conf->force_sockets == 0) + if (internal_conf->memory == 0 && internal_conf->force_numa == 0) internal_conf->memory = eal_get_hugepage_mem_size(); nr_hugefiles = nr_hugepages; @@ -1365,9 +1365,9 @@ eal_legacy_hugepage_init(void) } } - /* make a copy of socket_mem, needed for number of pages calculation */ + /* make a copy of numa_mem, needed for number of pages calculation */ for (i = 0; i < RTE_MAX_NUMA_NODES; i++) - memory[i] = internal_conf->socket_mem[i]; + memory[i] = internal_conf->numa_mem[i]; /* calculate final number of pages */ nr_hugepages = eal_dynmem_calc_num_pages_per_socket(memory, @@ -1722,12 +1722,12 @@ memseg_primary_init_32(void) */ active_sockets = 0; total_requested_mem = 0; - if (internal_conf->force_sockets) + if (internal_conf->force_numa) for (i = 0; i < rte_socket_count(); i++) { uint64_t mem; socket_id = rte_socket_id_by_idx(i); - mem = internal_conf->socket_mem[socket_id]; + mem = internal_conf->numa_mem[socket_id]; if (mem == 0) continue; @@ -1779,7 +1779,7 @@ memseg_primary_init_32(void) /* if we didn't specifically request memory on this socket */ skip = active_sockets != 0 && - internal_conf->socket_mem[socket_id] == 0; + internal_conf->numa_mem[socket_id] == 0; /* ...or if we didn't specifically request memory on *any* * socket, and this is not main lcore */ @@ -1794,7 +1794,7 @@ memseg_primary_init_32(void) /* max amount of memory on this socket */ max_socket_mem = (active_sockets != 0 ? - internal_conf->socket_mem[socket_id] : + internal_conf->numa_mem[socket_id] : internal_conf->memory) + extra_mem_per_socket; cur_socket_mem = 0; diff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c index 28b78a95a6..34bceeed4e 100644 --- a/lib/eal/windows/eal.c +++ b/lib/eal/windows/eal.c @@ -331,7 +331,7 @@ rte_eal_init(int argc, char **argv) return -1; } - if (internal_conf->memory == 0 && !internal_conf->force_sockets) { + if (internal_conf->memory == 0 && !internal_conf->force_numa) { if (internal_conf->no_hugetlbfs) internal_conf->memory = MEMSIZE_IF_NO_HUGE_PAGE; }