Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp929099rwn; Thu, 8 Sep 2022 10:39:20 -0700 (PDT) X-Google-Smtp-Source: AA6agR66npZUn+Jg9cREOBh41T5fzmQUkm4p51w6+bx4dkFejQhCKPibFWtuhzRfvGB0NIoQvQp/ X-Received: by 2002:a63:2b57:0:b0:434:eabe:b4e with SMTP id r84-20020a632b57000000b00434eabe0b4emr7493527pgr.173.1662658760318; Thu, 08 Sep 2022 10:39:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662658760; cv=none; d=google.com; s=arc-20160816; b=pgiClGcDorWUNRaHaldH8KVlvLKpzmeBoHCacFNqyX2PPpdpCA35/L5do3taP+zDwE mnOjNFMnTwFTnes466QJRW5rN6ubukAZ0zBNHbfAEQzunarMMftTsuQWxJgwJaHKj0ew Z0ujf73hme0UnhKzJG0NlBu2d8aSdypR3TbRKK6WZYc2BlVBu9qe0zYqQXtu0lzEkLz1 8Bexhhl1nQ5LK/RYqWAhZKg8MMydXVwSFTXPrffBMOxhAj55AGyrOIR78NowJ1y1JRJO r1Gn4hxFrxU+wkGEKuMBWZ3GKXzOa1cP99xRvyugnmn0xyeKGiHHhKft90WibDS9PPi2 a6ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=/xYl9F7dvDizxrEJbAOMr2P1bi8j+f43P51ZJzYBZTM=; b=0n+beU+VzhfI8MPK9k5/P58Gs2DeqcMz8TDFDfhPR2BKdiYXDqIAY62B2Cd634Cm2u nrHMcBDVkn/WY8vyx8iuK0iSVk8bMOUWTuNRMxF1kfF0917DkcEt02rhw8C7zgldZe+Q ynRp9TEe7v3vqzUIXzorMeyk/ZNEu+AqXJA+7GPt0wb1dyvEfBmLsZgT/oAUgx6UNdoS RTWNVLVYxZVKQmmTzdyngBOdab/HVcmlMp3QlRxGBQJRE8oXLs2qmcBsRmzjjtFzlTp4 zWPVDcIK/JcKEjdV/rz9fnsJAzOqU4lMoarpc0MLG1AwWiWKYPismqWZkgS5QF+BVtdm WQtw== 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 l13-20020a170903244d00b001751d0ac52asi18971520pls.435.2022.09.08.10.39.08; Thu, 08 Sep 2022 10:39:20 -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 S230407AbiIHRAr (ORCPT + 99 others); Thu, 8 Sep 2022 13:00:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229504AbiIHRAo (ORCPT ); Thu, 8 Sep 2022 13:00:44 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C2BDBC4831 for ; Thu, 8 Sep 2022 10:00:42 -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 58B85106F; Thu, 8 Sep 2022 10:00:48 -0700 (PDT) Received: from [10.1.197.78] (eglon.cambridge.arm.com [10.1.197.78]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CE0B33F71A; Thu, 8 Sep 2022 10:00:39 -0700 (PDT) Message-ID: <5b4da95f-28ac-a571-6c01-cf1a94d0753d@arm.com> Date: Thu, 8 Sep 2022 18:00:38 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH v6 12/21] x86/resctrl: Calculate bandwidth from the previous __mon_event_count() chunks Content-Language: en-GB To: haoxin , x86@kernel.org, linux-kernel@vger.kernel.org Cc: Fenghua Yu , Reinette Chatre , Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , Babu Moger , shameerali.kolothum.thodi@huawei.com, D Scott Phillips OS , lcherian@marvell.com, bobo.shaobowang@huawei.com, tan.shaopeng@fujitsu.com, Jamie Iles , Cristian Marussi , xingxin.hx@openanolis.org, baolin.wang@linux.alibaba.com References: <20220902154829.30399-1-james.morse@arm.com> <20220902154829.30399-13-james.morse@arm.com> <87aa9fd2-cae8-972d-81d4-8855cbd81569@linux.alibaba.com> From: James Morse In-Reply-To: <87aa9fd2-cae8-972d-81d4-8855cbd81569@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00,NICE_REPLY_A, 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 Hi Hao Xin, On 07/09/2022 07:47, haoxin wrote: > 在 2022/9/2 下午11:48, James Morse 写道: >> 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 an >> extra call to mbm_overflow_count() and get_corrected_mbm_count(). >> Calculating bandwidth like this means mbm_bw_count() no longer operates >> on hardware register values directly. >> diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c >> index 3e69386cfe00..2d81b6cd9632 100644 >> --- a/arch/x86/kernel/cpu/resctrl/monitor.c >> +++ b/arch/x86/kernel/cpu/resctrl/monitor.c >> @@ -516,10 +521,12 @@ static void mbm_update(struct rdt_resource *r, struct rdt_domain >> *d, int rmid) >>        */ >>       if (is_mbm_total_enabled()) { >>           rr.evtid = QOS_L3_MBM_TOTAL_EVENT_ID;>> +        rr.val = 0; > In mbm_update,  there no use the rr.val, so there no need to initialize ? >>           __mon_event_count(rmid, &rr); >>       } >>       if (is_mbm_local_enabled()) { >>           rr.evtid = QOS_L3_MBM_LOCAL_EVENT_ID; >> +        rr.val = 0; > ditto. >>           __mon_event_count(rmid, &rr); >>             /* No, but this just leaves that problem for someone else to discover the hard way! I think its fair for the compiler to complain that addition on an uninitialised field is a bug. I'd prefer to keep this as it is on the principle of 'least surprise'. Thanks, James