Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp29858ybh; Mon, 20 Jul 2020 09:34:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQI4dIwyL7VgcZNLU1OO9BBTF/xVmzNfisp6+TxnEsN1KhPEPwjMiCMF0tdsrzR4d70vwM X-Received: by 2002:a17:906:488:: with SMTP id f8mr20746213eja.215.1595262845838; Mon, 20 Jul 2020 09:34:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595262845; cv=none; d=google.com; s=arc-20160816; b=weROoFSJaahokNyWDWHTQwYC2x5R8Mo7pjTDPrXLErwyBQDfkkHB/z6FPjABGnV/oS SEqmnZl7JCYvxnm6dGlyxQsJ7AR/r+ipuCVqQMHkkLaDz6BThn8D3y33cMUO8eJbLIuu b03l60DBqEtTvQP+0q7Xd4EgQhcfzlE2qFR7Ju2qexjVzJZiDong5UojhFXXHxIMUver Ns9bf3g73xSoC9CnrDZwp5D1HCiL/AEEqUSafuJc3hpL4cseJygZT0/7tDDAxQdKRCRn 6nZi3g1K+cOZ2cBk5kFuo6k7ZuJX/lrMYFxtmkk+TEBCDTRg+2H1ZbcbbKuzyt4Vob5I H9Lw== 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=4/ywCu1ddv/vjOuhHxWVQ4Une/Z767iKPljoFb/YuCo=; b=uBm+T9RiGCj5VgpNfJWrZ1itfnRfMTiiO7iUX7Burje9sX/OgAd1MwjE0AejyaCgG4 JNHpTp9dXQLcRDuc98C8+R5DQapLLu3rhM63XU0ODtWOeRw4i49Tlqb6XyV+UyH0Fn89 kNnUSYYbRTixYLV1CW+NcKnpRy88bn9z6+rEYzehSt2AYsEiUWP76YG3YkC+AKpH0NOu P7DicoNxZS+vAwhntqIY7uyhxuTvUtbORZ7YgXILeEbRHI8PcUHPdz1DfY3UNEFpo83s LVEj0KPi8YqgcasNYwrxHQCgfyfPkGkrl80LBrE9NmqstmaSha8bX/2K8qjbzvPhUKKN HMnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=1BzcJb5U; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=TZmK83GN; 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 c12si11074582edv.217.2020.07.20.09.33.38; Mon, 20 Jul 2020 09:34: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=1BzcJb5U; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=TZmK83GN; 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 S2388867AbgGTQcO (ORCPT + 99 others); Mon, 20 Jul 2020 12:32:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731569AbgGTP4p (ORCPT ); Mon, 20 Jul 2020 11:56:45 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D7F9C061794; Mon, 20 Jul 2020 08:56:45 -0700 (PDT) From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1595260604; 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=4/ywCu1ddv/vjOuhHxWVQ4Une/Z767iKPljoFb/YuCo=; b=1BzcJb5UXd9c4r6mNPmIM30L+gZYQxNQR0/b8PAyf1hjroGleHqyfcIg/GcGhtqzO3JuRw iC6/myoxUzA7UUKI3oSXwesluhzC+hRLlB69BBrpMbPLlVhuY25AzQe1BT9YbsYyulIsgk TMhI215XiZdwxT111e/mfm68LHqWS5XDSd1leoJLXm/PhzZpPn65TrInWZDEfF+VOydiGi +KCmnea6qh1WEL/amO/GMRqBxcZeOqBX73KvYil15o1L0x2KPpLgVDYBOmXZV1YBBzf6tC QblCTyNdPThEpNzzNwgB0SZV6QPPaqh37vMS2eikcEAOz+IIHn3Myu+7+3Uwew== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1595260604; 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=4/ywCu1ddv/vjOuhHxWVQ4Une/Z767iKPljoFb/YuCo=; b=TZmK83GNtq3Vst9FIUeDTWJH2SozMZJcueFXszjMIJRTjrivYQVEcdDuytGUGcwEWTzQqT LXEKHCzqIguBjgBg== 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 v4 15/24] netfilter: nft_set_rbtree: Use sequence counter with associated rwlock Date: Mon, 20 Jul 2020 17:55:21 +0200 Message-Id: <20200720155530.1173732-16-a.darwish@linutronix.de> In-Reply-To: <20200720155530.1173732-1-a.darwish@linutronix.de> References: <20200519214547.352050-1-a.darwish@linutronix.de> <20200720155530.1173732-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 b6aad3fc46c3..4b2834fd17b2 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; }; @@ -523,7 +523,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