Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp887935pxb; Wed, 27 Oct 2021 14:30:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyT6aBkWh7IjMJy7uxPMM6Iyi+1YO7IJ/TRQ/LLree2+wRBbtGwkYf88t2sc5g5R0ENdfqQ X-Received: by 2002:a50:e108:: with SMTP id h8mr544112edl.42.1635370230728; Wed, 27 Oct 2021 14:30:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635370230; cv=none; d=google.com; s=arc-20160816; b=lM5FM7tqroxeP5QOuiAR7NAx0d9uviAB9yviOfFTGMR1TdHEIhPvnAhpLl+X9f4Lq1 jkTqgwek3rp1TfpmboibbaGbGANxjZ1iz+rhfDGNEg7ZZsoXF2yeg34cL5PR6tRMA9xm 0GJD6b/QdugmrnZUC/0iO4xhki8CGazg2UW757DaS3jCNyQ/WUrC0Sr4tuc918yB7d4u wU/GhyqP2nDWNi1XR7IgYWlP7/MCDvYwVmGJrp0Hk59Fcjq0mNQbl18LpETlsFMDHwHT YIZNE/tevecpPdZD3RS9xW09Kenbdgtap1BnX4zYDiQ3z8IC5PLUebns3C9b69lDUlVN FiIw== 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=/hWZu2DVl5ZBOW/hHRN9VcFzrazF0qXihT5hlF1h92o=; b=pBku6vQXHpXGMlJ7JX7B9ARLvwayvjl9L/AnaQz7y89xoLeV6ytOXT9PjnggW1bXrv aO/gQCIM9AHtp1/hwjTNsNrvVwiXsXNxGnyqaQot+VC9yoy8IwY43poM9g5XJ64i/nW8 tfuLwDYIc4czodDOkBa3BE6p8pG2fBlW1Wquww29vqN4wxkNQTHtKiqYyWOYv6oJj2Bg J8bJdFFSSbT3BlJX/Jvih6KzSziDh7T266dNiVNNUT7PPyZdCuKf5SdxN9pvxmfhevri O1OaaCPMNBy/YiwamV9aKhvsRB8B0S0HLD+qv4k41GHuxkNTO/jLtib9xxu7V5cG1Hzy iWDQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jy1si1171419ejc.592.2021.10.27.14.30.07; Wed, 27 Oct 2021 14:30:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243038AbhJ0QxA (ORCPT + 97 others); Wed, 27 Oct 2021 12:53:00 -0400 Received: from foss.arm.com ([217.140.110.172]:45470 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243037AbhJ0QxA (ORCPT ); Wed, 27 Oct 2021 12:53:00 -0400 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 86B91ED1; Wed, 27 Oct 2021 09:50:34 -0700 (PDT) Received: from [10.1.196.31] (eglon.cambridge.arm.com [10.1.196.31]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B55B93F70D; Wed, 27 Oct 2021 09:50:32 -0700 (PDT) Subject: Re: [PATCH v2 17/23] x86/resctrl: Abstract __rmid_read() To: Reinette Chatre , Babu Moger , x86@kernel.org, linux-kernel@vger.kernel.org Cc: Fenghua Yu , Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , shameerali.kolothum.thodi@huawei.com, Jamie Iles , D Scott Phillips OS , lcherian@marvell.com, bobo.shaobowang@huawei.com, tan.shaopeng@fujitsu.com References: <20211001160302.31189-1-james.morse@arm.com> <20211001160302.31189-18-james.morse@arm.com> <887f8946-6d2b-27bf-a49b-f83af05cbc68@amd.com> <81826a4f-c3de-787f-8059-4808815b4800@amd.com> <71efc804-4ca0-f31b-4485-005b3ad6e4d4@intel.com> From: James Morse Message-ID: <859c5573-b025-7754-94bf-294c7da3abdc@arm.com> Date: Wed, 27 Oct 2021 17:50:31 +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: <71efc804-4ca0-f31b-4485-005b3ad6e4d4@intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Reinette, Babu, On 20/10/2021 21:28, Reinette Chatre wrote: > On 10/20/2021 12:22 PM, Babu Moger wrote: >> On 10/20/21 1:15 PM, Reinette Chatre wrote: >>> On 10/19/2021 4:20 PM, Babu Moger wrote: >>>> On 10/1/21 11:02 AM, James Morse wrote: >>>>> __rmid_read() selects the specified eventid and returns the counter >>>>> value from the msr. The error handling is architecture specific, and >>>>> handled by the callers, rdtgroup_mondata_show() and __mon_event_count(). >>>>> >>>>> Error handling should be handled by architecture specific code, as >>>>> a different architecture may have different requirements. MPAM's >>>>> counters can report that they are 'not ready', requiring a second >>>>> read after a short delay. This should be hidden from resctrl. >>>>> >>>>> Make __rmid_read() the architecture specific function for reading >>>>> a counter. Rename it resctrl_arch_rmid_read() and move the error >>>>> handling into it. >>>>> diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c >>>>> b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c >>>>> index 25baacd331e0..c8ca7184c6d9 100644 >>>>> --- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c >>>>> +++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c >>>>> @@ -579,9 +579,9 @@ int rdtgroup_mondata_show(struct seq_file *m, void >>>>> *arg) >>>>>          mon_event_read(&rr, r, d, rdtgrp, evtid, false); >>>>>    -    if (rr.val & RMID_VAL_ERROR) >>>>> +    if (rr.err == -EIO) >>>>>            seq_puts(m, "Error\n"); >>>>> -    else if (rr.val & RMID_VAL_UNAVAIL) >>>>> +    else if (rr.err == -EINVAL) >>>>>            seq_puts(m, "Unavailable\n"); >>>>>        else >>>>>            seq_printf(m, "%llu\n", rr.val * hw_res->mon_scale); >>>> >>>> This patch breaks the earlier fix >>>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.kernel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git%2Fcommit%2F%3Fh%3Dv5.15-rc6%26id%3D064855a69003c24bd6b473b367d364e418c57625&data=04%7C01%7Cbabu.moger%40amd.com%7C85219a5827114935cdaa08d993f59fa0%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637703505420472920%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=yP8awDgGGZ%2BWj5ZItdTNJItTVuK828yGnibwq%2BrVaf0%3D&reserved=0 Aha! >>>> When the user reads the events on the default monitoring group with >>>> multiple subgroups, the events on all subgroups are consolidated >>>> together. In case if the last rmid read was resulted in error then whole >>>> group will be reported as error. The err field needs to be cleared. >>>> >>>> Please add this patch to clear the error. >>> Good catch, thank you. >>> >>> Even so, I do not think mon_event_count()'s usage of __mon_event_count() >>> was taken into account by this patch and needs a bigger rework than the >>> above fixup. For example, if I understand correctly ret_val is the error >>> and rr->val no longer expected to contain the error after this patch. So >>> keeping that assignment to rr->val is not correct. >> >> Yes. You are right. rr->val is not expected to contain the error. >> Hopefully, this should help. > Yes, this looks good. If the first __mon_event_count() succeeds but a following one fails > then the data still needs to be reported so the error code needs to be fixed up afterwards > and cannot be done inside __mon_event_count(). Thank you very much. Thanks both! I should have worked this out when splitting msr_val into two values, which end up getting set the same. I think the 'Unavailable' issue is subtle enough that it deserves a block comment. I've replaced the rr->val chunk with: | /* | * __mon_event_count() calls for newly created monitor groups may | * report -EINVAL/Unavailable if the monitor hasn't seen any traffic. | * If the first call for the control group succeed, discard any error | * set by reads of monitor groups. | */ | if (ret_val == 0) | rr->err = 0; Thanks. James