Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754043AbbBFDNL (ORCPT ); Thu, 5 Feb 2015 22:13:11 -0500 Received: from mail.efficios.com ([78.47.125.74]:57417 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753731AbbBFDNJ (ORCPT ); Thu, 5 Feb 2015 22:13:09 -0500 X-Greylist: delayed 344 seconds by postgrey-1.27 at vger.kernel.org; Thu, 05 Feb 2015 22:13:08 EST From: Mathieu Desnoyers To: Huang Ying Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , Paul McKenney , David Howells Subject: [PATCH] llist: Fix missing memory barrier Date: Thu, 5 Feb 2015 22:06:57 -0500 Message-Id: <1423192017-16735-1-git-send-email-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.1.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1425 Lines: 45 A smp_read_barrier_depends() appears to be missing in llist_del_first(). It should only matter for Alpha in practice. Adding it after the check of entry against NULL allows skipping the barrier in a common case. Signed-off-by: Mathieu Desnoyers CC: Huang Ying CC: Paul McKenney CC: David Howells --- lib/llist.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/llist.c b/lib/llist.c index f76196d..72861f3 100644 --- a/lib/llist.c +++ b/lib/llist.c @@ -26,6 +26,7 @@ #include #include #include +#include /** @@ -72,6 +73,12 @@ struct llist_node *llist_del_first(struct llist_head *head) if (entry == NULL) return NULL; old_entry = entry; + /* + * Load entry before entry->next. Matches the implicit + * memory barrier before the cmpxchg in llist_add_batch(), + * which ensures entry->next is stored before entry. + */ + smp_read_barrier_depends(); next = entry->next; entry = cmpxchg(&head->first, old_entry, next); if (entry == old_entry) -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/