Received: by 2002:a05:6512:2355:0:0:0:0 with SMTP id p21csp205455lfu; Wed, 30 Mar 2022 20:54:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyt6+uS0T+Kj33q0x1DsGc8XqZTHeMFBu2OthQEv/dZMjbn2u55m2hvnxEpJr/q1wQ4uz0+ X-Received: by 2002:a05:6a00:1a88:b0:4fa:9a8c:c05f with SMTP id e8-20020a056a001a8800b004fa9a8cc05fmr3291077pfv.46.1648698873629; Wed, 30 Mar 2022 20:54:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648698873; cv=none; d=google.com; s=arc-20160816; b=eVm7LBu9jQG6OQicnyWjwyYkpQ7Hl64J9EU1+YewravJtg/oG2aXMAdxZ1n1DMBzlg 1enQVWeL20we9prB7C7eGUgyu74uR6T/YGVnWdweTwFIUQJEFaSDz8Of0I97OkSiFXX8 Dlub9Jzu9lNkheg+h1/862VUaakmsEt5xFIRAhy5rm1ifyeCGsm02LycDynX9RIbmAl5 Cbc/cekzaokAe6WtTeuNiSyE5ijX6YWafcBCaEDNqKY0kdlJwBevT84Y6PAH+OxjWAeb GAP3VvMKbiKbC5SLfaX+cCdma/V6jZUZ9Jz4Yc+cKUPkGol7nkSnWBhf9eOUvl3ILrZW 9m4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=H+HVit9xBTV9g55PXF9T+wkkqgLiaGTLCc3LSMk4xMI=; b=GT8PTQndn273oR0WQAG3DGfraHItv61HTx1E+vsyea53WA05mbFIfbpdo1okdIJBid daR0qCcAmQfLxoQw3vVFn9WUyU1b1J7T27DFjRUJkEOzXVVwDunk5Slrhe+h3WTWAbBa LUlqdXLihmo14kT5S0CaQE+uurlAQANcTINKhEHfsas1nc0tN2K2+spdJK9+Sau5DZBG ZPn6ndsy3SjY/PQHJ5o+oku13pZqKyqG2GRbN0mVSu0REX+pef5SWYQvsN45plte155W iHdwVgThuvrLPszteAVIcG90pJbndtWYBLoGfXAmvNaZgM0YXUgs4RE3S/MNJtoI9XcA zZcQ== 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:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id bj3-20020a056a02018300b003816043ef10si26074586pgb.261.2022.03.30.20.54.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 20:54:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 4035F15D38F; Wed, 30 Mar 2022 20:06:59 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348928AbiC3QqM (ORCPT + 99 others); Wed, 30 Mar 2022 12:46:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348899AbiC3QqF (ORCPT ); Wed, 30 Mar 2022 12:46:05 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3A5F21D760C for ; Wed, 30 Mar 2022 09:44:18 -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 41A02153B; Wed, 30 Mar 2022 09:44:18 -0700 (PDT) Received: from [10.1.196.218] (eglon.cambridge.arm.com [10.1.196.218]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3081D3F73B; Wed, 30 Mar 2022 09:44:16 -0700 (PDT) Subject: Re: [PATCH v3 12/21] x86/resctrl: Calculate bandwidth from the previous __mon_event_count() chunks To: Reinette Chatre , x86@kernel.org, linux-kernel@vger.kernel.org Cc: Fenghua Yu , Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , Babu Moger , shameerali.kolothum.thodi@huawei.com, Jamie Iles , D Scott Phillips OS , lcherian@marvell.com, bobo.shaobowang@huawei.com, tan.shaopeng@fujitsu.com References: <20220217182110.7176-1-james.morse@arm.com> <20220217182110.7176-13-james.morse@arm.com> From: James Morse Message-ID: <146a1a64-7925-008f-a817-fe0860b30105@arm.com> Date: Wed, 30 Mar 2022 17:44:10 +0100 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, 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 Hi Reinette, On 05/03/2022 00:27, Reinette Chatre wrote: > On 2/17/2022 10:21 AM, James Morse wrote: >> mbm_bw_count() is only called by the mbm_handle_overflow() worker once a >> second. It reads the hardware register, calculates the bandwidth and >> updates m->prev_bw_msr which is used to hold the previous hardware register >> value. >> >> Operating directly on hardware register values makes it difficult to make >> this code architecture independent, so that it can be moved to /fs/, >> making the mba_sc feature something resctrl supports with no additional >> support from the architecture. >> Prior to calling mbm_bw_count(), mbm_update() reads from the same hardware >> register using __mon_event_count(). >> >> Change mbm_bw_count() to use the current chunks value most recently saved by >> __mon_event_count(). This removes an extra call to __rmid_read(). > >> Instead of using m->prev_msr to calculate the number of chunks seen, >> use the rr->val that was updated by __mon_event_count(). This removes a extra >> calls to mbm_overflow_count() and get_corrected_mbm_count(). > > "removes a extra calls" -> "removes an extra call" ? > > __mon_event_count() ends with "rr->val += get_corrected_mbm_count()" and > it is called twice by mbm_update(). The intention in this change is for > mbm_bw_count() to benefit from the rmid read done just before ... > but would using rr->val within mbm_bw_count() not result in it getting > data from both rmid reads due to the increment? Yes, bother. I thought those were mutually exclusive, but its __mon_event_count() that uses a different struct mbm_state for each set of raw values, not mbm_update(). [...] > Should rr.val perhaps be reset before each __mon_event_count() call instead of > just at the beginning of mbm_update()? Yes. This is because the struct rmid_read is just to allow __mon_event_count() to do its thing, nothing used to read those values. >> Calculating bandwidth like this means mbm_bw_count() no longer operates >> on hardware register values directly. Thanks! James