From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by dpdk.org (Postfix) with ESMTP id DE9DB1B2A9; Sun, 12 Nov 2017 18:51:39 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 8192820A82; Sun, 12 Nov 2017 12:51:38 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Sun, 12 Nov 2017 12:51:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=mesmtp; bh=1nSwRo5isQZuZnpkqeuuq5QDkB mqfmmmywX+e0oltM8=; b=hghLw4vJM+L2/3wI626KsBX2EmeWacm4zBFd85NrH1 80hOwK3OsKF0o/6CoGGcdNMyyUNOl0Bc/foBoy+vON8AoSKHFKAFR0TziTshf25L JUwpJuXHX/DikMw9Df85euMjiX3zJaT5WHU6d/qnhkGwtPLhrMYzs5DKheE0r/pL M= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=1nSwRo 5isQZuZnpkqeuuq5QDkBmqfmmmywX+e0oltM8=; b=htK1LLPjteb1unAhjdepHL WCRCsuFeH3/y2D2bG3ydERrj1CUiAD3hKmQk3BYu9VyuAAvm9YEQF5zpiGkATU4t b0HXxmy+KzVYY5b96yRT5Wc+mN2Upeu9JvXEJ8fw2joFhRcCNAXSvA1bXEb1hxmF LkzhsC3+fqWpbDnr+BS1BF3rjK7CAuEsxPuDcLxC2k8WyZJWiixPyB/tFWojQ7gU LtsQPJyvVELbAdD0o4TMGM/KFTaamVxCmpFWCPCFrKH1gT2f7SaeFzsMW5RiqMLW TB00ra/5YSu66N1pdN0d8iF4k6OZ7SkWNLVueUCl/W1PCjoxeY6B3G6kpAtWiOgQ == X-ME-Sender: Received: from xps.localnet (unknown [12.232.154.2]) by mail.messagingengine.com (Postfix) with ESMTPA id 2E1AF7F9D2; Sun, 12 Nov 2017 12:51:38 -0500 (EST) From: Thomas Monjalon To: Jia He , Jia He Cc: stable@dpdk.org, jerin.jacob@caviumnetworks.com, dev@dpdk.org, olivier.matz@6wind.com, konstantin.ananyev@intel.com, bruce.richardson@intel.com, jianbo.liu@arm.com, hemant.agrawal@nxp.com, jie2.liu@hxt-semitech.com, bing.zhao@hxt-semitech.com Date: Sun, 12 Nov 2017 18:51:37 +0100 Message-ID: <3554910.3QoyqmBB3R@xps> In-Reply-To: <1510284642-7442-2-git-send-email-hejianet@gmail.com> References: <1510278669-8489-1-git-send-email-hejianet@gmail.com> <1510284642-7442-1-git-send-email-hejianet@gmail.com> <1510284642-7442-2-git-send-email-hejianet@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [dpdk-stable] [PATCH v6] ring: guarantee load/load order in enqueue and dequeue 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: , X-List-Received-Date: Sun, 12 Nov 2017 17:51:40 -0000 10/11/2017 04:30, Jia He: > We watched a rte panic of mbuf_autotest in our qualcomm arm64 server > (Amberwing). > > Root cause: > In __rte_ring_move_cons_head() > ... > do { > /* Restore n as it may change every loop */ > n = max; > > *old_head = r->cons.head; //1st load > const uint32_t prod_tail = r->prod.tail; //2nd load > > In weak memory order architectures(powerpc,arm), the 2nd load might be > reodered before the 1st load, that makes *entries is bigger than we wanted. > This nasty reording messed enque/deque up. > > cpu1(producer) cpu2(consumer) cpu3(consumer) > load r->prod.tail > in enqueue: > load r->cons.tail > load r->prod.head > > store r->prod.tail > > load r->cons.head > load r->prod.tail > ... > store r->cons.{head,tail} > load r->cons.head > > Then, r->cons.head will be bigger than prod_tail, then make *entries very > big and the consumer will go forward incorrectly. > > After this patch, the old cons.head will be recaculated after failure of > rte_atomic32_cmpset > > There is no such issue on X86, because X86 is strong memory order model. > But rte_smp_rmb() doesn't have impact on runtime performance on X86, so > keep the same code without architectures specific concerns. > > Signed-off-by: Jia He > Signed-off-by: jie2.liu@hxt-semitech.com > Signed-off-by: bing.zhao@hxt-semitech.com > Acked-by: Jerin Jacob > Acked-by: Jianbo Liu > Cc: stable@dpdk.org Applied, thanks