From patchwork Thu Dec 7 19:21:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shanker Donthineni X-Patchwork-Id: 13483869 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 2A5EDC4167B for ; Thu, 7 Dec 2023 19:22:50 +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: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:In-Reply-To:References: List-Owner; bh=Vvl9WMRtarUkLq4XRen+oAkS1DAxGbQjFb21jvA1QyI=; b=0gJ7rSobOV9+LL 3raR8BxRuaK2E5dg6ufv7oS39RILrkzLqSltODsqod1d0eDL4IszWqVUkgE3MSKIFBqTjSLgfPoPu EvF3RbQa7hdIh3VKuqSNpTAMk2rrEyEzvOU6M4CNk9mYO9Mb30UTjubk56dbf2oMNe8dhPd9BLRjU +3BmvPGxpW0+1mHld8p7DoqgZPDWcHoIB8sh1/kwPx1ASIPMUUiMT1/6MdXrk9E/xAVIYtN5loiPw G7yM7bIWW7/xNpaNIsCqog+9hAbFLEEhvt5PhS8lLadYic6i5EnbQtyjf4MB3Qcz0bngrFPXuRI1X oWL/yMGTw4fkB4zsh+TQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rBJx0-00Dijf-3C; Thu, 07 Dec 2023 19:22:22 +0000 Received: from mail-bn8nam04on20631.outbound.protection.outlook.com ([2a01:111:f400:7e8d::631] helo=NAM04-BN8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rBJwx-00Dij9-0z for linux-arm-kernel@lists.infradead.org; Thu, 07 Dec 2023 19:22:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WXwYODXtDPyrnsjXY2hvlhJJbUyPqyGfxAJ8Govb6iG/7ZDH/wR5F07TaWLIO4pSkTVSkLBTfIVyWJ7zfShN1TzXP20FyX5a2lsP+xp8bk0kbQc7h0sthLAMx+amh+x5gQ+VDWHv6TtwwBrxniVcxYw68g4XhDyUZz6VNW/caDwhnzYcgmiDgOoJQQZYtvcvKraVtyM7Yy34SpOB3eLmQqmyG0vLSnOc2PYOtOtrd4pOtxRh3Ej34nC0rZpHs9pcz8OpjHiZNvK9MhOhEa5PWCs3zyuPRbgAECc6jYyBvszg8BrI8hDuAf5ekjevpOYHSPzrO4J/xwcm6hgW7ktTsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bESvgufJIPeWCvkJfF+Axf6usoe7sYSUJxJMoUl4I/Y=; b=LGkPwctKEdPJklvyvT8o4ff4W0kFiZkDtp6u8b2f5sVcRtnX22vNzCQyY2j0o2zmY8bK4bFRwTtVOcenE9xzmZtY2XYKj1pY5g5xWuQNot2Z14n0bRSLczFzl3FhbST0f7yI6ZB0Yc4H/05QfYIWWgRUjUxBmUMv70UbXoAv+ye1+31EOvaMC8QEUvxuNWaKbibPwRlmFb3XO978vqvKCW8iblMXu4MhkpbrKYaCeNh3ZFHKi2+rrX+ITLwfVNrG27MC+KARMi6Eb0WqaxJTxMqplMzTithZGjS2ZhpAwx05Hyns/oiWEWoysDDdOdl0rFK9/XaEiAG0j+rd9XDgJA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) smtp.rcpttodomain=arm.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bESvgufJIPeWCvkJfF+Axf6usoe7sYSUJxJMoUl4I/Y=; b=nL+S8UXf9+FfhJsR4LKfR/JDer6JfQhICWBmqtSXVhugorlhEN2gmoZhEm1Kn3O40U1P/qNxE39fsp0E8Hdj4AHxrmEDKb200NUDHeEow6NId3xhez+Va4kki5EtWKiMGbCTTHxYzvq6CZb6pWnv+Uek9F8gRqbglMcTF0xlTUc7AiRBKNbbSTy9+T6yfpMqckC1c3VUkQPFwI1nV6X+SU8J3Ii1XFNLt4M9ZmLCPg1T/w2VuGYON9Og0D7eGWuocc5mCChJ1fPLRdWsFkNfS8BuwOk0xQZGMzTEokjbDH5cxF13OMDEkMJFfw/73teofZpu1TtVhgTbOGXqznHmEg== Received: from CY5PR15CA0140.namprd15.prod.outlook.com (2603:10b6:930:67::10) by IA1PR12MB6555.namprd12.prod.outlook.com (2603:10b6:208:3a1::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.27; Thu, 7 Dec 2023 19:22:04 +0000 Received: from CY4PEPF0000EE34.namprd05.prod.outlook.com (2603:10b6:930:67:cafe::db) by CY5PR15CA0140.outlook.office365.com (2603:10b6:930:67::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.26 via Frontend Transport; Thu, 7 Dec 2023 19:22:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by CY4PEPF0000EE34.mail.protection.outlook.com (10.167.242.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.20 via Frontend Transport; Thu, 7 Dec 2023 19:22:04 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 7 Dec 2023 11:21:51 -0800 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 7 Dec 2023 11:21:50 -0800 Received: from SDONTHINENI-DESKTOP.nvidia.com (10.127.8.12) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Thu, 7 Dec 2023 11:21:49 -0800 From: Shanker Donthineni To: James Morse CC: Catalin Marinas , Mark Rutland , Shanker Donthineni , , Rohit Mathew , Vikram Sethi Subject: [PATCH v2 1/1] arm_mpam: Introduce resctrl_arch_mbm_has_long_counter() Date: Thu, 7 Dec 2023 13:21:43 -0600 Message-ID: <20231207192143.302910-1-sdonthineni@nvidia.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-NVConfidentiality: public X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE34:EE_|IA1PR12MB6555:EE_ X-MS-Office365-Filtering-Correlation-Id: 2746b197-2f51-4300-0b31-08dbf759cb99 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wHyCfu5b7KTq76jLKspgL/OkOUcroAxwpQHOZ0dBjhcC2lKZxN9JPkgAZT4eSmeVtVv1H1Sa4zcRBJ96Vfn9y3jNqySRD10jCvXQAZpTX6Lf/sVb5a8me5o0Amjbbrd6XbEtgO261tx6iP+gqusdb+z4NiqKwmyDMOO5Xea9NPnIlsCcr4p+iEvHOhPKUZ1/mcMBj6J0Z8A+VZm7vrmMtuWNmw6vskngAiYGcXSE4WyM2vrBoJAebifkwf2tyruL6mP/pjt1E2gwFFIbOiD0iBxMbANinrHgsMx7QRKxuybCunpZSXXjeOremDeEeRdP0SahWME/d5JV6s4sBOjoVyR++Zv/e35d7quOtk7tchWDT0RouAgA2N7cP3h3fZA8Lp4WOPZEC2fHR5dtFvIoVvIC7bgTMcJ8Mb9HcUOPfWJz8XCKAGDbtAydIYbkAJYVQK7MS/R24warbO2ua7f2PRr3n109tQgbKelt8YGfzrvml4P+pKC95C/QfE3rC+Ak05ks2wFakcBAfpGNbCoy+cCE9uR9JL7B7X47xHibZsdOpMqYnf/9Ud+8F8GzRz9QE/a3I0HIi6kONGu31DsDum9uxIjvhvyPaLhiWlCMRI73bPoTrqsnPJ+b59CDAufMjzyUxBpykfOfsLiJHVElKd7KeRcC7k/W3byH9OKUnMYTGZJJSLynNrD2UUEUXJkR9NWxSL/65MF2Sq9QaiFztsNTg1xTkNWRkmS0Vo0hDz+DQHEqWMAXqPMWb46kGax9pY1YWD7f959+EM3a9MyUOw== X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(346002)(396003)(39860400002)(376002)(136003)(230922051799003)(1800799012)(82310400011)(64100799003)(451199024)(186009)(40470700004)(46966006)(36840700001)(40460700003)(40480700001)(36860700001)(41300700001)(5660300002)(2906002)(36756003)(8676002)(316002)(4326008)(6916009)(336012)(7636003)(356005)(426003)(478600001)(1076003)(6666004)(7696005)(2616005)(54906003)(86362001)(70586007)(82740400003)(26005)(70206006)(107886003)(47076005)(8936002)(83380400001)(309714004);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2023 19:22:04.1918 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2746b197-2f51-4300-0b31-08dbf759cb99 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE34.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6555 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231207_112219_434690_BC5D532C X-CRM114-Status: GOOD ( 13.80 ) 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 It takes a substantial amount of time for long counters, which have more than 32 bits, to cause overflow. To support enable/disable of a periodic handler for monitoring memory bandwidth, introduce a common function resctrl_arch_mbm_has_long_counter(). FOr MPAM, disable periodic handler if the MSC component is capable of supporting 63-bit counters. Signed-off-by: Shanker Donthineni --- Changes since v1: - Skip 32bit overflow of MBW when checking config mismatch arch/x86/include/asm/resctrl.h | 5 +++++ drivers/platform/mpam/mpam_devices.c | 2 ++ drivers/platform/mpam/mpam_resctrl.c | 11 +++++++++++ fs/resctrl/rdtgroup.c | 9 +++++---- include/linux/arm_mpam.h | 1 + 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index 1adf16660ac10..96c7d86ab9b69 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -100,6 +100,11 @@ static inline bool resctrl_arch_is_mbm_local_enabled(void) return (rdt_mon_features & (1 << QOS_L3_MBM_LOCAL_EVENT_ID)); } +static bool resctrl_arch_mbm_has_long_counter(void) +{ + return false; +} + /* * __resctrl_sched_in() - Writes the task's CLOSid/RMID to IA32_PQR_MSR * diff --git a/drivers/platform/mpam/mpam_devices.c b/drivers/platform/mpam/mpam_devices.c index f7bcf9737dcf8..5d90eaa66711d 100644 --- a/drivers/platform/mpam/mpam_devices.c +++ b/drivers/platform/mpam/mpam_devices.c @@ -870,6 +870,8 @@ static void read_msmon_ctl_flt_vals(struct mon_read *m, u32 *ctl_val, case mpam_feat_msmon_mbwu: *ctl_val = mpam_read_monsel_reg(msc, CFG_MBWU_CTL); *flt_val = mpam_read_monsel_reg(msc, CFG_MBWU_FLT); + if (mpam_ris_has_mbwu_long_counter(m->ris)) + *ctl_val &= ~MSMON_CFG_x_CTL_OFLOW_STATUS; break; default: return; diff --git a/drivers/platform/mpam/mpam_resctrl.c b/drivers/platform/mpam/mpam_resctrl.c index 8ec963aca9d49..dee82b3c0dbe3 100644 --- a/drivers/platform/mpam/mpam_resctrl.c +++ b/drivers/platform/mpam/mpam_resctrl.c @@ -81,6 +81,17 @@ bool resctrl_arch_is_mbm_total_enabled(void) return mbm_total_class; } +bool resctrl_arch_mbm_has_long_counter(void) +{ + if (mbm_local_class) + return !!mpam_has_feature(mpam_feat_msmon_mbwu_63counter, &mbm_local_class->props); + + if (mbm_total_class) + return !!mpam_has_feature(mpam_feat_msmon_mbwu_63counter, &mbm_total_class->props); + + return false; +} + bool resctrl_arch_get_cdp_enabled(enum resctrl_res_level rid) { switch (rid) { diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 43efed317f1b7..cff77915395b0 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -2774,7 +2774,7 @@ static int rdt_get_tree(struct fs_context *fc) if (resctrl_arch_alloc_capable() || resctrl_arch_mon_capable()) resctrl_mounted = true; - if (resctrl_is_mbm_enabled()) { + if (resctrl_is_mbm_enabled() && (!resctrl_arch_mbm_has_long_counter())) { list_for_each_entry(dom, &l3->domains, list) mbm_setup_overflow_handler(dom, MBM_OVERFLOW_INTERVAL, RESCTRL_PICK_ANY_CPU); @@ -4014,7 +4014,7 @@ static void _resctrl_offline_domain(struct rdt_resource *r, if (resctrl_mounted && resctrl_arch_mon_capable()) rmdir_mondata_subdir_allrdtgrp(r, d->id); - if (resctrl_is_mbm_enabled()) + if (resctrl_is_mbm_enabled() && (!resctrl_arch_mbm_has_long_counter())) cancel_delayed_work(&d->mbm_over); if (resctrl_arch_is_llc_occupancy_enabled() && has_busy_rmid(d)) { /* @@ -4087,7 +4087,7 @@ static int _resctrl_online_domain(struct rdt_resource *r, struct rdt_domain *d) if (err) return err; - if (resctrl_is_mbm_enabled()) { + if (resctrl_is_mbm_enabled() && (!resctrl_arch_mbm_has_long_counter())) { INIT_DELAYED_WORK(&d->mbm_over, mbm_handle_overflow); mbm_setup_overflow_handler(d, MBM_OVERFLOW_INTERVAL, RESCTRL_PICK_ANY_CPU); @@ -4155,7 +4155,8 @@ void resctrl_offline_cpu(unsigned int cpu) d = resctrl_get_domain_from_cpu(cpu, l3); if (d) { - if (resctrl_is_mbm_enabled() && cpu == d->mbm_work_cpu) { + if (resctrl_is_mbm_enabled() && (!resctrl_arch_mbm_has_long_counter()) && + cpu == d->mbm_work_cpu) { cancel_delayed_work(&d->mbm_over); mbm_setup_overflow_handler(d, 0, cpu); } diff --git a/include/linux/arm_mpam.h b/include/linux/arm_mpam.h index 8b80745132723..766117c5ff555 100644 --- a/include/linux/arm_mpam.h +++ b/include/linux/arm_mpam.h @@ -79,6 +79,7 @@ bool resctrl_arch_mon_capable(void); bool resctrl_arch_is_llc_occupancy_enabled(void); bool resctrl_arch_is_mbm_local_enabled(void); bool resctrl_arch_is_mbm_total_enabled(void); +bool resctrl_arch_mbm_has_long_counter(void); /* reset cached configurations, then all devices */ void resctrl_arch_reset_resources(void);