Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3010513pxb; Mon, 18 Oct 2021 06:33:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+OriSQv8hrs6ab6EcoAcha379gs0U9U7r1NF7xu1ao+ojLGQ7QwMHGZ8neoR6SVC4PA1w X-Received: by 2002:a62:17d3:0:b0:44c:6022:9428 with SMTP id 202-20020a6217d3000000b0044c60229428mr28638028pfx.65.1634563995200; Mon, 18 Oct 2021 06:33:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634563995; cv=none; d=google.com; s=arc-20160816; b=kUSpCgNa/XluJPS8pZBMKVz2KWM4hI/9ULC7UK5kwdPFHvLk8llQa9aTyVpQ1UAOop hHzu5u5bZc1DK+rvBRJ/wbEcKJvaKyUWuR4h/ZiQH4xDCI+zc1xOPMUC5OEexjebBAHD UKwgYBqywsBC/kG9iwcQ0RjqYlIVR+TIFSUHBYF8Z5aJ7kTZxIqKCrtNwb39oBBkxo6i RaziA9J60orm6Q6J+Lx2i8KOpIGkJk8sc90sf7PkbE5jshawe2MnKEQHrMo9rLGYa03/ 828A6PsE+9mkNhCv1N3MpTsjHcF/K4xOlaRCVyVuhxYdglQmYXzSuEnXXmKXDOq2eWP3 CedA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=97eajrFWteWBLNP1a5jXx2xD9kMpzD4Kaq1phu3lNJo=; b=htZ+2SCsktp+CGlQNqA8A0ztSPl3MpyRT5EbYjtS4623IM9LAvfXhaPYIypWx1fX2Q b9ssarGjZGF3z5TWxpFLT8a93+R2xJP5CCgNEQ3cdIXnjQt5ckcbg25lgF9kzVuyc2eF c/4JbD68hTotpViuBiFE/UJoYJSQFYtdX9RdbV8k8rsxB/kEJCmlMC4ADzbUhmNau336 rmIfaMWN/Kl+6OGOHdIS/Gc1FC+/Gv+z1KGLh2VBCrjrLCe7q6besUoFab5OIC4g/3RO M1WutvViM2ZVFt7cMu647l9PpUDOi8cfhlsYlTXRUB4C9lL14wH0CvpORKRUHeUydMDZ ziQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TXcdbY6M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s197si20842130pfc.152.2021.10.18.06.33.01; Mon, 18 Oct 2021 06:33:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TXcdbY6M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232603AbhJRNeJ (ORCPT + 99 others); Mon, 18 Oct 2021 09:34:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:42664 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232059AbhJRNcW (ORCPT ); Mon, 18 Oct 2021 09:32:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 89DBD60EFE; Mon, 18 Oct 2021 13:29:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634563747; bh=QO8j95tTJerGA5WGZ1MrkB6rA66a4Ts7HXGfMmC/R8s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TXcdbY6M2uHnHYX6n0kTCpkwN0hLD+zscNMVFZlyPBe+uegM/rTdgCEOrZrJLkDbG Tl3T0Tn+i8HUc3vnaIBrwSd0sunlbKCGlmB+aK0oONqLxgubyMjaWFEIsy3JNSrY5A oh0dkAvRirzyECniphRoSru30Hu4zSOsPGluTpec= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, John Fastabend , Sebastian Andrzej Siewior , Jakub Kicinski Subject: [PATCH 4.19 48/50] mqprio: Correct stats in mqprio_dump_class_stats(). Date: Mon, 18 Oct 2021 15:24:55 +0200 Message-Id: <20211018132328.110231802@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132326.529486647@linuxfoundation.org> References: <20211018132326.529486647@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sebastian Andrzej Siewior commit 14132690860e4d06aa3e1c4d7d8e9866ba7756dd upstream. Introduction of lockless subqueues broke the class statistics. Before the change stats were accumulated in `bstats' and `qstats' on the stack which was then copied to struct gnet_dump. After the change the `bstats' and `qstats' are initialized to 0 and never updated, yet still fed to gnet_dump. The code updates the global qdisc->cpu_bstats and qdisc->cpu_qstats instead, clobbering them. Most likely a copy-paste error from the code in mqprio_dump(). __gnet_stats_copy_basic() and __gnet_stats_copy_queue() accumulate the values for per-CPU case but for global stats they overwrite the value, so only stats from the last loop iteration / tc end up in sch->[bq]stats. Use the on-stack [bq]stats variables again and add the stats manually in the global case. Fixes: ce679e8df7ed2 ("net: sched: add support for TCQ_F_NOLOCK subqueues to sch_mqprio") Cc: John Fastabend Signed-off-by: Sebastian Andrzej Siewior https://lore.kernel.org/all/20211007175000.2334713-2-bigeasy@linutronix.de/ Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/sched/sch_mqprio.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) --- a/net/sched/sch_mqprio.c +++ b/net/sched/sch_mqprio.c @@ -531,22 +531,28 @@ static int mqprio_dump_class_stats(struc for (i = tc.offset; i < tc.offset + tc.count; i++) { struct netdev_queue *q = netdev_get_tx_queue(dev, i); struct Qdisc *qdisc = rtnl_dereference(q->qdisc); - struct gnet_stats_basic_cpu __percpu *cpu_bstats = NULL; - struct gnet_stats_queue __percpu *cpu_qstats = NULL; spin_lock_bh(qdisc_lock(qdisc)); + if (qdisc_is_percpu_stats(qdisc)) { - cpu_bstats = qdisc->cpu_bstats; - cpu_qstats = qdisc->cpu_qstats; - } + qlen = qdisc_qlen_sum(qdisc); - qlen = qdisc_qlen_sum(qdisc); - __gnet_stats_copy_basic(NULL, &sch->bstats, - cpu_bstats, &qdisc->bstats); - __gnet_stats_copy_queue(&sch->qstats, - cpu_qstats, - &qdisc->qstats, - qlen); + __gnet_stats_copy_basic(NULL, &bstats, + qdisc->cpu_bstats, + &qdisc->bstats); + __gnet_stats_copy_queue(&qstats, + qdisc->cpu_qstats, + &qdisc->qstats, + qlen); + } else { + qlen += qdisc->q.qlen; + bstats.bytes += qdisc->bstats.bytes; + bstats.packets += qdisc->bstats.packets; + qstats.backlog += qdisc->qstats.backlog; + qstats.drops += qdisc->qstats.drops; + qstats.requeues += qdisc->qstats.requeues; + qstats.overlimits += qdisc->qstats.overlimits; + } spin_unlock_bh(qdisc_lock(qdisc)); }