Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6262375imu; Mon, 21 Jan 2019 06:03:16 -0800 (PST) X-Google-Smtp-Source: ALg8bN5LfWlnCopyFBciO7Af5Bn3RycvHR1zorvJcgWRLDKNn6+VqvOnb9RxJ4o+ogKhPH9X4CH5 X-Received: by 2002:a17:902:7791:: with SMTP id o17mr29978250pll.60.1548079396337; Mon, 21 Jan 2019 06:03:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548079396; cv=none; d=google.com; s=arc-20160816; b=icZTikzKXl60Yl4XWDW3bzmzhmjDHxpWhBFQIgOUGbsHL6J/zL6lM1WcQ0ZdLlNUAd Clyk1TMTkz+MSq3yYFT9uqrvMDfxJGcOlieUOLCNj4gH4zYUVlrOZ22+2vQUIYUkCokC btwEgl2LQPSOXVbROjA6RlDzPp4zfyZ5TSqodS53UqYaGi1TBFEpRXB9qPBkjY7HnwBo aV0ACiT+Z/pOZCCBwi1zditxgv01kWQVQ7glJsrtcMDtmZSw6mFxzDPLKoCtHf99+AA+ gXFFaqNZ7fNu+YUF80iiQK2DMj/0BJwV+/jM63mJTTH7BgtOxWe/6JBTQADSpXdkXDon 6Aug== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tbCeIFvQMygj+7VehJvlwGlUxfpoNy58vrlJnN9AUpg=; b=J8eEYECYM5xOdVgI+AjepYqzsJUn9WdNrrFOgtO74YatEmFoFY9Squn6qEwkSYFoyR X8gFrhunU/W3dBrs/0iWLTU8ICdGXgbRJmQjAoHbC1kCRCk9Ro9pv+RZ9n6cIGE+ip2f NoxfjQ3w8uv/AXUZd34kxUvnBZAH7gNseqmBIGdukxHEZx3SDuld0P+ft0TIGx7I9531 GP6mFhJNqHF05Adlx2vK/oInyNxjJjJZQWQOsqqwbZKJbjv2rbjJppgxYpjR1xn63mts 6PSoPIxG4gYh4pm2fH8tw3+RaZfegzRJJ0HVsImgHsOLOvVaFOtpbV1VK7kzfBD7yds/ YtWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vRF+ZcoW; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u184si13194045pgd.262.2019.01.21.06.02.54; Mon, 21 Jan 2019 06:03:16 -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=vRF+ZcoW; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731288AbfAUN77 (ORCPT + 99 others); Mon, 21 Jan 2019 08:59:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:46150 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732276AbfAUN7y (ORCPT ); Mon, 21 Jan 2019 08:59:54 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 DC09520879; Mon, 21 Jan 2019 13:59:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548079193; bh=njLAZT81n5lObx+g/QKTaX8FWFSaEbSIauG/5mFcyu0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vRF+ZcoWL5YLvkGYoflRYBiNxMI/QfJYu9ti3XLwr4pA0sCw8Z06BmVWs/j51QQKP sxzKiF2yvYzcdbO++wmkqmGOFvB/0kfu2+I5jBTyfkavt9dFEDgbwYhW6aNzXQXZ8o uHTKbFeGp2Z+gZHJIantvH7YwFGVLllNPuWxJ62k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Florian Westphal , Shawn Bohrer , Pablo Neira Ayuso Subject: [PATCH 4.19 06/99] netfilter: nf_conncount: replace CONNCOUNT_LOCK_SLOTS with CONNCOUNT_SLOTS Date: Mon, 21 Jan 2019 14:47:58 +0100 Message-Id: <20190121134914.168149053@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121134913.924726465@linuxfoundation.org> References: <20190121134913.924726465@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shawn Bohrer commit c78e7818f16f687389174c4569243abbec8dc68f upstream. Most of the time these were the same value anyway, but when CONFIG_LOCKDEP was enabled we would use a smaller number of locks to reduce overhead. Unfortunately having two values is confusing and not worth the complexity. This fixes a bug where tree_gc_worker() would only GC up to CONNCOUNT_LOCK_SLOTS trees which meant when CONFIG_LOCKDEP was enabled not all trees would be GCed by tree_gc_worker(). Fixes: 5c789e131cbb9 ("netfilter: nf_conncount: Add list lock and gc worker, and RCU for init tree search") Signed-off-by: Florian Westphal Signed-off-by: Shawn Bohrer Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman --- net/netfilter/nf_conncount.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) --- a/net/netfilter/nf_conncount.c +++ b/net/netfilter/nf_conncount.c @@ -33,12 +33,6 @@ #define CONNCOUNT_SLOTS 256U -#ifdef CONFIG_LOCKDEP -#define CONNCOUNT_LOCK_SLOTS 8U -#else -#define CONNCOUNT_LOCK_SLOTS 256U -#endif - #define CONNCOUNT_GC_MAX_NODES 8 #define MAX_KEYLEN 5 @@ -60,7 +54,7 @@ struct nf_conncount_rb { struct rcu_head rcu_head; }; -static spinlock_t nf_conncount_locks[CONNCOUNT_LOCK_SLOTS] __cacheline_aligned_in_smp; +static spinlock_t nf_conncount_locks[CONNCOUNT_SLOTS] __cacheline_aligned_in_smp; struct nf_conncount_data { unsigned int keylen; @@ -353,7 +347,7 @@ insert_tree(struct net *net, unsigned int count = 0, gc_count = 0; bool node_found = false; - spin_lock_bh(&nf_conncount_locks[hash % CONNCOUNT_LOCK_SLOTS]); + spin_lock_bh(&nf_conncount_locks[hash]); parent = NULL; rbnode = &(root->rb_node); @@ -430,7 +424,7 @@ insert_tree(struct net *net, rb_link_node_rcu(&rbconn->node, parent, rbnode); rb_insert_color(&rbconn->node, root); out_unlock: - spin_unlock_bh(&nf_conncount_locks[hash % CONNCOUNT_LOCK_SLOTS]); + spin_unlock_bh(&nf_conncount_locks[hash]); return count; } @@ -499,7 +493,7 @@ static void tree_gc_worker(struct work_s struct rb_node *node; unsigned int tree, next_tree, gc_count = 0; - tree = data->gc_tree % CONNCOUNT_LOCK_SLOTS; + tree = data->gc_tree % CONNCOUNT_SLOTS; root = &data->root[tree]; rcu_read_lock(); @@ -621,10 +615,7 @@ static int __init nf_conncount_modinit(v { int i; - BUILD_BUG_ON(CONNCOUNT_LOCK_SLOTS > CONNCOUNT_SLOTS); - BUILD_BUG_ON((CONNCOUNT_SLOTS % CONNCOUNT_LOCK_SLOTS) != 0); - - for (i = 0; i < CONNCOUNT_LOCK_SLOTS; ++i) + for (i = 0; i < CONNCOUNT_SLOTS; ++i) spin_lock_init(&nf_conncount_locks[i]); conncount_conn_cachep = kmem_cache_create("nf_conncount_tuple",