Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp8152496ybn; Tue, 1 Oct 2019 04:07:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqzIslLbaLJMeeQLJIaRVzzNV5s6tRBO/19wBOmvbt31pxBmwHU8vVseC+qoya2K3Kk0YYvb X-Received: by 2002:a17:906:18e2:: with SMTP id e2mr23328860ejf.129.1569928055321; Tue, 01 Oct 2019 04:07:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569928055; cv=none; d=google.com; s=arc-20160816; b=m5Aq8FiGLn5KgqwnIzYOaiqS1ep/7dxwYskt7IELidWOziQPoioT/ke/1mvURiGmcv AdzP7RLT1lpiIx8xeJQoRyJ2oMD1Yo4ckYsmDW9Ddlbdak/IuVLn0rSG0r9m0q9K2Qkw F639YgA2FSVCWEJSSj8e11oOfHl4wXbCvwPHkaC+73em5mIoWH2Tgf+R0FsTxjChDYld 8FxAMqRWWKYOoFNH5USyhQymliPHtS5UFBcmeYYy8fPUJTmMl3RRS3K2qcnHchwSFdIH We0qy8Vf2vbtwioQhl00/unzVx65nqb82mSh+rGkZMO1HIl72lvLkPhUjvDsz6D5v3cI LGfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:to:from:subject:message-id; bh=bS45XsrkDqT/VYoc+t7Kbzzz8jef2wUBv1ZPOFKdEQ8=; b=DX3k25tbXtnUSpAKsTcwGpkWNHaQf3V46fwEUtOqUTuqatXG6TzpUtHFVoNEjOiz/Q bukss3gu2Uj+KAaFsgeEGcNmD6bdsdjM04oECDZqzP1EmLUMgaGfNtsALHYIZ5JegkLd NzLgGQyhCtw3pfGhbnheH1yd5BtSMxW5T0P0JkEAzMWdGBy5+kUGUA6FFZCo6enKZwvr Cr47W7OrXacJ40+vhjPMSbli+DcZj1Pe8hlN5u+E7HHYAw6KovmRglaoLx5EvWLEMRbb 1LILXolVWILPLDNke+52EI5hK8T9VonWa0/alsIheRASAN+urPOxjDq7zYvyBgo3YTB9 t9gA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k17si8349718ejz.227.2019.10.01.04.07.10; Tue, 01 Oct 2019 04:07:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726939AbfJALGV (ORCPT + 99 others); Tue, 1 Oct 2019 07:06:21 -0400 Received: from s3.sipsolutions.net ([144.76.43.62]:59826 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725900AbfJALGU (ORCPT ); Tue, 1 Oct 2019 07:06:20 -0400 Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.92.2) (envelope-from ) id 1iFFz1-0006CO-1x; Tue, 01 Oct 2019 13:06:19 +0200 Message-ID: <8017042b74a05df72a7ebfb5ec21fc7cc088ed4e.camel@sipsolutions.net> Subject: Re: [PATCH 2/2] mac80211: minstrel_ht: replace rate stats ewma with a better moving average From: Johannes Berg To: Felix Fietkau , linux-wireless@vger.kernel.org Date: Tue, 01 Oct 2019 13:06:18 +0200 In-Reply-To: <017c1a59-edf2-0a1a-aa8c-3c32e57d6cd0@nbd.name> References: <20190929154646.90901-1-nbd@nbd.name> <20190929154646.90901-2-nbd@nbd.name> <017c1a59-edf2-0a1a-aa8c-3c32e57d6cd0@nbd.name> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.30.5 (3.30.5-1.fc29) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Tue, 2019-10-01 at 12:52 +0200, Felix Fietkau wrote: > > Might be useful, yes. The main issue here is that the period / window > size has to be hardcoded through the coefficient values, unless we find > a way to do floating point math, including exp() and cos() at compile > time, including conversion to fixed point. Works fine for me? #include #include #include #define E(x) ((int)(exp(x) * (1<<20))) #define C(x) ((int)(cos(x) * (1<<20))) int main() { int e2 = E(2); int c2 = C(2); printf("e2: %d\n", e2); printf("whole: %d frac: %d\n", e2 >> 20, e2 & ((1 << 20) - 1)); printf("c2: %d\n", c2); printf("sign: %s whole: %d frac: %d\n", c2 < 0 ? "-" : "", abs(c2) >> 20, abs(c2) & ((1 << 20) - 1)); } objdump -dr test: [...] 0000000000401040
: 401040: 48 83 ec 08 sub $0x8,%rsp 401044: be 92 39 76 00 mov $0x763992,%esi // exp(2) * (1<<20) 401049: bf 10 20 40 00 mov $0x402010,%edi 40104e: 31 c0 xor %eax,%eax 401050: e8 db ff ff ff callq 401030 401055: ba 92 39 06 00 mov $0x63992,%edx 40105a: be 07 00 00 00 mov $0x7,%esi 40105f: 31 c0 xor %eax,%eax 401061: bf 2b 20 40 00 mov $0x40202b,%edi 401066: e8 c5 ff ff ff callq 401030 40106b: be 77 57 f9 ff mov $0xfff95777,%esi 401070: bf 18 20 40 00 mov $0x402018,%edi 401075: 31 c0 xor %eax,%eax 401077: e8 b4 ff ff ff callq 401030 40107c: b9 89 a8 06 00 mov $0x6a889,%ecx // cos(2) * (1<<20) 401081: 31 d2 xor %edx,%edx 401083: 31 c0 xor %eax,%eax 401085: be 20 20 40 00 mov $0x402020,%esi 40108a: bf 22 20 40 00 mov $0x402022,%edi 40108f: e8 9c ff ff ff callq 401030 [...] johannes