From patchwork Wed Mar 2 15:09:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Copeland X-Patchwork-Id: 8481541 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3B2C29F2F0 for ; Wed, 2 Mar 2016 15:09:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 13CF62035E for ; Wed, 2 Mar 2016 15:09:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 10B032038E for ; Wed, 2 Mar 2016 15:09:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754269AbcCBPJf (ORCPT ); Wed, 2 Mar 2016 10:09:35 -0500 Received: from mail-ig0-f195.google.com ([209.85.213.195]:35107 "EHLO mail-ig0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752199AbcCBPJd (ORCPT ); Wed, 2 Mar 2016 10:09:33 -0500 Received: by mail-ig0-f195.google.com with SMTP id ww10so5129547igb.2 for ; Wed, 02 Mar 2016 07:09:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bobcopeland-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=cStAe334xki0kWGLON2M/AKojAen4OTjFAGiW/9MH7E=; b=kITt4fT4dd7z3dW8HStyJs2KIzhYuZaskFKk1FGBJCfdfKHcxBf3hbKCBXK6MOM8pU FGTdjqXabYxrjlwt4Wgh77eg9p7Xo7jmGZh2y5lk+5Q3DQViq3Fsi3ic1zc4Ic18xV38 TH76DgDL3GiKPJM9J8SkX/21ar9EZQV4epg9EVbYGNUQuD1S86aTD1nU3ZcvdoedY0mI 7ct2QgaFHtcBZDGQ+qZ5iMjfsBTWzuO1ZrheDHySNF1CuUc9E2Px2YFZiWtn5pK8CKyU lwZq/aDraFYHsH6fuJP/kYevplL9bIcWrRxpzP5auTWCTSnW/8l9knAYRRvvrg9cxq8k rUew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=cStAe334xki0kWGLON2M/AKojAen4OTjFAGiW/9MH7E=; b=aOjCNKGpBQOsjhB1otm6Y91nlcaOGSFn8g1VhaRcq6omWYoyf04SiTUzeb1PS7/nc7 Gp+XpPB7g3tjGPBXft0wUBGiVPXNflyTKZnkoQfkeHfDG+sMjavLkmt6kjlC3B0fNL5L oLD4JfIKAb/xy4OjaEJ8TuzABuZSgo3gquCi6+3JGUVBk6wEazXMod5vS0luc6yY7Try PJbIbxupUYNVWV0LCV20iohFlTtqnb5htSVaeKVSDfxcXrJslktRHk5nh1BaoEsyC1mL 4hNJ7MfbqNH2cUKRjU6OCS10E9cWiTfel1y2DBJuF5PmdI/uoLkzKMx+moU/ti7RRFXm G7Pg== X-Gm-Message-State: AD7BkJKiU7hW2Odjv8eHNRjUpx2rRQeL/tkBXWBTQeVk9/KmLopunEYuUi5t6ZWoNLYBXw== X-Received: by 10.50.79.202 with SMTP id l10mr378064igx.45.1456931370180; Wed, 02 Mar 2016 07:09:30 -0800 (PST) Received: from hash ([2001:470:1d:6db:230:48ff:fe9d:9c89]) by smtp.gmail.com with ESMTPSA id yq10sm1789444igb.8.2016.03.02.07.09.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Mar 2016 07:09:29 -0800 (PST) Received: from glass.lan ([192.168.1.51] helo=glass) by hash with esmtp (Exim 4.84) (envelope-from ) id 1ab8Op-0006bC-DB; Wed, 02 Mar 2016 10:09:15 -0500 Received: from bob by glass with local (Exim 4.86) (envelope-from ) id 1ab8P1-0000kb-Tx; Wed, 02 Mar 2016 10:09:27 -0500 From: Bob Copeland To: Johannes Berg Cc: linux-wireless@vger.kernel.org, Bob Copeland , Thomas Graf , netdev@vger.kernel.org Subject: [PATCH 1/2] rhashtable: accept GFP flags in rhashtable_walk_init Date: Wed, 2 Mar 2016 10:09:19 -0500 Message-Id: <1456931360-2846-1-git-send-email-me@bobcopeland.com> X-Mailer: git-send-email 2.6.1 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Cc: Thomas Graf Cc: netdev@vger.kernel.org Acked-by: Thomas Graf Signed-off-by: Bob Copeland --- (-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(-) diff --git a/include/linux/rhashtable.h b/include/linux/rhashtable.h index 63bd7601b6de..3eef0802a0cd 100644 --- a/include/linux/rhashtable.h +++ b/include/linux/rhashtable.h @@ -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); diff --git a/lib/rhashtable.c b/lib/rhashtable.c index cc808707d1cf..5d845ffd7982 100644 --- a/lib/rhashtable.c +++ b/lib/rhashtable.c @@ -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; diff --git a/net/ipv6/ila/ila_xlat.c b/net/ipv6/ila/ila_xlat.c index 295ca29a23c3..0b03533453e4 100644 --- a/net/ipv6/ila/ila_xlat.c +++ b/net/ipv6/ila/ila_xlat.c @@ -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) diff --git a/net/netfilter/nft_hash.c b/net/netfilter/nft_hash.c index 3f9d45d3d9b7..6fa016564f90 100644 --- a/net/netfilter/nft_hash.c +++ b/net/netfilter/nft_hash.c @@ -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; diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index c8416792cce0..6e0cbdeb21d3 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -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; diff --git a/net/sctp/proc.c b/net/sctp/proc.c index cfc3c7101a38..c5991e5e5daf 100644 --- a/net/sctp/proc.c +++ b/net/sctp/proc.c @@ -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;