Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp336387rwr; Tue, 25 Apr 2023 23:22:55 -0700 (PDT) X-Google-Smtp-Source: AKy350YXn6dtq5fL35ZeohC7fkd0uVB3ABuYTIxJjBCZdleyduCW18PyDpeVSWk0bBc7RvhHmfSM X-Received: by 2002:a05:6a20:6a1c:b0:ef:b02a:b35b with SMTP id p28-20020a056a206a1c00b000efb02ab35bmr27651534pzk.0.1682490175379; Tue, 25 Apr 2023 23:22:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682490175; cv=none; d=google.com; s=arc-20160816; b=0noi+e2sS7603vrgzrSMm0de5Q/AYaM8ch5uPvCi12wbZOAonHjkQ8e2bmRGWuBzYt OVM8bpqccAnWfLRjg1/Q+9DfCPYOub4PKF4TkzwJE3XRSoL/0gP9U4bi8on6Wrhllkzr Cezr/QiMSRI/h/MdyLVDTe2AqHQ7DG3IMc3kmlhky2GMgBDVQRuSwcH6k3kpp8qRnriR lYZKWTJ2+A2ClObqLooCXeZIDDMYxRdoqRFqrjhPWWV2tDyy1PQ4oP0y8mr//yRZ1mwy D8dBTB7doYoQvrEn9BA7RCbfS4BvuneIxARvlO9S2Xy9b5roh9zR7p1D//j8o6NqJXTx ZX5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:dkim-signature:dkim-signature; bh=e4TxUWFbHfbxvmEdNhXFdc4Bx4m+GTB7XKhuCjCdmvQ=; b=oYbitgkPA4IInNXTaVP7bLCyGDoAcE0saJQgSOm+eQ229MgHqQ2Tigk3zS934kJVkY xHYrDFEbASAofM1Raq73cFwe5JDyYHh/Jrn48tZfYoLCnwPefpdlP+WSSAqAXCUdwGel YbEORb3D9XwWL3iFJdJZ89nfPlRXw1bTq0gA0H5xF4qm6XbUwXEz+/khlALgOplISaJn 0uJzAasjmc6YliLaoOqDH83hsWH9MbveEhtq0hiB1t00NrLVb+fNVz6JG7THenk3++iJ pGX6HJFpJ+ZQuGr0DUObPcuWQTwFxMJeWwc54Zf3zu2Nnxu2DnO09A1iLwvrCXLBDPNd sK1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (no key) header.i=@uni-rostock.de header.b=4r9Iz4VW; dkim=pass header.i=@uni-rostock.de header.s=itmz header.b=k0Z9365x; 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=NONE dis=NONE) header.from=uni-rostock.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t191-20020a6381c8000000b0052881efbda0si1424251pgd.53.2023.04.25.23.22.46; Tue, 25 Apr 2023 23:22:55 -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=neutral (no key) header.i=@uni-rostock.de header.b=4r9Iz4VW; dkim=pass header.i=@uni-rostock.de header.s=itmz header.b=k0Z9365x; 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=NONE dis=NONE) header.from=uni-rostock.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239383AbjDZGTU (ORCPT + 63 others); Wed, 26 Apr 2023 02:19:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239359AbjDZGTT (ORCPT ); Wed, 26 Apr 2023 02:19:19 -0400 Received: from mx2.uni-rostock.de (mx2.uni-rostock.de [139.30.22.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A7FC2134 for ; Tue, 25 Apr 2023 23:19:13 -0700 (PDT) DKIM-Signature: v=1; c=relaxed/relaxed; d=uni-rostock.de; s=itmze; t=1682489951; bh=e4TxUWFbHfbxvmEdNhXFdc4Bx4m+GTB7XKhuCjCdmvQ=; h= Subject:Subject:From:From:Date:Date:ReplyTo:ReplyTo:Cc:Cc:Message-Id:Message-Id; a=ed25519-sha256; b= 4r9Iz4VW2Md+l+GPrfI55YosPbl17VILRz/uRh7jXg6yc42OS4BotQq6GNqrqWKv2hbsKvuFU15V8wQo1GOLDA== DKIM-Signature: v=1; c=relaxed/relaxed; d=uni-rostock.de; s=itmz; t=1682489951; bh=e4TxUWFbHfbxvmEdNhXFdc4Bx4m+GTB7XKhuCjCdmvQ=; h= Subject:Subject:From:From:Date:Date:ReplyTo:ReplyTo:Cc:Cc:Message-Id:Message-Id; a=rsa-sha256; b= k0Z9365x/Q6VwP2qUm/Wnn6tInqWRWyGxpk+pv2q28B2hF6C9DtQLYx41eaJkSxmFGZau3cMbQuQ8aFQ++3Y4aOTwxZv4sC6c0CHjRXSMTlFPdlJjIllZcN1wyqJcWNF2KVH3QTgqFf2NbiP4KaOWbXOvOnpwU6aQ5LK1O1xXg8= Received: from 139.30.22.84 by mx2.uni-rostock.de (Tls12, Aes256, Sha384, DiffieHellmanEllipticKey384); Wed, 26 Apr 2023 06:19:10 GMT Received: from [139.30.201.34] (139.30.201.34) by mail1.uni-rostock.de (139.30.22.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Wed, 26 Apr 2023 08:19:09 +0200 Message-ID: <6d672602-55b2-fb11-2707-84bd360411f2@uni-rostock.de> Date: Wed, 26 Apr 2023 08:19:09 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [RFC PATCH v3] average: change non-init state and add check for added values Content-Language: de-DE To: Johannes Berg , , References: <20230424210430.390592-1-benjamin.beichler@uni-rostock.de> From: Benjamin Beichler Organization: =?UTF-8?Q?Universit=c3=a4t_Rostock?= In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed X-Originating-IP: [139.30.201.34] X-ClientProxiedBy: EMAIL2.uni-rostock.de (139.30.22.82) To mail1.uni-rostock.de (139.30.22.84) X-TM-SNTS-SMTP: F98BB533A878CA01E4A04554030DAFC7F7BB3035E533284687BB5988F4E7C00D2000:8 Content-Transfer-Encoding: QUOTED-PRINTABLE X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MIME_QP_LONG_LINE,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,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 Am 25.04.2023 um 20:18 schrieb Johannes Berg: > =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =5F=5F=5F=5F=5F=5F=5F > Achtung! Externe E-Mail: Klicken Sie erst dann auf Links und Anh=C3=A4nge,= nachdem Sie die Vertrauensw=C3=BCrdigkeit der Absenderadresse gepr=C3=BCft ha= ben. > =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =5F=5F=5F=5F=5F=5F=5F > > 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=5Frcp 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=5FMAX. Therefore use this value >> to signal, that the ewma has no initial value. >> >> The add function needs to check, that val is not to big, otherwise the new >> value can overflow the internal state, which results in unexpected outputs. > This seems nice to me, FWIW. Okay. I would split up the patch into sensible parts and send it later. You are also fine with the extra init function with explicit init value=3F Of course this one also needs the check, that it really fits into the internal state :-D > >> 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=3F Should be enough to have them > once, since we always compile the static inline functions=3F Good question ... my assumption was, that the build-bug macro may not work, if the function is unused and maybe optimized away, but I'm not that familiar with those details. I'm more in favor with the static=5Fasserts of C++, which have defined semantics. :-D It would be nice to put the check into the struct, as some zero size bad member, but I found no example in the kernel, so maybe this is not easily doable. One may argue, that we only put it in init and if the users do not use init, we call it shit-in-shit-out, but I'm not really in favor of that. Anyone with more experiences on build time asserts in the kernel=3F Benjamin