From patchwork Fri Oct 6 12:57:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Abeni X-Patchwork-Id: 822394 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3y7qVB4bWlz9sRq for ; Fri, 6 Oct 2017 23:59:46 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752458AbdJFM7b (ORCPT ); Fri, 6 Oct 2017 08:59:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39072 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752226AbdJFM6S (ORCPT ); Fri, 6 Oct 2017 08:58:18 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 625A1356F0; Fri, 6 Oct 2017 12:58:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 625A1356F0 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=pabeni@redhat.com Received: from dhcppc0.redhat.com (ovpn-116-241.ams2.redhat.com [10.36.116.241]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9F6B570930; Fri, 6 Oct 2017 12:58:15 +0000 (UTC) From: Paolo Abeni To: linux-kernel@vger.kernel.org Cc: "Paul E. McKenney" , Josh Triplett , Steven Rostedt , "David S. Miller" , Eric Dumazet , Hannes Frederic Sowa , netdev@vger.kernel.org Subject: [PATCH 2/4] net: use RCU noref infrastructure to track dst noref Date: Fri, 6 Oct 2017 14:57:47 +0200 Message-Id: <7c7d6183314d8d4cafb9689ce498ec8759c440b0.1507294365.git.pabeni@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 06 Oct 2017 12:58:18 +0000 (UTC) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We can now ensure noref dsts do no escape the relevant RCU section. This does not introduce any functional changes, it adds the relevant debug code enabled by CONFIG_RCU_NOREF_DEBUG. Signed-off-by: Paolo Abeni --- include/linux/skbuff.h | 1 + include/net/dst.h | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 72299ef00061..5df77c8a0319 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -905,6 +905,7 @@ static inline void skb_dst_set(struct sk_buff *skb, struct dst_entry *dst) static inline void skb_dst_set_noref(struct sk_buff *skb, struct dst_entry *dst) { WARN_ON(!rcu_read_lock_held() && !rcu_read_lock_bh_held()); + rcu_track_noref(skb, dst, true); skb->_skb_refdst = (unsigned long)dst | SKB_DST_NOREF; } diff --git a/include/net/dst.h b/include/net/dst.h index 06a6765da074..6bc6fefe178e 100644 --- a/include/net/dst.h +++ b/include/net/dst.h @@ -294,6 +294,8 @@ static inline void refdst_drop(unsigned long refdst) static inline void skb_dst_drop(struct sk_buff *skb) { if (skb->_skb_refdst) { + if (skb->_skb_refdst & SKB_DST_NOREF) + rcu_track_noref(skb, skb_dst(skb), false); refdst_drop(skb->_skb_refdst); skb->_skb_refdst = 0UL; } @@ -304,6 +306,8 @@ static inline void __skb_dst_copy(struct sk_buff *nskb, unsigned long refdst) nskb->_skb_refdst = refdst; if (!(nskb->_skb_refdst & SKB_DST_NOREF)) dst_clone(skb_dst(nskb)); + else + rcu_track_noref(nskb, skb_dst(nskb), true); } static inline void skb_dst_copy(struct sk_buff *nskb, const struct sk_buff *oskb) @@ -335,6 +339,7 @@ static inline void skb_dst_force(struct sk_buff *skb) struct dst_entry *dst = skb_dst(skb); WARN_ON(!rcu_read_lock_held()); + rcu_track_noref(skb, dst, false); if (!dst_hold_safe(dst)) dst = NULL;