Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp375989pxb; Sat, 21 Aug 2021 05:20:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwONB2EJv+5LL0p2laaJgvNmHu4sSO9+VmmGu6mZP+jM0OzTTS7PPYhoPbkvFdtp1M63bUs X-Received: by 2002:a17:906:454b:: with SMTP id s11mr26488550ejq.1.1629548426365; Sat, 21 Aug 2021 05:20:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629548426; cv=none; d=google.com; s=arc-20160816; b=uoUA88B/C7FBAYfppzNnY2mEN7cviqI8rX7fODe/jXvuGM2SwIHZMgn3o204xpOE/T gIuKYPZ0B9VmSD3PBvLhK73Fzw8GnNbGRWzT6MU72Vywn09uI9gzufZ0EBuARelzYVIt 4GacLHmpQeP5AFagfoRRgi+as8536R87qsc/0AVtFYFNVrhty4WizFTo28AOU/4c9AAO Hs5CG290KY12z+xCnjFo0HZsK2LVDgRiQDroitnHESRf3NWYI3kUrIJvYDUd9RNp/x1Z caUXNXHe3wY2XqIcSmqyWB779o7bX4EplSfq4c+VnPVm6MIJCEqwpyVa5kFUJYmwjc3z s7OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=xDEu1apr1ZnQzl/vySKKVEKHlIYsqj07eYdtsvYFaQo=; b=kA5yNCoix3fhzhANck5+rN4wbh6fbP5XBTrUH4DA/TPNEpgEIF9z5W7uZwfKVMZTmC KPfP6H6x8w6hIDsaB2QI9ojr7G7TBE8rcaDwTuSZBxAyh22ym/1NR32hTZ4nt5W73Oq+ qIekdoWuJZz/gtOk6gow1pqVYyCp2DoIOocDRI6x8w5+JSFZaqABDBEYcpKvYkvdG34e wGwfB65eQISbbj/ZwrSMc32C4YTcPxv5SjqnYa7/oShIlHI6oxxw9HUVHotUXndiQ1Xt uVkVJ25HgtpbCfIK/oNc709VWgXTlFFwhMj+c3Jo3uHMS4ba4EOTygy5hYoyUicNzP3l uB6g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j3si9712773edp.549.2021.08.21.05.19.57; Sat, 21 Aug 2021 05:20:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234496AbhHUMUX (ORCPT + 99 others); Sat, 21 Aug 2021 08:20:23 -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-wireless@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