Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7346317rwr; Tue, 25 Apr 2023 11:30:35 -0700 (PDT) X-Google-Smtp-Source: AKy350YG51NvPhIjKvsLuQnCcKs1dmqKd7ZqYbz1ycwNV9CZLNGFGeDxgHmesZjE+GmnTmGDEY/M X-Received: by 2002:a17:903:5c3:b0:1a6:639e:887e with SMTP id kf3-20020a17090305c300b001a6639e887emr17377209plb.13.1682447434956; Tue, 25 Apr 2023 11:30:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682447434; cv=none; d=google.com; s=arc-20160816; b=I4wjfdblY4p+7LbTTIcuzG/9tWEm+L12q3mxFBUfq/xneg1Uy4lxz4w+VxNLmNESn0 FPBQzHFx/A6G8otm6c9swQS1x4AYW6nbjenRGc8/mMQuDonJlaRCGMyGh2i2f+DEbbOd bUHx2kEhKcIxgeOJ6f2dbe1BnA0Xk9YxXjR9XeD3SNZThs9QlR35k2vHtiW0OBxZdjrd EJuEPOTFXxm1GqhdmAVOv0jrjZAMuxt4dztygqEYb4Q/NFuzyz74GrH46qQ2aTqPietp FYOr2q8Jiut3NR9i8ik75I6U+FGuYy2wGbxnUE7eh1XwzcD2FOiNA1bq0yH7Xqm278Tn e9HQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:to:from :subject:message-id:dkim-signature; bh=OEm1h9Fvp/Tk3/rRCqLyzOHEG6dIAISOoeHlaFTz5ic=; b=tNONa2nxZkdJrDUKoNV2XuIpHKzUoTi53mSZK429LKScleno+m5eHn+f3OuwAdN1Jy JbRrIzepnyNAGnSpNOzEAcEl3vRSo3SEEuQcT1YX2hpJGltQC5jYmTVz04Gxd9BYReRj caojsMvso+lhMjNdMw7URXj/bRi1RN4a7N+LuSCOIGm+v0xWXJ1xPTegOSzJHD/MeWfN KgCBZZWcCT3H0pGbfDRRsGBDRLPc3cWqPMnaJyr5Hs7QSmucrh8mCJUnJ+vf7o1Zwsus tI8Sl4Oj1tEbr9G4MrXLR7/2gL9uoxLu1oMxf0Za6LOnbLslkH8Qxq03tFmG4qW0r89D ULzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=OyyqKzPm; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y7-20020a17090a86c700b0023fc6dc1092si16790645pjv.145.2023.04.25.11.30.26; Tue, 25 Apr 2023 11:30:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=OyyqKzPm; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234436AbjDYSTB (ORCPT + 62 others); Tue, 25 Apr 2023 14:19:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231200AbjDYSS7 (ORCPT ); Tue, 25 Apr 2023 14:18:59 -0400 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B49DE7D85 for ; Tue, 25 Apr 2023 11:18:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=MIME-Version:Content-Transfer-Encoding: Content-Type:References:In-Reply-To:Date:To:From:Subject:Message-ID:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=OEm1h9Fvp/Tk3/rRCqLyzOHEG6dIAISOoeHlaFTz5ic=; t=1682446738; x=1683656338; b=OyyqKzPmqTqwgBr6h6q+4PQ2yydLUUMozVVQFeWrgKoUn+n H3YIuC31NWoL5rxA2hzFgVt0DXJKtkC+dIS6K13DmdqHWopHEmL3H9DzWEWim7/VUaw4JXLmYsjNc X3nnnVJPHmpUqCHaufRl6obLH/iqrdAbXDjgry1V/lfpL2CuFUWPcfXJhXpM6j0df3ZaHartCknwg vMhHG8Spyyv9SHnT14YL4JMOWMscJk1JJ7KeChuETQEAAWG7kFRx3pjOhIdkg50TxJmtEMhhfa++L xZGlksnpfzgCwtZH9jozbcoUrYI4OVKxQWPOviA6yQikq5of+MfOD8mXYB+62OQw==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1prNFg-008JGT-0Q; Tue, 25 Apr 2023 20:18:56 +0200 Message-ID: Subject: Re: [RFC PATCH v3] average: change non-init state and add check for added values From: Johannes Berg To: Benjamin Beichler , nbd@nbd.name, linux-wireless@vger.kernel.org Date: Tue, 25 Apr 2023 20:18:55 +0200 In-Reply-To: <20230424210430.390592-1-benjamin.beichler@uni-rostock.de> References: <20230424210430.390592-1-benjamin.beichler@uni-rostock.de> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4 (3.46.4-1.fc37) MIME-Version: 1.0 X-malware-bazaar: not-scanned X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Mon, 2023-04-24 at 21:04 +0000, Benjamin Beichler wrote: > The uninitialized state 0 involves the danger of reaching that state in > normal operation. Since the weight_rcp value needs to be bigger than one > (otherwise no averaging takes place), the final shifting in add ensures, > that the internal state never reach ULONG_MAX. Therefore use this value > to signal, that the ewma has no initial value. >=20 > The add function needs to check, that val is not to big, otherwise the ne= w > value can overflow the internal state, which results in unexpected output= s. This seems nice to me, FWIW. > Move the compile time checks into a separate macro, as they are used > multiple times and noise up the functions. Why do we even have those multiple times? Should be enough to have them once, since we always compile the static inline functions? johannes