Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp260659imm; Tue, 22 May 2018 18:20:58 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrO3QwC4Aor4JZhnFyDwNHuDX19ZG3tTo8naWs3LdRuv4wW+vw7K7kI+s/f/Dn/mKaU70jB X-Received: by 2002:a17:902:70c4:: with SMTP id l4-v6mr810295plt.174.1527038458924; Tue, 22 May 2018 18:20:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527038458; cv=none; d=google.com; s=arc-20160816; b=rYaTsdbs1PrCgl1p8r6ll1PqjqteEOyZk2mtatbkATVZb+miZWZ+OcOgThTrXjUXG1 dNwcM3CVUpsnRtdQCsVXlN4jWEdVGczAisDaI3M8HmhYGNOv0BAYsf9dmif/28fM9vep lu3KmktX4NE0ePS2me/q/kIh9XEoO1ZkqhZECV+dkwcdAI3zXYqtT8T1PV3dQxKXLfo7 V9c2wGOJoMAAH1PvOlRWCDTS/Rx3qHQBAP1yweB+4WgQCpp2RKV8yt1RU82dGoYrI8S2 rWYVIghgH4psUl7B9tq5kZKOFqfLXJ1w0Kx8Vq9Aiq/CX/6W/7WjqrB8P/VU7eetDp+F SxDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=UaCf/IOnCDhTGRoAMSw1i3LiFrYD3u7d/3bKu7DVZTQ=; b=DGxaXlkN9e3MiBPhad5pMz+ziWj/3UqRZtv/JWFGMMoxJSi5e516p8NlbWpfjIWBCi U1jOMBhlDhO9656t7oRPwf3U+LP+eo5L7rpP/TjcdKLcCWzia3HcKk+7MmR2Lxumm7S2 oL90KW88lIhZIdc3UVpBWdub/bMtqg28BzU7vsmc5u6vRFnzhs9EfCqYw9cn34AqPpIP 64gmg3f9WEg0EwfiytNZ/F0o+h0COT+J4zVASa6t8ywmjJD02Pq7eAGhf+XidsoanJax dCJ410DvCvIFJqY9V2f5AUO67UAj+LiADooMgKUWwNJmwJwwASHP5625ChXyhog5eRih xmLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WfI0Cq2N; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k7-v6si451438pgp.448.2018.05.22.18.20.44; Tue, 22 May 2018 18:20:58 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=WfI0Cq2N; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753859AbeEWBUJ (ORCPT + 99 others); Tue, 22 May 2018 21:20:09 -0400 Received: from mail-qk0-f193.google.com ([209.85.220.193]:38363 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753655AbeEWBSt (ORCPT ); Tue, 22 May 2018 21:18:49 -0400 Received: by mail-qk0-f193.google.com with SMTP id c23-v6so1186095qkb.5; Tue, 22 May 2018 18:18:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UaCf/IOnCDhTGRoAMSw1i3LiFrYD3u7d/3bKu7DVZTQ=; b=WfI0Cq2NZvH9FFSI9SgTq/6vG2ommch65tBug0OEd/bKpSAwGFiG10waxrCsIaJ/Ko xDztRyJ4MsBqpSqRnfZdmz1oJpleNDP/LGIG/4T3Q3hUKr6bMG9E6Vgv4OJhk5He37BK aa1gR7qA8gHpvolcnq6lYrfXlyUe4HN9Gq6s1m0IOVMvL+kuYLPFODYBhM3tNTbyNEHu 5i6yGCRq7goaGAm9EK3ETWYjihwSUBNVbUZ9ldiTaqmWOsaHWgsgtRG7jdLlu1deNu13 uYESu0LABr2Pytg145n9sDwtHWFSiueN4nmgR2tUppMH01IYv9cBlA8kQDZMHo5cP9Jn VkJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UaCf/IOnCDhTGRoAMSw1i3LiFrYD3u7d/3bKu7DVZTQ=; b=FJ3kEfrFSARVCDeXJ5AJiVw9rXPXLk5g1Nlxc6xanWYU0xwB1dOPiqrUeheBrs/Ra1 ln6hwde12HzIRr5WgUnZZRTf7KpSs60Cj3HzIaQ06ZGX46M7tGI5yyhXsCZztT8gmNkl jcrp6k/IHCLKtMcmmA18jx4t75bz6UIj/caY5AljPaU5UF560l4eWs/YTmCJ54Lzl9FL zKE7pIe9wEkfaomBdzE4eoCx9jRo3jwt9x/2BkZfXwGAKc6cpM8fxjEK/I0v0STHx8E/ oab8RF7Wl8dbQDrR/r/LVsJKEvkvXIauUOSFKcPBMLsPo4ZY/N5JwBYDcD3cFGcIUzND JwKw== X-Gm-Message-State: ALKqPwf2dQA87EgLNChiNJ7+KGK4idYQFXQEloIZUF7LUyzlNz/w5pOd Vmuh95z0FpmJBK53vGY27RB4mQUXAg== X-Received: by 2002:a37:1214:: with SMTP id c20-v6mr101804qkh.248.1527038327707; Tue, 22 May 2018 18:18:47 -0700 (PDT) Received: from localhost.localdomain (c-71-234-172-214.hsd1.vt.comcast.net. [71.234.172.214]) by smtp.gmail.com with ESMTPSA id s127-v6sm12604251qkf.21.2018.05.22.18.18.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 18:18:46 -0700 (PDT) From: Kent Overstreet To: linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk, akpm@linux-foundation.org, willy@infradead.org, gregkh@linuxfoundation.org, linux-security-module@vger.kernel.org, selinux@tycho.nsa.gov, dev@openvswitch.org, shli@kernel.org, linux-raid@vger.kernel.org Cc: Kent Overstreet Subject: [PATCH 4/6] openvswitch: convert to genradix Date: Tue, 22 May 2018 21:18:19 -0400 Message-Id: <20180523011821.12165-4-kent.overstreet@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180523011821.12165-1-kent.overstreet@gmail.com> References: <20180523011821.12165-1-kent.overstreet@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org the new generic radix trees have a simpler API and implementation, and no limitations on number of elements, so all flex_array users are being converted Signed-off-by: Kent Overstreet --- net/openvswitch/flow.h | 1 - net/openvswitch/flow_netlink.h | 1 - net/openvswitch/flow_table.c | 45 ++++++++++------------------------ net/openvswitch/flow_table.h | 4 +-- 4 files changed, 15 insertions(+), 36 deletions(-) diff --git a/net/openvswitch/flow.h b/net/openvswitch/flow.h index c670dd24b8..4f06278166 100644 --- a/net/openvswitch/flow.h +++ b/net/openvswitch/flow.h @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include diff --git a/net/openvswitch/flow_netlink.h b/net/openvswitch/flow_netlink.h index 6657606b2b..66f9553758 100644 --- a/net/openvswitch/flow_netlink.h +++ b/net/openvswitch/flow_netlink.h @@ -30,7 +30,6 @@ #include #include #include -#include #include #include diff --git a/net/openvswitch/flow_table.c b/net/openvswitch/flow_table.c index 80ea2a7185..284f44d832 100644 --- a/net/openvswitch/flow_table.c +++ b/net/openvswitch/flow_table.c @@ -111,27 +111,19 @@ int ovs_flow_tbl_count(const struct flow_table *table) return table->count; } -static struct flex_array *alloc_buckets(unsigned int n_buckets) +static int alloc_buckets(struct table_instance *ti, unsigned int n_buckets) { - struct flex_array *buckets; - int i, err; + int i; - buckets = flex_array_alloc(sizeof(struct hlist_head), - n_buckets, GFP_KERNEL); - if (!buckets) - return NULL; + genradix_init(&ti->buckets); - err = flex_array_prealloc(buckets, 0, n_buckets, GFP_KERNEL); - if (err) { - flex_array_free(buckets); - return NULL; - } + if (genradix_prealloc(&ti->buckets, n_buckets, GFP_KERNEL)) + return -ENOMEM; for (i = 0; i < n_buckets; i++) - INIT_HLIST_HEAD((struct hlist_head *) - flex_array_get(buckets, i)); + INIT_HLIST_HEAD(genradix_ptr(&ti->buckets, i)); - return buckets; + return 0; } static void flow_free(struct sw_flow *flow) @@ -168,15 +160,9 @@ void ovs_flow_free(struct sw_flow *flow, bool deferred) flow_free(flow); } -static void free_buckets(struct flex_array *buckets) -{ - flex_array_free(buckets); -} - - static void __table_instance_destroy(struct table_instance *ti) { - free_buckets(ti->buckets); + genradix_free(&ti->buckets); kfree(ti); } @@ -187,9 +173,7 @@ static struct table_instance *table_instance_alloc(int new_size) if (!ti) return NULL; - ti->buckets = alloc_buckets(new_size); - - if (!ti->buckets) { + if (alloc_buckets(ti, new_size)) { kfree(ti); return NULL; } @@ -249,7 +233,7 @@ static void table_instance_destroy(struct table_instance *ti, for (i = 0; i < ti->n_buckets; i++) { struct sw_flow *flow; - struct hlist_head *head = flex_array_get(ti->buckets, i); + struct hlist_head *head = genradix_ptr(&ti->buckets, i); struct hlist_node *n; int ver = ti->node_ver; int ufid_ver = ufid_ti->node_ver; @@ -294,7 +278,7 @@ struct sw_flow *ovs_flow_tbl_dump_next(struct table_instance *ti, ver = ti->node_ver; while (*bucket < ti->n_buckets) { i = 0; - head = flex_array_get(ti->buckets, *bucket); + head = genradix_ptr(&ti->buckets, *bucket); hlist_for_each_entry_rcu(flow, head, flow_table.node[ver]) { if (i < *last) { i++; @@ -313,8 +297,7 @@ struct sw_flow *ovs_flow_tbl_dump_next(struct table_instance *ti, static struct hlist_head *find_bucket(struct table_instance *ti, u32 hash) { hash = jhash_1word(hash, ti->hash_seed); - return flex_array_get(ti->buckets, - (hash & (ti->n_buckets - 1))); + return genradix_ptr(&ti->buckets, hash & (ti->n_buckets - 1)); } static void table_instance_insert(struct table_instance *ti, @@ -347,9 +330,7 @@ static void flow_table_copy_flows(struct table_instance *old, /* Insert in new table. */ for (i = 0; i < old->n_buckets; i++) { struct sw_flow *flow; - struct hlist_head *head; - - head = flex_array_get(old->buckets, i); + struct hlist_head *head = genradix_ptr(&old->buckets, i); if (ufid) hlist_for_each_entry(flow, head, diff --git a/net/openvswitch/flow_table.h b/net/openvswitch/flow_table.h index 2dd9900f53..57fe93570a 100644 --- a/net/openvswitch/flow_table.h +++ b/net/openvswitch/flow_table.h @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include @@ -37,7 +37,7 @@ #include "flow.h" struct table_instance { - struct flex_array *buckets; + GENRADIX(struct hlist_head) buckets; unsigned int n_buckets; struct rcu_head rcu; int node_ver; -- 2.17.0