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 B2971A00BE; Mon, 16 May 2022 21:50:21 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5738A40A7A; Mon, 16 May 2022 21:50:21 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2055.outbound.protection.outlook.com [40.107.20.55]) by mails.dpdk.org (Postfix) with ESMTP id C29534068B for ; Mon, 16 May 2022 21:50:19 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KEIq+C0Y/be+nMxiIaIChnMcmJuuAonCfzCJ+GrHXwEwjCYTJsD4rpr3tmZjy9YeLt4eZDZglGfu3rMflPQOgvHkwa7ZwFAPFl01rAwhelaXrZG8jaO7G8wHXjq7eEI8Zu1j+DJCtVP1i534K3NObqPJ0KPEXa/FPewVCtNsTNeKsCCpJQ6pfuIc830q0VPmDfEsHAUBNYRiZGR8hGcVn3H+rIJGhlZzqySvu/TRwxNTIAsSXJP1BjGsHdosL5r2xIE1r2+30Fyc3by41vZZgZmv8KfXaq/O7lXf0xN9XELHPTFgptBElRdN+e0ofquAz1goxdPjNeXu6tZlxAY9NA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=U04QKVyzS9bwD9VQGFXA58OlJS9OcYpzDOfY6ZB1/oU=; b=geuxASIiW0ju58l6nlnmlW3ekqUFWQnFptu5ETU6QyzwQOC6F6qHIvD+loSIxa2aoArlDKoJO9LLXsRXjMIwy/vEHvn9TN32xPO0pFXU04ZtldpSldvSZIlrS4+qlIyOa4QSfNOtSqSMpgaZJEpHUnOyyWnh74c0t/16crB6paUiNn8EBuS58VUnjazMN4oXUxTWDfO3L4fgek1sCMyN47f8v06grD8dRvBlXNGFgLrMoLyKKwuYB3cdoEMgIbFYnE4jjaIzS66pgQugbMeSM6eDKZAOrZ8Gz5iS20gNDyk0Ama+Dl7NxclKhYuRK8UJuQ45P19BIIvR7hxvfGrLKg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=xsightlabs.com; dmarc=pass action=none header.from=xsightlabs.com; dkim=pass header.d=xsightlabs.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xsightlabs.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U04QKVyzS9bwD9VQGFXA58OlJS9OcYpzDOfY6ZB1/oU=; b=zzJqs4GZ76o58GQbS+BJFIfvQHxnLlbWvkef5fkNE+uGghVYwH9oEifRv/vAM/HSEBi08zYkRmXtxzNYIpLmf3bkmcpWVeuZxN2tRFeVx8JRi8+O39kN3CLVMQEeEsRtF1u17w3UuaYUfzhW9aq/Eu2CcbjAau6zcQ+hqyh8MCo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=xsightlabs.com; Received: from DB9P193MB1482.EURP193.PROD.OUTLOOK.COM (2603:10a6:10:2a6::7) by DB9P193MB1753.EURP193.PROD.OUTLOOK.COM (2603:10a6:10:240::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.13; Mon, 16 May 2022 19:50:19 +0000 Received: from DB9P193MB1482.EURP193.PROD.OUTLOOK.COM ([fe80::3c11:328c:a5e5:7253]) by DB9P193MB1482.EURP193.PROD.OUTLOOK.COM ([fe80::3c11:328c:a5e5:7253%6]) with mapi id 15.20.5250.018; Mon, 16 May 2022 19:50:19 +0000 From: Don Wallwork To: dev@dpdk.org Cc: donw@xsightlabs.com, stephen@networkplumber.org, fengchengwen@huawei.com, mb@smartsharesystems.com, anatoly.burakov@intel.com, dmitry.kozliuk@gmail.com, bruce.richardson@intel.com, Honnappa.Nagarahalli@arm.com, nd@arm.com, haiyue.wang@intel.com Subject: [PATCH v3] eal: allow worker lcore stacks to be allocated from hugepage memory Date: Mon, 16 May 2022 15:50:04 -0400 Message-Id: <20220516195004.10091-1-donw@xsightlabs.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220502141058.12707-1-donw@xsightlabs.com> References: <20220502141058.12707-1-donw@xsightlabs.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: MN2PR05CA0014.namprd05.prod.outlook.com (2603:10b6:208:c0::27) To DB9P193MB1482.EURP193.PROD.OUTLOOK.COM (2603:10a6:10:2a6::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 585846f9-9dba-4b2e-3440-08da37754e1f X-MS-TrafficTypeDiagnostic: DB9P193MB1753:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5VyxuxdD62PbxB2KK72NCXdbnfnibA4FUTVCihtAisFGmShushisU3r6tIFuH5lV3b6AN2z3hc19mResGCqy4Vhx/Pfwz9hjzzttB7hRnsCpEKezTQZSm96EcFxbhUZ8+KI/RkwJWGyDXrOnTR7sp03Gb9S02zPud7fqz4EfnUNA6dwmuU9D31FoYDzNffsqnZbEk8zEU+e5d6IJZ95HMAZIxoHBMVDiPLp1V5GJe6StSuU7ePXwiPx7itKP8aQigxlKlKYPTrGZ9RGQ+F/OtiiGW0O4jG/P1YTMybl+MqQ3+ARr+FnesUvTWYP2JWydRxL5AQnpXrsAKaEWQWuk67WFy6/zci5jS0Ca+LAdt/mbqVMYFtIBwG34oXThsL9aW+Fyk2IuIB1NsaWhWLwf7sIDtI0RI1THLpVTJNw9th08EJfXCVKMwKl2Xfl601NkwW2Qfm+ilm2P4AUdS2AtAHQInFFVz1DdEdvOZMuHdFoRaFrVMn4taLcsAKAF30LkrYnnIvcgxrmL9wgbFrK2xR3AuB3hSFxWrYGQjNyFUjP8jm8R3h4SbrftarOgsl0VziOsiLToE80EgKgGIZyzYqAzIzvQJ4k69OA02DFChW1Ldsm3Fezspa+miDUm6y+z4+Qa+8isEPm+Ieq9NjGiNtiVUvvWW01ljWTq8YMIJvy7/exwLqua5NP8ZUmYD7sWJ9lA69x/ofbLUJGZkORnVg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB9P193MB1482.EURP193.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(6916009)(36756003)(4326008)(6506007)(66556008)(66946007)(66476007)(6666004)(6512007)(8676002)(2906002)(2616005)(86362001)(1076003)(66574015)(52116002)(186003)(6486002)(8936002)(26005)(83380400001)(316002)(7416002)(5660300002)(38100700002)(508600001)(38350700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?RmVteXA3OThlY1ZoTjdtSEhTQ1grVy9LWTA2K2o5elFCMGNGRXdaQkNhK0hJ?= =?utf-8?B?T1pyRzZqcEY4S2FxR1BENzJueU5mZ2dJMGxDN3RYU2E2SlpsVDVzc21paVR2?= =?utf-8?B?L3F6ejFYZEFxVUtrYTkxN0ZhcjZ4aXp6Q0dveW5JVEgwOC9UajlVZXBnQlNh?= =?utf-8?B?MEF2dUJBMU5sNFBWMHdvU0UzWGdzR1hPZDNsaVA4QWlxQTNXRmw4NlJhY0Ft?= =?utf-8?B?VkJuRDBCVHdXN2pnOVdlTVI4MFpzMTR0eStBU1NXQjVQcjQyeWs0c1FkTUlQ?= =?utf-8?B?bzVCNS82alV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aVpaZGVuemxVQTBWNzdkOUpBR0VX?= =?utf-8?B?VUl5cGJTWndnZldZbk1vaDFtZmNBOWJINmprYWZHTVQrMWd3V2U2UG9hZ3lx?= =?utf-8?B?YmpaVXR5QVMrY0tPbHZoMjhIS1NJQS9WWC9rLytZSlZGejRwOTA4OTkxMG4r?= =?utf-8?B?ZGpQY3pyMmJuL0t5YWdoNWY1M2QzRm1pWEpCV292SVc3WDJkT3pkWW1wRVUz?= =?utf-8?B?bnB0c0hvV01DODI0OStOYTZ4MVR0Q051Vk9Pd3RaQ0YyUFFZdXBJdz09?= X-OriginatorOrg: xsightlabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 585846f9-9dba-4b2e-3440-08da37754e1f X-MS-Exchange-CrossTenant-AuthSource: DB9P193MB1482.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 May 2022 19:50:18.9122 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 646a3e34-83ea-4273-9177-ab01923abaa9 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: G5duK7Z596Ipve0wYbQtrE0VmrUZPNZ4H8rY5aNfBXXFJFAT+rPX0MMun7pEvZS0nTfI66lZRg5p8vpJmWJVcA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9P193MB1753 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 Add support for using hugepages for worker lcore stack memory. The intent is to improve performance by reducing stack memory related TLB misses and also by using memory local to the NUMA node of each lcore. EAL option '--huge-worker-stack [stack-size-in-kbytes]' is added to allow the feature to be enabled at runtime. If the size is not specified, the system pthread stack size will be used. Signed-off-by: Don Wallwork Acked-by: Morten Brørup --- doc/guides/linux_gsg/eal_args.include.rst | 6 ++ .../prog_guide/env_abstraction_layer.rst | 21 +++++++ lib/eal/common/eal_common_options.c | 36 +++++++++++ lib/eal/common/eal_internal_cfg.h | 4 ++ lib/eal/common/eal_options.h | 2 + lib/eal/linux/eal.c | 61 ++++++++++++++++++- 6 files changed, 128 insertions(+), 2 deletions(-) diff --git a/doc/guides/linux_gsg/eal_args.include.rst b/doc/guides/linux_gsg/eal_args.include.rst index 3549a0cf56..9cfbf7de84 100644 --- a/doc/guides/linux_gsg/eal_args.include.rst +++ b/doc/guides/linux_gsg/eal_args.include.rst @@ -116,6 +116,12 @@ Memory-related options Force IOVA mode to a specific value. +* ``--huge-worker-stack[=size]`` + + Allocate worker stack memory from hugepage memory. Stack size defaults + to system pthread stack size unless the optional size (in kbytes) is + specified. + Debugging options ~~~~~~~~~~~~~~~~~ diff --git a/doc/guides/prog_guide/env_abstraction_layer.rst b/doc/guides/prog_guide/env_abstraction_layer.rst index 5f0748fba1..e74516f0cf 100644 --- a/doc/guides/prog_guide/env_abstraction_layer.rst +++ b/doc/guides/prog_guide/env_abstraction_layer.rst @@ -329,6 +329,27 @@ Another option is to use bigger page sizes. Since fewer pages are required to cover the same memory area, fewer file descriptors will be stored internally by EAL. +.. _huge-worker-stack: + +Hugepage Worker Stacks +^^^^^^^^^^^^^^^^^^^^^^ + +When the ``--huge-worker-stack[=size]`` EAL option is specified, worker +thread stacks are allocated from hugepage memory local to the NUMA node +of the thread. Worker stack size defaults to system pthread stack size +if the optional size parameter is not specified. + +.. warning:: + Stacks allocated from hugepage memory are not protected by guard + pages. Worker stacks must be sufficiently sized to prevent stack + overflow when this option is used. + + As with normal thread stacks, hugepage worker thread stack size is + fixed and is not dynamically resized. Therefore, an application that + is free of stack page faults under a given load should be safe with + hugepage worker thread stacks given the same thread stack size and + loading conditions. + Support for Externally Allocated Memory ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c index f247a42455..b0d429ed34 100644 --- a/lib/eal/common/eal_common_options.c +++ b/lib/eal/common/eal_common_options.c @@ -103,6 +103,7 @@ eal_long_options[] = { {OPT_TELEMETRY, 0, NULL, OPT_TELEMETRY_NUM }, {OPT_NO_TELEMETRY, 0, NULL, OPT_NO_TELEMETRY_NUM }, {OPT_FORCE_MAX_SIMD_BITWIDTH, 1, NULL, OPT_FORCE_MAX_SIMD_BITWIDTH_NUM}, + {OPT_HUGE_WORKER_STACK, 2, NULL, OPT_HUGE_WORKER_STACK_NUM }, {0, 0, NULL, 0 } }; @@ -1618,6 +1619,25 @@ eal_parse_huge_unlink(const char *arg, struct hugepage_file_discipline *out) return -1; } +static int +eal_parse_huge_worker_stack(const char *arg, size_t *huge_worker_stack_size) +{ + size_t worker_stack_size; + char *end; + if (arg == NULL || arg[0] == '\0') { + *huge_worker_stack_size = WORKER_STACK_SIZE_FROM_OS; + return 0; + } + errno = 0; + worker_stack_size = strtoul(arg, &end, 10); + if (errno || end == NULL || worker_stack_size == 0 || + worker_stack_size >= (size_t)-1 / 1024) + return -1; + + *huge_worker_stack_size = worker_stack_size * 1024; + return 0; +} + int eal_parse_common_option(int opt, const char *optarg, struct internal_config *conf) @@ -1921,6 +1941,17 @@ eal_parse_common_option(int opt, const char *optarg, } break; +#ifndef RTE_EXEC_ENV_WINDOWS + case OPT_HUGE_WORKER_STACK_NUM: + if (eal_parse_huge_worker_stack(optarg, + &conf->huge_worker_stack_size) < 0) { + RTE_LOG(ERR, EAL, "invalid parameter for --" + OPT_HUGE_WORKER_STACK"\n"); + return -1; + } + break; +#endif /* !RTE_EXEC_ENV_WINDOWS */ + /* don't know what to do, leave this to caller */ default: return 1; @@ -2235,5 +2266,10 @@ eal_common_usage(void) " --"OPT_NO_PCI" Disable PCI\n" " --"OPT_NO_HPET" Disable HPET\n" " --"OPT_NO_SHCONF" No shared config (mmap'd files)\n" + " --"OPT_HUGE_WORKER_STACK"[=size]\n" + " Allocate worker thread stacks from\n" + " hugepage memory. Size is in units of\n" + " kbytes and defaults to system thread\n" + " stack size if not specified.\n" "\n", RTE_MAX_LCORE); } diff --git a/lib/eal/common/eal_internal_cfg.h b/lib/eal/common/eal_internal_cfg.h index b71faadd18..5e154967e4 100644 --- a/lib/eal/common/eal_internal_cfg.h +++ b/lib/eal/common/eal_internal_cfg.h @@ -48,6 +48,9 @@ struct hugepage_file_discipline { bool unlink_existing; }; +/** Worker hugepage stack size should default to OS value. */ +#define WORKER_STACK_SIZE_FROM_OS ((size_t)~0) + /** * internal configuration */ @@ -102,6 +105,7 @@ struct internal_config { unsigned int no_telemetry; /**< true to disable Telemetry */ struct simd_bitwidth max_simd_bitwidth; /**< max simd bitwidth path to use */ + size_t huge_worker_stack_size; /**< worker thread stack size */ }; void eal_reset_internal_config(struct internal_config *internal_cfg); diff --git a/lib/eal/common/eal_options.h b/lib/eal/common/eal_options.h index 8e4f7202a2..3cc9cb6412 100644 --- a/lib/eal/common/eal_options.h +++ b/lib/eal/common/eal_options.h @@ -87,6 +87,8 @@ enum { OPT_NO_TELEMETRY_NUM, #define OPT_FORCE_MAX_SIMD_BITWIDTH "force-max-simd-bitwidth" OPT_FORCE_MAX_SIMD_BITWIDTH_NUM, +#define OPT_HUGE_WORKER_STACK "huge-worker-stack" + OPT_HUGE_WORKER_STACK_NUM, OPT_LONG_MAX_NUM }; diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index 1ef263434a..2bee66577e 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -857,6 +857,64 @@ is_iommu_enabled(void) return n > 2; } +static int +eal_worker_thread_create(struct internal_config *internal_conf, + int lcore_id) +{ + pthread_attr_t attr; + size_t stack_size; + void *stack_ptr; + int ret; + + if (internal_conf->huge_worker_stack_size == 0) + return pthread_create(&lcore_config[lcore_id].thread_id, + NULL, + eal_thread_loop, + (void *)(uintptr_t)lcore_id); + + /* Allocate NUMA aware stack memory and set pthread attributes */ + if (pthread_attr_init(&attr) != 0) { + rte_eal_init_alert("Cannot init pthread attributes"); + rte_errno = EFAULT; + return -1; + } + if (internal_conf->huge_worker_stack_size == WORKER_STACK_SIZE_FROM_OS) { + if (pthread_attr_getstacksize(&attr, &stack_size) != 0) { + rte_errno = EFAULT; + return -1; + } + } else { + stack_size = internal_conf->huge_worker_stack_size; + } + stack_ptr = rte_zmalloc_socket("lcore_stack", + stack_size, + stack_size, + rte_lcore_to_socket_id(lcore_id)); + + if (stack_ptr == NULL) { + rte_eal_init_alert("Cannot allocate worker lcore stack memory"); + rte_errno = ENOMEM; + return -1; + } + + if (pthread_attr_setstack(&attr, stack_ptr, stack_size) != 0) { + rte_eal_init_alert("Cannot set pthread stack attributes"); + rte_errno = EFAULT; + return -1; + } + + ret = pthread_create(&lcore_config[lcore_id].thread_id, &attr, + eal_thread_loop, + (void *)(uintptr_t)lcore_id); + + if (pthread_attr_destroy(&attr) != 0) { + rte_eal_init_alert("Cannot destroy pthread attributes"); + rte_errno = EFAULT; + return -1; + } + return ret; +} + /* Launch threads, called at application init(). */ int rte_eal_init(int argc, char **argv) @@ -1144,8 +1202,7 @@ rte_eal_init(int argc, char **argv) lcore_config[i].state = WAIT; /* create a thread for each lcore */ - ret = pthread_create(&lcore_config[i].thread_id, NULL, - eal_thread_loop, (void *)(uintptr_t)i); + ret = eal_worker_thread_create(internal_conf, i); if (ret != 0) rte_panic("Cannot create thread\n"); -- 2.17.1