Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2911184pxb; Tue, 24 Aug 2021 10:24:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMmQ6nxwTuNvuDRAo8+aavuAVJqtMFoIfHsFl9YOsO2yAuxMEd+63MZDDvIaj+Z3kt7kV5 X-Received: by 2002:a6b:8e87:: with SMTP id q129mr14955742iod.176.1629825886807; Tue, 24 Aug 2021 10:24:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629825886; cv=none; d=google.com; s=arc-20160816; b=K2WAAPI7S9hAb3EEd7EPNPUs1+neYAOuwWi6x5scQjOMzNm5ydBjAbuajVuTn26b9t 52L+0LlLgu1AOt/AV29KgYzbPxnaqJsZuhzxXGy8w5Bd3c2iVYNw8z/yXc7u65LKhqG4 i/oqxZbhAngeY0yweeE/uR8bRpp3d07RY30yrWaErUhtbWUtpSb6d9ApSnPap+U1+Bnf HEsqFhtx0zN+3jh6KgbORJZDcBJWcIDu/yKgRP1X4VegZsrAa6Jg3XRuVIYG2bXXPd5+ W+lSaCZ7B4diWHhMxnwV/lcgzhiw9xzqJ7KtO64DAZONawq2K7LsegRDZBGxuS3/A4Nz Dm6w== 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 :dkim-signature; bh=d1IpOoluot533Xq9CLEXEhaYrPu3hiVITSd71SiXrBw=; b=g5g0JhqlT+d2qIVYBrjxqnUa4ZsOcJQm5tuJpyujULshqrLW+hxFH8zdwnsdmZHXMS MxWMQCmm1EM6kOVhAr2LM1PJn+B770gZIz7yK+Wfzt7BCUPqPfq3B3YLjhwhVlwNZOq4 ATy+2vc2zR4r9d4cUuipSar1KuyTEqhBR87W0dHFnX0m5K5lsck69LTzXRkICYJgcqGO MA8/XqlAx98NXO+0wI3Dyn2CZRXPSouOnthUqubAmlz+e4bOoysQ6rHkmyNXe/x7N6Wj eBKOYosklZuqt3lZtXqbaVdUmiID/EqoVL+otCioE3sM3AXgrfyAKVQ5t/lcbqXtzshS tRFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Fa5fKFwJ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n22si17084014jaj.53.2021.08.24.10.24.35; Tue, 24 Aug 2021 10:24:46 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Fa5fKFwJ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239862AbhHXRXv (ORCPT + 99 others); Tue, 24 Aug 2021 13:23:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:59766 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238906AbhHXRUy (ORCPT ); Tue, 24 Aug 2021 13:20:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 35E0E61B01; Tue, 24 Aug 2021 17:03:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629824600; bh=oLyHG1QY97lmFj2v8oQmseuWe0Vyeh/5WCM8bOcForc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fa5fKFwJw13tjgVxDJP0OJxhZxOg4T7YhIgGmq6CBgraZH0MDr7R7vheJtBRmz94z 4NcKqYQEa4a68KTkOoR75ozM6uX2OhAVE+YWu0oS5/Pk0NhNdBT+7/2Vzwp9LiAaFz uwxWpVIuACLL+L2HhEg18XnEV3VNNF1cqxNQs6HSwiBSJrdp2h2lVeWlsUDTHfjpIn pXYuhqizYUEEKCe/JSLzmTfP1YlwhMNT/l5+pQsvdBp4pp6sg5T9qiCQQjN5e77J2i HJtdxZlBVBNxhEamWX72JYexwgxuHuNeh7W0XlIqnaE1p61P4HK32T9OBrgIgnV/wO DhJa44K+2pFIg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Babu Moger , =?UTF-8?q?Pawe=C5=82=20Szulik?= , Borislav Petkov , Reinette Chatre , Greg Kroah-Hartman Subject: [PATCH 4.19 29/84] x86/resctrl: Fix default monitoring groups reporting Date: Tue, 24 Aug 2021 13:01:55 -0400 Message-Id: <20210824170250.710392-30-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210824170250.710392-1-sashal@kernel.org> References: <20210824170250.710392-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.205-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-4.19.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 4.19.205-rc1 X-KernelTest-Deadline: 2021-08-26T17:02+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Babu Moger commit 064855a69003c24bd6b473b367d364e418c57625 upstream. Creating a new sub monitoring group in the root /sys/fs/resctrl leads to getting the "Unavailable" value for mbm_total_bytes and mbm_local_bytes on the entire filesystem. Steps to reproduce: 1. mount -t resctrl resctrl /sys/fs/resctrl/ 2. cd /sys/fs/resctrl/ 3. cat mon_data/mon_L3_00/mbm_total_bytes 23189832 4. Create sub monitor group: mkdir mon_groups/test1 5. cat mon_data/mon_L3_00/mbm_total_bytes Unavailable When a new monitoring group is created, a new RMID is assigned to the new group. But the RMID is not active yet. When the events are read on the new RMID, it is expected to report the status as "Unavailable". When the user reads the events on the default monitoring group with multiple subgroups, the events on all subgroups are consolidated together. Currently, if any of the RMID reads report as "Unavailable", then everything will be reported as "Unavailable". Fix the issue by discarding the "Unavailable" reads and reporting all the successful RMID reads. This is not a problem on Intel systems as Intel reports 0 on Inactive RMIDs. Fixes: d89b7379015f ("x86/intel_rdt/cqm: Add mon_data") Reported-by: Paweł Szulik Signed-off-by: Babu Moger Signed-off-by: Borislav Petkov Acked-by: Reinette Chatre Cc: stable@vger.kernel.org Link: https://bugzilla.kernel.org/show_bug.cgi?id=213311 Link: https://lkml.kernel.org/r/162793309296.9224.15871659871696482080.stgit@bmoger-ubuntu Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/cpu/intel_rdt_monitor.c | 27 ++++++++++++------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/arch/x86/kernel/cpu/intel_rdt_monitor.c b/arch/x86/kernel/cpu/intel_rdt_monitor.c index 5dfa5ab9a5ae..6eeb17dfde48 100644 --- a/arch/x86/kernel/cpu/intel_rdt_monitor.c +++ b/arch/x86/kernel/cpu/intel_rdt_monitor.c @@ -233,15 +233,14 @@ static u64 mbm_overflow_count(u64 prev_msr, u64 cur_msr) return chunks >>= shift; } -static int __mon_event_count(u32 rmid, struct rmid_read *rr) +static u64 __mon_event_count(u32 rmid, struct rmid_read *rr) { struct mbm_state *m; u64 chunks, tval; tval = __rmid_read(rmid, rr->evtid); if (tval & (RMID_VAL_ERROR | RMID_VAL_UNAVAIL)) { - rr->val = tval; - return -EINVAL; + return tval; } switch (rr->evtid) { case QOS_L3_OCCUP_EVENT_ID: @@ -253,12 +252,6 @@ static int __mon_event_count(u32 rmid, struct rmid_read *rr) case QOS_L3_MBM_LOCAL_EVENT_ID: m = &rr->d->mbm_local[rmid]; break; - default: - /* - * Code would never reach here because - * an invalid event id would fail the __rmid_read. - */ - return -EINVAL; } if (rr->first) { @@ -308,23 +301,29 @@ void mon_event_count(void *info) struct rdtgroup *rdtgrp, *entry; struct rmid_read *rr = info; struct list_head *head; + u64 ret_val; rdtgrp = rr->rgrp; - if (__mon_event_count(rdtgrp->mon.rmid, rr)) - return; + ret_val = __mon_event_count(rdtgrp->mon.rmid, rr); /* - * For Ctrl groups read data from child monitor groups. + * For Ctrl groups read data from child monitor groups and + * add them together. Count events which are read successfully. + * Discard the rmid_read's reporting errors. */ head = &rdtgrp->mon.crdtgrp_list; if (rdtgrp->type == RDTCTRL_GROUP) { list_for_each_entry(entry, head, mon.crdtgrp_list) { - if (__mon_event_count(entry->mon.rmid, rr)) - return; + if (__mon_event_count(entry->mon.rmid, rr) == 0) + ret_val = 0; } } + + /* Report error if none of rmid_reads are successful */ + if (ret_val) + rr->val = ret_val; } /* -- 2.30.2