From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f194.google.com (mail-wr0-f194.google.com [209.85.128.194]) by dpdk.org (Postfix) with ESMTP id E35AC1B738 for ; Wed, 7 Feb 2018 17:47:17 +0100 (CET) Received: by mail-wr0-f194.google.com with SMTP id h9so1753389wre.12 for ; Wed, 07 Feb 2018 08:47:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UE0mcAeIuqO2u2HBc3yjZFafIWrBNMt11C89l/Nt3fE=; b=PxEtU2C1Z1YWXu1Bq6PC/2THNNqnYpylp2A4jLKeRwOde3dcX58tBTaTnqD/0U7uKj N7/ySqnziaKY9Caslkt7EVXEDK2cTadB9mw5z6nNQiyMoqVswb/Dh8qo76YfzyKVu40m zIkBn1vbzRdO3narkrDRhYOuBGFcJ9Ax0sm0c2v18VbgT6psje76mkE5WicNl58uvzi0 zhhRNG0td6TWdickxe6eUVAfME/rLxH7Y86r6PWVArHkr+KcBXmrTX5EDr6cebYkXt+n grPkcT9D9og++1ehXA8xXDAeM4mIb+V5Bni2IW1bQ4uWvcbx/zXHS11MPC1uub/hEIWC m5HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UE0mcAeIuqO2u2HBc3yjZFafIWrBNMt11C89l/Nt3fE=; b=CvgWryf60RyWg8L2NyZXdJUD9k2qs9s0UayHOtfzrvE1jR7HwPY9SUtAIgKy1qoE9b 33taa7yMJJqKEHDAoVTyXbaAJlauNyMiycczmohwTA1b8NGpNNcbGrou3A86Ejp/pIYI HTMKHxBCzqngkF6qK5vWXL+gBVb+i2KgQ9U0B278x5N2mxKaMHdVd35J8e1ujjzXKaCj saX11imeCrvtH7N9KbW7yyMJvaFA7p/dfkzS8Y3wXsCOKxn0+o79y45yFHG8MJ7hwZYB pMDOW7CiLZL6cGdndfrR7Cv2CaTlOaB4l/OmfVyDCrWqiWWL1/g74F1BQ9IMgJnrUVVX th2g== X-Gm-Message-State: APf1xPAAE763oS3cTH4HwQXL96Rl6p0WMsyO5DJfFEliZDa/DC9pka13 Vtu5bpxJu1VSbEz/qaDdODHwsW5x X-Google-Smtp-Source: AH8x227iI8RMphhvjS3+YApEV9iHEN03k+vzw0kZ4z05wn/QOyQIX7iyoMi+ZWJilh03RNQjltT2Ag== X-Received: by 10.223.132.195 with SMTP id 61mr6530304wrg.187.1518022037399; Wed, 07 Feb 2018 08:47:17 -0800 (PST) Received: from localhost ([2a00:23c5:bef3:400:9531:588b:44ae:bec4]) by smtp.gmail.com with ESMTPSA id t4sm2455154wmt.16.2018.02.07.08.47.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 07 Feb 2018 08:47:16 -0800 (PST) From: luca.boccassi@gmail.com To: Andriy Berestovskyy Cc: Remy Horton , dpdk stable Date: Wed, 7 Feb 2018 16:46:32 +0000 Message-Id: <20180207164705.29052-1-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180126131332.15346-62-luca.boccassi@gmail.com> References: <20180126131332.15346-62-luca.boccassi@gmail.com> Subject: [dpdk-stable] patch 'keepalive: fix state alignment' has been queued to LTS release 16.11.5 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: Wed, 07 Feb 2018 16:47:20 -0000 Hi, FYI, your patch has been queued to LTS release 16.11.5 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/09/18. So please shout if anyone has objections. Thanks. Luca Boccassi --- >>From 153b3ebc1da6a905b46c012c1ceff3d6d259ef00 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 389737792..48769270e 100644 --- a/doc/guides/sample_app_ug/keep_alive.rst +++ b/doc/guides/sample_app_ug/keep_alive.rst @@ -186,5 +186,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 9765d1bd9..4625fab09 100644 --- a/lib/librte_eal/common/rte_keepalive.c +++ b/lib/librte_eal/common/rte_keepalive.c @@ -42,8 +42,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]; @@ -96,19 +100,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( @@ -119,7 +126,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 */ @@ -129,7 +137,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] ); } @@ -173,11 +181,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.14.2