Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp893338rwd; Thu, 1 Jun 2023 07:54:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Es8Y8/w9bHrtpQKsmPtGKnRqWXEg4G0YOEXj+C6PnUuew8whwyVny9zdBfqAjd8BjEZgU X-Received: by 2002:a17:902:9b87:b0:1aa:f203:781c with SMTP id y7-20020a1709029b8700b001aaf203781cmr5526922plp.44.1685631282637; Thu, 01 Jun 2023 07:54:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685631282; cv=none; d=google.com; s=arc-20160816; b=E8GlViYEFFZA3LTBfUBQuNvgiMfWh793JMbvuWBvlQFAxhfhv1vbhlzzYg/T0+0jd2 h9556iKIvLwXt88EJIaS+Ct7gbrYnwRTy5X2UsdWqnSP6tues4daVgTTHsdGKmiYvfYx k0z/KfGcZ13BKuRFeLKk9JQiDy3JC7GkzmFSUqv9qzi7clst59gSIhLFZ4DduDLIghOu pX/MWEE86CYpNjxl1L5SyrHCubDvnwneTBe1uAiy9PqWM/f88xhJ9dBkAW9laRqNyNrD Ebsk7yvwqCobZ4kGsRb+4wUT7Xd8NGsTUnf9cVG0Cp6kaNyQ94EkSTQ1yaI+pySXqaIm c8Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Yj/+F86ImX5bW6d1HCDCVFjQFnm+jmUbdbf0quByU6M=; b=cpZ9zWNXvzjs3qBjtFjx5rtEMDWcUcUgr+uYG+TLdouEwteUNExukCvUbXMfX3XMmc Cf53YesVXFS2PeBqStnKoa2OIRJW6sMPnX/Aw9Ed9Ob7bLPaSyveR+EdgpU42VbqsBEh hDEtPp1nXML+g654YBx7Bs5Zdja7p5QZ5FEkfaLdByoTPLJhpNDxIlJsBAuK1h6j6RWn kJNPwmAxizkxabBVHqcXbs0vG9WTEqyKfFRhgAeoUCjpggQsNteunVRgFN+0cI4yHNdK VpNjMQR20+MYTeSHOx2f+qpIjDhyE8w4GVddcKxgzlXDWkLTPM2WDwuvkz++Tsa19gBG 95RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=TNCLAftt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q6-20020a170902dac600b001b02722139asi2942567plx.494.2023.06.01.07.54.28; Thu, 01 Jun 2023 07:54:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@google.com header.s=20221208 header.b=TNCLAftt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234528AbjFAOqG (ORCPT + 99 others); Thu, 1 Jun 2023 10:46:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234355AbjFAOp5 (ORCPT ); Thu, 1 Jun 2023 10:45:57 -0400 Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 721161B9 for ; Thu, 1 Jun 2023 07:45:39 -0700 (PDT) Received: by mail-qt1-x82a.google.com with SMTP id d75a77b69052e-3f6a6e9d90dso271121cf.0 for ; Thu, 01 Jun 2023 07:45:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1685630738; x=1688222738; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Yj/+F86ImX5bW6d1HCDCVFjQFnm+jmUbdbf0quByU6M=; b=TNCLAftt3Sq3ibkhD0YZTfkW5mUDcT6HDFygkTiE/ZIUkWpteiBdW/IWdD7REpV/15 aMo4rYTS2NmIard6ca23NRCb5X4vJ7dEjp3GE83gKHmzWiIPOhn4m+IjShzjlaGr3jPf CZKHiyW1sgcqAxVUWtprGk3w94EjLk2MUi/f0S4PXOU/Tn/+FJNcBvHYk9XLsA7ckuQM y+ycyQTPOiV05UJ6JCrACyNfcV/MkfCxVJhy9g3XRtGrbDsdMmw6AOi1sph3MjP2PgzL jAaOSFjMqyaeBholQjRFB90SGtCRzJKNuaVvdISBfzlv/hkyCcW9NNdSyqvOmom8ggYb VycA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685630738; x=1688222738; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Yj/+F86ImX5bW6d1HCDCVFjQFnm+jmUbdbf0quByU6M=; b=jJVFB/ySTRBhKzjyW0M0as0/22rUCJyqWNIQAjOs02YA/tzZUD7QeLEUKm5wU/oWIr W+kdzpPY1xqYF1dwQtn/mkU+dwBwSSi80zmjsDUtGd1ENXRXlbNN5dQsdDO3uCKvGyq0 aT6nFkjnAmUuNuhdbh/IhBzXWLViR7fCGp8+8gn+Lu4RGF55TAfqv1l0PHhxmVV9dfrf 77vvS6d4mpNNfEDfYWysEgEVlvlSlp6mfsTksUNv9GKxk0BtPwy9OhxnAKx9urcwes/7 TKbS9bHlXCfQYYL1R5VaPyGlQu3QCEpt+72+AVyCqAISddeg8blz+VWDcv2HPAcVSOfC ZDxA== X-Gm-Message-State: AC+VfDzNaOvb4v6y3YlIST5jYp2u8NmsPtzxbmDW6la0vzXOpOzpxRxd wIIrm6N2VXI8CeTo4ZrRY/HSyz/C9nI4jWb/2zqJgA== X-Received: by 2002:a05:622a:1102:b0:3e8:684b:195d with SMTP id e2-20020a05622a110200b003e8684b195dmr253911qty.10.1685630738485; Thu, 01 Jun 2023 07:45:38 -0700 (PDT) MIME-Version: 1.0 References: <20230421141723.2405942-1-peternewman@google.com> <20230421141723.2405942-4-peternewman@google.com> <38b9e6df-cccd-a745-da4a-1d1a0ec86ff3@intel.com> In-Reply-To: <38b9e6df-cccd-a745-da4a-1d1a0ec86ff3@intel.com> From: Peter Newman Date: Thu, 1 Jun 2023 16:45:27 +0200 Message-ID: Subject: Re: [PATCH v1 3/9] x86/resctrl: Add resctrl_mbm_flush_cpu() to collect CPUs' MBM events To: Reinette Chatre Cc: Fenghua Yu , Babu Moger , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Stephane Eranian , James Morse , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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-kernel@vger.kernel.org Hi Reinette, On Thu, May 11, 2023 at 11:37=E2=80=AFPM Reinette Chatre wrote: > On 4/21/2023 7:17 AM, Peter Newman wrote: > > + /* Count bandwidth after the first successful counter read. */ > > + if (counter->initialized) { > > + /* Assume that mbm_update() will prevent double-overflows= . */ > > + if (val !=3D counter->prev_bytes) > > + atomic64_add(val - counter->prev_bytes, > > + &m->soft_rmid_bytes); > > + } else { > > + counter->initialized =3D true; > > + } > > + > > + counter->prev_bytes =3D val; > > I notice a lot of similarities between the above and the software control= ler, > see mbm_bw_count(). I see the "a=3Dnow(); a-b; b=3Da;" and the not handling overflow parts being similar, but the use of the initialized flag seems quite different from delta_comp. Also mbm_state is on the arch-independent side and the new code is going to the arch-dependent side, so it wouldn't be convenient to try to use the mbm_bw structures for this. From this, I don't think trying to reuse this is worth it unless you have other suggestions. -Peter