Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2800115rda; Wed, 25 Oct 2023 12:39:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFZcEAH+Q3U1xlzzhpgcEQ3NJIgurJ3yXJsdcLAlvFm3VJHONsZrwqKnUBqSEOtG0kZgk/0 X-Received: by 2002:a25:40ce:0:b0:d9a:516a:8870 with SMTP id n197-20020a2540ce000000b00d9a516a8870mr16171713yba.49.1698262751724; Wed, 25 Oct 2023 12:39:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698262751; cv=none; d=google.com; s=arc-20160816; b=o4SfFvw3T6EibxJ14E1lHst2EoBG6vsE9Yj5oLQBQDmK/oMKwGy/V/YvVnD8YHcBmG BITG2kVmy8isnteoijcDuBX/fhMNM9vSd4TH6UlblCZiqbHt83pvuD5Suq70N/YS2Czu F/yLddE1FxNRkONmmDjOkB2Ct34pNoJgoAQqfSxMSNztgiR2qkjOK6r8OwChW+JxRkPp e+GlBSuQG3+e0mlbBhmcptg0wx3kuP9Q9TAESopneqlYcJV4F9cxiKf6Q24PDagWiHw7 Sn2vtSf/XKew3VKopb7WHt6kPcMpanf24wRz+n5jyI3mV/03ffQLowvgRULJ7eMEfRQu gUmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=kaBBSwULzNtGi4f4XUtf1W0ZvUnvC+nVc58vCkiNi50=; fh=ptkWKGWlQNIik+BEoFpIdNhogIbzLH4KDmABrVZ+/f0=; b=uL2XYCNqKv3FPa3TBkpbaCVgYtnVkIj2tp9YQgXEL4iYvc+E34VmfdLHYIRmo8qeVC figUtamHiHKwmWY9PiZ+viy/luz6yEr8uBsO5d5Xjmnd+5CUqdElJ4WNh/7ToHTaH4bO ypkzxykZ+mvPmIf3W7GGfUX3iNYc2vdpPIDto0nkAObnPY8SGzlHVXm3F+pKuSTb71p3 tqGf73dMmBnc6KzSPix9S40cou5hDK42Fuze8ZYX6xOuEaMvhxfwoffdcJGuhsg+4TTo hLKnLd6ikZ4dGO5aiUKmu4+O+QToizL1aJ+rEs2LTIRnRq9Ki1BxHJKIIGO3n7zbvtVJ BFCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CRv+3ZTY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id ck19-20020a05690218d300b00d8659ab6ce2si15660962ybb.616.2023.10.25.12.39.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 12:39:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CRv+3ZTY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id B0B1F8157DF8; Wed, 25 Oct 2023 12:39:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229892AbjJYTi4 (ORCPT + 99 others); Wed, 25 Oct 2023 15:38:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233876AbjJYTiy (ORCPT ); Wed, 25 Oct 2023 15:38:54 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD22F13D; Wed, 25 Oct 2023 12:38:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698262733; x=1729798733; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=+1FcziEC4Fko1fRoSTXWHKNgLHQEHQDm0zdcSDsN4rg=; b=CRv+3ZTYOMeUbP2RZ5zdTq8OPfu4LN14lPvM37N4FR7GgvOjif27RaAl QREwocGm/NAamGRylFdiNow7+ZSx23ppBOORiRZ9gZKiWoCxMpZ2wKKiM PvBV14rzq+Ou7hmP3eNDSppNf03iw+bStLjacf3/RcF+xz6ukO9bBnZSv HKxKjt8w7LJZ9/oytGRD+rfOuNxcx5DcghmvPB3y9JrhP1CCAi/Z9rMiM 4UDMsZMnun30bGtFyx6z3eeSW1rf5zFV/u2GF4Am/l5oR5m/UcqY2YfMJ 3Q5U8mIZqfxlyUYeB1f41/JE4A/+UDT6IggpHShgd4PyYJ681h75T//Od g==; X-IronPort-AV: E=McAfee;i="6600,9927,10874"; a="8941200" X-IronPort-AV: E=Sophos;i="6.03,250,1694761200"; d="scan'208";a="8941200" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2023 12:38:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10874"; a="829350374" X-IronPort-AV: E=Sophos;i="6.03,250,1694761200"; d="scan'208";a="829350374" Received: from agluck-desk3.sc.intel.com (HELO agluck-desk3) ([172.25.222.74]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2023 12:38:52 -0700 Date: Wed, 25 Oct 2023 12:38:50 -0700 From: Tony Luck To: Peter Newman Cc: Fenghua Yu , Reinette Chatre , Jonathan Corbet , Shuah Khan , x86@kernel.org, Shaopeng Tan , James Morse , Jamie Iles , Babu Moger , Randy Dunlap , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, patches@lists.linux.dev Subject: Re: [PATCH] x86/resctrl: mba_MBps: Fall back to total b/w if local b/w unavailable Message-ID: References: <20231024181600.8270-1-tony.luck@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 25 Oct 2023 12:39:08 -0700 (PDT) On Wed, Oct 25, 2023 at 02:46:53PM +0200, Peter Newman wrote: > Hi Tony, > > On Tue, Oct 24, 2023 at 8:16 PM Tony Luck wrote: > > --- a/arch/x86/kernel/cpu/resctrl/monitor.c > > +++ b/arch/x86/kernel/cpu/resctrl/monitor.c > > @@ -418,6 +418,14 @@ static int __mon_event_count(u32 rmid, struct rmid_read *rr) > > return 0; > > } > > > > +static struct mbm_state *get_mbm_data(struct rdt_domain *dom_mbm, int rmid) > > +{ > > + if (is_mbm_local_enabled()) > > + return &dom_mbm->mbm_local[rmid]; > > + > > + return &dom_mbm->mbm_total[rmid]; > > +} > > That looks very similar to the get_mbm_state() function I added to > this same file recently: > > https://lore.kernel.org/all/20221220164132.443083-2-peternewman%40google.com > > I think the name you picked is misleadingly general. "local if > available, otherwise total" seems to be a choice specific to the mbps > controller. I think these functions should be reconciled a little > better. > Peter (and Babu, who made the same point about get_mbm_state(). Do you want to see your function extended to do the "pick an MBM event?" I could add a s/w defined "event" to the enum resctrl_event_id and extend get_mbm_state() like this: static struct mbm_state *get_mbm_state(struct rdt_domain *d, u32 rmid, enum resctrl_event_id evtid) { switch (evtid) { case QOS_L3_MBM_TOTAL_EVENT_ID: return &d->mbm_total[rmid]; case QOS_L3_MBM_LOCAL_EVENT_ID: return &d->mbm_local[rmid]; + case QOS_L3_MBM_LOCAL_OR_TOTAL_EVENT_ID: + if (is_mbm_local_enabled()) + return &d->mbm_local[rmid]; + if (is_mbm_total_enabled()) + return &d->mbm_total[rmid]; + fallthrough; default: return NULL; } } Is this the direction you are thinking of? Callers then look like: static void mbm_bw_count(u32 rmid, struct rmid_read *rr) { struct mbm_state *m = get_mbm_state(rr->d, rmid, QOS_L3_MBM_LOCAL_OR_TOTAL_EVENT_ID); u64 cur_bw, bytes, cur_bytes; similar for the other three places where this is needed. Any suggestions on how "QOS_L3_MBM_LOCAL_OR_TOTAL_EVENT_ID" could be abbreviated, or just have some different, but descriptive, name? -Tony