Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3040813pxb; Mon, 18 Oct 2021 07:08:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgz3WndKcoRwpAQVP4ic2qL5XYcktp/dAa0UIB/JtJDQOCcJEQZTXKFxOSYomc3dvccnGG X-Received: by 2002:a17:907:8a12:: with SMTP id sc18mr28714552ejc.569.1634566088333; Mon, 18 Oct 2021 07:08:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634566088; cv=none; d=google.com; s=arc-20160816; b=kBAkxlnTFOLj0duJPMXG69WK2pBS5DeAYdTq3SSsbBK5YeULwx6YfP5eaWZ+8DRlvN VNdeSV7CLwHIPmgT81sq2Y0Go0mGeqnfi+4RchgchDA1qU00/oXwa5lV1Bx6RdSDTinb 5X10brVW2LFefUblB2IFqK4b/cotziaI6aPx4QpHRrisELFAc/qFxYnIwVIaJVNqV+bN LN5NBxrmmG8g2sSN88y8/S6lkFbtnXjwMUArwNLWHrwA22VP7WJSi5Z73ZjH1OzKs2XF ZHhemlWIj7vqI5euOpP08Iqan3+c6m4IZK2K0q2/4BiSrvMH+sBLUjdbHOl9TSc/YckO j3oA== 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=ADynOaYhAz3CIsqud4+gdsr3B0ikcGsMA6TF+KY2E0uHiSIvh9Do9ycZWB6g9bTjU9 uR0+DFTuqeX9wPlMvyYRGXhTv94LDkiFl7/VpBaUiJtq97QFXSlINf7uzjgJXVHNPRBH G/6SeoaKcqC7uHdMTPsclLAP6eNVARm8htRT1A4DEqEmL6QPAYSxnPzYInyoAcI4oly2 2AEKrwc8KAyJf/PHxZsvdoLrL3uUITHlApd1Qx1uWdX5vHSotNAb3xwIwAj3a9o5ulY0 DFKlGetan+BmwXnxwv0seckJwcPmwLlFo4u/PxVyWOc37AHXuGOLHM0XnbAgQE3/wIzV HzkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vzGnUQBj; 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 k13si19133336eja.414.2021.10.18.07.07.43; Mon, 18 Oct 2021 07:08:08 -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=vzGnUQBj; 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 S234907AbhJROGo (ORCPT + 99 others); Mon, 18 Oct 2021 10:06:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:40798 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234979AbhJRODl (ORCPT ); Mon, 18 Oct 2021 10:03:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 54305613A7; Mon, 18 Oct 2021 13:43:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634564624; bh=vgO7421nswS0O3mEoLkmcesOBtxJ6kzPILryIbihVac=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vzGnUQBjJtC2ByhZdhzGDaaZvaGAsMT76g6jyQ2SmsPDqxX/U17fZcmR2raUz2DK2 2Y6txMZ52/Z104s/Ek3zxDkYasJgxLQZGEI2pqytTbfZrxbP86lMyK7IudF/UIfGS2 EuN3kuzY21QPcSHRErxVUNxtFAA0Jw943sv/yHPI= 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.14 138/151] mqprio: Correct stats in mqprio_dump_class_stats(). Date: Mon, 18 Oct 2021 15:25:17 +0200 Message-Id: <20211018132345.150770812@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132340.682786018@linuxfoundation.org> References: <20211018132340.682786018@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)); }