Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3690922ybv; Mon, 10 Feb 2020 04:47:16 -0800 (PST) X-Google-Smtp-Source: APXvYqxA47Yx6oI3DS7WnomyX0SJvYX+hJohrCP/9U05xJarVyHwG+UtVHK/wcPH7o0jCB62T5DE X-Received: by 2002:aca:ccce:: with SMTP id c197mr685596oig.31.1581338836092; Mon, 10 Feb 2020 04:47:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581338836; cv=none; d=google.com; s=arc-20160816; b=OX4XgqIQiv8pXN+KTXKPvqpndc1s4+R5h3efuZhaYJcIZrVga05CiPio+A3ihMpxh0 iRswCm9cqKeksZPhM0umb5RNOK0QQylglbJ4JNgI8nn92/xjwWYvXWDWvXYNoCKAYOg2 0Ub7U++wgPoe0K0kVsPsToigOikkQImeNrvlzPS2/JpSVe912M/IO6kmhrTM1m7CcbsT kbJHRYLVlA6kiSEG6PfeMaIAPlWG8VQbGTkH4lLH5cLfupvKIw6v44u8hODj7Vfla0Mw gUupedDWFz4Yh9yiuQrmtOayUGwkukq35LLzmQFuy0PjFjbz0jRe3FKswxIuDZ784dof 932w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ve0l/2Yt9NfkKKjuhzCH2SADWsELv1ebAwkEf//zIIA=; b=HgUyCNSaUL169udIJPk13IY64xDo2zjLQqpqrKVbRFhrAvikRjpO+iQnySn3CCvxyD TS7Ou95nHJRxLiGGzVZTjpOaMBTmcS8ysooUa47kCJBIoUjwlHLelr7B3ycx85E0V+Ne DjmhwbSjJmkM94ZR8Pd01SrKW5eda1PzR7ZpZmUtj0xINjXEUL+5fLtjbIzCXRQUB8TB jYEOHjGFfVjv8zvmruL1IuIrflhhPcWacVen5lADRwzC0AxiNcHViapgdJzADQXJuZ0c R2wnJ+yYqd4GZIzhGFWXm2stbG1uN3MmwLkYW+IKRpMqTUDNBxk7Klc9K5EIEMnQ6i6V TaEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gmtrZixK; 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 z206si137485oia.142.2020.02.10.04.47.04; Mon, 10 Feb 2020 04:47:16 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=gmtrZixK; 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 S1730671AbgBJMq4 (ORCPT + 99 others); Mon, 10 Feb 2020 07:46:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:45252 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729281AbgBJMlz (ORCPT ); Mon, 10 Feb 2020 07:41:55 -0500 Received: from localhost (unknown [209.37.97.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E024221569; Mon, 10 Feb 2020 12:41:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338515; bh=mOSzqxDz+tG+hYHXsNf0YALzMyOPfatCMyLsctEUt80=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gmtrZixK32jt4fkx0qZ/mvlz0HNPVVagnRkEqfTT3TkWmVTsO4SBelViFjiCiETZB i3Y4mUrIe/QbsYHoN4e95WEUtKAz/HabVij6end6LycE3CNMqA5I05ehwtOKqe3110 Ny2vinWJQwtvB2VbiK6rovWKwcTexb4cpGs8ykjk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lorenzo Bianconi , "David S. Miller" Subject: [PATCH 5.5 322/367] net: mvneta: move rx_dropped and rx_errors in per-cpu stats Date: Mon, 10 Feb 2020 04:33:55 -0800 Message-Id: <20200210122452.741813885@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122423.695146547@linuxfoundation.org> References: <20200210122423.695146547@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lorenzo Bianconi [ Upstream commit c35947b8ff8acca33134ee39c31708233765c31a ] Move rx_dropped and rx_errors counters in mvneta_pcpu_stats in order to avoid possible races updating statistics Fixes: 562e2f467e71 ("net: mvneta: Improve the buffer allocation method for SWBM") Fixes: dc35a10f68d3 ("net: mvneta: bm: add support for hardware buffer management") Fixes: c5aff18204da ("net: mvneta: driver for Marvell Armada 370/XP network unit") Signed-off-by: Lorenzo Bianconi Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/marvell/mvneta.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) --- a/drivers/net/ethernet/marvell/mvneta.c +++ b/drivers/net/ethernet/marvell/mvneta.c @@ -401,6 +401,8 @@ struct mvneta_pcpu_stats { struct u64_stats_sync syncp; u64 rx_packets; u64 rx_bytes; + u64 rx_dropped; + u64 rx_errors; u64 tx_packets; u64 tx_bytes; }; @@ -738,6 +740,8 @@ mvneta_get_stats64(struct net_device *de struct mvneta_pcpu_stats *cpu_stats; u64 rx_packets; u64 rx_bytes; + u64 rx_dropped; + u64 rx_errors; u64 tx_packets; u64 tx_bytes; @@ -746,19 +750,20 @@ mvneta_get_stats64(struct net_device *de start = u64_stats_fetch_begin_irq(&cpu_stats->syncp); rx_packets = cpu_stats->rx_packets; rx_bytes = cpu_stats->rx_bytes; + rx_dropped = cpu_stats->rx_dropped; + rx_errors = cpu_stats->rx_errors; tx_packets = cpu_stats->tx_packets; tx_bytes = cpu_stats->tx_bytes; } while (u64_stats_fetch_retry_irq(&cpu_stats->syncp, start)); stats->rx_packets += rx_packets; stats->rx_bytes += rx_bytes; + stats->rx_dropped += rx_dropped; + stats->rx_errors += rx_errors; stats->tx_packets += tx_packets; stats->tx_bytes += tx_bytes; } - stats->rx_errors = dev->stats.rx_errors; - stats->rx_dropped = dev->stats.rx_dropped; - stats->tx_dropped = dev->stats.tx_dropped; } @@ -1736,8 +1741,14 @@ static u32 mvneta_txq_desc_csum(int l3_o static void mvneta_rx_error(struct mvneta_port *pp, struct mvneta_rx_desc *rx_desc) { + struct mvneta_pcpu_stats *stats = this_cpu_ptr(pp->stats); u32 status = rx_desc->status; + /* update per-cpu counter */ + u64_stats_update_begin(&stats->syncp); + stats->rx_errors++; + u64_stats_update_end(&stats->syncp); + switch (status & MVNETA_RXD_ERR_CODE_MASK) { case MVNETA_RXD_ERR_CRC: netdev_err(pp->dev, "bad rx status %08x (crc error), size=%d\n", @@ -2179,11 +2190,15 @@ mvneta_swbm_rx_frame(struct mvneta_port rxq->skb = build_skb(xdp->data_hard_start, PAGE_SIZE); if (unlikely(!rxq->skb)) { - netdev_err(dev, - "Can't allocate skb on queue %d\n", - rxq->id); - dev->stats.rx_dropped++; + struct mvneta_pcpu_stats *stats = this_cpu_ptr(pp->stats); + + netdev_err(dev, "Can't allocate skb on queue %d\n", rxq->id); rxq->skb_alloc_err++; + + u64_stats_update_begin(&stats->syncp); + stats->rx_dropped++; + u64_stats_update_end(&stats->syncp); + return -ENOMEM; } page_pool_release_page(rxq->page_pool, page); @@ -2270,7 +2285,6 @@ static int mvneta_rx_swbm(struct napi_st /* Check errors only for FIRST descriptor */ if (rx_status & MVNETA_RXD_ERR_SUMMARY) { mvneta_rx_error(pp, rx_desc); - dev->stats.rx_errors++; /* leave the descriptor untouched */ continue; } @@ -2372,7 +2386,6 @@ err_drop_frame_ret_pool: mvneta_bm_pool_put_bp(pp->bm_priv, bm_pool, rx_desc->buf_phys_addr); err_drop_frame: - dev->stats.rx_errors++; mvneta_rx_error(pp, rx_desc); /* leave the descriptor untouched */ continue;