From patchwork Fri Dec 7 10:16:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Lagerwall X-Patchwork-Id: 1009315 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=citrix.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43B7fj2RdKz9s0t for ; Fri, 7 Dec 2018 21:16:29 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726056AbeLGKQ1 (ORCPT ); Fri, 7 Dec 2018 05:16:27 -0500 Received: from smtp03.citrix.com ([162.221.156.55]:42321 "EHLO SMTP03.CITRIX.COM" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725976AbeLGKQ1 (ORCPT ); Fri, 7 Dec 2018 05:16:27 -0500 X-IronPort-AV: E=Sophos;i="5.56,326,1539648000"; d="scan'208";a="72648172" From: Ross Lagerwall To: CC: "David S. Miller" , Amritha Nambiar , Ross Lagerwall Subject: [PATCH] net: Fix xps_needed inc/dec mismatch Date: Fri, 7 Dec 2018 10:16:21 +0000 Message-ID: <20181207101621.24316-1-ross.lagerwall@citrix.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org xps_needed is incremented only when a new dev map is allocated (in __netif_set_xps_queue). Therefore it should be decremented only when we actually have a dev map to destroy. Without this, it may be decremented too many times which causes netif_reset_xps_queues to return early and not actually clean up the old dev maps. This results in a crash in __netif_set_xps_queue when it is called later. The crash occurred when having multiple ixgbe devices in a host. lldpad would reconfigure them to be FCoE-capable causing reset_xps_queues / set_xps_queue to be called several times. The xps_needed count would get out of sync and eventually the above-mentioned crash would occur. Signed-off-by: Ross Lagerwall --- net/core/dev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/core/dev.c b/net/core/dev.c index ddc551f24ba2..8aa72e93af9f 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -2233,11 +2233,12 @@ static void netif_reset_xps_queues(struct net_device *dev, u16 offset, clean_xps_maps(dev, possible_mask, dev_maps, nr_ids, offset, count, false); -out_no_maps: if (static_key_enabled(&xps_rxqs_needed)) static_key_slow_dec_cpuslocked(&xps_rxqs_needed); static_key_slow_dec_cpuslocked(&xps_needed); + +out_no_maps: mutex_unlock(&xps_map_mutex); cpus_read_unlock(); }