Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp858485ybx; Thu, 31 Oct 2019 01:56:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqyKp5ur6YUTWN/OL3asbP+JXZc6O3YHu2q98ZaKUEkT+UU3dq7ajwPe5KV341uYwOvMdupM X-Received: by 2002:a05:6402:60d:: with SMTP id n13mr4597663edv.218.1572512206464; Thu, 31 Oct 2019 01:56:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572512206; cv=none; d=google.com; s=arc-20160816; b=P/uT1py30pl5rEaSTjdbqzR1wbH5oAsBjKPt0m2LRyhyMBzMk5xX5eR7QaG1g5LhyR k6HQ+rI4QE5X4eOZcNp8xcXtVuWHehqS0WXGaNOuRRo/Hl8+b8Ww0Ge12ceU9kAMhhY/ Wp+Z1l3HJ9AE44whyOdkci5yErwZ9b5TtIPX29ru6L1VRcBXmp3t0jiljo1UV5OGp2WS f6pkj1a/BjuM1IYn48cfGbt+d5uRIsRqn6s32hJGCT99hN8iWGlbG19C+rdWjaBkXWw4 nRTXOU/TKUHdMaek2muIts/aECZUwGp64dBiLd3zepZ23Ot9j6BIa5+rtBV0MqopkvnE auRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=h4+p1X4rLkeqR5CPAy2ezTgvOMuwl9fbeWveaI41zLQ=; b=r/J/B0q0B/Cf2fcNEBcAFQXDD9ENxy4X9AB3H1wLcQnY5UW1QZsw5SEoQBqtNhqyRv NZm4/K7AdArQZK/j9EYqbBmRhT+DPdewlrKlmPyCMIdOyeYAiMRjzPv/u+aEQrrzFQxM vbYobYcgdIPSwWL6pm9mHMhm7SUA2c1ckva5rIRJwGtNmz6Y3WRXxYoE77HwbOowC9hm S4TBLcdegRfYQTPH/TPbCnKH6vG4VoJBPD57NikYYY+dgQF2o/gWOR2G7N+Rl3vrGylV eSDW1VuNqnJIJjLgHvldlIcY5NQl+VWp4LNW/DjoxjmOFFH2qGYNE6sNpFF887aZ0Oyp aEvw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z65si3756656ede.388.2019.10.31.01.56.22; Thu, 31 Oct 2019 01:56:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727183AbfJaIxN (ORCPT + 99 others); Thu, 31 Oct 2019 04:53:13 -0400 Received: from smtp07.smtpout.orange.fr ([80.12.242.129]:23525 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727169AbfJaIxN (ORCPT ); Thu, 31 Oct 2019 04:53:13 -0400 Received: from localhost.localdomain ([93.23.12.90]) by mwinf5d66 with ME id L8sy2100A1waAWt038syit; Thu, 31 Oct 2019 09:53:11 +0100 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Thu, 31 Oct 2019 09:53:11 +0100 X-ME-IP: 93.23.12.90 From: Christophe JAILLET To: davem@davemloft.net, mareklindner@neomailbox.ch, sw@simonwunderlich.de, a@unstable.cc, sven@narfation.org Cc: b.a.t.m.a.n@lists.open-mesh.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] batman-adv: Axe 'aggr_list_lock' Date: Thu, 31 Oct 2019 09:52:40 +0100 Message-Id: <20191031085240.7116-1-christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 'aggr_list.lock' can safely be used in place of another explicit spinlock when access to 'aggr_list' has to be guarded. This avoids to take 2 locks, knowing that the 2nd one is always successful. Now that the 'aggr_list.lock' is handled explicitly, the lock-free __sbk_something() variants should be used when dealing with 'aggr_list'. Signed-off-by: Christophe JAILLET --- Compile tested only. --- net/batman-adv/bat_v.c | 1 - net/batman-adv/bat_v_ogm.c | 30 +++++++++++++++--------------- net/batman-adv/types.h | 3 --- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c index 64054edc2e3c..4ff6cf1ecae7 100644 --- a/net/batman-adv/bat_v.c +++ b/net/batman-adv/bat_v.c @@ -1085,7 +1085,6 @@ void batadv_v_hardif_init(struct batadv_hard_iface *hard_iface) hard_iface->bat_v.aggr_len = 0; skb_queue_head_init(&hard_iface->bat_v.aggr_list); - spin_lock_init(&hard_iface->bat_v.aggr_list_lock); INIT_DELAYED_WORK(&hard_iface->bat_v.aggr_wq, batadv_v_ogm_aggr_work); } diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c index b841c83d9c3b..c9a00100f199 100644 --- a/net/batman-adv/bat_v_ogm.c +++ b/net/batman-adv/bat_v_ogm.c @@ -151,7 +151,7 @@ static unsigned int batadv_v_ogm_len(struct sk_buff *skb) * @skb: the OGM to check * @hard_iface: the interface to use to send the OGM * - * Caller needs to hold the hard_iface->bat_v.aggr_list_lock. + * Caller needs to hold the hard_iface->bat_v.aggr_list.lock. * * Return: True, if the given OGMv2 packet still fits, false otherwise. */ @@ -162,7 +162,7 @@ static bool batadv_v_ogm_queue_left(struct sk_buff *skb, BATADV_MAX_AGGREGATION_BYTES); unsigned int ogm_len = batadv_v_ogm_len(skb); - lockdep_assert_held(&hard_iface->bat_v.aggr_list_lock); + lockdep_assert_held(&hard_iface->bat_v.aggr_list.lock); return hard_iface->bat_v.aggr_len + ogm_len <= max; } @@ -173,13 +173,13 @@ static bool batadv_v_ogm_queue_left(struct sk_buff *skb, * * Empties the OGMv2 aggregation queue and frees all the skbs it contained. * - * Caller needs to hold the hard_iface->bat_v.aggr_list_lock. + * Caller needs to hold the hard_iface->bat_v.aggr_list.lock. */ static void batadv_v_ogm_aggr_list_free(struct batadv_hard_iface *hard_iface) { - lockdep_assert_held(&hard_iface->bat_v.aggr_list_lock); + lockdep_assert_held(&hard_iface->bat_v.aggr_list.lock); - skb_queue_purge(&hard_iface->bat_v.aggr_list); + __skb_queue_purge(&hard_iface->bat_v.aggr_list); hard_iface->bat_v.aggr_len = 0; } @@ -192,7 +192,7 @@ static void batadv_v_ogm_aggr_list_free(struct batadv_hard_iface *hard_iface) * * The aggregation queue is empty after this call. * - * Caller needs to hold the hard_iface->bat_v.aggr_list_lock. + * Caller needs to hold the hard_iface->bat_v.aggr_list.lock. */ static void batadv_v_ogm_aggr_send(struct batadv_hard_iface *hard_iface) { @@ -201,7 +201,7 @@ static void batadv_v_ogm_aggr_send(struct batadv_hard_iface *hard_iface) unsigned int ogm_len; struct sk_buff *skb; - lockdep_assert_held(&hard_iface->bat_v.aggr_list_lock); + lockdep_assert_held(&hard_iface->bat_v.aggr_list.lock); if (!aggr_len) return; @@ -215,7 +215,7 @@ static void batadv_v_ogm_aggr_send(struct batadv_hard_iface *hard_iface) skb_reserve(skb_aggr, ETH_HLEN + NET_IP_ALIGN); skb_reset_network_header(skb_aggr); - while ((skb = skb_dequeue(&hard_iface->bat_v.aggr_list))) { + while ((skb = __skb_dequeue(&hard_iface->bat_v.aggr_list))) { hard_iface->bat_v.aggr_len -= batadv_v_ogm_len(skb); ogm_len = batadv_v_ogm_len(skb); @@ -242,13 +242,13 @@ static void batadv_v_ogm_queue_on_if(struct sk_buff *skb, return; } - spin_lock_bh(&hard_iface->bat_v.aggr_list_lock); + spin_lock_bh(&hard_iface->bat_v.aggr_list.lock); if (!batadv_v_ogm_queue_left(skb, hard_iface)) batadv_v_ogm_aggr_send(hard_iface); hard_iface->bat_v.aggr_len += batadv_v_ogm_len(skb); - skb_queue_tail(&hard_iface->bat_v.aggr_list, skb); - spin_unlock_bh(&hard_iface->bat_v.aggr_list_lock); + __skb_queue_tail(&hard_iface->bat_v.aggr_list, skb); + spin_unlock_bh(&hard_iface->bat_v.aggr_list.lock); } /** @@ -373,9 +373,9 @@ void batadv_v_ogm_aggr_work(struct work_struct *work) batv = container_of(work, struct batadv_hard_iface_bat_v, aggr_wq.work); hard_iface = container_of(batv, struct batadv_hard_iface, bat_v); - spin_lock_bh(&hard_iface->bat_v.aggr_list_lock); + spin_lock_bh(&hard_iface->bat_v.aggr_list.lock); batadv_v_ogm_aggr_send(hard_iface); - spin_unlock_bh(&hard_iface->bat_v.aggr_list_lock); + spin_unlock_bh(&hard_iface->bat_v.aggr_list.lock); batadv_v_ogm_start_queue_timer(hard_iface); } @@ -406,9 +406,9 @@ void batadv_v_ogm_iface_disable(struct batadv_hard_iface *hard_iface) { cancel_delayed_work_sync(&hard_iface->bat_v.aggr_wq); - spin_lock_bh(&hard_iface->bat_v.aggr_list_lock); + spin_lock_bh(&hard_iface->bat_v.aggr_list.lock); batadv_v_ogm_aggr_list_free(hard_iface); - spin_unlock_bh(&hard_iface->bat_v.aggr_list_lock); + spin_unlock_bh(&hard_iface->bat_v.aggr_list.lock); } /** diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index be7c02aa91e2..75a72d6676ec 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h @@ -126,9 +126,6 @@ struct batadv_hard_iface_bat_v { /** @aggr_len: size of the OGM aggregate (excluding ethernet header) */ unsigned int aggr_len; - /** @aggr_list_lock: protects aggr_list */ - spinlock_t aggr_list_lock; - /** * @throughput_override: throughput override to disable link * auto-detection -- 2.20.1