Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp313742pxb; Fri, 15 Jan 2021 04:06:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJw2yykp4vkjXUll/29G+q1dcaQR6AV0Vt7RnoirmZwnfGNPlCBlUkh3+6kM7yaXGUv3d8yT X-Received: by 2002:a17:906:4893:: with SMTP id v19mr643812ejq.454.1610712386743; Fri, 15 Jan 2021 04:06:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610712386; cv=none; d=google.com; s=arc-20160816; b=COxpqJ7GyuydJgSbLSApjEA0aFZJJxKic1TnTHIjpUxp98NEYey7XL8rkp7gUb9nI8 WjgJoKE+qyqwRph5UHtnMMCjWDD8IX0BX4+/oGcanu+qQnXMahzXnGTSQgFgZMw8FsiI SAy8V3N/dkafNSlL37f2KjJvlLZbbvJJb9PymcB5VMfbJnGhCrnEfSwMha/NSIPxyo/3 CXCxDrKKZFnmlfSfkVRq999pejvbsMFzh2CBlhRQ5eFNUrirX92bWmX7J1Fvng0lhgbG XVKbhyv2iFO0pKUJJ0q4nXkHsKEhL8Nwp6qbeZ5FbBJtOtdz+8nabfJlYJ5vHWv0tDK6 sDaQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=OVQpEEDveWeQgJiIBCw9TIVF7ODOND/QMES/7ziT390=; b=rRIn8qGI8VP8UtXfMoz/yCVPpE+yV8daK/5x12b8mfCgg/rKh7VlTnj0ix9wB+qPMC 3ZqRWMZqKkpcMtnwU13vSCXQVMATDpaId2V17p2jX8zbWjRb0shJRmqqUUOYmb9LwewL gWt5glAdQTar02EWKl3qQM2242CAnOkYfOrO+uZnIYx4DV0XuU8sJO/VdcvzUyCPGtZ0 NSUlOm9xLsg02jXWx0JteMXXlaoxtszS6UiWRKjh3LSIFFIKJY4ReH/AGwMmMOeYFXp2 xewafEr+oa6+zEk+0rKQGrQpGAqmXOwuhCL5g/fbFlMlLW2EVghpKgR8LSQxA7LfdJXH HGRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nbd.name header.s=20160729 header.b=IbqAymDs; 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 o9si2961638ejr.672.2021.01.15.04.06.03; Fri, 15 Jan 2021 04:06:26 -0800 (PST) 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; dkim=fail header.i=@nbd.name header.s=20160729 header.b=IbqAymDs; 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 S1730699AbhAOMEP (ORCPT + 99 others); Fri, 15 Jan 2021 07:04:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726085AbhAOMEP (ORCPT ); Fri, 15 Jan 2021 07:04:15 -0500 Received: from nbd.name (nbd.name [IPv6:2a01:4f8:221:3d45::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5CF4C06179C for ; Fri, 15 Jan 2021 04:02:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nbd.name; s=20160729; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=OVQpEEDveWeQgJiIBCw9TIVF7ODOND/QMES/7ziT390=; b=IbqAymDswBEYitg+EClnkQUyZM 9a6Bgzzi9qfNRdX+BdtAVMmDsffO+k1JaEgRBddaz7eNSRJHhHvPZCrPTudwyO0aDhbkojOcFhjjC hQzqer8ALxmA95OPA+yQWEyGPfUdkwZELoG4Vo9FLA9NciiBI5S6Y4mm6Elfjm1S03JQ=; Received: from p54ae91f2.dip0.t-ipconnect.de ([84.174.145.242] helo=localhost.localdomain) by ds12 with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.89) (envelope-from ) id 1l0NoV-0006Y0-Ds; Fri, 15 Jan 2021 13:02:47 +0100 From: Felix Fietkau To: linux-wireless@vger.kernel.org Cc: johannes@sipsolutions.net Subject: [PATCH v3 9/9] mac80211: minstrel_ht: fix rounding error in throughput calculation Date: Fri, 15 Jan 2021 13:02:42 +0100 Message-Id: <20210115120242.89616-10-nbd@nbd.name> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210115120242.89616-1-nbd@nbd.name> References: <20210115120242.89616-1-nbd@nbd.name> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On lower data rates, the throughput calculation has a significant rounding error, causing rates like 48M and 54M OFDM to share the same throughput value with >= 90% success probablity. This is because the result of the division (prob_avg * 1000) / nsecs is really small (8 in this example). Improve accuracy by moving over some zeroes, making better use of the full range of u32 before the division. Signed-off-by: Felix Fietkau --- net/mac80211/rc80211_minstrel_ht.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c index 6496aa39f60b..9e010c8dd063 100644 --- a/net/mac80211/rc80211_minstrel_ht.c +++ b/net/mac80211/rc80211_minstrel_ht.c @@ -445,10 +445,9 @@ minstrel_ht_get_tp_avg(struct minstrel_ht_sta *mi, int group, int rate, * (prob is scaled - see MINSTREL_FRAC above) */ if (prob_avg > MINSTREL_FRAC(90, 100)) - return MINSTREL_TRUNC(100000 * ((MINSTREL_FRAC(90, 100) * 1000) - / nsecs)); - else - return MINSTREL_TRUNC(100000 * ((prob_avg * 1000) / nsecs)); + prob_avg = MINSTREL_FRAC(90, 100); + + return MINSTREL_TRUNC(100 * ((prob_avg * 1000000) / nsecs)); } /* -- 2.28.0