Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp4001318ybg; Sun, 7 Jun 2020 18:04:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1t8n2npWiy7NiySlRVMDCgG35NcXYbHkUWt9Igv0fF9bq8vebbhgueIppb4QP1vNxXzF7 X-Received: by 2002:aa7:c69a:: with SMTP id n26mr19443259edq.2.1591578275397; Sun, 07 Jun 2020 18:04:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591578275; cv=none; d=google.com; s=arc-20160816; b=kQPX8SluzAU7PviZIY/KlBQfiSou2IX93CAsQGTOrlKPW1Og++lXENo2lFLqXB4HAD oHKpLJWBcoW5JXImzFKPQiu5Lwh8GcTeEYPhaf8eO/eXTGlNqcJhY/mRpFvkVF3MFbA3 M3s/ex7CtVOyLLH9oSL2JPPGP7ANEl8fCj1kldzR4dsV+GZmd6Qk2gtgF2ySALr/sK2e ECPBOA7sPtyozLDzjxa30B47vMhGCfaxFpbVspyD6TP0znjZ7zRpb+6LEHypUhJSomr8 JunmawN5rh5Dt/LP+kyKnADd/AGli1iAIdIhNhLJTkJxg2mERBFp7IK0DUf7mkyZsgOw v7Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=L61pJxSRU8yRIzK3/wT0+4/FnQuZFh6diO59e1nBA5s=; b=YHhaP7+oQlAyz70pKzETWO5v34ffgROZl49tEpSM+x0qIbKTNXzNT0/qzXyi7djzAr qxvf8G5yr1/YRVpX7Sea0RjS6PRyokplncVTvGIKo+le8p8YhYqBZL6KDEP4aiXdhU9Z cJviFrSSTaDp/x9TP/KZN0mQZXXGqliXm/GCesTsGYm/UdTflIpzI706O43fkWLpS6N2 gKsSlKNFjzgOWQyNA+njiLNfbD7GU5dIw24mIR9czZ0HmJ38/6dOJizC1uZWaOddQLv6 EacTO0Xkcs9Je8nFu8/+pNzgaZhNsetA3UYRTbqlhKo+RJaMD32bXzgXuQHHr/qWvmhf a3EQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id zo8si8081322ejb.156.2020.06.07.18.04.13; Sun, 07 Jun 2020 18:04:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728928AbgFHA6c (ORCPT + 99 others); Sun, 7 Jun 2020 20:58:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728165AbgFHA61 (ORCPT ); Sun, 7 Jun 2020 20:58:27 -0400 Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3E5AC08C5C4; Sun, 7 Jun 2020 17:58:26 -0700 (PDT) Received: from [5.158.153.53] (helo=debian-buster-darwi.lab.linutronix.de.) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1ji67D-0000rM-03; Mon, 08 Jun 2020 02:58:15 +0200 From: "Ahmed S. Darwish" To: Peter Zijlstra , Ingo Molnar , Will Deacon Cc: Thomas Gleixner , "Paul E. McKenney" , "Sebastian A. Siewior" , Steven Rostedt , LKML , "Ahmed S. Darwish" , Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , "David S. Miller" , Jakub Kicinski , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org Subject: [PATCH v2 09/18] netfilter: nft_set_rbtree: Use sequence counter with associated rwlock Date: Mon, 8 Jun 2020 02:57:20 +0200 Message-Id: <20200608005729.1874024-10-a.darwish@linutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200608005729.1874024-1-a.darwish@linutronix.de> References: <20200519214547.352050-1-a.darwish@linutronix.de> <20200608005729.1874024-1-a.darwish@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A sequence counter write side critical section must be protected by some form of locking to serialize writers. A plain seqcount_t does not contain the information of which lock must be held when entering a write side critical section. Use the new seqcount_rwlock_t data type, which allows to associate a rwlock with the sequence counter. This enables lockdep to verify that the rwlock used for writer serialization is held when the write side critical section is entered. If lockdep is disabled this lock association is compiled out and has neither storage size nor runtime overhead. Signed-off-by: Ahmed S. Darwish --- net/netfilter/nft_set_rbtree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/netfilter/nft_set_rbtree.c b/net/netfilter/nft_set_rbtree.c index 62f416bc0579..9f58261ee4c7 100644 --- a/net/netfilter/nft_set_rbtree.c +++ b/net/netfilter/nft_set_rbtree.c @@ -18,7 +18,7 @@ struct nft_rbtree { struct rb_root root; rwlock_t lock; - seqcount_t count; + seqcount_rwlock_t count; struct delayed_work gc_work; }; @@ -516,7 +516,7 @@ static int nft_rbtree_init(const struct nft_set *set, struct nft_rbtree *priv = nft_set_priv(set); rwlock_init(&priv->lock); - seqcount_init(&priv->count); + seqcount_rwlock_init(&priv->count, &priv->lock); priv->root = RB_ROOT; INIT_DEFERRABLE_WORK(&priv->gc_work, nft_rbtree_gc); -- 2.20.1