Skip to content

Commit f16adba

Browse files
James Morsebp3tk0v
authored andcommitted
x86/resctrl: Move resctrl types to a separate header
When resctrl is fully factored into core and per-arch code, each arch will need to use some resctrl common definitions in order to define its own specializations and helpers. Following conventional practice, it would be desirable to put the dependent arch definitions in an <asm/resctrl.h> header that is included by the common <linux/resctrl.h> header. However, this can make it awkward to avoid a circular dependency between <linux/resctrl.h> and the arch header. To avoid such dependencies, move the affected common types and constants into a new header that does not need to depend on <linux/resctrl.h> or on the arch headers. The same logic applies to the monitor-configuration defines, move these too. Some kind of enumeration for events is needed between the filesystem and architecture code. Take the x86 definition as its convenient for x86. The definition of enum resctrl_event_id is needed to allow the architecture code to define resctrl_arch_mon_ctx_alloc() and resctrl_arch_mon_ctx_free(). The definition of enum resctrl_res_level is needed to allow the architecture code to define resctrl_arch_set_cdp_enabled() and resctrl_arch_get_cdp_enabled(). The bits for mbm_local_bytes_config et al are ABI, and must be the same on all architectures. These are documented in Documentation/arch/x86/resctrl.rst The maintainers entry for these headers was missed when resctrl.h was created. Add a wildcard entry to match both resctrl.h and resctrl_types.h. Signed-off-by: James Morse <james.morse@arm.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Reviewed-by: Tony Luck <tony.luck@intel.com> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com> Reviewed-by: Fenghua Yu <fenghuay@nvidia.com> Reviewed-by: Babu Moger <babu.moger@amd.com> Tested-by: Carl Worth <carl@os.amperecomputing.com> # arm64 Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com> Tested-by: Peter Newman <peternewman@google.com> Tested-by: Amit Singh Tomar <amitsinght@marvell.com> # arm64 Tested-by: Shanker Donthineni <sdonthineni@nvidia.com> # arm64 Tested-by: Babu Moger <babu.moger@amd.com> Link: https://lore.kernel.org/r/20250311183715.16445-14-james.morse@arm.com
1 parent e3d5138 commit f16adba

5 files changed

Lines changed: 57 additions & 44 deletions

File tree

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19894,6 +19894,7 @@ S: Supported
1989419894
F: Documentation/arch/x86/resctrl*
1989519895
F: arch/x86/include/asm/resctrl.h
1989619896
F: arch/x86/kernel/cpu/resctrl/
19897+
F: include/linux/resctrl*.h
1989719898
F: tools/testing/selftests/resctrl/
1989819899

1989919900
READ-COPY UPDATE (RCU)

arch/x86/include/asm/resctrl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <linux/jump_label.h>
88
#include <linux/percpu.h>
9+
#include <linux/resctrl_types.h>
910
#include <linux/sched.h>
1011

1112
/*

arch/x86/kernel/cpu/resctrl/internal.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,6 @@
3232
*/
3333
#define MBM_CNTR_WIDTH_OFFSET_MAX (62 - MBM_CNTR_WIDTH_BASE)
3434

35-
/* Reads to Local DRAM Memory */
36-
#define READS_TO_LOCAL_MEM BIT(0)
37-
38-
/* Reads to Remote DRAM Memory */
39-
#define READS_TO_REMOTE_MEM BIT(1)
40-
41-
/* Non-Temporal Writes to Local Memory */
42-
#define NON_TEMP_WRITE_TO_LOCAL_MEM BIT(2)
43-
44-
/* Non-Temporal Writes to Remote Memory */
45-
#define NON_TEMP_WRITE_TO_REMOTE_MEM BIT(3)
46-
47-
/* Reads to Local Memory the system identifies as "Slow Memory" */
48-
#define READS_TO_LOCAL_S_MEM BIT(4)
49-
50-
/* Reads to Remote Memory the system identifies as "Slow Memory" */
51-
#define READS_TO_REMOTE_S_MEM BIT(5)
52-
53-
/* Dirty Victims to All Types of Memory */
54-
#define DIRTY_VICTIMS_TO_ALL_MEM BIT(6)
55-
56-
/* Max event bits supported */
57-
#define MAX_EVT_CONFIG_BITS GENMASK(6, 0)
58-
5935
/**
6036
* cpumask_any_housekeeping() - Choose any CPU in @mask, preferring those that
6137
* aren't marked nohz_full

include/linux/resctrl.h

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <linux/kernel.h>
77
#include <linux/list.h>
88
#include <linux/pid.h>
9+
#include <linux/resctrl_types.h>
910

1011
/* CLOSID, RMID value used by the default control group */
1112
#define RESCTRL_RESERVED_CLOSID 0
@@ -37,28 +38,8 @@ enum resctrl_conf_type {
3738
CDP_DATA,
3839
};
3940

40-
enum resctrl_res_level {
41-
RDT_RESOURCE_L3,
42-
RDT_RESOURCE_L2,
43-
RDT_RESOURCE_MBA,
44-
RDT_RESOURCE_SMBA,
45-
46-
/* Must be the last */
47-
RDT_NUM_RESOURCES,
48-
};
49-
5041
#define CDP_NUM_TYPES (CDP_DATA + 1)
5142

52-
/*
53-
* Event IDs, the values match those used to program IA32_QM_EVTSEL before
54-
* reading IA32_QM_CTR on RDT systems.
55-
*/
56-
enum resctrl_event_id {
57-
QOS_L3_OCCUP_EVENT_ID = 0x01,
58-
QOS_L3_MBM_TOTAL_EVENT_ID = 0x02,
59-
QOS_L3_MBM_LOCAL_EVENT_ID = 0x03,
60-
};
61-
6243
/**
6344
* struct resctrl_staged_config - parsed configuration to be applied
6445
* @new_ctrl: new ctrl value to be loaded

include/linux/resctrl_types.h

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* Copyright (C) 2025 Arm Ltd.
4+
* Based on arch/x86/kernel/cpu/resctrl/internal.h
5+
*/
6+
7+
#ifndef __LINUX_RESCTRL_TYPES_H
8+
#define __LINUX_RESCTRL_TYPES_H
9+
10+
/* Reads to Local DRAM Memory */
11+
#define READS_TO_LOCAL_MEM BIT(0)
12+
13+
/* Reads to Remote DRAM Memory */
14+
#define READS_TO_REMOTE_MEM BIT(1)
15+
16+
/* Non-Temporal Writes to Local Memory */
17+
#define NON_TEMP_WRITE_TO_LOCAL_MEM BIT(2)
18+
19+
/* Non-Temporal Writes to Remote Memory */
20+
#define NON_TEMP_WRITE_TO_REMOTE_MEM BIT(3)
21+
22+
/* Reads to Local Memory the system identifies as "Slow Memory" */
23+
#define READS_TO_LOCAL_S_MEM BIT(4)
24+
25+
/* Reads to Remote Memory the system identifies as "Slow Memory" */
26+
#define READS_TO_REMOTE_S_MEM BIT(5)
27+
28+
/* Dirty Victims to All Types of Memory */
29+
#define DIRTY_VICTIMS_TO_ALL_MEM BIT(6)
30+
31+
/* Max event bits supported */
32+
#define MAX_EVT_CONFIG_BITS GENMASK(6, 0)
33+
34+
enum resctrl_res_level {
35+
RDT_RESOURCE_L3,
36+
RDT_RESOURCE_L2,
37+
RDT_RESOURCE_MBA,
38+
RDT_RESOURCE_SMBA,
39+
40+
/* Must be the last */
41+
RDT_NUM_RESOURCES,
42+
};
43+
44+
/*
45+
* Event IDs, the values match those used to program IA32_QM_EVTSEL before
46+
* reading IA32_QM_CTR on RDT systems.
47+
*/
48+
enum resctrl_event_id {
49+
QOS_L3_OCCUP_EVENT_ID = 0x01,
50+
QOS_L3_MBM_TOTAL_EVENT_ID = 0x02,
51+
QOS_L3_MBM_LOCAL_EVENT_ID = 0x03,
52+
};
53+
54+
#endif /* __LINUX_RESCTRL_TYPES_H */

0 commit comments

Comments
 (0)