Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3314593ybt; Mon, 29 Jun 2020 22:47:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqRmcflWGMdGN7XDdG13d7sSxm2RJ0ya/dbmrRIQYjd/Z/1dtiydqL03TbXqwkr8tzXjVd X-Received: by 2002:a17:906:3945:: with SMTP id g5mr17945382eje.549.1593496025410; Mon, 29 Jun 2020 22:47:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593496025; cv=none; d=google.com; s=arc-20160816; b=BP0SLYB0qaoImyPNrsDLtPEJ/SOBe/2V1Q4bdPtIkrk6lCgcFOTvi85ykQAd7l20pw RnNeqTiz6P1VBn2zqAtYXEfwc0KjSarrxaR4BittWwT4hwpYXrKr4fR0S6HB3CKaTBtv sGegGfbctX1oam91cIfTgJAbYgkIdfr4OnlxD+tbVUAxnQ/9gHohVwnT9/itTHJceYnL buuAqsI3WuFCiKZbR+zp+CZBJooGWMn40+XxMnfU6aBQlAwHrjEeavMiykmdmYSMdd0J KwrkqUgTs16QvU9WCTdhRaogwcdpp4JOBgd7EydK/viwHHm3O+7BPQR94+jpGw8nTXw+ uUKA== 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:dkim-signature :dkim-signature:from; bh=L61pJxSRU8yRIzK3/wT0+4/FnQuZFh6diO59e1nBA5s=; b=lJEZYjjtJcNKZom7tkY0VC8H54rjDf4ryyhvHSSiSJsWiyvNMoBiRJ3dkQazFaBm8s OWmhetXF+MTtrwqZfSD3YNH3XJfAR2K//3+ieTUN9OICAREIwuwJhka5LWb74JTsigLx qtNNqeEZL4Ywc2Bv3eK53OXZ+o2T4AK3ASm40CcNNh7jnUVIvR4d8wGr6iTV5isnohr+ /LGG8UoR6mdhBEFlT0GRYiphNFjlRDsMBvUTbIUP/zpuLak5TNhCr/UHHkZmIDefJOL4 machATiSyWg637+FZQg4YleLNH/KUXrS5feUCXcAHpktSt1iVuXQe1aUSbPdHSxT1mY/ 5HXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=LDZL++k3; dkim=neutral (no key) header.i=@linutronix.de header.b=NDVk0Wmv; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds2si1600508ejc.114.2020.06.29.22.46.42; Mon, 29 Jun 2020 22:47:05 -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; dkim=pass header.i=@linutronix.de header.s=2020 header.b=LDZL++k3; dkim=neutral (no key) header.i=@linutronix.de header.b=NDVk0Wmv; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729916AbgF3Fpz (ORCPT + 99 others); Tue, 30 Jun 2020 01:45:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728854AbgF3Fpy (ORCPT ); Tue, 30 Jun 2020 01:45:54 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D05BBC061755; Mon, 29 Jun 2020 22:45:54 -0700 (PDT) From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1593495951; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L61pJxSRU8yRIzK3/wT0+4/FnQuZFh6diO59e1nBA5s=; b=LDZL++k3mOdrAF/jnnRatPo7GE9cI70dYZEFt7L6l4Ji722izYdkGbzQtspXxEN03yzLmU DTiW6tr/S0yD/I4PAJCP7SRvmwoBxi491buWfD+PioCAW1wt1TDhCXiDm5bMP/R7JIw3uI 0BGV5ZNzDL7XxgCvgKzWBQx8XXptBZF22TpJEz3RDfdOUzSRRzCsRRU73QvD59ZuGNZerS rwz2IiCQAKHRIvKpogdSo/ipOUWD4KUeY0FEGclfrXtDaYOvjqeHWHLb7TaAFiY7hsQ25g ZtutgPIKxHuc/r+vIITUcd9OfAz/UPPv1z3rn9NcRzL15fNFPH+UYUYq4bMEUw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1593495951; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L61pJxSRU8yRIzK3/wT0+4/FnQuZFh6diO59e1nBA5s=; b=NDVk0WmvCuwmFWcSHotlDQy5Ka6dQn/tGUwE1nRJ/z7agWpbBW0MViNDPMbPeGheqNAetz tybLDJ8koYa4F6CQ== 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 v3 11/20] netfilter: nft_set_rbtree: Use sequence counter with associated rwlock Date: Tue, 30 Jun 2020 07:44:43 +0200 Message-Id: <20200630054452.3675847-12-a.darwish@linutronix.de> In-Reply-To: <20200630054452.3675847-1-a.darwish@linutronix.de> References: <20200519214547.352050-1-a.darwish@linutronix.de> <20200630054452.3675847-1-a.darwish@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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