From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756331AbcKWUsw (ORCPT ); Wed, 23 Nov 2016 15:48:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41886 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754302AbcKWUsu (ORCPT ); Wed, 23 Nov 2016 15:48:50 -0500 Date: Wed, 23 Nov 2016 22:48:19 +0200 From: "Michael S. Tsirkin" To: David Miller , "Paul E. McKenney" , Arnd Bergmann Cc: linux-kernel@vger.kernel.org Subject: [PATCH RFC] hlist_add_tail_rcu disable sparse warning Message-ID: <20161123223457-mutt-send-email-mst@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 23 Nov 2016 20:48:20 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org sparse is unhappy about this code in hlist_add_tail_rcu: struct hlist_node *i, *last = NULL; for (i = hlist_first_rcu(h); i; i = hlist_next_rcu(i)) last = i; This is because hlist_next_rcu and hlist_next_rcu return __rcu pointers. The following trivial patch disables the warning without changing the behaviour in any way. Signed-off-by: Michael S. Tsirkin --- I would appreciate review to confirm the function doesn't do anything unsafe though. In particular, should this use __hlist_for_each_rcu instead? I note that __hlist_for_each_rcu does rcu_dereference internally, which is missing here. compile-tested only. diff --git a/include/linux/rculist.h b/include/linux/rculist.h index 8beb98d..33574db 100644 --- a/include/linux/rculist.h +++ b/include/linux/rculist.h @@ -511,7 +511,7 @@ static inline void hlist_add_tail_rcu(struct hlist_node *n, { struct hlist_node *i, *last = NULL; - for (i = hlist_first_rcu(h); i; i = hlist_next_rcu(i)) + for (i = h->first; i; i = i->next) last = i; if (last) {