Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp816532rwd; Tue, 16 May 2023 08:04:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5vsgqK/01vr072UxKHUWXsq/ies/Gkmyek8l8m+dYPtNYNFKyXqMneT/qBE8rXvYB9QKDr X-Received: by 2002:a05:6a20:a11f:b0:106:a78f:be1d with SMTP id q31-20020a056a20a11f00b00106a78fbe1dmr5860393pzk.20.1684249494790; Tue, 16 May 2023 08:04:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684249494; cv=none; d=google.com; s=arc-20160816; b=o9YL36SHdbOuntGH1OAI/uJW27XOBnWYtz/fb4wLB/ud5IK4Hq90GllOwR0t0RqcJD Tw6u1IM95oW6e86OeJwj9NL/mj1nPoOVDo+fZk9ajV6ep6uae0qXJFMe5jbfv12q8KCJ 3ubs0xYtmkRuc/H0i1cxM0SNy9vqyYQz9brsjHqeo5qg1RDRMecfTA42qm9i66PGc8A6 XW1GilMciPh4FWx3Uj53Idgon2nKOCqvKHbu0T8goBaA9l2wRTkipuPvvNGIgNarpxvr YDQXSPjASxg4Z0Teinbb0cKrSdIZ4R6J3m3Ar3Yu1sfXEYwiv42jhjvXwJ6DXY/ldY8V iO5w== 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=rOyuxQWRj7mBxcG4uzXJBTcD+VFjWgiMqfEKYgz0FxE=; b=IOvzddIj951DW35l6ciSIwmuAPdK6A6yglysz+TlWtix17CGchpZa9bDX5juyOgYu1 m3h/hDZ2qQhKpvn+p6fPXGAFnlBoz0n9woZgPTS/1RLezTFGT/E06Jylf4ajMEAH4WSd Kbo0Z3bEGXRLBfbBp9ILSljaNlpF63Z3DBjgXc/4qX1E24Hb7AZnbFw4Mdm7y99L+L+K dp5sMd+fjFDwOPiks0/3RXB9mKeikketdZ5elJyUWP9In4kJHsLvkYajfpDffLU56k2N mkpf+28cilMnneqCBiv8y+QxUOmMLcuDBF+fwmZW4QdRJ0HG+A1nggv7VCfiYQNM6/kb 4Tzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=Lz0Tiqnc; 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 n20-20020a637214000000b005131739af72si18412984pgc.755.2023.05.16.08.04.31; Tue, 16 May 2023 08:04:54 -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=Lz0Tiqnc; 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 S232509AbjEPOt0 (ORCPT + 99 others); Tue, 16 May 2023 10:49:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232434AbjEPOtZ (ORCPT ); Tue, 16 May 2023 10:49:25 -0400 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AF96101 for ; Tue, 16 May 2023 07:49:24 -0700 (PDT) Received: by mail-qt1-x833.google.com with SMTP id d75a77b69052e-3f38824a025so1826901cf.0 for ; Tue, 16 May 2023 07:49:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684248564; x=1686840564; 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=rOyuxQWRj7mBxcG4uzXJBTcD+VFjWgiMqfEKYgz0FxE=; b=Lz0TiqncdRoXeVjHg44OrLFE2qLcXpMeVi+QvnvDEREwT9C5xa+IqBu3GpPJCqw/Q2 CvlsVAr7+c0jqQC6ixXNANzKotTrwahGzP3+29GAM9ONPuJ7OWs8jSoRbhD2was1U3n+ lq3Y3ZwbsHYzT7dydr5i4WwmqlaNitZcKehrbdbtUk8DNeVT6/wJpMlnArEPxJpE+LQW H9wGLfgaZVg0P6YGffsllV7wPquF4UpgSo32ORWhhZCX/blykpQ8/Dyw9yiLslVYoylD E9/uqMDbmSjtjYCyzQ6bWrs0qRSNfZG6nldBlho4sNyOqiyEAcrfscCpm3D/+lcafV0f JnkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684248564; x=1686840564; 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=rOyuxQWRj7mBxcG4uzXJBTcD+VFjWgiMqfEKYgz0FxE=; b=OGXn2nPFqrCitTDk0Dq9Zazxdgl+WIa0sUnI3RvOgGrDmBYa5Ejj0PFYnHHAmZVRDm G6SHOdeU0ZJBhm3mCon3+hGrSV73zKVJrduhgE8qGUajUP9tcuLRcdywm48oQK8H3kMB WX9rDgeYEpmLMVTzk9qA0aKCePa6L/Sq8qvktnZQUAVIhEtzVUfU4O0n9E0Jfuq1exet SdNglFUEMiArQYX6QlrZ9FDvMik/hNw+3tDwrYwB8NOturksE88Z77zTPttrH0aYFX5y t+w8HKIX4Nj530tkFblIkB++ZtfMbmK9dZyAVlSJDAL/sZjFl7C8zqu7C7iu1ZOIW1MF 13Gw== X-Gm-Message-State: AC+VfDwF2wUiqutEt/KH7Eq2uaOQkuZIRmH0I9aybZUujj5aibIGhVmZ NOabPh+Z9rkmdPyarSwb5Lfsewe9kUO7+3/yfwjPHQ== X-Received: by 2002:a05:622a:1a24:b0:3bf:e4e0:26a0 with SMTP id f36-20020a05622a1a2400b003bfe4e026a0mr368805qtb.14.1684248563679; Tue, 16 May 2023 07:49:23 -0700 (PDT) MIME-Version: 1.0 References: <20230421141723.2405942-1-peternewman@google.com> <20230421141723.2405942-8-peternewman@google.com> <3816ccf6-4f74-6406-5ca0-580743efa2a1@intel.com> In-Reply-To: <3816ccf6-4f74-6406-5ca0-580743efa2a1@intel.com> From: Peter Newman Date: Tue, 16 May 2023 16:49:10 +0200 Message-ID: Subject: Re: [PATCH v1 7/9] x86/resctrl: Assign HW RMIDs to CPUs for soft RMID 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=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-kernel@vger.kernel.org Hi Reinette, On Thu, May 11, 2023 at 11:40=E2=80=AFPM Reinette Chatre wrote: > On 4/21/2023 7:17 AM, Peter Newman wrote: > > + /* Locate the cacheinfo for this CPU's L3 cache. */ > > + for (i =3D 0; i < ci->num_leaves; i++) { > > + if (ci->info_list[i].level =3D=3D 3 && > > + (ci->info_list[i].attributes & CACHE_ID)) { > > + l3ci =3D &ci->info_list[i]; > > + break; > > + } > > + } > > + WARN_ON(!l3ci); > > + > > + if (!l3ci) > > + return 0; > > You can use "if (WARN_ON(..))" Thanks, I'll look for the other changes in the series which would benefit from this. > > + rmid =3D 0; > > + for_each_cpu(i, &l3ci->shared_cpu_map) { > > + if (i =3D=3D cpu) > > + break; > > + rmid++; > > + } > > + > > + return rmid; > > +} > > I do not see any impact to the (soft) RMIDs that can be assigned to monit= or > groups, yet from what I understand a generic "RMID" is used as index to M= BM state. > Is this correct? A hardware RMID and software RMID would thus share the > same MBM state. If this is correct I think we need to work on making > the boundaries between hard and soft RMID more clear. The only RMID-indexed state used by soft RMIDs right now is mbm_state::soft_rmid_bytes. The other aspect of the boundary is ensuring that nothing will access the hard RMID-specific state for a soft RMID. The remainder of the mbm_state is only accessed by the software controller, which you suggested that I disable. The arch_mbm_state is accessed only through resctrl_arch_rmid_read() and resctrl_arch_reset_rmid(), which are called by __mon_event_count() or the limbo handler. __mon_event_count() is aware of soft RMIDs, so I would just need to ensure the software controller is disabled and never put any RMIDs on the limbo list. To be safe, I can also add WARN_ON_ONCE(rdt_mon_soft_rmid) to the rmid-indexing of the mbm_state arrays in the software controller and before the resctrl_arch_rmid_read() call in the limbo handler to catch if they're ever using soft RMIDs. -Peter > > > + > > static void clear_closid_rmid(int cpu) > > { > > struct resctrl_pqr_state *state =3D this_cpu_ptr(&pqr_state); > > @@ -604,7 +636,12 @@ static void clear_closid_rmid(int cpu) > > state->default_rmid =3D 0; > > state->cur_closid =3D 0; > > state->cur_rmid =3D 0; > > - wrmsr(MSR_IA32_PQR_ASSOC, 0, 0); > > + state->hw_rmid =3D 0; > > + > > + if (static_branch_likely(&rdt_soft_rmid_enable_key)) > > + state->hw_rmid =3D determine_hw_rmid_for_cpu(cpu); > > + > > + wrmsr(MSR_IA32_PQR_ASSOC, state->hw_rmid, 0); > > } > > > > static int resctrl_online_cpu(unsigned int cpu) > > Reinette