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 C41C2A04B5; Fri, 2 Oct 2020 14:03:18 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1E4FE1D589; Fri, 2 Oct 2020 14:03:17 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 2C16F1D583 for ; Fri, 2 Oct 2020 14:03:14 +0200 (CEST) IronPort-SDR: ANWY/BNf2ICeR3+3ik9QiE8sbZspuGGiA4xbrNMwuB+1i5e/uVqWYnCKke+WRs0Ac1t9gZ3/xV q2cE7azb2DkA== X-IronPort-AV: E=McAfee;i="6000,8403,9761"; a="160307121" X-IronPort-AV: E=Sophos;i="5.77,327,1596524400"; d="scan'208";a="160307121" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Oct 2020 05:03:07 -0700 IronPort-SDR: tABp9T0FrSJ99ZiQTkws4qrd9krU61gpYYWAdFdqr8IAR7Kx7Tj9ZH4lRTFiU0ZJatWB1mQs5K iau69hg19I7w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,327,1596524400"; d="scan'208";a="515881407" Received: from silpixa00399498.ir.intel.com (HELO silpixa00399498.ger.corp.intel.com) ([10.237.222.52]) by fmsmga005.fm.intel.com with ESMTP; 02 Oct 2020 05:03:05 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: David Hunt , anatoly.burakov@intel.com Date: Fri, 2 Oct 2020 13:03:05 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] l3fwd-power: make interrupt wakeup log thread safe 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" Currently, the interrupt status notification prevents log spam by remembering whether previous interrupt wakeup was due to traffic or due to timeout expiring. However, it is a single variable that can potentially be accessed from multiple threads, so it is not thread-safe. Fix it by having per-lcore interrupt status. Fixes: f4d1e19c293d ("examples/l3fwd-power: add Rx interrupt timeout") Cc: anatoly.burakov@intel.com Signed-off-by: Anatoly Burakov --- examples/l3fwd-power/main.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c index d0e6c9bd77..46eac7c3e0 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -821,20 +821,23 @@ power_freq_scaleup_heuristic(unsigned lcore_id, * 0 on success */ static int -sleep_until_rx_interrupt(int num) +sleep_until_rx_interrupt(int num, int lcore) { /* * we want to track when we are woken up by traffic so that we can go - * back to sleep again without log spamming. + * back to sleep again without log spamming. Avoid cache line sharing + * to prevent threads stepping on each others' toes. */ - static bool timeout; + static struct { + bool wakeup; + } __rte_cache_aligned status[RTE_MAX_LCORE]; struct rte_epoll_event event[num]; int n, i; uint16_t port_id; uint8_t queue_id; void *data; - if (!timeout) { + if (!status[lcore].wakeup) { RTE_LOG(INFO, L3FWD_POWER, "lcore %u sleeps until interrupt triggers\n", rte_lcore_id()); @@ -851,7 +854,7 @@ sleep_until_rx_interrupt(int num) " port %d queue %d\n", rte_lcore_id(), port_id, queue_id); } - timeout = n == 0; + status[lcore].wakeup = n == 0; return 0; } @@ -1050,7 +1053,8 @@ static int main_intr_loop(__rte_unused void *dummy) if (intr_en) { turn_on_off_intr(qconf, 1); sleep_until_rx_interrupt( - qconf->n_rx_queue); + qconf->n_rx_queue, + lcore_id); turn_on_off_intr(qconf, 0); /** * start receiving packets immediately @@ -1473,7 +1477,8 @@ main_legacy_loop(__rte_unused void *dummy) if (intr_en) { turn_on_off_intr(qconf, 1); sleep_until_rx_interrupt( - qconf->n_rx_queue); + qconf->n_rx_queue, + lcore_id); turn_on_off_intr(qconf, 0); /** * start receiving packets immediately -- 2.17.1