From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id AE1332B8B for ; Thu, 1 Feb 2018 10:48:14 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 66448208B8; Thu, 1 Feb 2018 04:48:14 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Thu, 01 Feb 2018 04:48:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux.org; h=cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=JkiuYaBeCcvvicNkF IW+WxbsjNJsjuTOhy40p7DdjOM=; b=VQH/mv5nTTa0yqsgRi31HAoQ0bd+jTyYs bMVUnsmpX4ApcYkoHpZ7sETrVGsg84E9g6I+D1K4vob1wvByRnQJZe0WEsId1R7q 0ss65Gaw/9l7IbgxZbcRoKWAFfBd248XkgZqPS9NdHFkxfOzqu5TRRuXOqYy3Ies ddXY+KrtwfwF1pmIFV99zMAF/2C3Zv4J7kQWNK/1EMhbyDOEmS+L8aU9P2Kc2M2V Ef1D2hwJUgM1H/yrk6cGh9LzVABdZLpPHgLrYjOyrf3tu8inwdkRvrAV+0DpPkip nbzaGz4ku/8E/q2b1w/WrOqiBCm5PAWjIaap/X41FzibeCMQdVnuw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=JkiuYaBeCcvvicNkFIW+WxbsjNJsjuTOhy40p7DdjOM=; b=IhwoddDK y8LG4X03jFP7jUJQAFAVvmDXQ0he/4HQowmbCGwXpqTC3nWm4JgCy0gMzregqH1W 1eW8gx83zIjjT/a1oEkeYdO/vDAeeGY9tQ5aLvo2zj290P0fuJGvcVgXeWQlcCmG AhQmrqFRulgC90qw7IgB2LlQtPcNfyYYfq57QSUh+a2nXjig2zqiQg133ORHbhNj XVn8A5rP0Qq205UCiQdrHmzjHp+APATXb8mx7/R+iYiwAHv5as/AJyH0CpxUpX1y +0iGohFNsUdp0OaE6QJpfipWwgn8mzd+i1dkpav3GCiKFqRjH5bw4E8sequRCcgz 343hz82wJcyHXQ== X-ME-Sender: Received: from yliu-mob.mtl.com (unknown [115.150.27.200]) by mail.messagingengine.com (Postfix) with ESMTPA id 71481240B6; Thu, 1 Feb 2018 04:48:12 -0500 (EST) From: Yuanhan Liu To: Andriy Berestovskyy Cc: Remy Horton , dpdk stable Date: Thu, 1 Feb 2018 17:47:19 +0800 Message-Id: <1517478479-12417-5-git-send-email-yliu@fridaylinux.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517478479-12417-1-git-send-email-yliu@fridaylinux.org> References: <1517478479-12417-1-git-send-email-yliu@fridaylinux.org> Subject: [dpdk-stable] patch 'keepalive: fix state alignment' has been queued to LTS release 17.11.1 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Feb 2018 09:48:14 -0000 Hi, FYI, your patch has been queued to LTS release 17.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/03/18. So please shout if anyone has objections. Thanks. --yliu --- >>From 0197da770df2a30d6753634f00db8b39132a64ae Mon Sep 17 00:00:00 2001 From: Andriy Berestovskyy Date: Tue, 23 Jan 2018 16:43:16 +0100 Subject: [PATCH] keepalive: fix state alignment [ upstream commit 462d9189374f582166ff77b8c301b89947d016cc ] The __rte_cache_aligned was applied to the whole array, not the array elements. This leads to a false sharing between the monitored cores. Fixes: e70a61ad50ab ("keepalive: export states") Signed-off-by: Andriy Berestovskyy Acked-by: Remy Horton --- doc/guides/sample_app_ug/keep_alive.rst | 2 +- lib/librte_eal/common/rte_keepalive.c | 28 ++++++++++++++++++---------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/doc/guides/sample_app_ug/keep_alive.rst b/doc/guides/sample_app_ug/keep_alive.rst index 9b8be48..6c131a8 100644 --- a/doc/guides/sample_app_ug/keep_alive.rst +++ b/doc/guides/sample_app_ug/keep_alive.rst @@ -168,5 +168,5 @@ The rte_keepalive_mark_alive function simply sets the core state to alive. static inline void rte_keepalive_mark_alive(struct rte_keepalive *keepcfg) { - keepcfg->state_flags[rte_lcore_id()] = ALIVE; + keepcfg->live_data[rte_lcore_id()].core_state = RTE_KA_STATE_ALIVE; } diff --git a/lib/librte_eal/common/rte_keepalive.c b/lib/librte_eal/common/rte_keepalive.c index cdd6956..0c7ecba 100644 --- a/lib/librte_eal/common/rte_keepalive.c +++ b/lib/librte_eal/common/rte_keepalive.c @@ -41,8 +41,12 @@ struct rte_keepalive { /** Core Liveness. */ - enum rte_keepalive_state __rte_cache_aligned state_flags[ - RTE_KEEPALIVE_MAXCORES]; + struct { + /* + * Each element must be cache aligned to prevent false sharing. + */ + enum rte_keepalive_state core_state __rte_cache_aligned; + } live_data[RTE_KEEPALIVE_MAXCORES]; /** Last-seen-alive timestamps */ uint64_t last_alive[RTE_KEEPALIVE_MAXCORES]; @@ -95,19 +99,22 @@ rte_keepalive_dispatch_pings(__rte_unused void *ptr_timer, if (keepcfg->active_cores[idx_core] == 0) continue; - switch (keepcfg->state_flags[idx_core]) { + switch (keepcfg->live_data[idx_core].core_state) { case RTE_KA_STATE_UNUSED: break; case RTE_KA_STATE_ALIVE: /* Alive */ - keepcfg->state_flags[idx_core] = RTE_KA_STATE_MISSING; + keepcfg->live_data[idx_core].core_state = + RTE_KA_STATE_MISSING; keepcfg->last_alive[idx_core] = rte_rdtsc(); break; case RTE_KA_STATE_MISSING: /* MIA */ print_trace("Core MIA. ", keepcfg, idx_core); - keepcfg->state_flags[idx_core] = RTE_KA_STATE_DEAD; + keepcfg->live_data[idx_core].core_state = + RTE_KA_STATE_DEAD; break; case RTE_KA_STATE_DEAD: /* Dead */ - keepcfg->state_flags[idx_core] = RTE_KA_STATE_GONE; + keepcfg->live_data[idx_core].core_state = + RTE_KA_STATE_GONE; print_trace("Core died. ", keepcfg, idx_core); if (keepcfg->callback) keepcfg->callback( @@ -118,7 +125,8 @@ rte_keepalive_dispatch_pings(__rte_unused void *ptr_timer, case RTE_KA_STATE_GONE: /* Buried */ break; case RTE_KA_STATE_DOZING: /* Core going idle */ - keepcfg->state_flags[idx_core] = RTE_KA_STATE_SLEEP; + keepcfg->live_data[idx_core].core_state = + RTE_KA_STATE_SLEEP; keepcfg->last_alive[idx_core] = rte_rdtsc(); break; case RTE_KA_STATE_SLEEP: /* Idled core */ @@ -128,7 +136,7 @@ rte_keepalive_dispatch_pings(__rte_unused void *ptr_timer, keepcfg->relay_callback( keepcfg->relay_callback_data, idx_core, - keepcfg->state_flags[idx_core], + keepcfg->live_data[idx_core].core_state, keepcfg->last_alive[idx_core] ); } @@ -172,11 +180,11 @@ rte_keepalive_register_core(struct rte_keepalive *keepcfg, const int id_core) void rte_keepalive_mark_alive(struct rte_keepalive *keepcfg) { - keepcfg->state_flags[rte_lcore_id()] = RTE_KA_STATE_ALIVE; + keepcfg->live_data[rte_lcore_id()].core_state = RTE_KA_STATE_ALIVE; } void rte_keepalive_mark_sleep(struct rte_keepalive *keepcfg) { - keepcfg->state_flags[rte_lcore_id()] = RTE_KA_STATE_DOZING; + keepcfg->live_data[rte_lcore_id()].core_state = RTE_KA_STATE_DOZING; } -- 2.7.4