Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fs/resctrl: Introduce mbm_assign_on_mkdir to enable assignments on mkdir

The "mbm_event" counter assignment mode allows users to assign a hardware
counter to an RMID, event pair and monitor the bandwidth as long as it is
assigned.

Introduce a user-configurable option that determines if a counter will
automatically be assigned to an RMID, event pair when its associated
monitor group is created via mkdir. Accessible when "mbm_event" counter
assignment mode is enabled.

Suggested-by: Peter Newman <peternewman@google.com>
Signed-off-by: Babu Moger <babu.moger@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Link: https://lore.kernel.org/cover.1757108044.git.babu.moger@amd.com

authored by

Babu Moger and committed by
Borislav Petkov (AMD)
ac1df9bb f9ae5913

+89
+20
Documentation/filesystems/resctrl.rst
··· 355 355 # cat /sys/fs/resctrl/info/L3_MON/event_configs/mbm_total_bytes/event_filter 356 356 local_reads,local_non_temporal_writes 357 357 358 + "mbm_assign_on_mkdir": 359 + Exists when "mbm_event" counter assignment mode is supported. Accessible 360 + only when "mbm_event" counter assignment mode is enabled. 361 + 362 + Determines if a counter will automatically be assigned to an RMID, MBM event 363 + pair when its associated monitor group is created via mkdir. Enabled by default 364 + on boot, also when switched from "default" mode to "mbm_event" counter assignment 365 + mode. Users can disable this capability by writing to the interface. 366 + 367 + "0": 368 + Auto assignment is disabled. 369 + "1": 370 + Auto assignment is enabled. 371 + 372 + Example:: 373 + 374 + # echo 0 > /sys/fs/resctrl/info/L3_MON/mbm_assign_on_mkdir 375 + # cat /sys/fs/resctrl/info/L3_MON/mbm_assign_on_mkdir 376 + 0 377 + 358 378 "max_threshold_occupancy": 359 379 Read/write file provides the largest value (in 360 380 bytes) at which a previously used LLC_occupancy
+6
fs/resctrl/internal.h
··· 410 410 ssize_t event_filter_write(struct kernfs_open_file *of, char *buf, size_t nbytes, 411 411 loff_t off); 412 412 413 + int resctrl_mbm_assign_on_mkdir_show(struct kernfs_open_file *of, 414 + struct seq_file *s, void *v); 415 + 416 + ssize_t resctrl_mbm_assign_on_mkdir_write(struct kernfs_open_file *of, char *buf, 417 + size_t nbytes, loff_t off); 418 + 413 419 #ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK 414 420 int rdtgroup_locksetup_enter(struct rdtgroup *rdtgrp); 415 421
+53
fs/resctrl/monitor.c
··· 1027 1027 return ret; 1028 1028 } 1029 1029 1030 + int resctrl_mbm_assign_on_mkdir_show(struct kernfs_open_file *of, struct seq_file *s, 1031 + void *v) 1032 + { 1033 + struct rdt_resource *r = rdt_kn_parent_priv(of->kn); 1034 + int ret = 0; 1035 + 1036 + mutex_lock(&rdtgroup_mutex); 1037 + rdt_last_cmd_clear(); 1038 + 1039 + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) { 1040 + rdt_last_cmd_puts("mbm_event counter assignment mode is not enabled\n"); 1041 + ret = -EINVAL; 1042 + goto out_unlock; 1043 + } 1044 + 1045 + seq_printf(s, "%u\n", r->mon.mbm_assign_on_mkdir); 1046 + 1047 + out_unlock: 1048 + mutex_unlock(&rdtgroup_mutex); 1049 + 1050 + return ret; 1051 + } 1052 + 1053 + ssize_t resctrl_mbm_assign_on_mkdir_write(struct kernfs_open_file *of, char *buf, 1054 + size_t nbytes, loff_t off) 1055 + { 1056 + struct rdt_resource *r = rdt_kn_parent_priv(of->kn); 1057 + bool value; 1058 + int ret; 1059 + 1060 + ret = kstrtobool(buf, &value); 1061 + if (ret) 1062 + return ret; 1063 + 1064 + mutex_lock(&rdtgroup_mutex); 1065 + rdt_last_cmd_clear(); 1066 + 1067 + if (!resctrl_arch_mbm_cntr_assign_enabled(r)) { 1068 + rdt_last_cmd_puts("mbm_event counter assignment mode is not enabled\n"); 1069 + ret = -EINVAL; 1070 + goto out_unlock; 1071 + } 1072 + 1073 + r->mon.mbm_assign_on_mkdir = value; 1074 + 1075 + out_unlock: 1076 + mutex_unlock(&rdtgroup_mutex); 1077 + 1078 + return ret ?: nbytes; 1079 + } 1080 + 1030 1081 /* 1031 1082 * rdtgroup_assign_cntr() - Assign/unassign the counter ID for the event, RMID 1032 1083 * pair in the domain. ··· 1508 1457 resctrl_file_fflags_init("available_mbm_cntrs", 1509 1458 RFTYPE_MON_INFO | RFTYPE_RES_CACHE); 1510 1459 resctrl_file_fflags_init("event_filter", RFTYPE_ASSIGN_CONFIG); 1460 + resctrl_file_fflags_init("mbm_assign_on_mkdir", RFTYPE_MON_INFO | 1461 + RFTYPE_RES_CACHE); 1511 1462 } 1512 1463 1513 1464 return 0;
+7
fs/resctrl/rdtgroup.c
··· 1809 1809 .fflags = RFTYPE_TOP_INFO, 1810 1810 }, 1811 1811 { 1812 + .name = "mbm_assign_on_mkdir", 1813 + .mode = 0644, 1814 + .kf_ops = &rdtgroup_kf_single_ops, 1815 + .seq_show = resctrl_mbm_assign_on_mkdir_show, 1816 + .write = resctrl_mbm_assign_on_mkdir_write, 1817 + }, 1818 + { 1812 1819 .name = "num_closids", 1813 1820 .mode = 0444, 1814 1821 .kf_ops = &rdtgroup_kf_single_ops,
+3
include/linux/resctrl.h
··· 277 277 * monitoring events can be configured. 278 278 * @num_mbm_cntrs: Number of assignable counters. 279 279 * @mbm_cntr_assignable:Is system capable of supporting counter assignment? 280 + * @mbm_assign_on_mkdir:True if counters should automatically be assigned to MBM 281 + * events of monitor groups created via mkdir. 280 282 */ 281 283 struct resctrl_mon { 282 284 int num_rmid; 283 285 unsigned int mbm_cfg_mask; 284 286 int num_mbm_cntrs; 285 287 bool mbm_cntr_assignable; 288 + bool mbm_assign_on_mkdir; 286 289 }; 287 290 288 291 /**