Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3023548pxb; Mon, 18 Oct 2021 06:48:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweTzBNgDkJR7I3M/BnCEa2nTm1i3bERG7BYEbk1pl7VVSA//ezAn/n1EEhLuyxotprV7Hv X-Received: by 2002:a63:84c8:: with SMTP id k191mr23484233pgd.158.1634564925298; Mon, 18 Oct 2021 06:48:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634564925; cv=none; d=google.com; s=arc-20160816; b=e7B4aFldEDs6T0VVqIYFBVhkYkv5OMguPY+9SE8VPrynEF6XKLVYK9K7TfuIvzhyko 3YHfX7JPCbYnaoIXbtmix0XEpfMjysSk/SJcppmAs5AiTB1XhTbVyTxyhfQcqZ0QMdnc k5fy6N+u3e57cQMOu6L89A4HoyZyg2QDqPi2/WZcqxQy9FphOxrU2sGUnMlZpnwOo99f y9lXzVXEaywUXxZlEWna12EUJ2vjCkWQ9bo5u4T8jc6Yi/qITxDdI7tO43439ApSuWt8 YehYC9giOcYGgVj4PhQ/5u1l62hLlxs+gccc0CPDAxd9O1T0G90dNq12cUbxRLZVQOIC 6eaA== 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=CFOc3q8Yfa4peG5OcdvJfL7ggrAOie+wYEwfAAQP6Ck=; b=dIa3AvXq5AD5hM0fRxcp3BIUPj7FIe1HFkCIgf+T3Mj0LyV2Rq0a0KiW96HU1ZM8ve uLgs9xCm4yaOorXWcRWl7yOy8NzlFqWoWhbNMGUekiazY29Au9wjHxafLGQjz/LaMIHF XQyeQazmhkmyBxiYEgESamjl8ch/c0TBOZGSkh6GujoL0gQJn2+wAAJXsiStb7MFVyI5 2xT/Yi9yGYlcP+d5Uhhbl3DGyvFp04/D/WKGp/Wi8EiREjmO4dbxBDrjRawX0STrZsnZ J1BNGbrM6FfJhR0L50fUzPvLwPt3PS7q9l5HOFICCAxXnkOOXJL2NKIfALwGPY6xdBVn AF+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DnxI0Ne2; 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 p3si17524306pls.428.2021.10.18.06.48.32; Mon, 18 Oct 2021 06:48:45 -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=DnxI0Ne2; 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 S232934AbhJRNtS (ORCPT + 99 others); Mon, 18 Oct 2021 09:49:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:49508 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232454AbhJRNrk (ORCPT ); Mon, 18 Oct 2021 09:47:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B801F6128E; Mon, 18 Oct 2021 13:36:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634564183; bh=vgO7421nswS0O3mEoLkmcesOBtxJ6kzPILryIbihVac=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DnxI0Ne2LxmZJgwNfp1+Q3I+DS8C4wsBj7wIBLDO/QsKCQI6YAI6ZzFLueWk5qxdz DXnmSU3zut+GiP1DukmqQjWwwXop/rGCEPH7HXYxUQZLyKuM9FOqBCoR7R2RsV1a4h xCGLnLOzboNu5jIJ0I13dSEzlEThvmW+kk1AI2A0= 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 5.10 097/103] mqprio: Correct stats in mqprio_dump_class_stats(). Date: Mon, 18 Oct 2021 15:25:13 +0200 Message-Id: <20211018132337.999774964@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132334.702559133@linuxfoundation.org> References: <20211018132334.702559133@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 @@ -529,22 +529,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)); }