From patchwork Mon Feb 29 01:06:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Copeland X-Patchwork-Id: 8448281 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4596FC0553 for ; Mon, 29 Feb 2016 01:07:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2A5C720279 for ; Mon, 29 Feb 2016 01:07:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1E9DF20272 for ; Mon, 29 Feb 2016 01:07:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752895AbcB2BHI (ORCPT ); Sun, 28 Feb 2016 20:07:08 -0500 Received: from mail-qg0-f65.google.com ([209.85.192.65]:34842 "EHLO mail-qg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752497AbcB2BHG (ORCPT ); Sun, 28 Feb 2016 20:07:06 -0500 Received: by mail-qg0-f65.google.com with SMTP id p68so4974526qge.2 for ; Sun, 28 Feb 2016 17:07:05 -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=qcu/IsPUAVEglqxUor19/x4OYV2yRzh4sW8LibvPM0o=; b=Yy43xPh9qqPazGtGsEYeOx7UIRw/ZiY2AFbZSEZuONCmFLi8vU3lWHFamtD6zdtgtK +G+mcjOAVfAchUteC7ezTio7d9uOi5Vs8jaJ65gm+gmitaiiyqKG92GR0emMPMbjSAkG rMo2VxWGF4I9B89HfdZbjzrKFspA0DRIBGz/dVl3CEIPMyzQywu3+j9ucabPJKC/UZzu ZvuxojPHA6+Oi+BJQ332K5wZ/s7h6u2gl2RcumancfVABAN4tchsjQxJMga2oUXogU/w nXro1RACqHx9AKZXiwHfdkW4LOc6EQ7tEiLnVmmCNYj4VwXBCgJfaCQKyPp6iVwKQHt2 wEZA== 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=qcu/IsPUAVEglqxUor19/x4OYV2yRzh4sW8LibvPM0o=; b=SgyCwL0CgePnybGykZfMuOR0bHJzPi6byHHzuigg5gG6Rfoq+CZPC8F/Kv4scQ8QAB XnzrTHimgPOWc547N9+eyD2dFyYxg+WFc+EvM5smwg9MHKvUhoSYk2VlnD1F0yqVbdMf bbWkZ1/2vyOH78JAYFQdPz/53Y/FM/N7Je+UGETqqcn1TVpTS3hhL7N9GuhN7bFXHq6A frOEkmC5rn5d+HBFY7KDzWVKYb7iuNbjtqup1o6E/1GKQdMmKc3A+dkUXYk9R1mJxFno q80yEROQzW5QWMA4SpwrGFcbL24ZyzMveugj7sQCmxwXiPg/Lnusz8IRxRzC3ZxbgV9q QU+A== X-Gm-Message-State: AD7BkJKsRGTCU1lqxvxGGCW0Z/1/7Pr4F59vGkz0Or4pJxDpDcyOjjnyLMWfOMJJAjO0Xw== X-Received: by 10.141.23.207 with SMTP id z198mr16886506qhd.52.1456708025174; Sun, 28 Feb 2016 17:07:05 -0800 (PST) Received: from hash ([2001:470:1d:6db:230:48ff:fe9d:9c89]) by smtp.gmail.com with ESMTPSA id v74sm949469qkl.36.2016.02.28.17.07.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Feb 2016 17:07:04 -0800 (PST) Received: from glass.lan ([192.168.1.51] helo=glass) by hash with esmtp (Exim 4.84) (envelope-from ) id 1aaCIc-0006Tr-1Z; Sun, 28 Feb 2016 20:06:58 -0500 Received: from bob by glass with local (Exim 4.86) (envelope-from ) id 1aaCIh-00056f-L1; Sun, 28 Feb 2016 20:07:03 -0500 From: Bob Copeland To: linux-wireless@vger.kernel.org Cc: Johannes Berg , Bob Copeland , Thomas Graf , netdev@vger.kernel.org Subject: [PATCH RFC 1/2] rhashtable: accept GFP flags in rhashtable_walk_init Date: Sun, 28 Feb 2016 20:06:52 -0500 Message-Id: <1456708013-19590-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=ham 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 Signed-off-by: Bob Copeland Acked-by: Thomas Graf --- 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;