From patchwork Wed Jul 27 22:14:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 72914 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp538138qga; Wed, 27 Jul 2016 15:14:17 -0700 (PDT) X-Received: by 10.55.112.5 with SMTP id l5mr40720419qkc.82.1469657657270; Wed, 27 Jul 2016 15:14:17 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id d197si5773735qkb.148.2016.07.27.15.14.16; Wed, 27 Jul 2016 15:14:17 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 9DCE3688DA; Wed, 27 Jul 2016 22:14:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 0F29D688D2; Wed, 27 Jul 2016 22:14:13 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 432A76855E; Wed, 27 Jul 2016 22:14:11 +0000 (UTC) Received: from mail-oi0-f43.google.com (mail-oi0-f43.google.com [209.85.218.43]) by lists.linaro.org (Postfix) with ESMTPS id 6FF196855E for ; Wed, 27 Jul 2016 22:14:10 +0000 (UTC) Received: by mail-oi0-f43.google.com with SMTP id j185so37853432oih.0 for ; Wed, 27 Jul 2016 15:14:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=iL8QPMek+pgX3Wxpn8fpU5oohjASGV0GHwzfWxlHSvc=; b=KO+1xojafBsFE1OfoWaT/58pTrkC2DPGZfckMVvZ6rEBissKEYv7oJ4U/nzkR61SgJ 9p5lAiXBzeccgIb+LaT3Py2I447KPtznij9e2c8g9Dp0ULH6QhnnsJBWOpz5T8OOofMw MUqayPYpOr3mR58TAfsYeOU2hhZ/M4od0pk9NBfD/nAl0vGqKJ70ePnbH1qYZQhEHnyS P+OwJYZgLIQB0i8/2E+AKX8SSOQ53kJictGpeMV2BMYsE6PA3YxuRhu0KHV1ETuniiTn e+wSytKFAGpegg4jzjJnIK4bwhMKL9WAp7S6Xrj40lBT7kvMgdaV2LVlW6CUuSGeGdIw +f7g== X-Gm-Message-State: AEkoousABw4qDn+2brCFoe+OBYF1VU6null+ImGr1bnoLwwvKAXJovJH+HrnIn8uPlNxUhKNNIE= X-Received: by 10.202.76.141 with SMTP id z135mr17127972oia.43.1469657649774; Wed, 27 Jul 2016 15:14:09 -0700 (PDT) Received: from localhost.localdomain (cpe-66-68-129-43.austin.res.rr.com. [66.68.129.43]) by smtp.gmail.com with ESMTPSA id p72sm3329394oic.13.2016.07.27.15.14.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 27 Jul 2016 15:14:09 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Wed, 27 Jul 2016 17:14:07 -0500 Message-Id: <1469657647-23549-1-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.7.4 X-Topics: patch Subject: [lng-odp] [PATCH] linux-generic: tm: attempt to assign tm service threads to separate cores X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" When creating multiple TM service threads, attempt to assign them to separate cores to avoid overloading a single core. This addresses the issue raised in Bug https://bugs.linaro.org/show_bug.cgi?id=2444 Signed-off-by: Bill Fischofer --- platform/linux-generic/odp_traffic_mngr.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/platform/linux-generic/odp_traffic_mngr.c b/platform/linux-generic/odp_traffic_mngr.c index e668bf9..6e04392 100644 --- a/platform/linux-generic/odp_traffic_mngr.c +++ b/platform/linux-generic/odp_traffic_mngr.c @@ -83,6 +83,7 @@ static odp_ticketlock_t tm_profile_lock; static odp_barrier_t tm_first_enq; static int g_main_thread_cpu = -1; +static int g_tm_cpu_num = 0; /* Forward function declarations. */ static void tm_queue_cnts_decrement(tm_system_t *tm_system, @@ -2559,6 +2560,7 @@ static uint32_t tm_thread_cpu_select(void) { odp_cpumask_t odp_cpu_mask; int cpu_count; + int cpu; odp_cpumask_default_worker(&odp_cpu_mask, 0); if ((g_main_thread_cpu != -1) && @@ -2576,7 +2578,18 @@ static uint32_t tm_thread_cpu_select(void) odp_cpumask_all_available(&odp_cpu_mask); } - return odp_cpumask_first(&odp_cpu_mask); + if (g_tm_cpu_num == 0) { + cpu = odp_cpumask_first(&odp_cpu_mask); + } else { + cpu = odp_cpumask_next(&odp_cpu_mask, g_tm_cpu_num); + if (cpu == -1) { + g_tm_cpu_num = 0; + cpu = odp_cpumask_first(&odp_cpu_mask); + } + } + + g_tm_cpu_num++; + return cpu; } static int tm_thread_create(tm_system_t *tm_system) @@ -2770,6 +2783,9 @@ int odp_tm_destroy(odp_tm_t odp_tm) ODP_ASSERT(rc == 0); pthread_attr_destroy(&tm_system->attr); + if (g_tm_cpu_num > 0) + g_tm_cpu_num--; + input_work_queue_destroy(tm_system->input_work_queue); _odp_sorted_pool_destroy(tm_system->_odp_int_sorted_pool); _odp_queue_pool_destroy(tm_system->_odp_int_queue_pool);