Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7144266rwd; Tue, 6 Jun 2023 07:01:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6swNtlsHWFMdKcvy/I8AGpFPeA8SPv6ZguuazDkliQQcNIaAya7sz8gxJpZj+MWqLzA2EG X-Received: by 2002:a05:620a:828d:b0:75e:c730:7590 with SMTP id ox13-20020a05620a828d00b0075ec7307590mr1821137qkn.25.1686060072103; Tue, 06 Jun 2023 07:01:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686060072; cv=none; d=google.com; s=arc-20160816; b=mbBNpGrxY0tEJzqn5eF0sEsf8ZhLVMW4jYk3X3jMPRsLkMzEnG9punNuGGdf0AHLvY fkgowhvARxkW0RDhEKDQf7Chc56X6uACHiSUpP9OKp+EOWaxo8MkeWMtv6j9BKNLOUa0 ziHDJzBMdcTUk4fb2pvXzTmpjLfN9hXiSONV827gmciM3j68O5ay9aDq3ZxhWxO26iaq tipilTHjJ8tDIEpVyWIGf232Hu7cOoNOMLg25LRJZ5q+QW/nJvkznKWDro2HkFOA9ScG wfbnAftHlec6eOY3fs2MOeF0l3oFnt2HRRRRu9cy5gO8VXxe/NNzr+oPFceGFvPxO6es uRJw== 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=Eu495ErLblvkCqCHGMpwun0U7rLfauxkN4tFcXNAkpw=; b=gxFKgEm5KsL7zL64WojwgeTMe7z8ALIGWQ7/sy6ZmIanpXYgJqhC8FMOYfTDiyGYJU /LFD1wmt1pi8HXw2qALjX22aWnQJRvOaYgukuRTODT2g55Kffd/6opqPHsheDXy14yAV 3DbczON1Q7eZV3F1PpC0QYugrSqOFsBE/OYrGvuZtgj9B9mQEthxTpwonhV2el+p6top qS9BRdB1L3Io7gac8ZKw81H6XEY3IEF24/ZDj5/vVUC4+AyDUWNS+38faEzQh1gdApJu mzesPpeyAwQWNNdU8yHfdsnYw74Wjc/AZ2qiF7ua/lQ8hC71PkNBDGzrRhmihvTAKmly cy2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=fCgdktNW; 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 f18-20020a05620a069200b0074a5ff89c2fsi6050122qkh.333.2023.06.06.07.00.25; Tue, 06 Jun 2023 07:01:12 -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=fCgdktNW; 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 S237347AbjFFNbW (ORCPT + 99 others); Tue, 6 Jun 2023 09:31:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237489AbjFFNbT (ORCPT ); Tue, 6 Jun 2023 09:31:19 -0400 Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61B6A126 for ; Tue, 6 Jun 2023 06:31:18 -0700 (PDT) Received: by mail-qt1-x829.google.com with SMTP id d75a77b69052e-3f6c6320d4eso173101cf.1 for ; Tue, 06 Jun 2023 06:31:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686058277; x=1688650277; 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=Eu495ErLblvkCqCHGMpwun0U7rLfauxkN4tFcXNAkpw=; b=fCgdktNWB2LogtugfQhIIiIvjESV9vkobdDHV7kpj1nHH43vKoyAjogajpYO5qaL96 HGx2vQMSpYpUjTKXSdp80HyvH7LGmNhAss3khdsLQ6uvbFoWsz6u41mq4FIQibyD9P4e 4ZvJ1jm3d4KBbGTCmLguUyu99AehOuhORlJU1fkgnIKVbMx2sFmjLHHDATHoDk7NSUcQ nZn2bbhEpA6HROEnI0HhaKbWpFLFvs0fb/KcibhOuvVPpiQtAZ4SLHuG/2YlS//AqN01 HBTpFhfSnsrpR1VPhPGECEgS8CEfHW/XGmsFJn1qTPWb+twT2yPmKFfceuw6N6bcxiMV a1TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686058277; x=1688650277; 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=Eu495ErLblvkCqCHGMpwun0U7rLfauxkN4tFcXNAkpw=; b=CSBBU/uxEZgGdaMxOLMKOL4ibK0QjTLxWHhAXv4DvgAlHeHk4iu3JRbY7tc4IsaPTx 0XkZL388owGrkGqT7UXkQnjFbUPyqVUWvJ3R2aRAYU/BDB2WRaNVItGt/YVCkvHyHkJm Hq0SI40hAZgXfZE6wdWoZYNcjnPU/GLu9HWxtfiY06pOMoXDYvoVpjF6VAWlulIzcnRj tkX6+NOvpkR0yescqJ9MdevSCtHbUvJSr9rZ52c8ThobH1Qi3iECFUDAmr5RA5U8IUnL R2ZIURRIHGoRxp/9YhgHeKHCULiGpbePosJXCml3V8ceF3Q96Wb9YDePSySt92iL+wgi GtSQ== X-Gm-Message-State: AC+VfDyGbwTNC2xLnS5IM3wSKueN+phlpEUPAaYBKghTgh+r2O1ptMus x6PbaQdx8Srwqbi7yD8E5M263Sty23OZdMscOj0JSw== X-Received: by 2002:a05:622a:1a20:b0:3f9:b81c:3a0f with SMTP id f32-20020a05622a1a2000b003f9b81c3a0fmr7430qtb.17.1686058277351; Tue, 06 Jun 2023 06:31:17 -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> <00b0c70d-eed8-8dc1-8046-25764d991bf4@intel.com> In-Reply-To: <00b0c70d-eed8-8dc1-8046-25764d991bf4@intel.com> From: Peter Newman Date: Tue, 6 Jun 2023 15:31:06 +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=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 Wed, May 17, 2023 at 2:06=E2=80=AFAM Reinette Chatre wrote: > On 5/16/2023 7:49 AM, Peter Newman wrote: > > On Thu, May 11, 2023 at 11:40=E2=80=AFPM Reinette Chatre > > wrote: > >> I do not see any impact to the (soft) RMIDs that can be assigned to mo= nitor > >> groups, yet from what I understand a generic "RMID" is used as index t= o MBM state. > >> Is this correct? A hardware RMID and software RMID would thus share th= e > >> 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. > > I understand and trust that you can ensure that this implementation is > done safely. Please also consider how future changes to resctrl may stumb= le > if there are not clear boundaries. You may be able to "ensure the softwar= e > controller is disabled and never put any RMIDs on the limbo list", but > consider if these rules will be clear to somebody who comes along in a ye= ar > or more. > > Documenting the data structures with these unique usages will help. > Specific accessors can sometimes be useful to make it obvious in which st= ate > the data is being accessed and what data can be accessed. Using WARN > as you suggest is a useful tool. After studying the present usage of RMID values some more, I've concluded that I can cleanly move all knowledge of the soft RMID implementation to be within resctrl_arch_rmid_read() and that none of the FS-layer code should need to be aware of them. However, doing this would require James's patch to allow resctrl_arch_rmid_read() to block[1], since resctrl_arch_rmid_read() would be the first opportunity architecture-dependent code has to IPI the other CPUs in the domain. The alternative to blocking in resctrl_arch_rmid_read() would be introducing an arch hook to mon_event_read(), where blocking can be done today without James's patches, so that architecture-dependent code can IPI all CPUs in the target domain to flush their event counts to memory before calling mon_event_count() to total their MBM event counts. The remaining special case for soft RMIDs would be knowing that they should never go on the limbo list. Right now I've hard-coded the soft RMID read to always return 0 bytes for occupancy events, but this answer is only correct in the context of deciding whether RMIDs are dirty, so I have to prevent the events from being presented to the user. If returning an error wasn't considered "dirty", maybe that would work too. Maybe the cleanest approach would be to cause enabling soft RMIDs to somehow cause is_llc_occupancy_enabled() to return false, but this is difficult as long as soft RMIDs are configured at mount time and rdt_mon_features is set at boot time. If soft RMIDs move completely into the arch layer, is it preferable to configure them with an rdt boot option instead of adding an architecture-dependent mount option? I recall James being opposed to adding a boot option for this. Thanks! -Peter [1] https://lore.kernel.org/lkml/20230525180209.19497-15-james.morse@arm.co= m/