Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2930900ybx; Fri, 8 Nov 2019 11:25:45 -0800 (PST) X-Google-Smtp-Source: APXvYqwrwNoZfv3zpyanr7MnaygpeMhC4h9nL72/vfePpH7snKt+gX8jmQQ1WiJ2GiImtTNeUv1k X-Received: by 2002:a05:6402:142c:: with SMTP id c12mr12103338edx.96.1573241145042; Fri, 08 Nov 2019 11:25:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573241145; cv=none; d=google.com; s=arc-20160816; b=EYQwC/CeBCS87Ct7L+T3QTKiIOiyTYHm1Rq8nUh3bVSI6j9JgPCFO5dPgIOtPrUr/w /fBnOfUP7otjGVsWxG8tQXvcXz24TJXElNbucOQKpl1T+C2BT1dO1Ifr87m/LsGlQbwq jFlVUmf/BE1dmSGzc9iRQhMkYaXacB3XIyQL5TL01va6K8mB33ejCb5Nph79PvbZtfRZ iVTE08QSgJjLDNzmi6z0xyZ2plpPrKiXvqdV5qdVh9ud3+g6IXTvssmHyVdy9UIwOGi/ hlIQVOHrxcH5998rjAz6GjGcu8K9l56fCQjkkai76volTf5hu9spLZLb0vOwlinTA7Ai j2mA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=qTNAO8BdYRe9IKfKr9+yVGQUzNE1lNa54Ubcew5jWS4=; b=crNxHPd/LB5zVxwxTCLjQ0m48RjVKGk1/LXprRzj0qvicjsme3X19Nc9d1AJ7XW/8l O+oP78hPse0Dyh3WEFUSXJU8CTXt7wjkY7oHl5cSjTf3Y1vU59EBKqDgrFqEFpC/GI86 XwD5EQps4KjCFSbAkjwH0PS3XM6XMwPRwyoOszoniz1yt3OU+PebeRxboeTnGxpQ+gvm XTJPBLgi6yU2KSp3tvImY6CCItqX+SNxRnchmnrOeZ5y4qtqHVyGo7DHP0Dh+AnO6JJm HC1DUmyd1cXqZMR+teMsdlQEHGslf69Y9X6sKhTOJx7/w/qaisalb0bhBcvxPGBo3Q7O j0pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=f2lwSIAp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fx21si4134110ejb.254.2019.11.08.11.25.21; Fri, 08 Nov 2019 11:25:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=f2lwSIAp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731267AbfKHTYx (ORCPT + 99 others); Fri, 8 Nov 2019 14:24:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:54712 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730461AbfKHTYx (ORCPT ); Fri, 8 Nov 2019 14:24:53 -0500 Received: from paulmck-ThinkPad-P72.home (unknown [213.233.149.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 45C2A2067B; Fri, 8 Nov 2019 19:24:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573241091; bh=WdMTwF1tMvTKaGQ2zKNu14ZCzIA4ENht4XBnlGbzRDE=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=f2lwSIApoACkQCh24xuonVotpzuhxyurrnHhDAs33TFpEI4qWWDPf2fNyytYr5jCP QMTAXF1UmkK5GhLPP6SbK/Kp127Im9UvPIzvQwnVagvsyOCVfrJ2RJKS8nyvy+pWwO sF9cNTFa78XoMmBWD8XeNAn4BtdnpMsVA9N9QzVg= Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 02A4F35204A1; Fri, 8 Nov 2019 11:24:49 -0800 (PST) Date: Fri, 8 Nov 2019 11:24:48 -0800 From: "Paul E. McKenney" To: Eric Dumazet Cc: Thomas Gleixner , linux-kernel , Eric Dumazet Subject: Re: [PATCH 1/2] list: add hlist_unhashed_lockless() Message-ID: <20191108192448.GB20975@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <20191107193738.195914-1-edumazet@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191107193738.195914-1-edumazet@google.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 07, 2019 at 11:37:37AM -0800, Eric Dumazet wrote: > We would like to use hlist_unhashed() from timer_pending(), > which runs without protection of a lock. > > Note that other callers might also want to use this variant. > > Instead of forcing a READ_ONCE() for all hlist_unhashed() > callers, add a new helper with an explicit _lockless suffix > in the name to better document what is going on. > > Also add various WRITE_ONCE() in __hlist_del(), hlist_add_head() > and hlist_add_before()/hlist_add_behind() to pair with > the READ_ONCE(). > > Signed-off-by: Eric Dumazet > Cc: "Paul E. McKenney" > Cc: Thomas Gleixner I have queued this, but if you prefer it go some other way: Acked-by: Paul E. McKenney But shouldn't the uses in include/linux/rculist.h also be converted into the patch below? If so, I will squash the following into your patch. Thanx, Paul ------------------------------------------------------------------------ diff --git a/include/linux/rculist.h b/include/linux/rculist.h index 61c6728a..4b7ae1b 100644 --- a/include/linux/rculist.h +++ b/include/linux/rculist.h @@ -173,7 +173,7 @@ static inline void hlist_del_init_rcu(struct hlist_node *n) { if (!hlist_unhashed(n)) { __hlist_del(n); - n->pprev = NULL; + WRITE_ONCE(n->pprev, NULL); } } @@ -473,7 +473,7 @@ static inline void list_splice_tail_init_rcu(struct list_head *list, static inline void hlist_del_rcu(struct hlist_node *n) { __hlist_del(n); - n->pprev = LIST_POISON2; + WRITE_ONCE(n->pprev, LIST_POISON2); } /** @@ -489,11 +489,11 @@ static inline void hlist_replace_rcu(struct hlist_node *old, struct hlist_node *next = old->next; new->next = next; - new->pprev = old->pprev; + WRITE_ONCE(new->pprev, old->pprev); rcu_assign_pointer(*(struct hlist_node __rcu **)new->pprev, new); if (next) - new->next->pprev = &new->next; - old->pprev = LIST_POISON2; + WRITE_ONCE(new->next->pprev, &new->next); + WRITE_ONCE(old->pprev, LIST_POISON2); } /* @@ -528,10 +528,10 @@ static inline void hlist_add_head_rcu(struct hlist_node *n, struct hlist_node *first = h->first; n->next = first; - n->pprev = &h->first; + WRITE_ONCE(n->pprev, &h->first); rcu_assign_pointer(hlist_first_rcu(h), n); if (first) - first->pprev = &n->next; + WRITE_ONCE(first->pprev, &n->next); } /** @@ -564,7 +564,7 @@ static inline void hlist_add_tail_rcu(struct hlist_node *n, if (last) { n->next = last->next; - n->pprev = &last->next; + WRITE_ONCE(n->pprev, &last->next); rcu_assign_pointer(hlist_next_rcu(last), n); } else { hlist_add_head_rcu(n, h); @@ -592,10 +592,10 @@ static inline void hlist_add_tail_rcu(struct hlist_node *n, static inline void hlist_add_before_rcu(struct hlist_node *n, struct hlist_node *next) { - n->pprev = next->pprev; + WRITE_ONCE(n->pprev, next->pprev); n->next = next; rcu_assign_pointer(hlist_pprev_rcu(n), n); - next->pprev = &n->next; + WRITE_ONCE(next->pprev, &n->next); } /** @@ -620,10 +620,10 @@ static inline void hlist_add_behind_rcu(struct hlist_node *n, struct hlist_node *prev) { n->next = prev->next; - n->pprev = &prev->next; + WRITE_ONCE(n->pprev, &prev->next); rcu_assign_pointer(hlist_next_rcu(prev), n); if (n->next) - n->next->pprev = &n->next; + WRITE_ONCE(n->next->pprev, &n->next); } #define __hlist_for_each_rcu(pos, head) \