From patchwork Sat Mar 19 02:11:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bob Copeland X-Patchwork-Id: 8624651 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 B7FAC9F44D for ; Sat, 19 Mar 2016 02:12:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C8EB720425 for ; Sat, 19 Mar 2016 02:11:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C81DC20429 for ; Sat, 19 Mar 2016 02:11:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754348AbcCSCLy (ORCPT ); Fri, 18 Mar 2016 22:11:54 -0400 Received: from mail-qg0-f66.google.com ([209.85.192.66]:33481 "EHLO mail-qg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754470AbcCSCLu (ORCPT ); Fri, 18 Mar 2016 22:11:50 -0400 Received: by mail-qg0-f66.google.com with SMTP id y89so8715941qge.0 for ; Fri, 18 Mar 2016 19:11:49 -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=OorZTVF8Fji2ecl9aXnaDOe3RG6MxBPRw2JeVlBzWTA=; b=OK0ex1sHLbbKaPgXq+TMUIX9RRRKMlti1HOL9UzFyaP5bLFZzPMmn4pHu5SxGcFjix z+oxtvicTHpE4arHEVzbRzDk/GNCdEfzexRkd60RgjbCwsNXDvs6CDJlXqnVXCQBDLhO H0gwzMYLpTHho2G+dIsyv6fgByDMyERfWOxBH4uSM9l1gMAmhXev8j27329SomuYyi0+ tu2wVcTRN7TRcPqcn4W/2uzLcLnrwjnB6QqVhn9/uxjBDrHWPd2obk9/5+wKFQhEWLpG /vCNJTXne3DpJ8uvSHGyjvkxFrOE6QHeHDWeDcJ0+iL3ALUWemE44Brd4vLw1pD0luo4 Flxg== 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=OorZTVF8Fji2ecl9aXnaDOe3RG6MxBPRw2JeVlBzWTA=; b=YCUYKZccQGInPes0InmOIT4mTLeoggk4sFWCQscnHZ9E1JpbMfw3VASuQD3nBINw2D TVaoXpeYQtR0pRTD+OdCRy7AmqMOZTrTn7U8YnVAKaPDCVieMHZQ4yrr07xxPYOQ0KFC /vuyEZaeLK2orGPVmXsrHjqmedU1OyySNNmxtzHGyVZ4210AisBXgeSPbspHNGTiSOwO UAQcWdso1WewN7bjSBJMjLbL7fO4qevMOqAcqK/hb+GDDkRyvTjBwwH3g4ubsbcnKLg5 NEbhZQZZE1pZDVhja03BMAcFcbG9uvPqed9IjiYEeGxglqgpcgyzVVi3Els0o9a/OW6z Wx9Q== X-Gm-Message-State: AD7BkJKhu9gD9TVIoE+ueBMOEdf6vlajf0r0O4GA2NqWtxFq5/Oq0EEm7ssHYgOy/njXsw== X-Received: by 10.140.143.134 with SMTP id 128mr28397280qhp.25.1458353508912; Fri, 18 Mar 2016 19:11:48 -0700 (PDT) Received: from hash ([2001:470:1d:6db:230:48ff:fe9d:9c89]) by smtp.gmail.com with ESMTPSA id v70sm7296787qge.25.2016.03.18.19.11.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Mar 2016 19:11:48 -0700 (PDT) Received: from glass.lan ([192.168.1.51] helo=glass) by hash with esmtp (Exim 4.84_2) (envelope-from ) id 1ah6MS-00053x-GC; Fri, 18 Mar 2016 22:11:28 -0400 Received: from bob by glass with local (Exim 4.86) (envelope-from ) id 1ah6Md-0002GT-LL; Fri, 18 Mar 2016 22:11:39 -0400 From: Bob Copeland To: Johannes Berg Cc: linux-wireless@vger.kernel.org, Bob Copeland Subject: [PATCH 2/5] mac80211: mesh: use hlist for rmc cache Date: Fri, 18 Mar 2016 22:11:29 -0400 Message-Id: <1458353492-8654-3-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 The RMC cache has 256 list heads plus a u32, which puts it at the unfortunate size of 4104 bytes with padding. kmalloc() will then round this up to the next power-of-two, so we wind up actually using two pages here where most of the second is wasted. Switch to hlist heads here to reduce the structure size down to fit within a page. Signed-off-by: Bob Copeland --- net/mac80211/mesh.c | 18 ++++++++++-------- net/mac80211/mesh.h | 4 ++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c index d0d8eeaa8129..1a2aaf461e98 100644 --- a/net/mac80211/mesh.c +++ b/net/mac80211/mesh.c @@ -174,22 +174,23 @@ int mesh_rmc_init(struct ieee80211_sub_if_data *sdata) return -ENOMEM; sdata->u.mesh.rmc->idx_mask = RMC_BUCKETS - 1; for (i = 0; i < RMC_BUCKETS; i++) - INIT_LIST_HEAD(&sdata->u.mesh.rmc->bucket[i]); + INIT_HLIST_HEAD(&sdata->u.mesh.rmc->bucket[i]); return 0; } void mesh_rmc_free(struct ieee80211_sub_if_data *sdata) { struct mesh_rmc *rmc = sdata->u.mesh.rmc; - struct rmc_entry *p, *n; + struct rmc_entry *p; + struct hlist_node *n; int i; if (!sdata->u.mesh.rmc) return; for (i = 0; i < RMC_BUCKETS; i++) { - list_for_each_entry_safe(p, n, &rmc->bucket[i], list) { - list_del(&p->list); + hlist_for_each_entry_safe(p, n, &rmc->bucket[i], list) { + hlist_del(&p->list); kmem_cache_free(rm_cache, p); } } @@ -218,7 +219,8 @@ int mesh_rmc_check(struct ieee80211_sub_if_data *sdata, u32 seqnum = 0; int entries = 0; u8 idx; - struct rmc_entry *p, *n; + struct rmc_entry *p; + struct hlist_node *n; if (!rmc) return -1; @@ -226,11 +228,11 @@ int mesh_rmc_check(struct ieee80211_sub_if_data *sdata, /* Don't care about endianness since only match matters */ memcpy(&seqnum, &mesh_hdr->seqnum, sizeof(mesh_hdr->seqnum)); idx = le32_to_cpu(mesh_hdr->seqnum) & rmc->idx_mask; - list_for_each_entry_safe(p, n, &rmc->bucket[idx], list) { + hlist_for_each_entry_safe(p, n, &rmc->bucket[idx], list) { ++entries; if (time_after(jiffies, p->exp_time) || entries == RMC_QUEUE_MAX_LEN) { - list_del(&p->list); + hlist_del(&p->list); kmem_cache_free(rm_cache, p); --entries; } else if ((seqnum == p->seqnum) && ether_addr_equal(sa, p->sa)) @@ -244,7 +246,7 @@ int mesh_rmc_check(struct ieee80211_sub_if_data *sdata, p->seqnum = seqnum; p->exp_time = jiffies + RMC_TIMEOUT; memcpy(p->sa, sa, ETH_ALEN); - list_add(&p->list, &rmc->bucket[idx]); + hlist_add_head(&p->list, &rmc->bucket[idx]); return 0; } diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h index e1415c952e9c..bc3f9a32b5a4 100644 --- a/net/mac80211/mesh.h +++ b/net/mac80211/mesh.h @@ -158,14 +158,14 @@ struct mesh_table { * that are found in the cache. */ struct rmc_entry { - struct list_head list; + struct hlist_node list; u32 seqnum; unsigned long exp_time; u8 sa[ETH_ALEN]; }; struct mesh_rmc { - struct list_head bucket[RMC_BUCKETS]; + struct hlist_head bucket[RMC_BUCKETS]; u32 idx_mask; };