From patchwork Sat Mar 19 02:11:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Copeland X-Patchwork-Id: 8624611 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 1B0A99F44D for ; Sat, 19 Mar 2016 02:11:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 157B420429 for ; Sat, 19 Mar 2016 02:11:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BB80B20425 for ; Sat, 19 Mar 2016 02:11:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754362AbcCSCLn (ORCPT ); Fri, 18 Mar 2016 22:11:43 -0400 Received: from mail-qg0-f68.google.com ([209.85.192.68]:33964 "EHLO mail-qg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753720AbcCSCLl (ORCPT ); Fri, 18 Mar 2016 22:11:41 -0400 Received: by mail-qg0-f68.google.com with SMTP id j92so6595918qgj.1 for ; Fri, 18 Mar 2016 19:11:41 -0700 (PDT) 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:in-reply-to:references; bh=Jk5+zEjBHiGkfnNP2ZCzEnlEGRj6UL+sTPaQn8EZLaE=; b=lHJhHJ9CX1UNXpQeKhP0/C4zFgAAFruX6q9yyiuFh+BIvTIZvbbuqhGNVbOryC71E/ dlSOtYVbgZQuhDrD3XtphHR3PyFlp2T661NPl2I8XpUqDMVf0OQQ5a1aR2+rt2i5Jq34 9KCE4f6xkmC7f5NC154eqU8SlO4Xffmd0dwRGp6iYPf8JwcxNQjRdx8p6nIN5xJp9k62 VjaeB4jSICTHaPje+d+wrKsusBb+SKoRYh637ToUL0RZ9Iw5ZhC+3Po06hVMtoLjMqR2 vnrmODEJmcCseClRFyVTYuhHZ9jewn1RgHUml+cccQQz5hf2YyrXoH4dz5GERwDBmWfN MuDA== 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:in-reply-to :references; bh=Jk5+zEjBHiGkfnNP2ZCzEnlEGRj6UL+sTPaQn8EZLaE=; b=ZG1sa1ccv2ttk/ZJqEdGzzIslEbdjhCqb09G3rVugPc/ZA8R09mDZrQEm/9VUu7GrC r9MIVu2qlIjeU2Rud+jQ2/S39I+n58NRQShJ5nfi4w3cjuKWNq1mxaILnZbrHxRJx/Zh 6qXgW3Ex+H6KhV3ktZ9chV0bEaTwLuyRjqpIveLui6lR30Yp3Ic2dWSanQWxwEYiCXDJ dzI5FXgyGvj83NHAjy2BTyQRytBEpVUQakd4suhQOzZG1LxQaZ7pjQxJt9qTwtce2dTS qLCxn0CciwI+6Mr2VyhIJ8pTL1bvIwLUzMaMMOUdkMlGPWAJVjwKXly2Xax/7YAt8qW1 sYsA== X-Gm-Message-State: AD7BkJIDXXv5v8APtjPgwawZfjn676eTqVxOZJ14HsKWO8dxnaGtzuH9gx6m2nbEBnR9rw== X-Received: by 10.140.42.39 with SMTP id b36mr26160714qga.4.1458353500986; Fri, 18 Mar 2016 19:11:40 -0700 (PDT) Received: from hash ([2001:470:1d:6db:230:48ff:fe9d:9c89]) by smtp.gmail.com with ESMTPSA id 191sm7273629qhq.17.2016.03.18.19.11.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Mar 2016 19:11:40 -0700 (PDT) Received: from glass.lan ([192.168.1.51] helo=glass) by hash with esmtp (Exim 4.84_2) (envelope-from ) id 1ah6MS-00053z-Gb; Fri, 18 Mar 2016 22:11:28 -0400 Received: from bob by glass with local (Exim 4.86) (envelope-from ) id 1ah6Md-0002GY-M2; Fri, 18 Mar 2016 22:11:39 -0400 From: Bob Copeland To: Johannes Berg Cc: linux-wireless@vger.kernel.org, Bob Copeland Subject: [PATCH 3/5] mac80211: mesh: embed gates hlist head directly Date: Fri, 18 Mar 2016 22:11:30 -0400 Message-Id: <1458353492-8654-4-git-send-email-me@bobcopeland.com> X-Mailer: git-send-email 2.6.1 In-Reply-To: <1458353492-8654-1-git-send-email-me@bobcopeland.com> References: <1458353492-8654-1-git-send-email-me@bobcopeland.com> 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 Since we have converted the mesh path tables to rhashtable, we are no longer swapping out the entire mesh_pathtbl pointer with RCU. As a result, we no longer need indirection to the hlist head for the gates list and can simply embed it, saving a pair of pointer-sized allocations. Signed-off-by: Bob Copeland --- net/mac80211/mesh.h | 2 +- net/mac80211/mesh_pathtbl.c | 18 ++++-------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h index bc3f9a32b5a4..46b540a25d9d 100644 --- a/net/mac80211/mesh.h +++ b/net/mac80211/mesh.h @@ -134,7 +134,7 @@ struct mesh_path { */ struct mesh_table { atomic_t entries; /* Up to MAX_MESH_NEIGHBOURS */ - struct hlist_head *known_gates; + struct hlist_head known_gates; spinlock_t gates_lock; struct rhashtable rhead; diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c index 1c9412a29ca3..6db2ddfa0695 100644 --- a/net/mac80211/mesh_pathtbl.c +++ b/net/mac80211/mesh_pathtbl.c @@ -58,12 +58,7 @@ static struct mesh_table *mesh_table_alloc(void) if (!newtbl) return NULL; - newtbl->known_gates = kzalloc(sizeof(struct hlist_head), GFP_ATOMIC); - if (!newtbl->known_gates) { - kfree(newtbl); - return NULL; - } - INIT_HLIST_HEAD(newtbl->known_gates); + INIT_HLIST_HEAD(&newtbl->known_gates); atomic_set(&newtbl->entries, 0); spin_lock_init(&newtbl->gates_lock); @@ -341,7 +336,7 @@ int mesh_path_add_gate(struct mesh_path *mpath) mpath->sdata->u.mesh.num_gates++; spin_lock(&tbl->gates_lock); - hlist_add_head_rcu(&mpath->gate_list, tbl->known_gates); + hlist_add_head_rcu(&mpath->gate_list, &tbl->known_gates); spin_unlock(&tbl->gates_lock); spin_unlock_bh(&mpath->state_lock); @@ -759,16 +754,11 @@ int mesh_path_send_to_gates(struct mesh_path *mpath) struct mesh_path *from_mpath = mpath; struct mesh_path *gate; bool copy = false; - struct hlist_head *known_gates; tbl = sdata->u.mesh.mesh_paths; - known_gates = tbl->known_gates; - - if (!known_gates) - return -EHOSTUNREACH; rcu_read_lock(); - hlist_for_each_entry_rcu(gate, known_gates, gate_list) { + hlist_for_each_entry_rcu(gate, &tbl->known_gates, gate_list) { if (gate->flags & MESH_PATH_ACTIVE) { mpath_dbg(sdata, "Forwarding to %pM\n", gate->dst); mesh_path_move_to_queue(gate, from_mpath, copy); @@ -781,7 +771,7 @@ int mesh_path_send_to_gates(struct mesh_path *mpath) } } - hlist_for_each_entry_rcu(gate, known_gates, gate_list) { + hlist_for_each_entry_rcu(gate, &tbl->known_gates, gate_list) { mpath_dbg(sdata, "Sending to %pM\n", gate->dst); mesh_path_tx_pending(gate); }