Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp812527pxb; Thu, 17 Feb 2022 15:34:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJwzQc0lUeeZJwTi20vHEJTmZo4106pzJgggFwO6ug+hl4TYinwwj1/mEguw3skyfZXq7L8E X-Received: by 2002:a17:90a:fd10:b0:1bb:8ad7:b351 with SMTP id cv16-20020a17090afd1000b001bb8ad7b351mr9744160pjb.208.1645140849867; Thu, 17 Feb 2022 15:34:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645140849; cv=none; d=google.com; s=arc-20160816; b=PgNUADl3X64zSfGGO+SJ45UdMkpMLqsciV1qCq9pbv/Hy4MT4+sGU1naC2ih9oCg7q a8cb3KlicRrRQzKlxzLMwm3clBoaSl10+CAJVIyABxETCJ44I2+/d5ZRRH3uZ3jlOTRG 0qbcFTTXM10qcxT4g5CiNqiTUqOFimgueoYAiTqikvzio4Otfmq9BdKKHVJRQbqCOb5i ZOohy1nbhCoY61c4sOhKlvXKQtDrqSXYFOMPS75q7xGiCKHpJQpzVGVb6KGDYy5sW8rt Ky5G6Or7DX1pz6+DIHXaFJ0c0/1DTWC6mMBHyisE0RSqst5oNUVME9S3ANfQs3RenFkS mLzA== 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=R9y8EvwVKI3Y57xO6sBJebwnncLg6ppdPbeC9O9cVy8=; b=Ia+m1NfOYfKRqrMpSy5gqgUcJuTGJD4LURyeBtSZqX8VIHeRD9lqIep1sCCUNNrIaZ mpm9nLUUqLCk51fxMSgQJmeA5CPcR4JZEuU5rL+8G3scRX5qxLUeofsoPMGturzrCgSh 5QspGkLAxuMy5hVfbnNmHHUzuJu7TS4NonN2zoGQJBiRp5AJlEjumRetgYBjxELlf7M+ 49DjC0go7E0HtDe1xfNRIw2/yJxojxMQ+/ZeoBt7dsdQGHy3SiMi+VK8MtUNa5+ZCrvJ aWTv3K1c3nNeUd46RURIckl9X7Y1dCgdAntI74tCI5ddKsepLyYwmmAJvJ/V3TIgJCOa eT4w== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id t9si1918543pjw.64.2022.02.17.15.34.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 15:34:09 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5BCA029413E; Thu, 17 Feb 2022 15:14:31 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244441AbiBQSYb (ORCPT + 99 others); Thu, 17 Feb 2022 13:24:31 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:56430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244346AbiBQSYC (ORCPT ); Thu, 17 Feb 2022 13:24:02 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1F4103B035 for ; Thu, 17 Feb 2022 10:23:47 -0800 (PST) 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 D6DCE15EC; Thu, 17 Feb 2022 10:23:46 -0800 (PST) Received: from merodach.members.linode.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A6CCC3F718; Thu, 17 Feb 2022 10:23:44 -0800 (PST) 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, Jamie Iles , D Scott Phillips OS , lcherian@marvell.com, bobo.shaobowang@huawei.com, tan.shaopeng@fujitsu.com Subject: [PATCH v3 18/21] x86/resctrl: Move get_corrected_mbm_count() into resctrl_arch_rmid_read() Date: Thu, 17 Feb 2022 18:21:07 +0000 Message-Id: <20220217182110.7176-19-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220217182110.7176-1-james.morse@arm.com> References: <20220217182110.7176-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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. 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 5ab8b448fb7e..c8d52fbee8cd 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 when 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 e04bc97c710d..e89ae648046b 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 u64 __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