From patchwork Wed Dec 14 16:28:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Koen Vandeputte X-Patchwork-Id: 9474375 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 80B386021C for ; Wed, 14 Dec 2016 16:31:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73C6828713 for ; Wed, 14 Dec 2016 16:31:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 68EE22872F; Wed, 14 Dec 2016 16:31:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE91528713 for ; Wed, 14 Dec 2016 16:31:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932578AbcLNQa4 (ORCPT ); Wed, 14 Dec 2016 11:30:56 -0500 Received: from mail-wm0-f54.google.com ([74.125.82.54]:35805 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753783AbcLNQay (ORCPT ); Wed, 14 Dec 2016 11:30:54 -0500 Received: by mail-wm0-f54.google.com with SMTP id a197so121171274wmd.0 for ; Wed, 14 Dec 2016 08:29:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ncentric.com; s=google; h=from:to:cc:subject:date:message-id; bh=gFR4O8768G8+bECM+T49k+J75OR03zdjjkUCFvsFa4g=; b=pJw5tuuAaAopVz1Z7PKKq/PwmPx8RnISC4XMhXoKGX2qQxcKUmpVXniF8YHtICf3DA eVmkVX48mztKc27Y47VP/t31WFnPbi86LHHTb7pgZgTMOWy0N+fk9GUkkkybk5v93kji qcXf32Ci+eypVS+HMsRgQVVBsubxgD54zN9Lk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=gFR4O8768G8+bECM+T49k+J75OR03zdjjkUCFvsFa4g=; b=GjogPMl1TOlyka3eoACD73eX/WmLyK0zocjxCnn7wtLS7wEqzenbgkGcwsUXqSvvoJ PGeCUkIoJOY8Cyw23l5sJJ+JrDK5kekJ3tcEZwLjzDUNFRN+0ohegWzzqvaf7G9U2sm8 YArnC5FrMlLbAwNCh/uj7KIHHrxPq06pKdE5xrvVmDC8CJFu+iyaB9Wd5yS+HZ6k3FKh 1TBtb6T8JCgejW2vJOohNH9QdoR6RC7iYSHzqpgumTV7tv33Q2YoQvhJAuFUEx+6eGho stdmE6LuPdxihrL7iou7sSMJeraXxgKcYLtwrYx1QgVzqhu68LxZdoWgcwJKnvL6dHwK ncXw== X-Gm-Message-State: AKaTC02hGkKX4fpPsee0oRRH5vgo5rNaIsgG6W9iCNfc0/cS43Mv/MgWEH6kIPfin/d+0ncE X-Received: by 10.28.105.78 with SMTP id e75mr8549504wmc.55.1481732982762; Wed, 14 Dec 2016 08:29:42 -0800 (PST) Received: from localhost.localdomain (d515300d8.static.telenet.be. [81.83.0.216]) by smtp.googlemail.com with ESMTPSA id u78sm8353099wma.11.2016.12.14.08.29.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Dec 2016 08:29:42 -0800 (PST) From: Koen Vandeputte To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Koen Vandeputte Subject: [PATCH] mac80211: only alloc mem if a station doesnt exist yet Date: Wed, 14 Dec 2016 17:28:59 +0100 Message-Id: <1481732939-8237-1-git-send-email-koen.vandeputte@ncentric.com> X-Mailer: git-send-email 2.7.4 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This speeds up the function in case a station already exists by avoiding calling an expensive kzalloc just to free it again after the next check. Signed-off-by: Koen Vandeputte --- net/mac80211/sta_info.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index 1711bae..0a42e6e 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -513,23 +513,23 @@ static int sta_info_insert_finish(struct sta_info *sta) __acquires(RCU) { struct ieee80211_local *local = sta->local; struct ieee80211_sub_if_data *sdata = sta->sdata; - struct station_info *sinfo; + struct station_info *sinfo = NULL; int err = 0; lockdep_assert_held(&local->sta_mtx); - sinfo = kzalloc(sizeof(struct station_info), GFP_KERNEL); - if (!sinfo) { - err = -ENOMEM; - goto out_err; - } - /* check if STA exists already */ if (sta_info_get_bss(sdata, sta->sta.addr)) { err = -EEXIST; goto out_err; } + sinfo = kzalloc(sizeof(struct station_info), GFP_KERNEL); + if (!sinfo) { + err = -ENOMEM; + goto out_err; + } + local->num_sta++; local->sta_generation++; smp_mb();