From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E027C4320A for ; Sat, 21 Aug 2021 12:19:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DE11B61214 for ; Sat, 21 Aug 2021 12:19:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234636AbhHUMUY (ORCPT ); Sat, 21 Aug 2021 08:20:24 -0400 Received: from wtarreau.pck.nerim.net ([62.212.114.60]:37816 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229968AbhHUMUW (ORCPT ); Sat, 21 Aug 2021 08:20:22 -0400 Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 17LCJ0Nc000440; Sat, 21 Aug 2021 14:19:00 +0200 Date: Sat, 21 Aug 2021 14:19:00 +0200 From: Willy Tarreau To: Oleksandr Natalenko Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, Jakub Kicinski , "David S. Miller" , Johannes Berg , Felix Fietkau , Lorenzo Bianconi , Ryder Lee , Kalle Valo Subject: Re: Divide error in minstrel_ht_get_tp_avg() Message-ID: <20210821121900.GA32713@1wt.eu> References: <20210529165728.bskaozwtmwxnvucx@spock.localdomain> <20210607145223.tlxo5ge42mef44m5@spock.localdomain> <2137329.lhgpPQ2jGW@natalenko.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2137329.lhgpPQ2jGW@natalenko.name> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Aug 21, 2021 at 01:14:34PM +0200, Oleksandr Natalenko wrote: > > > So, it seems `minstrel_ht_avg_ampdu_len()` can return 0, which is not > > > really legitimate. > > > > > > Looking at `minstrel_ht_avg_ampdu_len()`, I see the following: > > > > > > ``` > > > 16:#define MINSTREL_SCALE 12 > > > ... > > > 18:#define MINSTREL_TRUNC(val) ((val) >> MINSTREL_SCALE) > > > ``` > > > > > > ``` > > > > > > 401 static unsigned int > > > 402 minstrel_ht_avg_ampdu_len(struct minstrel_ht_sta *mi) > > > 403 { > > > > > > ... > > > > > > 406 if (mi->avg_ampdu_len) > > > 407 return MINSTREL_TRUNC(mi->avg_ampdu_len); > > > > > > ``` > > > > > > So, likely, `mi->avg_ampdu_len` is non-zero, but it's too small, hence > > > right bitshift makes it zero. (...) > I've also found out that this happens exactly at midnight, IOW, at 00:00:00. > Not every midnight, though. > > Does it have something to do with timekeeping? This is strange, I wouldn't > expect kernel to act like that. Probably, some client sends malformed frame? > How to find out? Well, in minstrel_ht_update_stats() at line 1006 avg_ampdu_len is explicitly set to zero. And this seems to be called based on timing criteria from minstrel_ht_tx_status() so this could confirm your experience. Thus there is some inconsistency there. Willy