rhashtable: accept GFP flags in rhashtable_walk_init
Subsystems (7)
PATCH 1/2 rhashtable: accept GFP flags in rhashtable_walk_init
In certain cases, the 802.11 mesh pathtable code wants to iterate over all of the entries in the forwarding table from the receive path, which is inside an RCU read-side critical section. Enable walks inside atomic sections by allowing GFP_ATOMIC allocations for the walker state.
Change all existing callsites to pass in GFP_KERNEL.
---
(-RFC, +Thomas's Ack)
include/linux/rhashtable.h | 3 ++- lib/rhashtable.c | 6 ++++-- net/ipv6/ila/ila_xlat.c | 3 ++- net/netfilter/nft_hash.c | 4 ++-- net/netlink/af_netlink.c | 3 ++- net/sctp/proc.c | 3 ++- 6 files changed, 14 insertions(+), 8 deletions(-)
include/linux/rhashtable.h +2 -1
@@ -346,7 +346,8 @@ struct bucket_table *rhashtable_insert_slow(struct rhashtable *ht, struct bucket_table *old_tbl);int rhashtable_insert_rehash (struct rhashtable *ht,struct bucket_table *tbl); -int rhashtable_walk_init (struct rhashtable *ht,struct rhashtable_iter *iter); +int rhashtable_walk_init (struct rhashtable *ht,struct rhashtable_iter *iter, +gfp_t gfp);void rhashtable_walk_exit (struct rhashtable_iter *iter); int rhashtable_walk_start(struct rhashtable_iter *iter) __acquires(RCU);void *rhashtable_walk_next (struct rhashtable_iter *iter);
lib/rhashtable.c +4 -2
@@ -487,6 +487,7 @@ EXPORT_SYMBOL_GPL(rhashtable_insert_slow);* rhashtable_walk_init - Initialise an iterator * @ht: Table to walk over * @iter: Hash table Iterator +* @gfp: GFP flags for allocations * * This function prepares a hash table walk. *
@@ -504,14 +505,15 @@ EXPORT_SYMBOL_GPL(rhashtable_insert_slow);* You must call rhashtable_walk_exit if this function returns * successfully. */ -int rhashtable_walk_init (struct rhashtable *ht,struct rhashtable_iter *iter) +int rhashtable_walk_init (struct rhashtable *ht,struct rhashtable_iter *iter, +gfp_t gfp) { iter->ht = ht; iter->p =NULL ; iter->slot =0 ; iter->skip =0 ; - iter->walker =kmalloc (sizeof (*iter->walker),GFP_KERNEL ); + iter->walker =kmalloc (sizeof (*iter->walker), gfp);if (!iter->walker)return -ENOMEM ;
net/ipv6/ila/ila_xlat.c +2 -1
@@ -501,7 +501,8 @@ static int ila_nl_dump_start(struct netlink_callback *cb)struct ila_net *ilan =net_generic (net, ila_net_id);struct ila_dump_iter *iter = (struct ila_dump_iter *)cb->args; -return rhashtable_walk_init (&ilan->rhash_table, &iter->rhiter); +return rhashtable_walk_init (&ilan->rhash_table, &iter->rhiter, +GFP_KERNEL ); }static int ila_nl_dump_done (struct netlink_callback *cb)
net/netfilter/nft_hash.c +2 -2
@@ -192,7 +192,7 @@ static void nft_hash_walk(const struct nft_ctx *ctx, const struct nft_set *set,u8 genmask =nft_genmask_cur (read_pnet (&set->pnet));int err; - err =rhashtable_walk_init (&priv->ht, &hti); + err =rhashtable_walk_init (&priv->ht, &hti,GFP_KERNEL ); iter->err = err;if (err)return ;
@@ -248,7 +248,7 @@ static void nft_hash_gc(struct work_struct *work) priv = container_of(work, struct nft_hash, gc_work.work); set =nft_set_container_of (priv); - err =rhashtable_walk_init (&priv->ht, &hti); + err =rhashtable_walk_init (&priv->ht, &hti,GFP_KERNEL );if (err) goto schedule;
net/netlink/af_netlink.c +2 -1
@@ -2335,7 +2335,8 @@ static int netlink_walk_start(struct nl_seq_iter *iter) {int err; - err =rhashtable_walk_init (&nl_table[iter->link].hash, &iter->hti); + err =rhashtable_walk_init (&nl_table[iter->link].hash, &iter->hti, +GFP_KERNEL );if (err) { iter->link =MAX_LINKS ;return err;
net/sctp/proc.c +2 -1
@@ -319,7 +319,8 @@ static int sctp_transport_walk_start(struct seq_file *seq)struct sctp_ht_iter *iter = seq->private;int err; - err =rhashtable_walk_init (&sctp_transport_hashtable, &iter->hti); + err =rhashtable_walk_init (&sctp_transport_hashtable, &iter->hti, +GFP_KERNEL );if (err)return err;
Signature · 6 lines
2.6.1 -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/2 mac80211: mesh: convert path table to rhashtable
In the time since the mesh path table was implemented as an RCU-traversable, dynamically growing hash table, a generic RCU hashtable implementation was added to the kernel.
Switch the mesh path table over to rhashtable to remove some code and also gain some features like automatic shrinking.
--- net/mac80211/ieee80211_i.h | 11 +- net/mac80211/mesh.c | 6 - net/mac80211/mesh.h | 31 +- net/mac80211/mesh_pathtbl.c | 786 ++++++++++++++------------------------------ 4 files changed, 259 insertions(+), 575 deletions(-)
net/mac80211/ieee80211_i.h +2 -9
@@ -697,17 +697,10 @@ struct ieee80211_if_mesh {/* offset from skb->data while building IE */ int meshconf_offset; -struct mesh_table __rcu *mesh_paths; -struct mesh_table __rcu *mpp_paths;/* Store paths for MPP&MAP */ +struct mesh_table *mesh_paths; +struct mesh_table *mpp_paths;/* Store paths for MPP&MAP */ int mesh_paths_generation;int mpp_paths_generation; - -/* Protects assignment of the mesh_paths/mpp_paths table -* pointer for resize against reading it for add/delete -* of individual paths. Pure readers (lookups) just use -* RCU. -*/ -rwlock_t pathtbl_resize_lock; };#ifdef CONFIG_MAC80211_MESH
net/mac80211/mesh.c +0 -6
@@ -1347,12 +1347,6 @@ void ieee80211_mesh_work(struct ieee80211_sub_if_data *sdata) ifmsh->last_preq + msecs_to_jiffies(ifmsh->mshcfg.dot11MeshHWMPpreqMinInterval)))mesh_path_start_discovery (sdata); -if (test_and_clear_bit (MESH_WORK_GROW_MPATH_TABLE , &ifmsh->wrkq_flags)) -mesh_mpath_table_grow (sdata); - -if (test_and_clear_bit (MESH_WORK_GROW_MPP_TABLE , &ifmsh->wrkq_flags)) -mesh_mpp_table_grow (sdata); -if (test_and_clear_bit (MESH_WORK_HOUSEKEEPING , &ifmsh->wrkq_flags))ieee80211_mesh_housekeeping (sdata);
net/mac80211/mesh.h +3 -28
@@ -51,10 +51,6 @@ enum mesh_path_flags {* * * @MESH_WORK_HOUSEKEEPING: run the periodic mesh housekeeping tasks -* @MESH_WORK_GROW_MPATH_TABLE: the mesh path table is full and needs -* to grow. -* @MESH_WORK_GROW_MPP_TABLE: the mesh portals table is full and needs to -* grow * @MESH_WORK_ROOT: the mesh root station needs to send a frame * @MESH_WORK_DRIFT_ADJUST: time to compensate for clock drift relative to other * mesh nodes
@@ -62,8 +58,6 @@ enum mesh_path_flags {*/ enum mesh_deferred_task_flags {MESH_WORK_HOUSEKEEPING , -MESH_WORK_GROW_MPATH_TABLE , -MESH_WORK_GROW_MPP_TABLE ,MESH_WORK_ROOT ,MESH_WORK_DRIFT_ADJUST ,MESH_WORK_MBSS_CHANGED ,
@@ -105,6 +99,7 @@ enum mesh_deferred_task_flags {struct mesh_path {u8 dst[ETH_ALEN ];u8 mpp[ETH_ALEN ];/* used for MPP or MAP */ +struct rhash_head rhash;struct hlist_node gate_list;struct ieee80211_sub_if_data *sdata;struct sta_info __rcu *next_hop;
@@ -129,34 +124,17 @@ struct mesh_path {/** * struct mesh_table * -* @hash_buckets: array of hash buckets of the table -* @hashwlock: array of locks to protect write operations, one per bucket -* @hash_mask: 2^size_order - 1, used to compute hash idx -* @hash_rnd: random value used for hash computations * @entries: number of entries in the table -* @free_node: function to free nodes of the table -* @copy_node: function to copy nodes of the table -* @size_order: determines size of the table, there will be 2^size_order hash -* buckets * @known_gates: list of known mesh gates and their mpaths by the station. The * gate's mpath may or may not be resolved and active. -* -* rcu_head: RCU head to free the table +* @rhash: the rhashtable containing struct mesh_paths, keyed by dest addr */ struct mesh_table { -/* Number of buckets will be 2^N */ -struct hlist_head *hash_buckets; -spinlock_t *hashwlock;/* One per bucket, for add/del */ -unsigned int hash_mask;/* (2^size_order) - 1 */ -__u32 hash_rnd;/* Used for hash generation */ atomic_t entries;/* Up to MAX_MESH_NEIGHBOURS */ -void (*free_node) (struct hlist_node *p,bool free_leafs); -int (*copy_node) (struct hlist_node *p,struct mesh_table *newtbl); -int size_order;struct hlist_head *known_gates;spinlock_t gates_lock; -struct rcu_head rcu_head; +struct rhashtable rhead; };/* Recent multicast cache */
@@ -300,9 +278,6 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata,void mesh_sta_cleanup (struct sta_info *sta);/* Private interfaces */ -/* Mesh tables */ -void mesh_mpath_table_grow (struct ieee80211_sub_if_data *sdata); -void mesh_mpp_table_grow (struct ieee80211_sub_if_data *sdata);/* Mesh paths */ int mesh_path_error_tx(struct ieee80211_sub_if_data *sdata, u8 ttl, const u8 *target, u32 target_sn,
net/mac80211/mesh_pathtbl.c +254 -532
1,035 lines not on this page · raw message
Signature · 1 line
2.6.1
David Miller
maintainerRe: [PATCH 2/2] mac80211: mesh: convert path table to rhashtable
From: Bob Copeland <[email protected]>
Date: Wed, 2 Mar 2016 10:09:20 -0500
Quoted 10 lines
In the time since the mesh path table was implemented as an RCU-traversable, dynamically growing hash table, a generic RCU hashtable implementation was added to the kernel.
Switch the mesh path table over to rhashtable to remove some code and also gain some features like automatic shrinking.
Cc Thomas Graf <[email protected]>Signed-off-by Bob Copeland <[email protected]>
Johannes, feel free to take both patches via your tree, thanks.
Johannes Berg
maintainerRe: [PATCH 2/2] mac80211: mesh: convert path table to rhashtable
Quoted 14 lines · David Miller
From: Bob Copeland <[email protected]>
Date: Wed, 2 Mar 2016 10:09:20 -0500Quoted 10 lines
In the time since the mesh path table was implemented as an RCU-traversable, dynamically growing hash table, a generic RCU hashtable implementation was added to the kernel.
Switch the mesh path table over to rhashtable to remove some code and also gain some features like automatic shrinking.Cc Thomas Graf <[email protected]>Signed-off-by Bob Copeland <[email protected]>
Quoted 1 line
Johannes, feel free to take both patches via your tree, thanks.
Will do, thanks.
johannes
Johannes Berg
maintainerQuoted 7 lines · Bob Copeland
In certain cases, the 802.11 mesh pathtable code wants to iterate over all of the entries in the forwarding table from the receive path, which is inside an RCU read-side critical section. Enable walks inside atomic sections by allowing
GFP_ATOMICallocations for the walker state.Change all existing callsites to pass in
GFP_KERNEL.
Applied both. You missed 3 callsites, I've fixed those. I hope I got them all :)
johannes
Quoted 11 lines · Johannes Berg
Quoted 7 lines · Bob Copeland
In certain cases, the 802.11 mesh pathtable code wants to iterate over all of the entries in the forwarding table from the receive path, which is inside an RCU read-side critical section. Enable walks inside atomic sections by allowing
GFP_ATOMICallocations for the walker state.Change all existing callsites to pass in
GFP_KERNEL.Applied both. You missed 3 callsites, I've fixed those. I hope I got them all :)
Ouch, thanks for the catch, I must've grepped only in net. And now I added those files to my build config. :)
Signature · 1 line
Bob Copeland %% http://bobcopeland.com/