From patchwork Wed Mar 8 13:45:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Singh Tomar X-Patchwork-Id: 13165866 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4A27AC678D5 for ; Wed, 8 Mar 2023 13:47:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=G4N00HzISsL8eqFNI08vGlAFkT1SLoVPLu8ebQNNbf4=; b=Dj35n1n1W/q+5Y heMy+7ilPgnc29aoxkbEcTq6ymthFPaENzT47RG9QlKd5Y3HRBqEUVESkueCJd6FbTtc+EgWr/bdn YQVIrk3TacP+7pjaUU+q40nPsWiXSONZM02AmkhG/Eef4+i0JBMvd1yOuxSbnS5qF9RHIfrshWoqT JHZ/lQNXwWpeYyoqWXQeTohSrAe/SnswZRE5HLURcB7MyVFGbTP9JUkI5y+AxPbHpXg/shGk2vr/P GUhyqBrLF/GMMTjIMjBL9VEgWlIOuLRBUAlQRlTCV8Lw4aWCIG2odC7/q2byt2TUEufNBncGJWNz5 p8T78GuJxbgHgy9nbQdg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZu7q-005Gn3-Q7; Wed, 08 Mar 2023 13:46:38 +0000 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZu7e-005GiM-Rz for linux-arm-kernel@lists.infradead.org; Wed, 08 Mar 2023 13:46:28 +0000 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3286q8It010722; Wed, 8 Mar 2023 05:46:23 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=T6/5SzI6GatMHFbFgl98l/8pOSm6MmoHYCnHQ6pK554=; b=i8fVh0tIVdVuPODLR6rvEJ8pANnJu70c89WBqSOyBa0AVlAGiWrLbrIp6Y1rGZZcIwYM xk0YriSCBAEcIkk6oT41TWDzL8bA6On2gUEhEo3NJglSscG290SGpzeXH2FptYKOp1ln yNClAKJ3xFszcVUffTF533APCdRxHgLBnTEBG01KmrRHeTjrPdtWpKpi/sg+GUuWIBi9 VzVXO80GHIZvFxUaiEKfTJBrh7FIffUlqLQ5t23DmMEZtPZ/ZA+uMOXkEsz2jzD3Uo7W llktkAsWw91Lb0GU1BV4MAD9F+UZ9OA5CTaS+9QwT+21o/gSuSkbIWYN6Xcst2/0e8ia 2Q== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3p6ff3bcrd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 08 Mar 2023 05:46:23 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Wed, 8 Mar 2023 05:46:20 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.42 via Frontend Transport; Wed, 8 Mar 2023 05:46:20 -0800 Received: from localhost.localdomain (unknown [10.28.36.167]) by maili.marvell.com (Postfix) with ESMTP id A08FD5B6932; Wed, 8 Mar 2023 05:46:15 -0800 (PST) From: Amit Singh Tomar To: CC: , , , Amit Singh Tomar Subject: [RFC 1/2] arm_mpam: resctrl: Add support for mbm total Date: Wed, 8 Mar 2023 19:15:38 +0530 Message-ID: <20230308134539.3071034-2-amitsinght@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230308134539.3071034-1-amitsinght@marvell.com> References: <20230308134539.3071034-1-amitsinght@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: YYskj-ITsfkNARSRJM3MutT8oKfWYZxd X-Proofpoint-GUID: YYskj-ITsfkNARSRJM3MutT8oKfWYZxd X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-08_08,2023-03-08_03,2023-02-09_01 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230308_054627_061720_1666A0B8 X-CRM114-Status: GOOD ( 24.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently, the driver enables "mbm_local" if mpam class that is picked to be "L3" resource control, and bandwidth counter is enumerated as part of "L3" resource control. But this will be a problem when bandwidth counter is hosted by DDR MSC, and is enumerated as part of "MB" mpam class. To support this configuration, lets enable mbm_total if the mpam class picked to be "MB" resource control. mbm_local is still used for the bandwidth counter enumerated as part of "L3" resource control. Signed-off-by: Amit Singh Tomar Change-Id: Ida7c0367465ba9f1343af3226f475b862d0fa214 --- drivers/perf/resctrl_pmu.c | 1 + drivers/platform/mpam/mpam_resctrl.c | 35 ++++++++++++++++++++++++++-- fs/resctrl/monitor.c | 28 +++++++++++++--------- include/linux/arm_mpam.h | 7 ++---- 4 files changed, 53 insertions(+), 18 deletions(-) diff --git a/drivers/perf/resctrl_pmu.c b/drivers/perf/resctrl_pmu.c index 99a2b90b5d83..ed77edc59d23 100644 --- a/drivers/perf/resctrl_pmu.c +++ b/drivers/perf/resctrl_pmu.c @@ -57,6 +57,7 @@ static struct rdt_resource *resctrl_event_get_resource(u16 event_num) switch (event_id) { case QOS_L3_OCCUP_EVENT_ID: case QOS_L3_MBM_TOTAL_EVENT_ID: + return resctrl_arch_get_resource(RDT_RESOURCE_MBA); case QOS_L3_MBM_LOCAL_EVENT_ID: return resctrl_arch_get_resource(RDT_RESOURCE_L3); } diff --git a/drivers/platform/mpam/mpam_resctrl.c b/drivers/platform/mpam/mpam_resctrl.c index a1304fbfb26f..e1b7d27ed7ad 100644 --- a/drivers/platform/mpam/mpam_resctrl.c +++ b/drivers/platform/mpam/mpam_resctrl.c @@ -30,7 +30,7 @@ static struct mpam_resctrl_res mpam_resctrl_exports[RDT_NUM_RESOURCES]; static bool exposed_alloc_capable; static bool exposed_mon_capable; -static struct mpam_class *mbm_local_class; +static struct mpam_class *mbm_local_class, *mbm_total_class; /* * MPAM emulates CDP by setting different PARTID in the I/D fields of MPAM1_EL1. @@ -38,6 +38,11 @@ static struct mpam_class *mbm_local_class; */ static bool cdp_enabled; +bool resctrl_arch_is_mbm_total_enabled(void) +{ + return mbm_total_class; +} + /* * If resctrl_init() succeeded, resctrl_exit() can be used to remove support * for the filesystem in the event of an error. @@ -300,6 +305,11 @@ int resctrl_arch_mon_ctx_alloc_no_wait(struct rdt_resource *r, int evtid) return mpam_alloc_mbwu_mon(res->class); case QOS_L3_MBM_TOTAL_EVENT_ID: + if (mpam_monitors_free_runing) + return USE_RMID_IDX; + res = container_of(r, struct mpam_resctrl_res, resctrl_res); + + return mpam_alloc_mbwu_mon(res->class); default: return -EOPNOTSUPP; } @@ -325,6 +335,13 @@ void resctrl_arch_mon_ctx_free(struct rdt_resource *r, int evtid, int ctx) wake_up(&resctrl_mon_ctx_waiters); return; case QOS_L3_MBM_TOTAL_EVENT_ID: + if (mpam_monitors_free_runing) + return; + res = container_of(r, struct mpam_resctrl_res, resctrl_res); + + mpam_free_mbwu_mon(res->class, ctx); + wake_up(&resctrl_mon_ctx_waiters); + return; default: return; } @@ -350,6 +367,9 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_domain *d, type = mpam_feat_msmon_mbwu; break; case QOS_L3_MBM_TOTAL_EVENT_ID: + type = mpam_feat_msmon_mbwu; + break; + default: return -EOPNOTSUPP; } @@ -726,6 +746,7 @@ static int mpam_resctrl_resource_init(struct mpam_resctrl_res *res) } } else if (res->resctrl_res.rid == RDT_RESOURCE_MBA) { struct mpam_props *cprops = &class->props; + bool has_mbwu = class_has_usable_mbwu(class); /* TODO: kill these properties off as they are derivatives */ r->format_str = "%d=%0*u"; @@ -750,7 +771,17 @@ static int mpam_resctrl_resource_init(struct mpam_resctrl_res *res) r->alloc_capable = true; exposed_alloc_capable = true; } - } + + if (has_mbwu) { + r->mon_capable = true; + exposed_mon_capable = true; + } + + r->num_rmid = 1; + + if (class_has_usable_mbwu(class)) + mbm_total_class = class; + } return 0; } diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 18b544c4ca79..843759131f88 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -448,7 +448,8 @@ static void update_mba_bw(struct rdtgroup *rgrp, struct rdt_domain *dom_mbm) struct list_head *head; struct rdtgroup *entry; - if (!resctrl_arch_is_mbm_local_enabled()) + if (!resctrl_arch_is_mbm_local_enabled() || + !resctrl_arch_is_mbm_total_enabled()) return; r_mba = resctrl_arch_get_resource(RDT_RESOURCE_MBA); @@ -721,29 +722,34 @@ static struct mon_evt mbm_local_event = { * because as per the SDM the total and local memory bandwidth * are enumerated as part of L3 monitoring. */ -static void l3_mon_evt_init(struct rdt_resource *r) +static void resource_mon_evt_init(struct rdt_resource *r) { INIT_LIST_HEAD(&r->evt_list); - if (resctrl_arch_is_llc_occupancy_enabled()) + if (resctrl_arch_is_llc_occupancy_enabled() && !strcmp(r->name, "L3")) list_add_tail(&llc_occupancy_event.list, &r->evt_list); - if (resctrl_arch_is_mbm_total_enabled()) + if (resctrl_arch_is_mbm_total_enabled() && !strcmp(r->name, "MB")) list_add_tail(&mbm_total_event.list, &r->evt_list); - if (resctrl_arch_is_mbm_local_enabled()) + if (resctrl_arch_is_mbm_local_enabled() && !strcmp(r->name, "L3")) list_add_tail(&mbm_local_event.list, &r->evt_list); } int resctrl_mon_resource_init(void) { - struct rdt_resource *r = resctrl_arch_get_resource(RDT_RESOURCE_L3); + enum resctrl_res_level i; + struct rdt_resource *r; int ret; - ret = dom_data_init(r); - if (ret) - return ret; + for (i = 0; i < RDT_NUM_RESOURCES; i++) { + r = resctrl_arch_get_resource(i); - if (r->mon_capable) - l3_mon_evt_init(r); + ret = dom_data_init(r); + if (ret) + return ret; + + if (r->mon_capable) + resource_mon_evt_init(r); + } return 0; } diff --git a/include/linux/arm_mpam.h b/include/linux/arm_mpam.h index 1d82d9dfbc3f..2f3c354c13d0 100644 --- a/include/linux/arm_mpam.h +++ b/include/linux/arm_mpam.h @@ -47,6 +47,7 @@ static inline bool resctrl_arch_event_is_free_running(enum resctrl_event_id evt) case QOS_L3_OCCUP_EVENT_ID: return true; case QOS_L3_MBM_TOTAL_EVENT_ID: + return mpam_monitors_free_runing; case QOS_L3_MBM_LOCAL_EVENT_ID: return mpam_monitors_free_runing; } @@ -65,11 +66,7 @@ bool resctrl_arch_alloc_capable(void); bool resctrl_arch_mon_capable(void); bool resctrl_arch_is_llc_occupancy_enabled(void); bool resctrl_arch_is_mbm_local_enabled(void); - -static inline bool resctrl_arch_is_mbm_total_enabled(void) -{ - return false; -} +bool resctrl_arch_is_mbm_total_enabled(void); /* reset cached configurations, then all devices */ void resctrl_arch_reset_resources(void);