From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 92CCAB3A1 for ; Thu, 11 Sep 2014 16:18:19 +0200 (CEST) Received: from azsmga001.ch.intel.com ([10.2.17.19]) by orsmga101.jf.intel.com with ESMTP; 11 Sep 2014 07:23:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,506,1406617200"; d="scan'208";a="476889860" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by azsmga001.ch.intel.com with ESMTP; 11 Sep 2014 07:23:08 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id s8BEN7YA013312; Thu, 11 Sep 2014 15:23:07 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id s8BEN7Ht004896; Thu, 11 Sep 2014 15:23:07 +0100 Received: (from bricha3@localhost) by sivswdev02.ir.intel.com with id s8BEN7cL004892; Thu, 11 Sep 2014 15:23:07 +0100 From: Bruce Richardson To: dev@dpdk.org Date: Thu, 11 Sep 2014 15:23:05 +0100 Message-Id: <1410445387-4849-2-git-send-email-bruce.richardson@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1410445387-4849-1-git-send-email-bruce.richardson@intel.com> References: <1410445387-4849-1-git-send-email-bruce.richardson@intel.com> Subject: [dpdk-dev] [PATCH 1/3] eal: add core id param to eal_thread_set_affinity X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Sep 2014 14:18:21 -0000 the function eal_thread_set_affinity always sets the affinity of the thread to the lcore_id of the thread as given by the thread-local variable. To allow this function to be used by arbitrary threads (e.g. eal utility threads such as those for interrupts, timers, etc.), add a parameter to specify the core id to be used for the affinity. Signed-off-by: Bruce Richardson --- lib/librte_eal/bsdapp/eal/eal_thread.c | 10 +++++----- lib/librte_eal/linuxapp/eal/eal_thread.c | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/librte_eal/bsdapp/eal/eal_thread.c b/lib/librte_eal/bsdapp/eal/eal_thread.c index ab05368..18df2a3 100644 --- a/lib/librte_eal/bsdapp/eal/eal_thread.c +++ b/lib/librte_eal/bsdapp/eal/eal_thread.c @@ -96,7 +96,7 @@ rte_eal_remote_launch(int (*f)(void *), void *arg, unsigned slave_id) /* set affinity for current thread */ static int -eal_thread_set_affinity(void) +eal_thread_set_affinity(unsigned lcore_id) { int s; pthread_t thread; @@ -126,7 +126,7 @@ eal_thread_set_affinity(void) size = CPU_ALLOC_SIZE(RTE_MAX_LCORE); CPU_ZERO_S(size, cpusetp); - CPU_SET_S(rte_lcore_id(), size, cpusetp); + CPU_SET_S(lcore_id, size, cpusetp); thread = pthread_self(); s = pthread_setaffinity_np(thread, size, cpusetp); @@ -140,7 +140,7 @@ eal_thread_set_affinity(void) #else /* CPU_ALLOC */ cpuset_t cpuset; CPU_ZERO( &cpuset ); - CPU_SET( rte_lcore_id(), &cpuset ); + CPU_SET(lcore_id, &cpuset ); thread = pthread_self(); s = pthread_setaffinity_np(thread, sizeof( cpuset ), &cpuset); @@ -158,7 +158,7 @@ void eal_thread_init_master(unsigned lcore_id) RTE_PER_LCORE(_lcore_id) = lcore_id; /* set CPU affinity */ - if (eal_thread_set_affinity() < 0) + if (eal_thread_set_affinity(lcore_id) < 0) rte_panic("cannot set affinity\n"); } @@ -192,7 +192,7 @@ eal_thread_loop(__attribute__((unused)) void *arg) RTE_PER_LCORE(_lcore_id) = lcore_id; /* set CPU affinity */ - if (eal_thread_set_affinity() < 0) + if (eal_thread_set_affinity(lcore_id) < 0) rte_panic("cannot set affinity\n"); /* read on our pipe to get commands */ diff --git a/lib/librte_eal/linuxapp/eal/eal_thread.c b/lib/librte_eal/linuxapp/eal/eal_thread.c index 80a985f..9dc3f98 100644 --- a/lib/librte_eal/linuxapp/eal/eal_thread.c +++ b/lib/librte_eal/linuxapp/eal/eal_thread.c @@ -96,7 +96,7 @@ rte_eal_remote_launch(int (*f)(void *), void *arg, unsigned slave_id) /* set affinity for current thread */ static int -eal_thread_set_affinity(void) +eal_thread_set_affinity(unsigned lcore_id) { int s; pthread_t thread; @@ -126,7 +126,7 @@ eal_thread_set_affinity(void) size = CPU_ALLOC_SIZE(RTE_MAX_LCORE); CPU_ZERO_S(size, cpusetp); - CPU_SET_S(rte_lcore_id(), size, cpusetp); + CPU_SET_S(lcore_id, size, cpusetp); thread = pthread_self(); s = pthread_setaffinity_np(thread, size, cpusetp); @@ -140,7 +140,7 @@ eal_thread_set_affinity(void) #else /* CPU_ALLOC */ cpu_set_t cpuset; CPU_ZERO( &cpuset ); - CPU_SET( rte_lcore_id(), &cpuset ); + CPU_SET(lcore_id, &cpuset); thread = pthread_self(); s = pthread_setaffinity_np(thread, sizeof( cpuset ), &cpuset); @@ -158,7 +158,7 @@ void eal_thread_init_master(unsigned lcore_id) RTE_PER_LCORE(_lcore_id) = lcore_id; /* set CPU affinity */ - if (eal_thread_set_affinity() < 0) + if (eal_thread_set_affinity(lcore_id) < 0) rte_panic("cannot set affinity\n"); } @@ -192,7 +192,7 @@ eal_thread_loop(__attribute__((unused)) void *arg) RTE_PER_LCORE(_lcore_id) = lcore_id; /* set CPU affinity */ - if (eal_thread_set_affinity() < 0) + if (eal_thread_set_affinity(lcore_id) < 0) rte_panic("cannot set affinity\n"); /* read on our pipe to get commands */ -- 1.9.3