Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp5013187iog; Wed, 22 Jun 2022 10:07:30 -0700 (PDT) X-Google-Smtp-Source: AGRyM1udcPw7lwvUNjo824JdJwBQUb1+eVg90hJKE+IQ1nWDyMc5Zz4itJLzCY+SedCxxIhX/aio X-Received: by 2002:a05:6402:5409:b0:42a:a643:4eb8 with SMTP id ev9-20020a056402540900b0042aa6434eb8mr5356595edb.71.1655917650574; Wed, 22 Jun 2022 10:07:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655917650; cv=none; d=google.com; s=arc-20160816; b=mVq0vODbttDBWSj6LyleF15ofF4x8rm/LPwUX8TetUGG7+3gy57yEdwL3FRxS4N1NV rY8K9SnAfKRwnfbTuVfKGO4V6wX3GdnF+JoQFodHWiXn9ww0yalXBy2+Q6J50h4RirpN 2zVS+lC0/Zz72tdi5F0Z7EDfMNGJFUTO7iDt2zf2Fbqsn7wcuioUp1wKeXy2NWu/bK4u ZgYPPQp0CszXFTqcjntetT0nfmaqCZ0Dax8iH8gbXaBe2Y32Bi6t9YY/3Lmp77CFavJP d7BFkwvdxxlDI6tGaPsDg7EYwDRtdVz1WnrNOb/rviK1xGRkJLsSZx9RB3/SwgzMegGO s8vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=GjPEi7K31TJDFSvDq8Vg/tkI6B/CC6pcwfhwKBxxRTE=; b=C3XjZ7BHPKEQj0gEY/uZQx/XI+/nPQpsDJ0qOZqWNKwIuEYtHLj+VmaCqOIoKNn9A9 4h6GHr7reUgA9vlzWgEPa7NQVD2v5sGggGexaesd2SPGnFshB0pe/1ZsKl+c9+M3qGCQ W+j63jn5ph6GPoCsHdfjT6CqwyIs4HvH0gBe41w8yr1jeWpXhF72OAtkJP/YPQ1O/4Eb RSqNaNtQbdIObfyuN/TocQJGs8T04bDV9UogKNToxPTTNRQ4FOTz7G9XTl7Zi2ePpcNP /K+unrED9nSAGbU0KWUr5352zgqdsuPnGNt37yEpWRqxZrgwd2YJJrWdI6XVDPaOpWvM 5cLg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p12-20020a056402500c00b004356df259b4si15213205eda.361.2022.06.22.10.07.04; Wed, 22 Jun 2022 10:07:30 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376959AbiFVQtf (ORCPT + 99 others); Wed, 22 Jun 2022 12:49:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376857AbiFVQsY (ORCPT ); Wed, 22 Jun 2022 12:48:24 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6EEE1403FC for ; Wed, 22 Jun 2022 09:47:46 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 54CB91477; Wed, 22 Jun 2022 09:47:46 -0700 (PDT) Received: from merodach.members.linode.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CC1983F792; Wed, 22 Jun 2022 09:47:43 -0700 (PDT) From: James Morse To: x86@kernel.org, linux-kernel@vger.kernel.org Cc: Fenghua Yu , Reinette Chatre , Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , Babu Moger , James Morse , shameerali.kolothum.thodi@huawei.com, D Scott Phillips OS , lcherian@marvell.com, bobo.shaobowang@huawei.com, tan.shaopeng@fujitsu.com, Jamie Iles , Cristian Marussi , Xin Hao , xingxin.hx@openanolis.org, baolin.wang@linux.alibaba.com Subject: [PATCH v5 18/21] x86/resctrl: Move get_corrected_mbm_count() into resctrl_arch_rmid_read() Date: Wed, 22 Jun 2022 16:46:26 +0000 Message-Id: <20220622164629.20795-19-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220622164629.20795-1-james.morse@arm.com> References: <20220622164629.20795-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 resctrl_arch_rmid_read() is intended as the function that an architecture agnostic resctrl filesystem driver can use to read a value in bytes from a counter. Currently the function returns the MBM values in chunks directly from hardware. When reading a bandwidth counter, get_corrected_mbm_count() must be used to correct the value read. get_corrected_mbm_count() is architecture specific, this work should be done in resctrl_arch_rmid_read(). Move the function calls. This allows the resctrl filesystems's chunks value to be removed in favour of the architecture private version. Reviewed-by: Jamie Iles Tested-by: Xin Hao Reviewed-by: Shaopeng Tan Tested-by: Shaopeng Tan Tested-by: Cristian Marussi Signed-off-by: James Morse --- arch/x86/kernel/cpu/resctrl/internal.h | 4 ++-- arch/x86/kernel/cpu/resctrl/monitor.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h index 8039e8aba7de..bdb55c2fbdd3 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -280,14 +280,12 @@ struct rftype { /** * struct mbm_state - status for each MBM counter in each domain - * @chunks: Total data moved (multiply by rdt_group.mon_scale to get bytes) * @prev_bw_chunks: Previous chunks value read for bandwidth calculation * @prev_bw: The most recent bandwidth in MBps * @delta_bw: Difference between the current and previous bandwidth * @delta_comp: Indicates whether to compute the delta_bw */ struct mbm_state { - u64 chunks; u64 prev_bw_chunks; u32 prev_bw; u32 delta_bw; @@ -297,10 +295,12 @@ struct mbm_state { /** * struct arch_mbm_state - values used to compute resctrl_arch_rmid_read()s * return value. + * @chunks: Total data moved (multiply by rdt_group.mon_scale to get bytes) * @prev_msr: Value of IA32_QM_CTR last time it was read for the RMID used to * find this struct. */ struct arch_mbm_state { + u64 chunks; u64 prev_msr; }; diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c index 862a4462ed60..27bb4947a176 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -204,7 +204,9 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_domain *d, am = get_arch_mbm_state(hw_dom, rmid, eventid); if (am) { - *val = mbm_overflow_count(am->prev_msr, msr_val, hw_res->mbm_width); + am->chunks += mbm_overflow_count(am->prev_msr, msr_val, + hw_res->mbm_width); + *val = get_corrected_mbm_count(rmid, am->chunks); am->prev_msr = msr_val; } else { *val = msr_val; @@ -374,9 +376,7 @@ static int __mon_event_count(u32 rmid, struct rmid_read *rr) return 0; } - m->chunks += tval; - - rr->val += get_corrected_mbm_count(rmid, m->chunks); + rr->val += tval; return 0; } -- 2.30.2