From patchwork Thu Oct 26 14:31:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shanker Donthineni X-Patchwork-Id: 13437617 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 A6966C25B67 for ; Thu, 26 Oct 2023 14:32:20 +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=dQwbqaE25H4x11jdVUoXbVyCraASiTwZYdQe/YJhPrE=; b=MC0L06e7+yTbA5 lcXJy6+ETUtAZli7u0Yg0k1/6g4m8bN3cA1gNLO50Qi9ylZO8v0RvWkvS/msNES40yPZdSxUwxOol dNIzBTmO3EfkG09FMlV/8ejZDzO1UyuteeizkPhLke/6jbDVq3RI1J/VVU16qmkimUiL6/UpN97Ec Uo5PXi8o6szXn8UydR+c58pEG4Yq03qEkaO6/raxbEu8hXJQoxEmNsW3cZdLCEbsNGKha1WEppm3U duI8yhZ0EkuvXZsxBDk64eHzYUVKinC9UxjzF54ccKtm3j+C/vL9c7e9bU5YGFrTwPG03e+ebeDhh Qw1llVyyYswxrIxDcm2Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qw1Os-00EggT-0f; Thu, 26 Oct 2023 14:31:54 +0000 Received: from mail-sn1nam02on20620.outbound.protection.outlook.com ([2a01:111:f400:7ea9::620] helo=NAM02-SN1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qw1Oa-00EgWQ-1i for linux-arm-kernel@lists.infradead.org; Thu, 26 Oct 2023 14:31:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C8/r/n46ttpYESmrNI/NHHydSovNVxmp1CfEK7H1ATptQZeRbSBfTppJOqqKWYtOk7SSvMbmk97jFj+Uye0kP9FW2i+lfPioBUhPNC9e66fjn8Tg0IbCQ3Q3S9caMGWiP8Z3AV+GfxGjLy12eyjI99UIsxWvh0PKsZyaZFH8BD3XTgZmrGq0IbHqK/JMxG2EpuSENXczf85lvooyi7gK2xEdyfRVIo1t4CYyvWx6Ee4JEl+WFmAfaAbdewvRqcIt/z18PFvwFPlVpKF3gaincz17EXDxZk0jl3YymGqiVZsKokKBqgIa6Yc+XHS6Q764/4hhBpiIwymWyiQFoxd5Tw== 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=VFmZd1CkKQzN5HymDI2VkOoCED16qepAVKWHReKAAQE=; b=I1fLTDLB1f3JhupQUsRTwGgQpWJH9Pbftp5t7ZKTuJwvow84lnu7DjXfBSqE91yiTc3zKTuHp5U5ADn49n6GCAS+8NmmGsotaanI16PXUz4GV/AL8VcU8jcTos5qUTCw3Snsaf8AEhbcN6dOe+yNAxy0gH0xVhn576VjIg1VRAiMIF49hU22k/UqaB8QkM0zY0eXRt9wLQjzyWBadIR0Gy+9j3awPslOjAd5+IZpO9H29UwRT7yphA7Tt4ej31qmuQSti+/u0DzcxCHbrSEWdIRo2wOi1diun0HWAZZI4NjN0rUx1gOkyjuCvseEMGRyuEz+3w60Pb4Vlc4OzrTlrw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) 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=VFmZd1CkKQzN5HymDI2VkOoCED16qepAVKWHReKAAQE=; b=B8UQNk+pMv3JnBHE61gNttpWyr7G+08OuDby4emiArx2RJWlWgfmWRyhNcuVaR5QDEi3hM83Ks22k8wHm9H62WRa8v+LvUxfwybJ+vJoo1DQx79UCkZN+F0sqsKY/XqTNIt3LtNC7ztC70Gy1I4sxEHxT4N4gOOSlb+4aI8iqhBUs3UqoHcsOHWKAPKLXE4UFF/E+2frsRoVJNb82Y5MjBxMSf9Ub6V/J3OtaReXjZp7uye3oDu2B8SmCUZ2i41EV9jMsfvAM1ThGxDxT3chrdNLfCkAlE3UZjeHR0aQEdP97UXSb+fsddSo2t1raxW5olCdqMxRtfDU4Jv3zy6kiA== Received: from SA1P222CA0150.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:3c2::20) by IA1PR12MB8585.namprd12.prod.outlook.com (2603:10b6:208:451::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.19; Thu, 26 Oct 2023 14:31:32 +0000 Received: from SA2PEPF000015C8.namprd03.prod.outlook.com (2603:10b6:806:3c2:cafe::c7) by SA1P222CA0150.outlook.office365.com (2603:10b6:806:3c2::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.22 via Frontend Transport; Thu, 26 Oct 2023 14:31:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) 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.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by SA2PEPF000015C8.mail.protection.outlook.com (10.167.241.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.15 via Frontend Transport; Thu, 26 Oct 2023 14:31:31 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 26 Oct 2023 07:31:10 -0700 Received: from drhqmail202.nvidia.com (10.126.190.181) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.41; Thu, 26 Oct 2023 07:31:10 -0700 Received: from SDONTHINENI-DESKTOP.nvidia.com (10.127.8.12) by mail.nvidia.com (10.126.190.181) with Microsoft SMTP Server id 15.2.986.41 via Frontend Transport; Thu, 26 Oct 2023 07:31:09 -0700 From: Shanker Donthineni To: James Morse CC: Catalin Marinas , Mark Rutland , Will Deacon , Shanker Donthineni , , "Rohit Mathew" , Vikram Sethi Subject: [PATCH 1/1] arm_mpam: Introduce resctrl_arch_mbm_has_long_counter() Date: Thu, 26 Oct 2023 09:31:07 -0500 Message-ID: <20231026143107.2670808-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: SA2PEPF000015C8:EE_|IA1PR12MB8585:EE_ X-MS-Office365-Filtering-Correlation-Id: 9795c9f3-b355-42b3-97e1-08dbd6303fca X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Z6vsGg/ymgdmgWDhrdo2QW2SbEroDctOpNmriOx1zSrcVe1sL0s7HH6SeaF6zfnxfwyE5ZNePYgnBhg3oQx6+1cPVKp0pi+G/H4BeUceVQZMt+lK/m3ThROC76f8Ee3cS1/b7dWGBYza7lYrMAJ+9VbWjQ8F9wUa3tngs73gJNgBr05nMvNTUQOJkgUR5Bgv2m7/Mb/0fBAE1XS6KSFFQsldjlpUF+EtXvVhp8NtfG5GQKaCcs/2UQHMpgm+nEOYjQ/DDoSOzdX44JCUIRt46e27S2YyawpEIgcTWUf9FZV+PiNh+iQcLcTQlFWXFDt7PiLUs/WIjrqVmw4BiTjia8s6OtH5v8casDsBPUIhHwq9PkMXqU1EiFsRNj/Gx6rklj+iriedu8ZXaVwFShES+oeNTUC0cm/BZqI20vkoSRUHcXPjQ1gok70zByJE7eg7QAcpo6Km466ZnBDMk1ew+5lHL5mYfpMX0u2hV82c1AL2SiW0mwJ5BGLuZg8uMkG/v9Jn518iguyNQe3gj3a5313GHOr1DskyDw6qrxAahgNdwaAESiYvm3kUdkRFqWN5o5hZ5q0FLPfRdwTjpj2ehsxPWkjEyzmIYhkwtTyvZrDIl63GH2fX0xTHskDzmT/KlkHryexWxQoEqANR9YZnHXAkTvKV4JS+qa1n5+KZxT+ULyTwQDAoUoqonrzorzjXhWriohaaZC8IsoIcJNrWquDIADUpL1Zqv+lUvdZFzWV+G2acouQfLwI6IOr0Zvu+4tN9v/YTDAzu36EwVeLHMQ== X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230031)(4636009)(376002)(136003)(346002)(396003)(39860400002)(230922051799003)(64100799003)(82310400011)(1800799009)(451199024)(186009)(40470700004)(36840700001)(46966006)(26005)(478600001)(1076003)(7696005)(426003)(336012)(316002)(6916009)(40480700001)(54906003)(40460700003)(70206006)(70586007)(36756003)(36860700001)(47076005)(86362001)(2616005)(107886003)(356005)(7636003)(83380400001)(8676002)(4326008)(8936002)(2906002)(82740400003)(5660300002)(41300700001)(309714004);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Oct 2023 14:31:31.8666 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9795c9f3-b355-42b3-97e1-08dbd6303fca 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.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF000015C8.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8585 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231026_073136_595128_9A7738BC X-CRM114-Status: GOOD ( 13.34 ) 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 --- arch/x86/include/asm/resctrl.h | 5 +++++ drivers/platform/mpam/mpam_resctrl.c | 11 +++++++++++ fs/resctrl/rdtgroup.c | 9 +++++---- include/linux/arm_mpam.h | 1 + 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index 1adf16660ac1..96c7d86ab9b6 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_resctrl.c b/drivers/platform/mpam/mpam_resctrl.c index 1a691535d23d..6197e957e323 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 43efed317f1b..cff77915395b 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 8b8074513272..766117c5ff55 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);