From nobody Sun Apr 12 02:49:45 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DF11C3F6B0 for ; Mon, 1 Aug 2022 20:56:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234716AbiHAU4F (ORCPT ); Mon, 1 Aug 2022 16:56:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234746AbiHAUz7 (ORCPT ); Mon, 1 Aug 2022 16:55:59 -0400 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2050.outbound.protection.outlook.com [40.107.95.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E1D0402E3; Mon, 1 Aug 2022 13:55:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ApBo0oy10rxg+jlf6HG/rlQzcQtE3XK89l2qMZlr686ykGithH+nQii+wPdLo71sXjGhK3dmsjpuJMxxALErjHilz89ZKTImb+htnhQbLy5TQkeD6shWSgoPGHZIdCcmFEk29gHlLKLwta/8ZRMHVlcoiAu30izoKvlSQRyX7SIBLzGFqvPwvzKI/IZWQ8gP3M1kHDWuznJ79wg4BWbGpj0uiDlyGAh21yvhf8vbD6Zd7l8/YzT3CCWfpdjmto96en6YEjY87yg83F3EzQIrB1evq68clGcB3J/w0+zuyIbJ33LQgG45QfWpBXvNXGXmXAc5Zns+0fG1FzDGG+kE9A== 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=xUTJaVFr9zeTUfYJTGvwQ3bqgyfIjbUmjqlPaaPRahU=; b=fnPvWiziYtd/CGm4S3fuM09gDu7XWFR+lGhr9yMCUMs3hHZTzGKzNLEjNJtM3Ojv4xM15qPEWEl/UuKYmZCDQO9MaQlT7BN1B++ZjF4Phgk26RIAZI/wibVkrh285FfAbIgtLbL+RDy6LEiOQBnJ6uzoF2xQx6mwf7AEDj4GKId6txhAiLOlJMQfhxbj0wxSZfP7yCIlUjZFd9GVoRdtpbg8LMO6uH9pQXrk+POqavbRuCjvcmwqSVmKNTeAdfikoVZs/9tVvaQWcJf/8nKRn6XbQbuJaI/wOg9sqQV66/P5ubcmoy5KLiGYMuX7sfM6EIVwE2vwBTrwO4i+Zu7bEw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xUTJaVFr9zeTUfYJTGvwQ3bqgyfIjbUmjqlPaaPRahU=; b=Ae5HRwchn6q1uod0YxCRY7Fef6NEOqh2Q2WMGOI/F9y4a1zZy9UGHw+kXaLj+vM8iz6tJbcedS6CQsxone8aUHJ3dnMp0PTVivCPqNpbfKZqfaoF0U5x2ha2mG6Y66UqWh7fxkK1dFc/cMfS6E0hmzG7MI4wATYHNudVkCCCnHw= Received: from BN8PR04CA0023.namprd04.prod.outlook.com (2603:10b6:408:70::36) by DS7PR12MB5885.namprd12.prod.outlook.com (2603:10b6:8:78::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.6; Mon, 1 Aug 2022 20:55:53 +0000 Received: from BN8NAM11FT050.eop-nam11.prod.protection.outlook.com (2603:10b6:408:70:cafe::a8) by BN8PR04CA0023.outlook.office365.com (2603:10b6:408:70::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.12 via Frontend Transport; Mon, 1 Aug 2022 20:55:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT050.mail.protection.outlook.com (10.13.177.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Mon, 1 Aug 2022 20:55:53 +0000 Received: from [127.0.1.1] (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Mon, 1 Aug 2022 15:55:47 -0500 Subject: [PATCH v2 01/10] x86/resctrl: Fix min_cbm_bits for AMD From: Babu Moger To: , , , , CC: , , , , , , , Date: Mon, 1 Aug 2022 15:55:47 -0500 Message-ID: <165938734704.724959.15776618190142591928.stgit@bmoger-ubuntu> In-Reply-To: <165938717220.724959.10931629283087443782.stgit@bmoger-ubuntu> References: <165938717220.724959.10931629283087443782.stgit@bmoger-ubuntu> User-Agent: StGit/1.1.dev103+g5369f4c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fe049a26-5ce4-4afa-b409-08da74003902 X-MS-TrafficTypeDiagnostic: DS7PR12MB5885:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cRpp4jD9kHBoCoCUtkhvCfxL7unNUGLTad3WPZi7vQR3AGv6ollZnbjiDM+zx+vxMGSiQeFFl74TlfCQwIn6YFHk2X3P+DucWDZWNFGrICVrIncfNTkq8Nez2DYrlRBqZsVgQ7TUtQNJ3c3ddm2cPMOHD1LIfF+n06ca076mC24O+t7ZGEV7q9H1W6hDL1kswjrSCRLLcFEcf6AFNSV0gYIeKsXE+5FI/+4GClqyZHrXsu1tYlqfhdemCq7uW2V7ocJNLmBJEjESX6FnITy58iVDf5pwFYNYSLb775b+w38CXi8LkWCGaYI1LssTcGdGv2hZZ1fVyg95V3hfgtgToh+Iqxo+V4DzCzF/vdbVHUJOU4ui2epm61X9v/L0g9O+aKQuvr2zN5SWQr2M45/sXNJsUCtbBRjmNxKeLjLKhiFxrnb+zbDI27aFmmSs1fGTM11YOyBTuwh7VF5rmI/bdTnhSj4ONkdPXm7wXEWSzUI2z6Z9otTQCwS2/UpHJm7jzOtOpZeWbP5dXRdUiHMHizpIEUPy8GkysfPxHDj481+Wr8mixE1BHlrAWUKp4Hkir0HNUi8NYw6VmYk4RPFNHj6Cql1qlcC3sbPmQZ+pebP6f84hbvDatbOihC6JZssMfRBq0LSlBW8sAf0K4NiJxxLsCdiGP2Gl2lLCJmClm2pHoB7TNZjdi2a/fvBw+UfhmS0IG1sdCzMt0Onma9C1ik0oEX3EJfoTF3u2hyadVLSNSSbC/o+1F1eV0vYW+kBH1tBATbwJbz14C7nDavMf2NTE/i4tlAvjZaSHaxMappp0C1pFBBNN/Zc5Q7aUZ/uiwqT8K7at6iCfZIr7v/n/4f4ojKYa9xhopLsc7DaQbibnSz+I54Zuv04oc8TVdQefExKXvZyMRQaAjGeAGzhrpA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(7916004)(396003)(136003)(346002)(39860400002)(376002)(36840700001)(40470700004)(46966006)(5660300002)(7416002)(8936002)(70206006)(33716001)(186003)(16526019)(2906002)(40480700001)(70586007)(356005)(40460700003)(4326008)(36860700001)(44832011)(83380400001)(82310400005)(82740400003)(103116003)(86362001)(966005)(81166007)(8676002)(316002)(426003)(54906003)(110136005)(47076005)(41300700001)(336012)(26005)(9686003)(16576012)(478600001)(71626007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2022 20:55:53.0865 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fe049a26-5ce4-4afa-b409-08da74003902 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT050.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5885 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org AMD systems support zero CBM (capacity bit mask) for L3 allocation. That is reflected in rdt_init_res_defs_amd() by: r->cache.arch_has_empty_bitmaps =3D true; However given the unified code in cbm_validate(), checking for: val =3D=3D 0 && !arch_has_empty_bitmaps is not enough because of another check in cbm_validate(): if ((zero_bit - first_bit) < r->cache.min_cbm_bits) The default value of r->cache.min_cbm_bits =3D 1. Leading to: $ cd /sys/fs/resctrl $ mkdir foo $ cd foo $ echo L3:0=3D0 > schemata -bash: echo: write error: Invalid argument $ cat /sys/fs/resctrl/info/last_cmd_status Need at least 1 bits in the mask Fix the issue by initializing the min_cbm_bits to 0 for AMD. Also remove the default setting of min_cbm_bits and initialize it separately. After the fix $ cd /sys/fs/resctrl $ mkdir foo $ cd foo $ echo L3:0=3D0 > schemata $ cat /sys/fs/resctrl/info/last_cmd_status ok Link: https://lore.kernel.org/lkml/20220517001234.3137157-1-eranian@google.= com/ Fixes: 316e7f901f5a ("x86/resctrl: Add struct rdt_cache::arch_has_{sparse, = empty}_bitmaps") Signed-off-by: Stephane Eranian Signed-off-by: Babu Moger --- arch/x86/kernel/cpu/resctrl/core.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index bb1c3f5f60c8..a5c51a14fbce 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -66,9 +66,6 @@ struct rdt_hw_resource rdt_resources_all[] =3D { .rid =3D RDT_RESOURCE_L3, .name =3D "L3", .cache_level =3D 3, - .cache =3D { - .min_cbm_bits =3D 1, - }, .domains =3D domain_init(RDT_RESOURCE_L3), .parse_ctrlval =3D parse_cbm, .format_str =3D "%d=3D%0*x", @@ -83,9 +80,6 @@ struct rdt_hw_resource rdt_resources_all[] =3D { .rid =3D RDT_RESOURCE_L2, .name =3D "L2", .cache_level =3D 2, - .cache =3D { - .min_cbm_bits =3D 1, - }, .domains =3D domain_init(RDT_RESOURCE_L2), .parse_ctrlval =3D parse_cbm, .format_str =3D "%d=3D%0*x", @@ -877,6 +871,7 @@ static __init void rdt_init_res_defs_intel(void) r->cache.arch_has_sparse_bitmaps =3D false; r->cache.arch_has_empty_bitmaps =3D false; r->cache.arch_has_per_cpu_cfg =3D false; + r->cache.min_cbm_bits =3D 1; } else if (r->rid =3D=3D RDT_RESOURCE_MBA) { hw_res->msr_base =3D MSR_IA32_MBA_THRTL_BASE; hw_res->msr_update =3D mba_wrmsr_intel; @@ -897,6 +892,7 @@ static __init void rdt_init_res_defs_amd(void) r->cache.arch_has_sparse_bitmaps =3D true; r->cache.arch_has_empty_bitmaps =3D true; r->cache.arch_has_per_cpu_cfg =3D true; + r->cache.min_cbm_bits =3D 0; } else if (r->rid =3D=3D RDT_RESOURCE_MBA) { hw_res->msr_base =3D MSR_IA32_MBA_BW_BASE; hw_res->msr_update =3D mba_wrmsr_amd; From nobody Sun Apr 12 02:49:45 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2B79C00144 for ; Mon, 1 Aug 2022 20:56:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234923AbiHAU4N (ORCPT ); Mon, 1 Aug 2022 16:56:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234734AbiHAU4B (ORCPT ); Mon, 1 Aug 2022 16:56:01 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60B303F324; Mon, 1 Aug 2022 13:55:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kPcKQmOrP2R3a0QiITew3kg6dyK6j4reHT8QIuBOLiPFKFAePTkoXcIrbwB3O2+TSezPIrsgJfqBRlR/Wnm3rByou9HNwcybFkWtYtnG/zo+XIJPhV3UggY1CNzzSjWtloCwldpBEFfwNWsz9y5ZHRUW6gES9uNETnELqS/XNC4Z3OC9/VaGWBJw56FE4jSxdzFpc30AKmP3Wb9U4TkSlalHOuHL0Kjf9nBdR3CCJB3EXWN3howmWhPoEZeDR8+VBk5eKh0sv6ZQfzgnw6v3RSGaysBHW2KCByFdZVQzZ+kotFeRV1JV5cmMvtTGShZbY0obprpF2cN7w4PktSre0g== 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=dGcR8Bn9Juihll8qkfXWCv6P5+f9yNxBdpXQUmyEYfI=; b=D1XoyseBIjdOsiHZ1iKyiS8qaNaskwe+svHJ4zb8UeHtxzosSvJZ2IfBabkX2bvrYreUdYNQ9SoC1WijKRavIntvA+rFuy10wCA+oPwOwv8W91zu2NjkxIYKO88kHFIQFJ72hxXcbe+JyzmNAS9cQNkJo76fvNtIC7AqpH4C8GCfZaHA/5ldqIF24ZV1lbc3Ry0mnYXNAfrwCQYbgI50rlU9kxfrTu7b/sWWImBVnLxK4NkCsmKCXxIFUl2zTiR1FTnvoIDXm9Xsv04SoC74kobSFwNHmQ1o6OJS+ywhk0qTLQj5d/8rn1Zy1Cq2PY9Blzkm9cL39Q6bC+l+amFZGw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dGcR8Bn9Juihll8qkfXWCv6P5+f9yNxBdpXQUmyEYfI=; b=IMp2MuJw7/dP8iPIZN6x7ohNRvdGyuC9ayOdJtrSUKxTbeZeOJjYpDtxyCG4bjcpKM3TFxJDvZeECg8cBvddr/BBvBOWyQJ0cnbPhgHDtClcbbeOo1hFgbf24udQ997xGS3V6/cWPlPD+Hy/ifwemSR521d2L59dcx8MKa4tjMo= Received: from BN8PR04CA0004.namprd04.prod.outlook.com (2603:10b6:408:70::17) by BY5PR12MB4193.namprd12.prod.outlook.com (2603:10b6:a03:20c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.6; Mon, 1 Aug 2022 20:55:56 +0000 Received: from BN8NAM11FT050.eop-nam11.prod.protection.outlook.com (2603:10b6:408:70:cafe::e) by BN8PR04CA0004.outlook.office365.com (2603:10b6:408:70::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.13 via Frontend Transport; Mon, 1 Aug 2022 20:55:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT050.mail.protection.outlook.com (10.13.177.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Mon, 1 Aug 2022 20:55:55 +0000 Received: from [127.0.1.1] (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Mon, 1 Aug 2022 15:55:53 -0500 Subject: [PATCH v2 02/10] x86/cpufeatures: Add Slow Memory Bandwidth Allocation feature flag From: Babu Moger To: , , , , CC: , , , , , , , Date: Mon, 1 Aug 2022 15:55:53 -0500 Message-ID: <165938735329.724959.1672436410988441536.stgit@bmoger-ubuntu> In-Reply-To: <165938717220.724959.10931629283087443782.stgit@bmoger-ubuntu> References: <165938717220.724959.10931629283087443782.stgit@bmoger-ubuntu> User-Agent: StGit/1.1.dev103+g5369f4c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 317209df-5955-4412-c360-08da74003a7d X-MS-TrafficTypeDiagnostic: BY5PR12MB4193:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qkq9Xt9lrI7mkHX6JposUxItAepU9yTtWNNeNbInyEa69IlweP1ehDe+OoFL2Ow4SO7uuwluTk7HVwHofEgbKOIRVxziQ/ODx21N4yBz4e2IZWlFfAdfKGGLjy0olHlO0SYYVLGfSePKVW5r4PyM62Qp4y2yW+/LPfX2VSR+lyYDu2yjWS2998uIOn5vcIYyU+1id878uQkZm6prk9F9PokgPjZTpjik0emSu4SaNnTuTwsh59MaxNyaOAESs96dLoX0Yo07yz1iCEPjFrah4yH3BBqnDNV+83udZBtLuyPT92ih8oe6vd9KLvjivR85zXJgmjfvdjLlqLJP86KURmHsbNFm8n4pi3Y/KhzqWMojS+F84He19bhfgWcsT5HZypEjrrhfEiqUkmS5u3w9E6P4y3zs6DNWstDjLdBiR8V72XARVTeNArgRBV3OGd3ckcLkKZjPZskXzd6JxRviT6xFEW57mDuW2mVhuynmz/d4edMgQ3sSBeRyqk9sxBla/jozMpNGFp/Kdfc0qXOxQ8CWTv52b+Y2FTPLdJG0gXtVV0IF4xebCFJONmRBvBPqFIwkonh3na86/2s4iofQkpmlKKP7qRlPzdWHGlAyhNYEMVCeJCTmV5pIgRjBKdm8QoaQ3+uk4VAjg78IqzVvcL0+dlDlDlcpo4IzUnnFUSeYJJD2rdqvcMCd4juGvj/hmHdAQXgSDH3fK9t5SpDTh/QauiS7MYu6n0p6WoKDtzV+YgMn9k8ufzz8VPq8dNXVCfrPhDp8yyBTfaSxCIL/XAfKgOfD/qqjBnBM1noaYcVl393yyini4H/zHgD0gZ80fP+eHmJz6OAXNm/UMer5gxW+kx/2tM9/gHfD08UCqb+KR0rOsRLpJ4d5OKkgHsP0pIIG58RYHhM7U5kyae/hZAW3lgUKnrpgWVQ5pGqF8OzrCK7iPbTN9crnF3gDI6ba X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(7916004)(396003)(376002)(39860400002)(346002)(136003)(36840700001)(46966006)(40470700004)(103116003)(36860700001)(81166007)(82740400003)(356005)(9686003)(86362001)(426003)(336012)(47076005)(26005)(83380400001)(16526019)(186003)(110136005)(2906002)(478600001)(41300700001)(54906003)(16576012)(316002)(966005)(7416002)(44832011)(70206006)(70586007)(40460700003)(8676002)(8936002)(5660300002)(4326008)(82310400005)(33716001)(40480700001)(71626007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2022 20:55:55.5707 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 317209df-5955-4412-c360-08da74003a7d X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT050.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4193 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adds the new AMD feature X86_FEATURE_SMBA. With this feature, the QOS enforcement policies can be applied to external slow memory connected to the host. QOS enforcement is accomplished by assigning a Class Of Service (COS) to a processor and specifying allocations or limits for that COS for each resource to be allocated. This feature is identified by the CPUID Function 8000_0020_EBX_x0. CPUID Fn8000_0020_EBX_x0 AMD Bandwidth Enforcement Feature Identifiers (ECX= =3D0) Bits Field Name Description 2 L3SBE L3 external slow memory bandwidth enforcement Feature description is available in the specification, "AMD64 Technology Pl= atform Quality of Service Extensions, Revision: 1.03 Publication # 56375 Revision: 1.03 Is= sue Date: February 2022". Link: https://www.amd.com/en/support/tech-docs/amd64-technology-platform-qu= ality-service-extensions Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 Signed-off-by: Babu Moger --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kernel/cpu/scattered.c | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpuf= eatures.h index a77b915d36a8..14b5cc8da75c 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -303,6 +303,7 @@ #define X86_FEATURE_RETHUNK (11*32+14) /* "" Use REturn THUNK */ #define X86_FEATURE_UNRET (11*32+15) /* "" AMD BTB untrain return */ #define X86_FEATURE_USE_IBPB_FW (11*32+16) /* "" Use IBPB during runtime = firmware calls */ +#define X86_FEATURE_SMBA (11*32+17) /* SLOW Memory Bandwidth Allocation */ =20 /* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */ #define X86_FEATURE_AVX_VNNI (12*32+ 4) /* AVX VNNI instructions */ diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattere= d.c index fd44b54c90d5..885ecf46abb2 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c @@ -44,6 +44,7 @@ static const struct cpuid_bit cpuid_bits[] =3D { { X86_FEATURE_CPB, CPUID_EDX, 9, 0x80000007, 0 }, { X86_FEATURE_PROC_FEEDBACK, CPUID_EDX, 11, 0x80000007, 0 }, { X86_FEATURE_MBA, CPUID_EBX, 6, 0x80000008, 0 }, + { X86_FEATURE_SMBA, CPUID_EBX, 2, 0x80000020, 0 }, { X86_FEATURE_PERFMON_V2, CPUID_EAX, 0, 0x80000022, 0 }, { 0, 0, 0, 0, 0 } }; From nobody Sun Apr 12 02:49:45 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FA19C19F2C for ; Mon, 1 Aug 2022 20:56:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234700AbiHAU4i (ORCPT ); Mon, 1 Aug 2022 16:56:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234937AbiHAU4X (ORCPT ); Mon, 1 Aug 2022 16:56:23 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2088.outbound.protection.outlook.com [40.107.93.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 860243FA3B; Mon, 1 Aug 2022 13:56:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZdS30GQmbCllWF6qMff4WaT7yUgW2hoQCsNxWURX9iyuyhZY6qYnEfuGRJZ7/cReWREf7owXMq/bow41Nvro65jg4KFRdwZt6Z/sLDWJU/3ywKg34AWM9Pa697lkEIaJuwHlQb9vJYeDuXaMVr41VnLk6KG7XXYGDXaI6p0t1/ApWIxduAiLZ/+lnwigEn7ZHx2tPg/de22m1uMIBIHWj1kv+B2zwa8/pYH2oe6QTI71SmAj+rME/z4UeB3+V+PFQnCKwvLnsdJdtlP7dlfjamA6/kESH1LrAQtPUvjBNTe9GX8gFYHQBzl5gAHUEXOoR/I+rdloKUM1XmRtidJeuA== 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=EEIMSt5H1vUExObSsOpvPgK8YeTjuCc4Dx70hoQKJ6M=; b=j1PlF18O8SeAOp2oWt8fVLSNzImqAIALPAHOZluJ/6i0jd9MO5dZ2n7tg8gQZ5w8hK73NFKx1xfd1wUDwBQw9PQK2UEMczmd9yC2fACdCjftSOoS3V1Z4ZR2Lrqxpf2EQ1gPtCdqVv8gqkfVJ5Eo7pMkUXj/QgNXmZqCaJl1agkufXUcy6oJ188bg8KtVMUzEiDAkaK2MrDL3hi9gSy6BHQHo673AwpbzaJpxW+y0rrNlEThLx0EqW5FLUMmCZg08w7S+Tc6k5iyuf58fHZgrgQryVBmFVQou2uQEvpVcVdlBbRO83MEeY38++uOFeGTpr07VIN4LRCO1VJznmFhpQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EEIMSt5H1vUExObSsOpvPgK8YeTjuCc4Dx70hoQKJ6M=; b=Gm324O4pU2lgU0VBgNJrNqvLENuNNtpzGoIK/h4GntrQo3hR79RIDoD8VZimFu6Xx40BtI6F2UhQZAd0OBI6D0kEE4l/fdCK5zTDHyrj8/UzJ3DXrSFDarn1Qmg1yWMcZnhv1EL48tLUdKIK975PXVztZUovOnzKzGMEVam+QAs= Received: from BN0PR08CA0010.namprd08.prod.outlook.com (2603:10b6:408:142::11) by BL3PR12MB6425.namprd12.prod.outlook.com (2603:10b6:208:3b4::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.15; Mon, 1 Aug 2022 20:56:01 +0000 Received: from BN8NAM11FT014.eop-nam11.prod.protection.outlook.com (2603:10b6:408:142:cafe::4e) by BN0PR08CA0010.outlook.office365.com (2603:10b6:408:142::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.16 via Frontend Transport; Mon, 1 Aug 2022 20:56:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT014.mail.protection.outlook.com (10.13.177.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Mon, 1 Aug 2022 20:56:01 +0000 Received: from [127.0.1.1] (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Mon, 1 Aug 2022 15:55:59 -0500 Subject: [PATCH v2 03/10] x86/resctrl: Add a new resource type RDT_RESOURCE_SMBA From: Babu Moger To: , , , , CC: , , , , , , , Date: Mon, 1 Aug 2022 15:55:59 -0500 Message-ID: <165938735951.724959.5927072727388257548.stgit@bmoger-ubuntu> In-Reply-To: <165938717220.724959.10931629283087443782.stgit@bmoger-ubuntu> References: <165938717220.724959.10931629283087443782.stgit@bmoger-ubuntu> User-Agent: StGit/1.1.dev103+g5369f4c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ec0359c8-05a0-496e-a7bc-08da74003df4 X-MS-TrafficTypeDiagnostic: BL3PR12MB6425:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: celss2sTKFWpNSDDb18IiaWoNluu62dtjy+Ypm/9dfirrcF2z9l30fp2VnCSacQul8uiJF7VBy853GnbKH1/jz8i2pdDv3YOcdn96vfivbbwblN6/ThkK5bDwu26j54YSfPE4HVZQ+EKejBlSY27JjG63n7CuBhb3GcsWFOlh2Klw4KdsNJ7Lw8kzofGEMk/eWMp1Zi+MahUoBTiwRmPFSLloTCHrngf/C7f4Nb7dnxBH+PHakEXDcETak0Lw/ybJAWmPu0s8W/SuqO0rTlY0IGr0ESQUvtg/QJFiXIRxBdZ/wNwziZG7g4gJ6h5hmxQrY8w7qkdicqbvze4UmWBZNo8wtAYJE8+Y1XOISi/1fLEEhpV1I6ClW+Pv80CyBNNOpGYXj0dHaz7HAsNKAatN1F14bOPW2NxX9uTCVafmQHFSqtvz4ZRdMn44PFnjEw2N2p1NwO/3/l2xUVLNhNN7W6m7OvjhMT6M7/5Mkb22wFSUupmJi70qbF5QbLmZOEqJiuFHxBtaArgm43ZN/v0/O2/gd5gfmkEL47mfH8DcqzSY8OsKGHPdVCgpv0Qlg66TDfl9cOjjMeC4oyFHs+XwIuHefSyGB3pzcZfdUohyapXTpxdLyhX3tT2nouDvvM8UCLHo96m7RR97xBnjs0ll5Hr8Jd0kLS3GYw5ocMEE0fbwstNklovOB79QwYpKDiJA1N2l5mXhojBuJg7mqoKmqw/TGllc7KWliAiCP0NUrOPAizDdW1t/q5Mm3Qqf4ngmA8Z+5T9g5xjpuhi8e6lo27h042J9WafFs0FJqXmaX8y/Ed/jYZ2dygHedjKiFM+4fHLOLH1rXxZ5Kp1Wr4/3P4zixMAAb4Lc8zH+nA2qQ8= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(7916004)(4636009)(396003)(346002)(136003)(376002)(39860400002)(36840700001)(40470700004)(46966006)(16526019)(336012)(186003)(16576012)(54906003)(110136005)(5660300002)(2906002)(426003)(26005)(47076005)(41300700001)(9686003)(44832011)(7416002)(86362001)(40480700001)(103116003)(82740400003)(356005)(40460700003)(82310400005)(33716001)(81166007)(36860700001)(8936002)(316002)(478600001)(70586007)(4326008)(8676002)(70206006)(71626007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2022 20:56:01.3987 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ec0359c8-05a0-496e-a7bc-08da74003df4 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT014.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB6425 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adds a new resource type RDT_RESOURCE_SMBA to handle the QoS enforcement policies on the external slow memory. Signed-off-by: Babu Moger --- arch/x86/kernel/cpu/resctrl/core.c | 12 ++++++++++++ arch/x86/kernel/cpu/resctrl/internal.h | 1 + 2 files changed, 13 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index a5c51a14fbce..6c38427b71a2 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -100,6 +100,18 @@ struct rdt_hw_resource rdt_resources_all[] =3D { .fflags =3D RFTYPE_RES_MB, }, }, + [RDT_RESOURCE_SMBA] =3D + { + .r_resctrl =3D { + .rid =3D RDT_RESOURCE_SMBA, + .name =3D "SB", + .cache_level =3D 3, + .domains =3D domain_init(RDT_RESOURCE_SMBA), + .parse_ctrlval =3D parse_bw, + .format_str =3D "%d=3D%*u", + .fflags =3D RFTYPE_RES_MB, + }, + }, }; =20 /* diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 1d647188a43b..24a1dfeb6cb2 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -418,6 +418,7 @@ enum resctrl_res_level { RDT_RESOURCE_L3, RDT_RESOURCE_L2, RDT_RESOURCE_MBA, + RDT_RESOURCE_SMBA, =20 /* Must be the last */ RDT_NUM_RESOURCES, From nobody Sun Apr 12 02:49:45 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39AC9C00144 for ; Mon, 1 Aug 2022 20:56:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235028AbiHAU4l (ORCPT ); Mon, 1 Aug 2022 16:56:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234765AbiHAU4b (ORCPT ); Mon, 1 Aug 2022 16:56:31 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2084.outbound.protection.outlook.com [40.107.223.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 941F241D39; Mon, 1 Aug 2022 13:56:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bumQroBIVw+7xw7KyWYrnI2EZiV47+zzm19ZdqHc2LkpMkdMh3JNgs8TcnXokjRInBKYYugtYI9J/Qpze8zNwVasyPpC6wADxGZi6s6VJ9zoUn4BoFsZ+ndAY84fLQ+cM+Bjf5rUqSDNLwN9EroUmQ2u+oHY5GlTdBQkWD2Ttz8hJ4sbAseJOIbVVue3rj4Gax68klmk1dqca+Bhfzz9o+UEQsnpuQAlXonzs6iCzjUyiNDg8D92DyqTLEX0zkuRGIpDJiSTLpeMdL1YV/iKDPvbnKGJ2VOWfhqp73I8/EH/joJcznIzxSWgjG5OauJyS83rU6BfRyLOFE59nxRVCA== 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=TodA1u0FOCd/e37Ph+m2LOFY1m4jVoPBDU/dKbuSAoA=; b=cPjAZqysBx88D1gS1nv1TxB4+r9ZrII8vM1MmE3ehQQWqUYx+vzpmgUrFrZBMypckC6sHMQ5wSGxqRq4gywrYJ1Pbw0A7GkvmNWtE+MwpZjIDFkvu2RJM0olMrhiTSA66EBxNBItDnhZsYUupuqtAjWxkYsUUmY11Tic78LzjR2RQn5fGofAjQbiUZoEkK/glaQk31GhaT7DQ487xmfSdj4B6KSsE5/T5s7TwLsn2wLZMHmBr1mmYlCaO1sj6ev0aRncmnF0EGFk7AO+wYx1O7paF8x5E+ReHZ3YTlwV97ZWtZcRJzFydQMzxjeB8HrKm8RYiGhKDPk72Jyzx4js2Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TodA1u0FOCd/e37Ph+m2LOFY1m4jVoPBDU/dKbuSAoA=; b=FrK4ocHE2J+cDpCYHl1xEvlXfAuPN2Xq24c852y6WQhlJ/zGyqOcMm8Th8wdOrCCbQ1daJVGjScXp5HB/HsZiNHz74ebTIQqJgyH5LNqvRWcL1sMBiF7nbZmx4Z0J3WN75KYiwudzrVjm8z0ZjjdOf1cIRKk6w8N6p3ciJR7ZC0= Received: from BN0PR08CA0017.namprd08.prod.outlook.com (2603:10b6:408:142::24) by MWHPR12MB1166.namprd12.prod.outlook.com (2603:10b6:300:7::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.11; Mon, 1 Aug 2022 20:56:12 +0000 Received: from BN8NAM11FT014.eop-nam11.prod.protection.outlook.com (2603:10b6:408:142:cafe::87) by BN0PR08CA0017.outlook.office365.com (2603:10b6:408:142::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.15 via Frontend Transport; Mon, 1 Aug 2022 20:56:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT014.mail.protection.outlook.com (10.13.177.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Mon, 1 Aug 2022 20:56:11 +0000 Received: from [127.0.1.1] (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Mon, 1 Aug 2022 15:56:06 -0500 Subject: [PATCH v2 04/10] x86/resctrl: Detect and configure Slow Memory Bandwidth allocation From: Babu Moger To: , , , , CC: , , , , , , , Date: Mon, 1 Aug 2022 15:56:05 -0500 Message-ID: <165938736577.724959.8916617946994540883.stgit@bmoger-ubuntu> In-Reply-To: <165938717220.724959.10931629283087443782.stgit@bmoger-ubuntu> References: <165938717220.724959.10931629283087443782.stgit@bmoger-ubuntu> User-Agent: StGit/1.1.dev103+g5369f4c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d8c1f5b7-6ee7-4888-2d90-08da7400440e X-MS-TrafficTypeDiagnostic: MWHPR12MB1166:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: K4fPuaNtU+z+cwMTH/cD4hJ6Xji47KQeTsY6BLVaLbX3jBSaQYu+T1sgQYve8eTqPdx003IPrMBiKL9B4l/hkkj3qbwDiPDk4kCibQRz7wY3ehiIUbzzKc7EKjW57By9XTIvLOLOzUbll2HM7EsYx6gTsR8QPE0vrzPdz5YyRo6kwhbTdvlDPHd7d2vI1VDH8PW/i4IzySAy6zQXDhuMpDxFGmnAigFcmvm+2vluaaEZ8f6j2/SQ5F9OTiFuBeWxbOjZix47l8NcRX675pe7AAzWQ4ftwk0jtN/E0R7BZrjFPyZFmvWWCIQADpDUTGv9+3B1GBI3w7xgSYt3jx84ueG5OQWeT7/+zkOpg1k316wdkzL1WtDQRcfhgRsiQpI9MkBiZ9lxVz/lXeVJD4hO6O5MG8fsTcSJTltxMLY71Mln9txnmVHXNVas60lR5o9Xa71KRjoreCUwDrXwcJEF/3iXPyChWUpCv1JRPAukTe9KW+QlElvodNwmskX1h752MqQRyjuS8VH9/olqRVi+wjN1PXhZYf1cAZrk2UsNsZe2s9H+3QMbz+EMMqpD7SttFmdgpnyta6or0rkcc3IC6dfRN0lPpRFlAxTri1YZamH/knp1amZFtj0SxRcCtnyB07JrBaX2gVQtFmF0D7PcAICkkCyq5xzLK13y2a4pPTBOEhxCUtoxeBnwxYIdms/QP1e6fiSXFgErbCTKO7t4Pu5g/P99Mi9vHEcRXCI7vGoF4fMPIcyDYBI+dgZ+GNaNZRUWd7II+Z6b6bKzJxvZ9os2N40/U5d/7sOiLvNLQH39y9t/bqrTJgpiRLnIBebqyGuqRnm+BN6y0bGnch5HeS+g22KC5FOKOmKFiNiMPlI= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(7916004)(4636009)(396003)(136003)(39860400002)(346002)(376002)(36840700001)(46966006)(40470700004)(103116003)(70206006)(2906002)(8676002)(4326008)(70586007)(8936002)(7416002)(83380400001)(16526019)(186003)(9686003)(40460700003)(26005)(41300700001)(478600001)(16576012)(336012)(40480700001)(81166007)(47076005)(316002)(82740400003)(44832011)(33716001)(356005)(86362001)(110136005)(54906003)(36860700001)(426003)(5660300002)(82310400005)(71626007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2022 20:56:11.6323 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d8c1f5b7-6ee7-4888-2d90-08da7400440e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT014.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1166 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The QoS slow memory configuration details are available via CPUID_Fn80000020_EDX_x02. Detect the available details and initialize the rest to defaults. Signed-off-by: Babu Moger --- arch/x86/kernel/cpu/resctrl/core.c | 50 +++++++++++++++++++++++++= ++++ arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 2 + arch/x86/kernel/cpu/resctrl/internal.h | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 9 +++-- 4 files changed, 58 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 6c38427b71a2..36ad97ab7342 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -253,6 +253,37 @@ static bool __rdt_get_mem_config_amd(struct rdt_resour= ce *r) return true; } =20 +static bool __rdt_get_s_mem_config_amd(struct rdt_resource *r) +{ + struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); + union cpuid_0x10_3_eax eax; + union cpuid_0x10_x_edx edx; + u32 ebx, ecx; + + cpuid_count(0x80000020, 2, &eax.full, &ebx, &ecx, &edx.full); + hw_res->num_closid =3D edx.split.cos_max + 1; + r->default_ctrl =3D MAX_MBA_BW_AMD; + + /* AMD does not use delay */ + r->membw.delay_linear =3D false; + r->membw.arch_needs_linear =3D false; + + /* + * AMD does not use memory delay throttle model to control + * the allocation like Intel does. + */ + r->membw.throttle_mode =3D THREAD_THROTTLE_UNDEFINED; + r->membw.min_bw =3D 0; + r->membw.bw_gran =3D 1; + /* Max value is 2048, Data width should be 4 in decimal */ + r->data_width =3D 4; + + r->alloc_capable =3D true; + r->alloc_enabled =3D true; + + return true; +} + static void rdt_get_cache_alloc_cfg(int idx, struct rdt_resource *r) { struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); @@ -787,6 +818,19 @@ static __init bool get_mem_config(void) return false; } =20 +static __init bool get_s_mem_config(void) +{ + struct rdt_hw_resource *hw_res =3D &rdt_resources_all[RDT_RESOURCE_SMBA]; + + if (!rdt_cpu_has(X86_FEATURE_SMBA)) + return false; + + if (boot_cpu_data.x86_vendor =3D=3D X86_VENDOR_AMD) + return __rdt_get_s_mem_config_amd(&hw_res->r_resctrl); + + return false; +} + static __init bool get_rdt_alloc_resources(void) { struct rdt_resource *r; @@ -817,6 +861,9 @@ static __init bool get_rdt_alloc_resources(void) if (get_mem_config()) ret =3D true; =20 + if (get_s_mem_config()) + ret =3D true; + return ret; } =20 @@ -908,6 +955,9 @@ static __init void rdt_init_res_defs_amd(void) } else if (r->rid =3D=3D RDT_RESOURCE_MBA) { hw_res->msr_base =3D MSR_IA32_MBA_BW_BASE; hw_res->msr_update =3D mba_wrmsr_amd; + } else if (r->rid =3D=3D RDT_RESOURCE_SMBA) { + hw_res->msr_base =3D MSR_IA32_SMBA_BW_BASE; + hw_res->msr_update =3D mba_wrmsr_amd; } } } diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cp= u/resctrl/ctrlmondata.c index 87666275eed9..11ec3577db40 100644 --- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c +++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c @@ -203,7 +203,7 @@ static int parse_line(char *line, struct resctrl_schema= *s, unsigned long dom_id; =20 if (rdtgrp->mode =3D=3D RDT_MODE_PSEUDO_LOCKSETUP && - r->rid =3D=3D RDT_RESOURCE_MBA) { + (r->rid =3D=3D RDT_RESOURCE_MBA || r->rid =3D=3D RDT_RESOURCE_SMBA)) { rdt_last_cmd_puts("Cannot pseudo-lock MBA resource\n"); return -EINVAL; } diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 24a1dfeb6cb2..c049a274383c 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -14,6 +14,7 @@ #define MSR_IA32_L2_CBM_BASE 0xd10 #define MSR_IA32_MBA_THRTL_BASE 0xd50 #define MSR_IA32_MBA_BW_BASE 0xc0000200 +#define MSR_IA32_SMBA_BW_BASE 0xc0000280 =20 #define MSR_IA32_QM_CTR 0x0c8e #define MSR_IA32_QM_EVTSEL 0x0c8d diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index f276aff521e8..fc5286067201 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1218,7 +1218,7 @@ static bool rdtgroup_mode_test_exclusive(struct rdtgr= oup *rdtgrp) =20 list_for_each_entry(s, &resctrl_schema_all, list) { r =3D s->res; - if (r->rid =3D=3D RDT_RESOURCE_MBA) + if (r->rid =3D=3D RDT_RESOURCE_MBA || r->rid =3D=3D RDT_RESOURCE_SMBA) continue; has_cache =3D true; list_for_each_entry(d, &r->domains, list) { @@ -1399,7 +1399,8 @@ static int rdtgroup_size_show(struct kernfs_open_file= *of, ctrl =3D resctrl_arch_get_config(r, d, rdtgrp->closid, schema->conf_type); - if (r->rid =3D=3D RDT_RESOURCE_MBA) + if (r->rid =3D=3D RDT_RESOURCE_MBA || + r->rid =3D=3D RDT_RESOURCE_SMBA) size =3D ctrl; else size =3D rdtgroup_cbm_to_size(r, d, ctrl); @@ -2807,7 +2808,9 @@ static int rdtgroup_init_alloc(struct rdtgroup *rdtgr= p) =20 list_for_each_entry(s, &resctrl_schema_all, list) { r =3D s->res; - if (r->rid =3D=3D RDT_RESOURCE_MBA) { + if (r->rid =3D=3D RDT_RESOURCE_MBA || + r->rid =3D=3D RDT_RESOURCE_SMBA) { + rdtgroup_init_mba(r); } else { ret =3D rdtgroup_init_cat(s, rdtgrp->closid); From nobody Sun Apr 12 02:49:45 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6EE04C00144 for ; Mon, 1 Aug 2022 20:57:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235082AbiHAU45 (ORCPT ); Mon, 1 Aug 2022 16:56:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235063AbiHAU4e (ORCPT ); Mon, 1 Aug 2022 16:56:34 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2076.outbound.protection.outlook.com [40.107.243.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4079C42AC1; Mon, 1 Aug 2022 13:56:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Lf88UgBpnzaQXrnEhotQyYE2LiEBGvIWuhrtK0YmG8bf0O0oG6k7QEwxKeEDSTnn1qB/+OmR3bU2v9yK+x3khwu7wS09v0RJWs/Iz0f7/Mafm0iZjR5cWBaXWE1lv3wzVuS4cNfd/aCHSs4eyeZgCWLfiOQg6pRkFpuNRBmMybmmHq35HkfCOsGBlhnDWsxJ7ne/GXt1fVmmUEwtE+OG6hXIVpf6KfBad8b8HZiWb1ZzoLvymim9O3YK3buVbbHpQ+Zqr1qL1zRrGYoH+15QVFa2P9nFdyY2rjppST6zEjUUIz8esuM/M5Az4jVbaC7tqG/sgHkmwgSD67hzhADtQQ== 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=tQ5T8HnBOEposxGk63tLWEyPKZ/lSiXWL/XTli2xPs4=; b=FhY7BSC+guQpSZkIiYpWW8GiJKSEwEeOPjtdoaDrZOVonZtvVfNSimN6dcq03M7DsdYZ2SNa01w/b4Vbaeru+WG2hL7IddDREVnOtPncZM+41Bawd25diUOpzUJv2SA5cjxOUrQSzg0X9EjNuQ9hSEo87tyWsy+McSjh0XGZBav/+RmpPcdyWuyHU66M97IKl7CGPrG6AM1+Qx1VT7Mc29yPH/Q6dNyONJEuODTLz4KFXRuVAq1JAbTL9+IMpKTk1kIMDy/XjJ0IlcX4rJz2sztzzkQEGfHaRZBJvn7YuwpQ0ysYaYaE9Rvk47Ep0i/eSSQ18kdb5bI5JJouDT5Lhg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tQ5T8HnBOEposxGk63tLWEyPKZ/lSiXWL/XTli2xPs4=; b=nkvlZZ2VCNYbbgXCAIqu7noULC5oyAgWts3G76aW9eBNjtyT6Ra+1S7v90r9vcxLecTguZGbeokAIXk8jhnPJ6Hn8mQn2rvCThHs9TkdMoEpK4sJM+VpGvAOwS8rgSmiJCdMm7grCU4l75S8H8Zl8veDJOvenULK0+4xEvVw4oY= Received: from BN0PR08CA0017.namprd08.prod.outlook.com (2603:10b6:408:142::24) by BN8PR12MB3492.namprd12.prod.outlook.com (2603:10b6:408:67::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.10; Mon, 1 Aug 2022 20:56:15 +0000 Received: from BN8NAM11FT014.eop-nam11.prod.protection.outlook.com (2603:10b6:408:142:cafe::87) by BN0PR08CA0017.outlook.office365.com (2603:10b6:408:142::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.15 via Frontend Transport; Mon, 1 Aug 2022 20:56:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT014.mail.protection.outlook.com (10.13.177.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Mon, 1 Aug 2022 20:56:15 +0000 Received: from [127.0.1.1] (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Mon, 1 Aug 2022 15:56:12 -0500 Subject: [PATCH v2 05/10] x86/cpufeatures: Add Bandwidth Monitoring Event Configuration feature flag From: Babu Moger To: , , , , CC: , , , , , , , Date: Mon, 1 Aug 2022 15:56:12 -0500 Message-ID: <165938737200.724959.7329082251366107356.stgit@bmoger-ubuntu> In-Reply-To: <165938717220.724959.10931629283087443782.stgit@bmoger-ubuntu> References: <165938717220.724959.10931629283087443782.stgit@bmoger-ubuntu> User-Agent: StGit/1.1.dev103+g5369f4c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9c95c3c4-d690-4509-1b62-08da7400464f X-MS-TrafficTypeDiagnostic: BN8PR12MB3492:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: o14qc0mGK9ygmyfcd/vIbALYVogK5QJEITS8D5qbxauBwzr6k347mJOe9z36WEYAxz0es5/gQy31HrK/w07LfertEG0xn+81h6rD9GN7RHsfM7WT+VJcLRssLcbDW7q1Y5C9wBPphzsu5exO6mzV5oQPu4jeS69i9hY108yzYsPMARZPFdDJZFPkbLt1Xkixk015Y2NaAD4M+DYsACU+1oxQPyOgiAhmh7bHCZVKHuKezHHZHksxrdhA5t7xEAyGJxjR4BQggKfV/w1GGg8GsS8yg/sR0DH8/B9ntjVRlV97DoYQKP7JcKesPpHv8VGORPdM9ongni1zY3E3zkFcXO33JkUU1bOly1zPJ1zqzpNTSq96fRBLgGPUReS/85n2wijuzEFrw85Qzq2psChMDxcxo0JqrS4EG8dSt4CHmzwp1dpJ/sZDUmL99W3CU/aKkBzdkU7sxXxIpFTIxT4+2MMm3woVWqc07ANednlpm9pGB7llxzXceCrNo6+27DDHGrTvN0XAjmZgvrQ4pmEUnViTzxGUjKrS2vGXcaDbMPrx94+K1kY+5YLyejLBfY5PVAQSLJ1UCtxPBemsmF+1evdQdzQmb1viDHMyvNr9DXf+rQNQtoINH5lOZLTqAj6qfOn0bIbuOBfHicyddcmufsumtVZIVrOxN/1iMwNiX9ZTPdo/PGqcWUFL0GoGoPz8SFw2N9OTEtkQn8HzS+ud21G4Rl4NRHqS7WFx89vvfPMhXFsivVDVvvv3SKRK6n029OqTpaLxhCg22J5faTs/rBW+HSLMpOU6ic6H8wqJmmjW1AoPu27RHSgnfGaT/73Y89IVwsRTX5I008vYoT8MT/oqDWe8qWLJoCJ9ul/HsmC2SPHRXKmNM+fbydr2Ik4TF9CTpbl2XIIeFzP90Tw2vZa5tHO5aVTb0NvbZm0JmKweJ9/drKcuOdbMDAS3FiXB X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(7916004)(396003)(376002)(346002)(39860400002)(136003)(40470700004)(36840700001)(46966006)(82310400005)(356005)(16576012)(81166007)(82740400003)(316002)(2906002)(70206006)(70586007)(33716001)(4326008)(8676002)(110136005)(54906003)(336012)(966005)(5660300002)(40480700001)(16526019)(186003)(8936002)(478600001)(40460700003)(7416002)(36860700001)(41300700001)(47076005)(426003)(103116003)(44832011)(83380400001)(9686003)(26005)(86362001)(71626007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2022 20:56:15.3976 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9c95c3c4-d690-4509-1b62-08da7400464f X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT014.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8PR12MB3492 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Newer AMD processors support the new feature Bandwidth Monitoring Event Configuration (BMEC). Support of this feature is available via CPUID Fn8000_0020_EBX_x0 (ECX=3D0). Bits Field Name Description 3 EVT_CFG Bandwidth Monitoring Event Configuration (BMEC) Currently, the bandwidth monitoring events mbm_total_bytes and mbm_local_bytes are set to count all the total and local reads/writes respectively. With the introduction of SLOW memory, the two counters are not enough to count all the different types of memory events. With the feature BMEC, the users have the option to configure mbm_total_bytes and mbm_local_bytes to count the specific type of events. Each BMEC event has a configuration MSR, QOS_EVT_CFG (0x000_0400h + EventID) which contains one field for each Bandwidth Type that can be used to configure the Bandwidth Event to track any combination of supported bandwidth types. The event will count requests from every Bandwidth Type bit that is set in the corresponding configuration register. Following are the types of events supported. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Bits Description 6 Dirty Victims from the QOS domain to all types of memory 5 Reads to slow memory in the non-local NUMA domain 4 Reads to slow memory in the local NUMA domain 3 Non-temporal writes to non-local NUMA domain 2 Non-temporal writes to local NUMA domain 1 Reads to memory in the non-local NUMA domain 0 Reads to memory in the local NUMA domain Feature description is available in the specification, "AMD64 Technology Platform Quality of Service Extensions, Revision: 1.03 Publication # 56375 Revision: 1.03 Issue Date: February 2022". Link: https://www.amd.com/en/support/tech-docs/amd64-technology-platform-qu= ality-service-extensions Link: https://bugzilla.kernel.org/show_bug.cgi?id=3D206537 Signed-off-by: Babu Moger --- arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/kernel/cpu/scattered.c | 1 + 2 files changed, 2 insertions(+) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpuf= eatures.h index 14b5cc8da75c..2608416f5d0a 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -304,6 +304,7 @@ #define X86_FEATURE_UNRET (11*32+15) /* "" AMD BTB untrain return */ #define X86_FEATURE_USE_IBPB_FW (11*32+16) /* "" Use IBPB during runtime = firmware calls */ #define X86_FEATURE_SMBA (11*32+17) /* SLOW Memory Bandwidth Allocation */ +#define X86_FEATURE_BMEC (11*32+18) /* AMD Bandwidth Monitoring Event Con= figuration (BMEC) */ =20 /* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */ #define X86_FEATURE_AVX_VNNI (12*32+ 4) /* AVX VNNI instructions */ diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattere= d.c index 885ecf46abb2..7981df0b910e 100644 --- a/arch/x86/kernel/cpu/scattered.c +++ b/arch/x86/kernel/cpu/scattered.c @@ -45,6 +45,7 @@ static const struct cpuid_bit cpuid_bits[] =3D { { X86_FEATURE_PROC_FEEDBACK, CPUID_EDX, 11, 0x80000007, 0 }, { X86_FEATURE_MBA, CPUID_EBX, 6, 0x80000008, 0 }, { X86_FEATURE_SMBA, CPUID_EBX, 2, 0x80000020, 0 }, + { X86_FEATURE_BMEC, CPUID_EBX, 3, 0x80000020, 0 }, { X86_FEATURE_PERFMON_V2, CPUID_EAX, 0, 0x80000022, 0 }, { 0, 0, 0, 0, 0 } }; From nobody Sun Apr 12 02:49:45 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4490C00144 for ; Mon, 1 Aug 2022 20:57:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234991AbiHAU5H (ORCPT ); Mon, 1 Aug 2022 16:57:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234797AbiHAU4f (ORCPT ); Mon, 1 Aug 2022 16:56:35 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2068.outbound.protection.outlook.com [40.107.237.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2629A13FB6; Mon, 1 Aug 2022 13:56:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A+pQ9Wd7CKalHUgggSMmOOZCrPY23kG0UJT84c2ja5tEe/rvfR0qoZloRQd/pm2TbsVOVsetpkrge4i+NmlEb3B/F4HsB9OVr+vr4kKKdW6nMdl2diTokmg/B1bmC+WOkmDhE6iJNmW0afnTvfDR9E6AcP+WNvriTpYJe2UTIhKeiUm8306Hs2G0uiUJksQxv71thJU1ojyvUsiTcueWVGhKJlfWzh5JZ/KjDxInr4eTmb8ymt+Odl4EDR/w6M/H4PcZq49pBdtRTbUCYVeB+qvpwa1mdk2RplIrnL/BJkH8Ibksizw33+b18iJj1+h/+pd9/4kh0VHrtntbYpICLQ== 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=pFfgMuYkADALOBUFl88SwOIHqs3XC6t28Gu6oy2MR1s=; b=AvoqensuF9ZqM3phQvBJz4Poo0whLEnttd0lEwLIROWB7ofNmmZrXFfynvUziorSyDZz5SJOLRg281a3Z7PFhWLxWP8EYe4eUj+IhTgVOAu+BdHxSgFsEQxaCGTgHpQcZiYVNs+DHSdMInLhU7xmYaZCcOWA2+i1CcPuRK92sGYg+trJS8+U5/hLgBmxnTHGQH+qrG4+P5nd699ik1QnMzZ+21qm5HJ7T6nf21VhhJ9VhDvDIZfKa/r7btRyOvj2Y5zJ/yN3rBxVP6A0PWgwYUgKR0ztgfFd11ss0s3RxCLV7uwgPCIqtQBqJH/haFOOswzGGVplCl2C0H1qFNJ+jA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pFfgMuYkADALOBUFl88SwOIHqs3XC6t28Gu6oy2MR1s=; b=qpyCT+gmMiznlDmRRRTNUffkmN5AXJugKJPy7oAtUh76+Woo3bvmgsmYYo5jlvJJmG41ISeewohj8DgExNCYktCQbDAk2eDrhzrtuvUfP6AsDOFDd9nY2q64yqRZr2NEtX+847FVyIC8BXdgfcv6evcuBvsMVQOamHtD2ftSn2g= Received: from BN9PR03CA0348.namprd03.prod.outlook.com (2603:10b6:408:f6::23) by DM6PR12MB3276.namprd12.prod.outlook.com (2603:10b6:5:15e::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.6; Mon, 1 Aug 2022 20:56:20 +0000 Received: from BN8NAM11FT020.eop-nam11.prod.protection.outlook.com (2603:10b6:408:f6:cafe::1a) by BN9PR03CA0348.outlook.office365.com (2603:10b6:408:f6::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.23 via Frontend Transport; Mon, 1 Aug 2022 20:56:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT020.mail.protection.outlook.com (10.13.176.223) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Mon, 1 Aug 2022 20:56:20 +0000 Received: from [127.0.1.1] (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Mon, 1 Aug 2022 15:56:18 -0500 Subject: [PATCH v2 06/10] x86/resctrl: Introduce mon_configurable to detect Bandwidth Monitoring Event Configuration From: Babu Moger To: , , , , CC: , , , , , , , Date: Mon, 1 Aug 2022 15:56:18 -0500 Message-ID: <165938737828.724959.2910385805798358887.stgit@bmoger-ubuntu> In-Reply-To: <165938717220.724959.10931629283087443782.stgit@bmoger-ubuntu> References: <165938717220.724959.10931629283087443782.stgit@bmoger-ubuntu> User-Agent: StGit/1.1.dev103+g5369f4c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7ba4fae2-9519-4304-7718-08da74004939 X-MS-TrafficTypeDiagnostic: DM6PR12MB3276:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Wl49TFUelUEpgwtJdnBt1CDD0GBj7RxphwwT7o9I465PUC+Cs10fkXUI19dUb22qDxPusLuRIPw8dSGTdJvYkezzrIYNpv7OmtNDky6Fy52Fp+KNkVN49haCoCWmTBTvvsQ2Ozs1EcS0tSW6Dz5sTVHJTUolC96nqWnNy4li+/6P2H4BbkqI53Fq62hOs4IcX4dowsYcIg7iM81Yvsp3dAaWU17NQ4Ar8z7EmymUO9shPjCGILYBd/66kS9gjwNHEbbXxWHHqO7AQVyv9gGZOQ24JfqH9rD5l+DkYfoLV8wXo8z79kj+kjkCrXisS5avdsoeA5C8MQw73Y211Mh1d7T7Zk0QUpBpQbXajaU0F9ziT9Upx3G1leXMQPN+TCE38GqGt0CL3DWoE1MfOynzC1BgPLSVrjxQOxfFHVD1gHVQ0lQFrTZJycmWqUfWYj5ajX31Oo13UtEu2ZvbNG9+aGmIYyP3CzQ4KaWsdmaTroSduqe3ik4SvLtm3s39Y2Y3979R4DHyKC20Jwgy0fqClHqEeFwKMtih+FlgvlichnmGl1whNFG3k+TYje2J7ksjhWx+tMzeAW9pyA3Xuzzu6S88hdH2db47EYHdENxXpgalolzyxWVLGJlOEymEu4/GCeN+kPa3lBVx8z+9Oq9d8NZlIT1LHVVujoVRjks5LZjjB2Vv5K6s/dUABrmRjAQY1HLvKyS1a8G/Asaovd97vFEBLWr1g+3j9U9NDw8MVVDFZwgWxdsV26Nig+MyIc8r+fu+BRN1Iryjm+j5iRofkD3E+pOARj7fqcPXsL4L476l91epcOUFAZurrvtqgcdjgeXAhkRQpKa0XTzpqSvUlOUWxuRjTnM2A/faacPOl5E= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(7916004)(4636009)(396003)(39860400002)(346002)(376002)(136003)(46966006)(36840700001)(40470700004)(4326008)(8676002)(110136005)(316002)(8936002)(54906003)(478600001)(16576012)(33716001)(82310400005)(70586007)(36860700001)(7416002)(70206006)(44832011)(5660300002)(186003)(16526019)(41300700001)(9686003)(26005)(426003)(47076005)(336012)(103116003)(2906002)(40480700001)(81166007)(86362001)(356005)(82740400003)(40460700003)(71626007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2022 20:56:20.3046 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7ba4fae2-9519-4304-7718-08da74004939 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT020.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3276 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Newer AMD processors support the new feature Bandwidth Monitoring Event Configuration (BMEC). The events mbm_total_bytes and mbm_local_bytes are configurable when this feature is present. Set mon_configurable if the feature is available. Signed-off-by: Babu Moger --- arch/x86/kernel/cpu/resctrl/monitor.c | 14 ++++++++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 17 +++++++++++++++++ include/linux/resctrl.h | 1 + 3 files changed, 32 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index eaf25a234ff5..b9de417dac1c 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -682,6 +682,16 @@ static void l3_mon_evt_init(struct rdt_resource *r) list_add_tail(&mbm_local_event.list, &r->evt_list); } =20 + +void __rdt_get_mon_l3_config_amd(struct rdt_resource *r) +{ + /* + * Check if CPU supports the Bandwidth Monitoring Event Configuration + */ + if (boot_cpu_has(X86_FEATURE_BMEC)) + r->mon_configurable =3D true; +} + int rdt_get_mon_l3_config(struct rdt_resource *r) { unsigned int mbm_offset =3D boot_cpu_data.x86_cache_mbm_width_offset; @@ -714,6 +724,10 @@ int rdt_get_mon_l3_config(struct rdt_resource *r) if (ret) return ret; =20 + if (boot_cpu_data.x86_vendor =3D=3D X86_VENDOR_AMD) + __rdt_get_mon_l3_config_amd(r); + + l3_mon_evt_init(r); =20 r->mon_capable =3D true; diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index fc5286067201..855483b297a8 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -995,6 +995,16 @@ static int rdt_num_rmids_show(struct kernfs_open_file = *of, return 0; } =20 +static int rdt_mon_configurable_show(struct kernfs_open_file *of, + struct seq_file *seq, void *v) +{ + struct rdt_resource *r =3D of->kn->parent->priv; + + seq_printf(seq, "%d\n", r->mon_configurable); + + return 0; +} + static int rdt_mon_features_show(struct kernfs_open_file *of, struct seq_file *seq, void *v) { @@ -1447,6 +1457,13 @@ static struct rftype res_common_files[] =3D { .seq_show =3D rdt_num_rmids_show, .fflags =3D RF_MON_INFO, }, + { + .name =3D "mon_configurable", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D rdt_mon_configurable_show, + .fflags =3D RF_MON_INFO, + }, { .name =3D "cbm_mask", .mode =3D 0444, diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 21deb5212bbd..4ee2b606ac14 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -154,6 +154,7 @@ struct rdt_resource { bool mon_enabled; bool alloc_capable; bool mon_capable; + bool mon_configurable; int num_rmid; int cache_level; struct resctrl_cache cache; From nobody Sun Apr 12 02:49:45 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32CB2C00144 for ; Mon, 1 Aug 2022 20:57:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234734AbiHAU5T (ORCPT ); Mon, 1 Aug 2022 16:57:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234768AbiHAU4h (ORCPT ); Mon, 1 Aug 2022 16:56:37 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2078.outbound.protection.outlook.com [40.107.223.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CED814D2F; Mon, 1 Aug 2022 13:56:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ld3N+SkqcS+sbB5OcXWt6V5FLnpw6PZIop65eTgYJ6AW5/jVnih4tAr/QXd+z6cxJeJLSLxv0ZpkkI9pQJVfIjqClbn/xGMNW9uQxmTbzNGZeztsZHiIR7L01dONRoh0MK3PANGBtwso0g9vlotE5ZmoChzZmKv7HU7Y/hapBfg4RbvgFeesPP1W5z/iP739t0FbSFxAe9IzeVi18YrYLchXv7Cu+0ueNOEXC9XxmZvjCpay6V12IqnLWav+G8D6RRXOYi47OXRoHSsMuslGJ/RtHWpBObhM7xLwrbp3GOu92HY2iL8r4Ptf+7HXaKLrdUH77ZGZ3KqePm8XQcxvKA== 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=v2hVQFstr8tM+N5wK2rA7VHzevAR441TvRF+4BIXnqQ=; b=ZInNMBNdmOa3Lfq1EINiL8QJ5vIYhlbJbOkbbfvaO1AaJtqQzbkW8JYZFuX5ezE83J2ZktyCaSJm977pSMe7S70yacRaQ5eU0SCRKA346gCkupelPxVsNvzlzJcJaf+Bghlvqgef/20JqYz+q9yrButRYNKvxs4SjZ9admGwA2V74j9rMtZwrwxozS1uXdc59vPjN5p3y/vk2U2tF5KOEZpLN0TlmJfTQGwKzHinW0DXkk3UbAIa36gjirYptCv4fGA+FAoVItSmkSMCj/8bzF6OR4qBBH768B7uT3PIOg0yO7zqkGYdM1vjanH4vp6KjU50Zt1JOBvLiyAyKmZp0Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=v2hVQFstr8tM+N5wK2rA7VHzevAR441TvRF+4BIXnqQ=; b=MdbNRTVcAFdjTwMwhTWcUQyGjOYIS/sgpd/wRJ1IElLSRuQOQ+mTGoqNttYJS/PotO17CGO4w35knjRKuX/8Jlqp3M6N667mZZU2bM2928yfbi0Ie2vkeZJYoFPMIu+OhC89w2GFSTq3M08xdpKdPOcFUUA85ep02uLoum5E40Y= Received: from BN0PR04CA0206.namprd04.prod.outlook.com (2603:10b6:408:e9::31) by CY4PR12MB1605.namprd12.prod.outlook.com (2603:10b6:910:f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.14; Mon, 1 Aug 2022 20:56:34 +0000 Received: from BN8NAM11FT058.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e9:cafe::13) by BN0PR04CA0206.outlook.office365.com (2603:10b6:408:e9::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.14 via Frontend Transport; Mon, 1 Aug 2022 20:56:34 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT058.mail.protection.outlook.com (10.13.177.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Mon, 1 Aug 2022 20:56:33 +0000 Received: from [127.0.1.1] (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Mon, 1 Aug 2022 15:56:25 -0500 Subject: [PATCH v2 07/10] x86/resctrl: Add sysfs interface files to read/write event configuration From: Babu Moger To: , , , , CC: , , , , , , , Date: Mon, 1 Aug 2022 15:56:24 -0500 Message-ID: <165938738481.724959.179823924599228076.stgit@bmoger-ubuntu> In-Reply-To: <165938717220.724959.10931629283087443782.stgit@bmoger-ubuntu> References: <165938717220.724959.10931629283087443782.stgit@bmoger-ubuntu> User-Agent: StGit/1.1.dev103+g5369f4c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cfa46bcb-5946-4ede-666c-08da74005158 X-MS-TrafficTypeDiagnostic: CY4PR12MB1605:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bMgBMCRoIjDIt6RGWzfURCFIrRxdu1r/ZHXrjizzaqmjg8mEJ2GTJYu37+a30ycXePX5zKZOaXCbbAgj7HMddHYm0E5H7xX9i5JmMaRylS9R9vIXyjBkISQ+sKOCNpPDJeHgzHqSv1UVm23oJWQVpkFcg4j8zaUnyidaOhzoHbdLHJtuxr52b963Drk0nwc4jWnfthEAhbcSne2510oRlDfDGJ3MTFQGmoyK7zXNIFdK2UQw7xq70GdAuPu4k7d/dmtHcuWHRkqtEkDte9F5M8Pyz9WTOgrunhR+xRWXs5zN0tn5ajGxb5p8Vi0LM1fghmB0onHaW6MBwbEigdb8IcFiolmNhBAA9OV5gJEnYwVwcVA+ahFP5TeKNBo0K3dTodbuAFsBIqT+SgD3+h9hoZpFj6CIUvhfwz8G5x6qGFD6AwW05TzPvndUa0EFz3DTx7qOritKs5iOEsrQRgUZDETmQtTuM5+qpKAc/PNuALKSnK/U+pE1N+xwbXr7yzoF5Xe/VeFNULtHiB2U2fg7qlLlsF3ncUmCvJbQ5zrQEIfWhesTCgXA+E78Yt8OKpeOHO3aRSQb7wKqKrQQKqGjB5+V6b9MKKnSM4Y6FSjDgnE0ePgxLe3Nwg7nWaBzbktlG7rCx/odiAvF40xDTLwyQb/AbIpBzh+MQ9E9OCz8JKNYIG+/foU33OSFvJdX9vZGps6ZmsmOhPIz3s8vXl6YtGOoTi1E6wTHwHIlm3ZsfENVBoT3PIrAAt6wvjseUGdY9booqrF/IqNmuwer2CVU9S7xd4vyU5nWfzgqeanR0yxAFHrFYScya4sxU31qkhTmxNVbLGwDHyGRsjZa/AxlXY4XvTiO3JKjtw0qXp2S7MY= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(7916004)(396003)(376002)(39860400002)(346002)(136003)(46966006)(36840700001)(40470700004)(33716001)(478600001)(36860700001)(103116003)(40480700001)(110136005)(16576012)(8936002)(54906003)(4326008)(47076005)(40460700003)(70586007)(8676002)(70206006)(86362001)(426003)(82310400005)(81166007)(316002)(7416002)(82740400003)(356005)(336012)(2906002)(41300700001)(186003)(44832011)(16526019)(26005)(9686003)(5660300002)(71626007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2022 20:56:33.8822 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cfa46bcb-5946-4ede-666c-08da74005158 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT058.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1605 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add two new sysfs files to read/write the event configuration if the feature Bandwidth Monitoring Event Configuration (BMEC) is supported. The file mbm_local_config is for the configuration of the event mbm_local_bytes and the file mbm_total_config is for the configuration of mbm_total_bytes. $ls /sys/fs/resctrl/mon_data/mon_L3_00/mbm_local* /sys/fs/resctrl/mon_data/mon_L3_00/mbm_local_bytes /sys/fs/resctrl/mon_data/mon_L3_00/mbm_local_config $ls /sys/fs/resctrl/mon_data/mon_L3_00/mbm_total* /sys/fs/resctrl/mon_data/mon_L3_00/mbm_total_bytes /sys/fs/resctrl/mon_data/mon_L3_00/mbm_total_config Signed-off-by: Babu Moger --- arch/x86/kernel/cpu/resctrl/internal.h | 3 +++ arch/x86/kernel/cpu/resctrl/monitor.c | 2 ++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 32 ++++++++++++++++++++++++++++= ++++ 3 files changed, 37 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index c049a274383c..fc725f5e9024 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -72,11 +72,13 @@ DECLARE_STATIC_KEY_FALSE(rdt_mon_enable_key); * struct mon_evt - Entry in the event list of a resource * @evtid: event id * @name: name of the event + * @config: current configuration * @list: entry in &rdt_resource->evt_list */ struct mon_evt { u32 evtid; char *name; + char *config; struct list_head list; }; =20 @@ -95,6 +97,7 @@ union mon_data_bits { unsigned int rid : 10; unsigned int evtid : 8; unsigned int domid : 14; + unsigned int mon_config : 32; } u; }; =20 diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index b9de417dac1c..3f900241dbab 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -656,11 +656,13 @@ static struct mon_evt llc_occupancy_event =3D { static struct mon_evt mbm_total_event =3D { .name =3D "mbm_total_bytes", .evtid =3D QOS_L3_MBM_TOTAL_EVENT_ID, + .config =3D "mbm_total_config", }; =20 static struct mon_evt mbm_local_event =3D { .name =3D "mbm_local_bytes", .evtid =3D QOS_L3_MBM_LOCAL_EVENT_ID, + .config =3D "mbm_local_config", }; =20 /* diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 855483b297a8..30d2182d4fda 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -254,6 +254,10 @@ static const struct kernfs_ops kf_mondata_ops =3D { .seq_show =3D rdtgroup_mondata_show, }; =20 +static const struct kernfs_ops kf_mondata_config_ops =3D { + .atomic_write_len =3D PAGE_SIZE, +}; + static bool is_cpu_list(struct kernfs_open_file *of) { struct rftype *rft =3D of->kn->priv; @@ -2534,6 +2538,25 @@ void rmdir_mondata_subdir_allrdtgrp(struct rdt_resou= rce *r, unsigned int dom_id) } } =20 +static int mon_config_addfile(struct kernfs_node *parent_kn, const char *n= ame, + void *priv) +{ + struct kernfs_node *kn; + int ret =3D 0; + + kn =3D __kernfs_create_file(parent_kn, name, 0644, + GLOBAL_ROOT_UID, GLOBAL_ROOT_GID, 0, + &kf_mondata_config_ops, priv, NULL, NULL); + if (IS_ERR(kn)) + return PTR_ERR(kn); + + ret =3D rdtgroup_kn_set_ugid(kn); + if (ret) + kernfs_remove(kn); + + return ret; +} + static int mkdir_mondata_subdir(struct kernfs_node *parent_kn, struct rdt_domain *d, struct rdt_resource *r, struct rdtgroup *prgrp) @@ -2568,6 +2591,15 @@ static int mkdir_mondata_subdir(struct kernfs_node *= parent_kn, if (ret) goto out_destroy; =20 + /* Create the sysfs event configuration files */ + if (r->mon_configurable && + (mevt->evtid =3D=3D QOS_L3_MBM_TOTAL_EVENT_ID || + mevt->evtid =3D=3D QOS_L3_MBM_LOCAL_EVENT_ID)) { + ret =3D mon_config_addfile(kn, mevt->config, priv.priv); + if (ret) + goto out_destroy; + } + if (is_mbm_event(mevt->evtid)) mon_event_read(&rr, r, d, prgrp, mevt->evtid, true); } From nobody Sun Apr 12 02:49:45 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01052C00144 for ; Mon, 1 Aug 2022 20:57:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234776AbiHAU5X (ORCPT ); Mon, 1 Aug 2022 16:57:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234756AbiHAU4j (ORCPT ); Mon, 1 Aug 2022 16:56:39 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2068.outbound.protection.outlook.com [40.107.93.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70C011759E; Mon, 1 Aug 2022 13:56:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BvABaBjx1l1jH/NVvjI6zaigKK+mq7nIB9HLdpICuvjIO5oJjyOUaJNwYV3He14dxzLZv4vsAzBjdbN6/2qoh4wNzOMVHkdBDwafhWt4dSP8M3vKGTNuVZP3gvTRInvKOZPchlvFRPit7LwM/zHhtNUABo8XzT6r8VVp/+Oc2Q61OwI3MMm9igj6+4d2Q1rMli5StuEn1uAEELib2vUoiIys+5EXdDJRUj1o0R23y/VA1VcwbSUvf+pPi0590G3oyqTWydJjZFz8HrTKZR1bVwiyznWzgQ4Jo+nA1EmhuBsfUMw5VP/VQSsKoUzmuCNm2AKEVHfcAMrq28frnBCNxw== 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=vfGercsQhgo2O8Rec4uKMMlwFWA1+1hnZNnzZHgBMV4=; b=E7WmBGbg2Tj0VHLmmR71Y3uUqyQA2NFk1Coxb7gaO109iEB8Zm8J7HOohyIhk7/sRRaOfgqzGGHdPo4+ukGNTB1xHZ1dxBdxg1EYnpwqPI5bkGi8k0vwiFteYjeBftnk2HgK04nije6A07xSH/rFy5L1sionYRzZcAvaY8wNiSYzUJ6dm9wchZyGylq1WEpH2loaLYYT1ZvMk8tPxvskHMPrG2YmEyhQkbyP2SwxopRIji9vCbwjPjpCU/8/dxQ92NQWo3KysGN2pbb/WC3lmZCt2yUTDdvveIEDA8ypq8chhj/dzxVq4r6StYKz6UwLlH+hn9QUa3XFC8rxBjo7pg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vfGercsQhgo2O8Rec4uKMMlwFWA1+1hnZNnzZHgBMV4=; b=OvkDuu6jLzO7Zzpp/X7AUJAIPug7MAvUwWqIzwvbOTfTLFMOluVSFVSfgWqBsYYxwavA+6LwXKCPItwh4VUbS+a2mQkTES0b1sZwloXJwyufW9mFoiEsOkZfUKOrOEjNuiTdm+JLTeRXuLYpyhEKUqjIC51dao09vZV3IDU3NoI= Received: from BN0PR04CA0182.namprd04.prod.outlook.com (2603:10b6:408:e9::7) by MW3PR12MB4506.namprd12.prod.outlook.com (2603:10b6:303:53::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.12; Mon, 1 Aug 2022 20:56:35 +0000 Received: from BN8NAM11FT058.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e9:cafe::5b) by BN0PR04CA0182.outlook.office365.com (2603:10b6:408:e9::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.20 via Frontend Transport; Mon, 1 Aug 2022 20:56:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT058.mail.protection.outlook.com (10.13.177.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Mon, 1 Aug 2022 20:56:34 +0000 Received: from [127.0.1.1] (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Mon, 1 Aug 2022 15:56:31 -0500 Subject: [PATCH v2 08/10] x86/resctrl: Add the sysfs interface to read the event configuration From: Babu Moger To: , , , , CC: , , , , , , , Date: Mon, 1 Aug 2022 15:56:31 -0500 Message-ID: <165938739105.724959.5094448646566923271.stgit@bmoger-ubuntu> In-Reply-To: <165938717220.724959.10931629283087443782.stgit@bmoger-ubuntu> References: <165938717220.724959.10931629283087443782.stgit@bmoger-ubuntu> User-Agent: StGit/1.1.dev103+g5369f4c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a698e639-51f3-4556-ac62-08da740051e2 X-MS-TrafficTypeDiagnostic: MW3PR12MB4506:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LT2ErsSqbCgnF9Q+1DxMDZHLQfu89RiZmKhQH4zdT/qMojbpu6JnHhvVigXo4yoGOBBrBBe2T32FuITvF81EyqNNvvbEcJvZzwYDTH1DRtFIlSONdn/ETJKTKsRSEnrr9Vujt+81WDU8CGcnXDoBuiRCAx5VqWJwXJT8I6IGS1r6cynCaeyMxe8V2iB3OoU9uaDDqjgScIOpfG4iEj342Q57Wf/zvp8lgnb36YOsoNmyyOdTbCV0C1od9DrV/hAY90Q74zpV+7ouosolQA+Iu/tzvka3FNKc1Scjnd6b6iORKcXXz/Rq0M9jP6ntO2e7/NS6NdLjkgJmP197/B7JVGeGrzuHOvMdf/7GOAZl8/butMtocLLLnVlT44yMAKlmKPTBBC/Zi10dQQKUzAyz+jYHtBMJWKlpv4KdEI2XiEc1kZFjp7b3tLnZMPeR3ZjQcs4nd+pS8l+RmkyT/BkpTwvagzeYV3H36WIsI9NtYBCuQq+ogZWZPbdAezXttvANIcuDAAyHjwwwySOMF0krdJHsSxkQf9B2u7rUqPsLmAWGBPDk5haQIcXF/CYMWw/TidWZ9G3wBddxlxQZO/i5dgSIb4fBEzlSQyaAvFojCQF2RHCJGDaqwLPSdlNrd4E3K4e2ZuTsepC7lFihsntXJpVr0Mz3DSTd/NCo5QQDwFiUb638lM/CfzXFwxuKq4REA1qhi/Vr+VzF2bdW900dnFLVsY9hdA8dEjzl/+h1EuVuALNujEJCo7WmftX/uspGfcpCSnEovyUBwFyruwedS1DrUAG1/JuXN+n2Ih7R4TgbCLwGGASgCWSBi1L4DYg5eA//231XYkfX4EbUKkO8RNn5F38LYifaOcrPv5bbGfc= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(7916004)(396003)(136003)(346002)(376002)(39860400002)(40470700004)(36840700001)(46966006)(9686003)(82310400005)(86362001)(2906002)(26005)(41300700001)(66574015)(336012)(81166007)(356005)(426003)(47076005)(36860700001)(33716001)(83380400001)(103116003)(82740400003)(16526019)(186003)(40480700001)(4326008)(70206006)(8676002)(70586007)(5660300002)(8936002)(54906003)(478600001)(16576012)(316002)(110136005)(40460700003)(44832011)(7416002)(71626007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2022 20:56:34.7103 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a698e639-51f3-4556-ac62-08da740051e2 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT058.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4506 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The current event configuration can be viewed by the user by reading the sysfs configuration file. Following are the types of events supported. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Bits Description 6 Dirty Victims from the QOS domain to all types of memory 5 Reads to slow memory in the non-local NUMA domain 4 Reads to slow memory in the local NUMA domain 3 Non-temporal writes to non-local NUMA domain 2 Non-temporal writes to local NUMA domain 1 Reads to memory in the non-local NUMA domain 0 Reads to memory in the local NUMA domain By default the mbm_total_bytes configuration is set to 0x7f to count all the types of events and mbm_local_bytes configuration is set to 0x15 to count all the local memory events. $cat /sys/fs/resctrl/mon_data/mon_L3_00/mbm_total_config 0x7f $cat /sys/fs/resctrl/mon_data/mon_L3_00/mbm_local_config 0x15 Signed-off-by: Babu Moger --- arch/x86/kernel/cpu/resctrl/internal.h | 21 ++++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 70 ++++++++++++++++++++++++++++= ++++ 2 files changed, 91 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index fc725f5e9024..457666709386 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -15,6 +15,7 @@ #define MSR_IA32_MBA_THRTL_BASE 0xd50 #define MSR_IA32_MBA_BW_BASE 0xc0000200 #define MSR_IA32_SMBA_BW_BASE 0xc0000280 +#define MSR_IA32_EVT_CFG_BASE 0xc0000400 =20 #define MSR_IA32_QM_CTR 0x0c8e #define MSR_IA32_QM_EVTSEL 0x0c8d @@ -50,6 +51,26 @@ */ #define MBM_CNTR_WIDTH_OFFSET_MAX (62 - MBM_CNTR_WIDTH_BASE) =20 +/* Reads to Local DRAM Memory */ +#define READS_TO_LOCAL_MEM BIT(0) + +/* Reads to Remote DRAM Memory */ +#define READS_TO_REMOTE_MEM BIT(1) + +/* Non-Temporal Writes to Local Memory */ +#define NON_TEMP_WRITE_TO_LOCAL_MEM BIT(2) + +/* Non-Temporal Writes to Remote Memory */ +#define NON_TEMP_WRITE_TO_REMOTE_MEM BIT(3) + +/* Reads to Local Memory the system identi=EF=AC=81es as "Slow Memory" */ +#define READS_TO_LOCAL_S_MEM BIT(4) + +/* Reads to Remote Memory the system identi=EF=AC=81es as "Slow Memory" */ +#define READS_TO_REMOTE_S_MEM BIT(5) + +/* Dirty Victims to All Types of Memory */ +#define DIRTY_VICTIS_TO_ALL_MEM BIT(6) =20 struct rdt_fs_context { struct kernfs_fs_context kfc; diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 30d2182d4fda..e1847d49fa15 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -254,8 +254,78 @@ static const struct kernfs_ops kf_mondata_ops =3D { .seq_show =3D rdtgroup_mondata_show, }; =20 +/* + * This is called via IPI to read the CQM/MBM counters + * in a domain. + */ +void mon_event_config_read(void *info) +{ + union mon_data_bits *md =3D info; + u32 evtid =3D md->u.evtid; + u32 h, msr_index; + + switch (evtid) { + case QOS_L3_MBM_TOTAL_EVENT_ID: + msr_index =3D 0; + break; + case QOS_L3_MBM_LOCAL_EVENT_ID: + msr_index =3D 1; + break; + default: + return; /* Not expected to come here */ + } + + rdmsr(MSR_IA32_EVT_CFG_BASE + msr_index, md->u.mon_config, h); +} + +void mondata_config_read(struct rdt_domain *d, union mon_data_bits *md) +{ + smp_call_function_any(&d->cpu_mask, mon_event_config_read, md, 1); +} + +int rdtgroup_mondata_config_show(struct seq_file *m, void *arg) +{ + struct kernfs_open_file *of =3D m->private; + struct rdt_hw_resource *hw_res; + u32 resid, evtid, domid; + struct rdtgroup *rdtgrp; + struct rdt_resource *r; + union mon_data_bits md; + struct rdt_domain *d; + int ret =3D 0; + + rdtgrp =3D rdtgroup_kn_lock_live(of->kn); + if (!rdtgrp) { + ret =3D -ENOENT; + goto out; + } + + md.priv =3D of->kn->priv; + resid =3D md.u.rid; + domid =3D md.u.domid; + evtid =3D md.u.evtid; + + hw_res =3D &rdt_resources_all[resid]; + r =3D &hw_res->r_resctrl; + + d =3D rdt_find_domain(r, domid, NULL); + if (IS_ERR_OR_NULL(d)) { + ret =3D -ENOENT; + goto out; + } + + mondata_config_read(d, &md); + + seq_printf(m, "0x%x\n", md.u.mon_config); + +out: + rdtgroup_kn_unlock(of->kn); + return ret; +} + static const struct kernfs_ops kf_mondata_config_ops =3D { .atomic_write_len =3D PAGE_SIZE, + .seq_show =3D rdtgroup_mondata_config_show, }; =20 static bool is_cpu_list(struct kernfs_open_file *of) From nobody Sun Apr 12 02:49:45 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F88BC00144 for ; Mon, 1 Aug 2022 20:57:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235178AbiHAU51 (ORCPT ); Mon, 1 Aug 2022 16:57:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235035AbiHAU4n (ORCPT ); Mon, 1 Aug 2022 16:56:43 -0400 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2044.outbound.protection.outlook.com [40.107.101.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC68041992; Mon, 1 Aug 2022 13:56:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QtWW2r455YecChyFFSYHdZpNcL8zwQ3qkHEorychSuHwbwMY1lkXFXTY1/vaTRd43SgLrTIXz61ZJwJa497/CFQ04jgoxnGe/uFAnEVJ26VaQu6r+GCgGI4QlZmYIemvIGptQsO6oNVRi/yl5Ys5RLuu3YHA4BHX8gBpHXqdn/+lnvNAYY1S9eznFWUOdW3z9BfHWnKwULUYFgaE2v5EMUn5w1SRVvx+XoYqgEf38l7V4lUeINazMZgsLIPsb+uPUWO15itfDtV+iWkEBrBXCzpREGim39SdvThgT9P85bmQD89IC4CW+yKa+lrL/Ns2pD//SE+7oZHU7idvC5veOg== 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=H3SDTR/kL4O1R4+mhUqund24vBhQUTOpem5bZn5n4P4=; b=gYNs/2AAmdBRMXpDnsQ38ZX/yN5svwdqikQsTyJplmVsZBxgkM5mmCQd9y/YTuAAUPMKUXrrStOS1PuBvacTnrWS7ZLuGZcFTtnVPykscN7lhEtPPiV1mqv41/wZxjQYrm/YxN8oMxPBIgreES+WvKmm0WAnk5d5xUWMVOKW9zi+My+Te92EuLMUv59LHduFa75xP8EyocXcoFGLV2cFaTjYBnjl/0lVtFCQHhD5G4n83x3GLdptEfz22pIM2ZiC/8I20kDxSmWoL8k/YU+rXaRwKs4+pl6PTWIeW6kf8/7UTp1UfXAI6VfzGa3JrxUTy4BpNdzewew/KHPf/M8fcQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H3SDTR/kL4O1R4+mhUqund24vBhQUTOpem5bZn5n4P4=; b=iO3XUvBW4DfPkLeJ1xQxJGzrivR1J2pe2bzXMRwOriaqk+6hHTnfZt6S1u474rq/lMl7XEAnk5aSGwY6H2iQmdOK3xPbXzLWCITVp1qOT7/3Ko2qr3fOP9s4EMnAfNYIczEYNIta+6k+QbVZPkCGsNAmuzzPc5/YBFoS2NyTbQg= Received: from BN0PR04CA0189.namprd04.prod.outlook.com (2603:10b6:408:e9::14) by DM6PR12MB4498.namprd12.prod.outlook.com (2603:10b6:5:2a2::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.6; Mon, 1 Aug 2022 20:56:39 +0000 Received: from BN8NAM11FT058.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e9:cafe::ec) by BN0PR04CA0189.outlook.office365.com (2603:10b6:408:e9::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.23 via Frontend Transport; Mon, 1 Aug 2022 20:56:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT058.mail.protection.outlook.com (10.13.177.58) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Mon, 1 Aug 2022 20:56:39 +0000 Received: from [127.0.1.1] (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Mon, 1 Aug 2022 15:56:37 -0500 Subject: [PATCH v2 09/10] x86/resctrl: Add sysfs interface to write the event configuration From: Babu Moger To: , , , , CC: , , , , , , , Date: Mon, 1 Aug 2022 15:56:37 -0500 Message-ID: <165938739737.724959.9952911763036010551.stgit@bmoger-ubuntu> In-Reply-To: <165938717220.724959.10931629283087443782.stgit@bmoger-ubuntu> References: <165938717220.724959.10931629283087443782.stgit@bmoger-ubuntu> User-Agent: StGit/1.1.dev103+g5369f4c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7ffeb334-7a19-4946-4376-08da740054b0 X-MS-TrafficTypeDiagnostic: DM6PR12MB4498:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: i7kjce+xTpQ6jZ4b4ZCg2Ca0lg7MdyDvVJvdr2yDjmXNCcOSkalqUGT7c65ZVST8d7MluY7SzFnPmrm3dZegTkS3v50KhworCw6IPlmm1v1MhEcp9zUAHmuXGdMapOl35X/zqYthLMi4jnacfYKsNgapLI0MSPp0Ps6QtDEj67R69r1+j3tccrb72eOQMHC945+y0JKQvWfjMIs1Y+XsTQDl4pv4r18o2YH2fG9KatGwNyMPvughpK7Ni4ITNusJJ8VlhBWtJJplBn+COEUJxhDctElz/zoIdwYpV6SVVLm/nplog2PTiCVwM1iLueaoUBp1bzq2iyEm8Cg+81cdZugwnBPH3CmFwNU0CudDuCu5X/esdTubj0UFfWg6dsA9ThfcElOKCVsFgH3TqKJETWi0YptPWTpMj7M9TzmNzL5r5KI7BENLJTaPwbI+JAuSSI82cAsajSRYQsrnBj8JBW83TygQQbJH0SIML+ixnwt48YbHbJesnH48TkaUxgnsXASVcF+fEKeAaEJZEj+uV7ig6M4YfAwTP4DUI1LqB6FVkvzs+QF0JXMUGcqlKzBTDRINUphWJSKJvHF/rIHeHXPTcwNlsesshdLE0BqCCx/xTCD12tWVTqGxperYyMJgzPpPkRLbrnyZpZWKPg1Fr9391PFyY6cARAfkrtv/a93oFXraP5/4sybOiWh9ODXkTnF+tq4VmpcaNAvaGx3bp6l7QDIhK80TQ/rB01m8crpv+cgGuhUsR7Gvo5AG7Wiv+ROuLBrEw3kyLjPXakp7q5K/1broTAxup7oVOZQvg0XtFlMzH9GpOFvnyzE9hEt2QQxUTao4Oat8lM9bSeoRvw2Rd16/uyOEb9zgrfTJetI= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(7916004)(346002)(39860400002)(376002)(136003)(396003)(40470700004)(46966006)(36840700001)(4326008)(478600001)(70206006)(8676002)(70586007)(33716001)(36860700001)(40480700001)(83380400001)(86362001)(110136005)(8936002)(316002)(54906003)(16576012)(9686003)(44832011)(26005)(103116003)(5660300002)(186003)(336012)(47076005)(426003)(2906002)(7416002)(16526019)(41300700001)(356005)(82740400003)(81166007)(82310400005)(40460700003)(71626007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2022 20:56:39.4443 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7ffeb334-7a19-4946-4376-08da740054b0 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT058.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4498 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add the sysfs interface to write the event configuration for the MBM configurable events. The event configuration can be changed by writing to the sysfs file for that specific event. Following are the types of events supported. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Bits Description 6 Dirty Victims from the QOS domain to all types of memory 5 Reads to slow memory in the non-local NUMA domain 4 Reads to slow memory in the local NUMA domain 3 Non-temporal writes to non-local NUMA domain 2 Non-temporal writes to local NUMA domain 1 Reads to memory in the non-local NUMA domain 0 Reads to memory in the local NUMA domain By default the mbm_total_bytes configuration is set to 0x7f to count all the types of events and mbm_local_bytes configuration is set to 0x15 to count all the local memory events. For example: To change the mbm_total_bytes to count all the reads, run the command. $echo 0x33 > /sys/fs/resctrl/mon_data/mon_L3_00/mbm_total_config To change the mbm_local_bytes to count all the slow memory reads, run the command. $echo 0x30 > /sys/fs/resctrl/mon_data/mon_L3_00/mbm_local_config Signed-off-by: Babu Moger --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 109 ++++++++++++++++++++++++++++= ++++ 1 file changed, 109 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index e1847d49fa15..83c8780726ff 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -323,9 +323,118 @@ int rdtgroup_mondata_config_show(struct seq_file *m, = void *arg) return ret; } =20 +/* + * This is called via IPI to read the CQM/MBM counters + * in a domain. + */ +void mon_event_config_write(void *info) +{ + union mon_data_bits *md =3D info; + u32 evtid =3D md->u.evtid; + u32 msr_index; + + switch (evtid) { + case QOS_L3_MBM_TOTAL_EVENT_ID: + msr_index =3D 0; + break; + case QOS_L3_MBM_LOCAL_EVENT_ID: + msr_index =3D 1; + break; + default: + return; /* Not expected to come here */ + } + + wrmsr(MSR_IA32_EVT_CFG_BASE + msr_index, md->u.mon_config, 0); +} + +ssize_t rdtgroup_mondata_config_write(struct kernfs_open_file *of, + char *buf, size_t nbytes, loff_t off) +{ + struct rdt_hw_resource *hw_res; + struct rdtgroup *rdtgrp; + struct rdt_resource *r; + unsigned int mon_config; + cpumask_var_t cpu_mask; + union mon_data_bits md; + struct rdt_domain *d; + u32 resid, domid; + int ret =3D 0, cpu; + + ret =3D kstrtouint(buf, 0, &mon_config); + if (ret) + return ret; + + rdt_last_cmd_clear(); + + /* mon_config cannot be more than the supported set of events */ + if (mon_config > GENMASK(6, 0)) { + rdt_last_cmd_puts("Invalid event configuration\n"); + return -EINVAL; + } + + cpus_read_lock(); + rdtgrp =3D rdtgroup_kn_lock_live(of->kn); + if (!rdtgrp) { + return -ENOENT; + goto e_unlock; + } + + if (!zalloc_cpumask_var(&cpu_mask, GFP_KERNEL)) { + ret =3D -ENOMEM; + goto e_unlock; + } + + + md.priv =3D of->kn->priv; + resid =3D md.u.rid; + domid =3D md.u.domid; + + hw_res =3D &rdt_resources_all[resid]; + r =3D &hw_res->r_resctrl; + d =3D rdt_find_domain(r, domid, NULL); + if (IS_ERR_OR_NULL(d)) { + ret =3D -ENOENT; + goto e_cpumask; + } + + md.u.mon_config =3D mon_config & 0xFF; + + /* Pick all the CPUs in the domain instance */ + for_each_cpu(cpu, &d->cpu_mask) + cpumask_set_cpu(cpu, cpu_mask); + + cpu =3D get_cpu(); + /* Update MSR_IA32_EVT_CFG_BASE MSR on this cpu if it's in cpu_mask */ + if (cpumask_test_cpu(cpu, cpu_mask)) + mon_event_config_write(&md); + + /* Update MSR_IA32_EVT_CFG_BASE MSR on all other cpus in cpu_mask */ + smp_call_function_many(cpu_mask, mon_event_config_write, &md, 1); + put_cpu(); + + /* + * When an Event Configuration is changed, the bandwidth counters + * for all RMIDs and Events will be cleared, and the U-bit for every + * RMID will be set on the next read to any BwEvent for every RMID. + * Clear the mbm_local and mbm_total counts for all the RMIDs. + */ + memset(d->mbm_local, 0, sizeof(struct mbm_state) * r->num_rmid); + memset(d->mbm_total, 0, sizeof(struct mbm_state) * r->num_rmid); + +e_cpumask: + free_cpumask_var(cpu_mask); + +e_unlock: + rdtgroup_kn_unlock(of->kn); + cpus_read_unlock(); + + return ret ?: nbytes; +} + static const struct kernfs_ops kf_mondata_config_ops =3D { .atomic_write_len =3D PAGE_SIZE, .seq_show =3D rdtgroup_mondata_config_show, + .write =3D rdtgroup_mondata_config_write, }; =20 static bool is_cpu_list(struct kernfs_open_file *of) From nobody Sun Apr 12 02:49:45 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C50FBC00144 for ; Mon, 1 Aug 2022 20:58:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235288AbiHAU5t (ORCPT ); Mon, 1 Aug 2022 16:57:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235126AbiHAU47 (ORCPT ); Mon, 1 Aug 2022 16:56:59 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2079.outbound.protection.outlook.com [40.107.94.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0088F419A9; Mon, 1 Aug 2022 13:56:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KUwXwCrplym9RN+OsWd8/FaTxJHE+gOuXCuovqBilDLIyK10O6cdgWzSI2qtPXzCwHxCnGDCtClacG+AvyGe8BSaElMvsldiI+c5GFw2Yzq65A9zPHVTC/8AvlHhogLdl/SAHrsldFpeCIuJ5HE7RcXnAv+mg9mbfmjgIgH6/XOfKIj9dwj7v6VUmlBJRglWbo+XMg0X+d8g3yRizgIvJXeKo1ESclYU1/vjVIr9jLmcMv6dtrSR9+5IDpPik4bsMIhR68zUzBd6MaoM92uUV5+7rHHA8r6wm0xGXB7/AapNJnxxZ2mWudR+4rUHBI1QajhSmEatIuUc8ZdbBr4OvA== 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=IpmP5Sq4lnk7Jen1kRc+TyLKQQ7YKpPOmvrbvhAjAT0=; b=QCx8kQO4g63p+zGuJOYuVUkCda9lbKkwHeDy3JllaOFnYIu3lq23nm1ItsbFWMfYY86NaEMkuKIKX7xdTb0eM4otPP5gw+sxRGmT2UyZlFvgIsmHYHBgnBo2cwRgqbfNhQjZDQIIdmxOFyu+iB0l9/yeYrFswZX+ZUB5AjemyW6tr56BwSy6MbJ6pJ1pxtTJcqeX3c1lkxi9RQDMdUQfyZBzUFk9FwvIo0xHMIfbE2vgtRB0K7rGuautR1TFU+6K/GKZxochIf0vzK0E/ydPM1idjnof+eqa9o+05QUtsGccVR34mEpJte0PxVC7wVcel5+cs/FIdCYyP8f/ZDcN+Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IpmP5Sq4lnk7Jen1kRc+TyLKQQ7YKpPOmvrbvhAjAT0=; b=LHCWpQ1dIwnLoLdLJ9jP6qXosPTDnO8HCjLO4Iq2VAMH/H+s4DJYLaIUmWniDNG08U35BicYSETaIt24XI78VxcoobP7w6VN3vp3jKkcypz4LgWVCAlr6asmC2rEI6snCw8gydqsj3YRaTAo8afRNM2ItvuRqjakzqlcnEpdbRg= Received: from BN9PR03CA0484.namprd03.prod.outlook.com (2603:10b6:408:130::9) by BN9PR12MB5161.namprd12.prod.outlook.com (2603:10b6:408:11a::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.11; Mon, 1 Aug 2022 20:56:45 +0000 Received: from BN8NAM11FT059.eop-nam11.prod.protection.outlook.com (2603:10b6:408:130:cafe::22) by BN9PR03CA0484.outlook.office365.com (2603:10b6:408:130::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.25 via Frontend Transport; Mon, 1 Aug 2022 20:56:45 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT059.mail.protection.outlook.com (10.13.177.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Mon, 1 Aug 2022 20:56:45 +0000 Received: from [127.0.1.1] (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Mon, 1 Aug 2022 15:56:44 -0500 Subject: [PATCH v2 10/10] Documentation/x86: Update resctrl_ui.rst for new features From: Babu Moger To: , , , , CC: , , , , , , , Date: Mon, 1 Aug 2022 15:56:43 -0500 Message-ID: <165938740360.724959.7059659465268246182.stgit@bmoger-ubuntu> In-Reply-To: <165938717220.724959.10931629283087443782.stgit@bmoger-ubuntu> References: <165938717220.724959.10931629283087443782.stgit@bmoger-ubuntu> User-Agent: StGit/1.1.dev103+g5369f4c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0e352887-c6c6-4210-ccf8-08da7400586a X-MS-TrafficTypeDiagnostic: BN9PR12MB5161:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +rxmEq/UEkvzboQoGpLV6EXBluszHogPakp5q0WjGmd/1kN3K87BGib8hypPUtcs9ulc3NeklevqSDAS8G4sw4a/IEbC+0jVaisc6dST/rQ3/iyqS5NoyH4lPpxNN3mn8JyEXLye3KnUyUN3oyB5jFpwlZIO2xO+nT59sJH3/NKCbtpZTLZdP3ldNTL+nefeo/db7jhA2alpU06HJzxtESqCZmEZaQHFD9dGTBnSd57f8eeQRLgPijtBP0qbZShcumCPwsqhr2oYUyiORqORP5UgYu9mQ00W/HTpBvVV6e9aMhX03pbxzx9olkTzEUjGMXNMxWXv5x5zMDPr+2zsxnFnyCealx2o3N5waqsf4k9PTjmjwP8QL9DZ92qG3XqsTCVpJXKIRiw+SZ8i9G/EZpA/Qxg3dGuhzc0R8W19I61BXqhxPHUlOgIrEX58wj6DScuNN9yda0Czw9+8T42pIrcNYOzclXSG+RCrkGfRuIYxpkUKfLvGcySAVqIfCy71EKkpaWFeAiYYObLTw4WyJXLQDWCBuq+MImRXa4xzEJDDXsbZcuagMYgcPRaCieJDxuwrCqh/r02EZIF2Ci7N+kd5Kqfi9rfxfyfZvaWfo8U6vs5gLL5PvRXs8GamPRyDqQ3GyM7bBJWjB4TqMSe5nu57SVX0CZTqkne7g3Td+3a5umRAcWwgl3kAjIVp2s+P2XD97ejR+qdJC/UnI15C28BjkD18qo9+4N/qZujzGcJwwpaIB4X0DdPIoK7Qlrk7d6J8NKBWCgNUT+Hden68RcCXDvHR1ag4CAlofqswtPL+3iqg4v4wm07Sy8wzJN0QN0ByAsfpOqtRbbqDaZZr5s99fhTcnPDP88Owwxuoz+c= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(7916004)(4636009)(396003)(39860400002)(136003)(346002)(376002)(36840700001)(46966006)(40470700004)(82740400003)(40480700001)(356005)(16576012)(316002)(81166007)(54906003)(110136005)(36860700001)(33716001)(82310400005)(70206006)(426003)(336012)(9686003)(40460700003)(26005)(47076005)(41300700001)(15650500001)(83380400001)(70586007)(4326008)(478600001)(186003)(16526019)(5660300002)(8936002)(103116003)(44832011)(7416002)(2906002)(8676002)(86362001)(71626007)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Aug 2022 20:56:45.7937 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0e352887-c6c6-4210-ccf8-08da7400586a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT059.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5161 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Update the documentation for the new features: 1. Slow Memory Bandwidth allocation. With this feature, the QOS enforcement policies can be applied to the external slow memory connected to the host. QOS enforcement is accomplished by assigning a Class Of Service (COS) to a processor and specifying allocations or limits for that COS for each resource to be allocated. 2. Bandwidth Monitoring Event Configuration (BMEC). The bandwidth monitoring events mbm_total_bytes and mbm_local_bytes are set to count all the total and local reads/writes respectively. With the introduction of slow memory, the two counters are not enough to count all the different types are memory events. With the feature BMEC, the users have the option to configure mbm_total_bytes and mbm_local_bytes to count the specific type of events. Added the instructions to configure with examples. Signed-off-by: Babu Moger --- Documentation/x86/resctrl.rst | 123 +++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 123 insertions(+) diff --git a/Documentation/x86/resctrl.rst b/Documentation/x86/resctrl.rst index 71a531061e4e..ba6833171c0a 100644 --- a/Documentation/x86/resctrl.rst +++ b/Documentation/x86/resctrl.rst @@ -167,6 +167,12 @@ with the following files: bytes) at which a previously used LLC_occupancy counter can be considered for re-use. =20 +"mon_configurable": + Provides the information if the events mbm_total and + mbm_local are configurable. See the configuration + details for "mbm_total_config" and "mbm_local_config" + for more information. + Finally, in the top level of the "info" directory there is a file named "last_cmd_status". This is reset with every "command" issued via the file system (making new directories or writing to any of the @@ -264,6 +270,29 @@ When monitoring is enabled all MON groups will also co= ntain: the sum for all tasks in the CTRL_MON group and all tasks in MON groups. Please see example section for more details on usage. =20 +"mbm_total_config": +"mbm_local_config": + This contains the current event configuration for the events + mbm_total_bytes and mbm_local_bytes, respectively, when the + Bandwidth Monitoring Event Configuration (BMEC) feature is support= ed. + These files are organized by L3 domains under the subdirectories + "mon_L3_00" and "mon_L3_01". When BMEC is supported, the events + mbm_local_bytes and mbm_total_bytes are configurable. + + Following are the types of events supported. + Bits Description + 6 Dirty Victims from the QOS domain to all types of memory + 5 Reads to slow memory in the non-local NUMA domain + 4 Reads to slow memory in the local NUMA domain + 3 Non-temporal writes to non-local NUMA domain + 2 Non-temporal writes to local NUMA domain + 1 Reads to memory in the non-local NUMA domain + 0 Reads to memory in the local NUMA domain + + By default, the mbm_total_bytes configuration is set to 0x7f to co= unt + all the event types and the mbm_local_bytes configuration is set to + 0x15 to count all the local memory events. + Resource allocation rules ------------------------- =20 @@ -464,6 +493,14 @@ Memory bandwidth domain is L3 cache. =20 MB:=3Dbw_MBps0;=3Dbw_MBps1;... =20 +Slow Memory bandwidth Allocation (when supported) +------------------------------------------ + +Slow Memory b/w domain is L3 cache. +:: + + SB:=3Dbandwidth0;=3Dbandwidth1;... + Reading/writing the schemata file --------------------------------- Reading the schemata file will show the state of all resources @@ -479,6 +516,44 @@ which you wish to change. E.g. L3DATA:0=3Dfffff;1=3Dfffff;2=3D3c0;3=3Dfffff L3CODE:0=3Dfffff;1=3Dfffff;2=3Dfffff;3=3Dfffff =20 +Reading/writing the schemata file (on AMD systems) +--------------------------------------------------------------- +Reading the schemata file will show the state of all resources +on all domains. When writing the memory bandwidth allocation you +only need to specify those values in an absolute number expressed +in 1/8 GB/s increments. To allocate bandwidth limit of 2GB, you +need to specify the value 16 (16 * 1/8 =3D 2). E.g. +:: + + # cat schemata + MB:0=3D2048;1=3D2048;2=3D2048;3=3D2048 + L3:0=3Dffff;1=3Dffff;2=3Dffff;3=3Dffff + + # echo "MB:1=3D16" > schemata + # cat schemata + MB:0=3D2048;1=3D 16;2=3D2048;3=3D2048 + L3:0=3Dffff;1=3Dffff;2=3Dffff;3=3Dffff + +Reading/writing the schemata file (on AMD systems) with slow memory +--------------------------------------------------------------- +Reading the schemata file will show the state of all resources +on all domains. When writing the memory bandwidth allocation you +only need to specify those values in an absolute number expressed +in 1/8 GB/s increments. To allocate bandwidth limit of 8GB, you +need to specify the value 64 (64 * 1/8 =3D 8). E.g. +:: + + # cat schemata + SB:0=3D2048;1=3D2048;2=3D2048;3=3D2048 + MB:0=3D2048;1=3D2048;2=3D2048;3=3D2048 + L3:0=3Dffff;1=3Dffff;2=3Dffff;3=3Dffff + + # echo "SB:1=3D64" > schemata + # cat schemata + SB:0=3D2048;1=3D 64;2=3D2048;3=3D2048 + MB:0=3D2048;1=3D2048;2=3D2048;3=3D2048 + L3:0=3Dffff;1=3Dffff;2=3Dffff;3=3Dffff + Cache Pseudo-Locking =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D CAT enables a user to specify the amount of cache space that an @@ -1210,6 +1285,54 @@ View the llc occupancy snapshot:: # cat /sys/fs/resctrl/p1/mon_data/mon_L3_00/llc_occupancy 11234000 =20 +Example 5 (Configure and Monitor specific event types) +------------------------------------------------- + +A single socket system which has real time tasks running on cores 0-4 +and non real time tasks on other CPUs. We want to monitor the memory +bandwidth allocation for specific events. +:: + + # mount -t resctrl resctrl /sys/fs/resctrl + # cd /sys/fs/resctrl + # mkdir p1 + +Move the CPUs 0-4 over to p1:: + + # echo 0xf > p1/cpus + +View the current mbm_local_bytes:: + + # cat /sys/fs/resctrl/p1/mon_data/mon_L3_00/mbm_local_bytes + 112501 + +Change the mbm_local_bytes to count mon-temporal writes to both local +and non-local NUMA domain. Refer to event supported bitmap under +mbm_local_config:: + + # echo 0xc > /sys/fs/resctrl/p1/mon_data/mon_L3_00/mbm_local_config + +View the updated mbm_local_bytes:: + + # cat /sys/fs/resctrl/p1/mon_data/mon_L3_00/mbm_local_bytes + 12601 + +Similar experiment on mbm_total_bytes. First view the current mbm_total_by= tes:: + + # cat /sys/fs/resctrl/p1/mon_data/mon_L3_00/mbm_total_bytes + 1532501 + +Change the mbm_total_bytes to count only reads to slow memory on both local +and non-local NUMA domain. Refer to event supported bitmap under +mbm_total_config:: + + # echo 0x30 > /sys/fs/resctrl/p1/mon_data/mon_L3_00/mbm_total_config + +View the updated mbm_total_bytes:: + + # cat /sys/fs/resctrl/p1/mon_data/mon_L3_00/mbm_total_bytes + 104562 + Intel RDT Errata =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20