Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp2133841rwe; Fri, 2 Sep 2022 09:01:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR43QYOvegJbIB0YCaPl4DRiIwJaJlGYhCpEpl8mRmNHfPs6nHT1jZJcOfT+/GAhXUZXW9O5 X-Received: by 2002:a17:907:75db:b0:741:4155:b52f with SMTP id jl27-20020a17090775db00b007414155b52fmr21763312ejc.638.1662134462735; Fri, 02 Sep 2022 09:01:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662134462; cv=none; d=google.com; s=arc-20160816; b=lzGG/oIxYwG7CqVJjbdbBfe3t2sDVHhXeZM6e6sa4WFp6FZSnw1vAmx47JmmmB1jbY vUjeIrZHFSmzenriIeQjcBIYKNDxZcqBn6tHWZrZLJOjkWZZZJ3tatU4aUtq0+Uq4ORA 4haXJrZTMBI8hnKyNC017HfHoEsmJANozSC9pPseElEg9Xa44+3AXV+6quat872FBNMw lLEwDL3uju5dzX5XEoP80RiJvpONYFCaqoTr7uygToU1ncvTAL6SdFLR2quTf3iF+p/3 Sw71vzzXLyJiA5JdCRBILcu5zf9FjDNafbHVnJiDyVJNJMgERIzEcR74fj6yjiBLfN3i Q4rw== 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=KQZci+Q0HNBicLf6a5yNjUCRRiCa/uRouTT9r/v9/7k=; b=NPPvRW86hpSB4wtPGGfSa3EgEWR9Z9YEnk/e56h5dvrZ/VvBdnmeeVHJ50gL4gr5Vp Jrk0uVzOJtWSHRdJeY8ktt/ilOjQDzYGlk0NxPkTVT4+500uiClRO3BHd1e/nL2y18Iy ewRBY3rIgJuuKt83gE6gFVYHVqr+a8naTejQ29x6rSfcEdbWFQHD3dIOZUVIb3rJUoZO Sv+yzZj5h6fqYo/QUwFqk+Xcrv+RgwBXyeWD7DXEUXHAD4cPaFL5GAyXNo/udmsY86q0 HKniTKuae9VyvO4juPwcHeg2VSO/LuqHRd6HfHtpvCIS9dC+9jwdQdqVwA6a5D+M1rx5 6abg== 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 hh9-20020a170906a94900b0073f71b125b6si1568008ejb.532.2022.09.02.09.00.31; Fri, 02 Sep 2022 09:01:02 -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 S237775AbiIBP5v (ORCPT + 99 others); Fri, 2 Sep 2022 11:57:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237433AbiIBPz7 (ORCPT ); Fri, 2 Sep 2022 11:55:59 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B5611D21CD for ; Fri, 2 Sep 2022 08:49:41 -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 8695F15BF; Fri, 2 Sep 2022 08:49:47 -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 01A183F766; Fri, 2 Sep 2022 08:49:38 -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 v6 18/21] x86/resctrl: Move get_corrected_mbm_count() into resctrl_arch_rmid_read() Date: Fri, 2 Sep 2022 15:48:26 +0000 Message-Id: <20220902154829.30399-19-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220902154829.30399-1-james.morse@arm.com> References: <20220902154829.30399-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 Reviewed-by: Reinette Chatre 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