From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 17F0DA0577; Mon, 13 Apr 2020 11:09:40 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5B5C71B53; Mon, 13 Apr 2020 11:09:39 +0200 (CEST) Received: from integrity.niometrics.com (integrity.niometrics.com [42.61.70.122]) by dpdk.org (Postfix) with ESMTP id E4AE2FFA for ; Mon, 13 Apr 2020 11:09:36 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by integrity.niometrics.com (Postfix) with ESMTP id 796EB409CBA9; Mon, 13 Apr 2020 17:09:34 +0800 (+08) DKIM-Filter: OpenDKIM Filter v2.11.0 integrity.niometrics.com 796EB409CBA9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niometrics.com; s=default; t=1586768975; bh=zqtnhF9UemdiX3gN4eZt6GGhZIHRdaefq+5ncrcRgw4=; h=From:To:Cc:Subject:Date:From; b=THEAlAHsf4ZAzliSUwsUVOtGV8E9C25zxPckZIaukavnDRs3UtSaRlHTuSyCG+KSS QjympT8tDsEcybCYgZ3p3YEu4qdaBTC24j319smgT9YDKom6R5Cqm34HdsLIA7VQpB i+KBVNox4vSUbHt6h6NG5frOOREmTKwVVCf6grnc= X-Virus-Scanned: amavisd-new at niometrics.com Received: from integrity.niometrics.com ([127.0.0.1]) by localhost (integrity.niometrics.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zJNYBQxVGV8q; Mon, 13 Apr 2020 17:09:34 +0800 (+08) Received: from devserver-sg-11.niometrics.com (test-site-3.niometrics.com [192.168.2.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by integrity.niometrics.com (Postfix) with ESMTPSA id 821AD409CBA8; Mon, 13 Apr 2020 17:09:33 +0800 (+08) DKIM-Filter: OpenDKIM Filter v2.11.0 integrity.niometrics.com 821AD409CBA8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niometrics.com; s=default; t=1586768974; bh=zqtnhF9UemdiX3gN4eZt6GGhZIHRdaefq+5ncrcRgw4=; h=From:To:Cc:Subject:Date:From; b=FoVDK+SmPZosJepJQu/hOYWlxGX+mMSkEXnC7HeyAoW09jXROqWQDd0xrNYIqnGu5 TXKLcI+JGcxaqwi6MXIznX+C3QdRyvYntv8fupuY/xsaNwcmEmjGwyqLWvqocuR/yY 32rbn+XT64FCrDK4pxptujjYOF9QG5b3O3HuIpNE= From: Christos Ricudis To: Anatoly Burakov Cc: dev@dpdk.org, Christos Ricudis Date: Mon, 13 Apr 2020 17:09:12 +0800 Message-Id: <1586768952-10554-1-git-send-email-ricudis@niometrics.com> X-Mailer: git-send-email 1.8.3.1 X-Spam-Status: No, score=-1.1 required=3.5 tests=ALL_TRUSTED, AWL, DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on integrity.niometrics.com Subject: [dpdk-dev] [PATCH] eal: Place EAL thread stack in a reserved per-lcore memzone X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Reserve a per-lcore 4MB memzone and allocate thread stack of EAL threads there for better NUMA locality of stack-allocated variables Signed-off-by: Christos Ricudis --- lib/librte_eal/linux/eal.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/librte_eal/linux/eal.c b/lib/librte_eal/linux/eal.c index 9530ee5..e047107 100644 --- a/lib/librte_eal/linux/eal.c +++ b/lib/librte_eal/linux/eal.c @@ -68,6 +68,8 @@ #define KERNEL_IOMMU_GROUPS_PATH "/sys/kernel/iommu_groups" +#define THREAD_STACK_SIZE_DEFAULT (4ULL * 1024ULL * 1024ULL) +#include /* Allow the application to print its usage message too if set */ static rte_usage_hook_t rte_application_usage_hook = NULL; @@ -1224,6 +1226,24 @@ static void rte_eal_init_alert(const char *msg) lcore_config[i].state = WAIT; + pthread_attr_t attr; + pthread_attr_init(&attr); + size_t thread_stack_size = THREAD_STACK_SIZE_DEFAULT; + char thread_stack_name[64]; + snprintf(thread_stack_name, sizeof thread_stack_name, "rte:lcore:%s:%d:threadstack", rte_eal_process_type() == RTE_PROC_PRIMARY ? "p" : "s", i); + const struct rte_memzone *mz = rte_memzone_lookup(thread_stack_name); + if (mz == NULL) { + if ((mz = rte_memzone_reserve(thread_stack_name, thread_stack_size, lcore_config[i].socket_id, 0)) == NULL) { + rte_panic("Cannot allocate memzone for thread stack"); + } + } + void *thread_stack = mz->addr; + + if (pthread_attr_setstack(&attr, thread_stack, thread_stack_size) < 0) { + rte_panic("Cannot set thread stack\n"); + } + RTE_LOG(DEBUG, EAL, "Thread stack for lcore %d on socket %d set to %p\n", i, lcore_config[i].socket_id, thread_stack); + /* create a thread for each lcore */ ret = pthread_create(&lcore_config[i].thread_id, NULL, eal_thread_loop, NULL); -- 1.8.3.1