Skip to content

Commit 19c635a

Browse files
Vikas ShivappaKAGA-KOKO
authored andcommitted
x86/intel_rdt/mba_sc: Enable/disable MBA software controller
Currently user does memory bandwidth allocation(MBA) by specifying the bandwidth in percentage via the resctrl schemata file: "/sys/fs/resctrl/schemata" Add a new mount option "mba_MBps" to enable the user to specify MBA in MBps: $mount -t resctrl resctrl [-o cdp[,cdpl2][mba_MBps]] /sys/fs/resctrl Signed-off-by: Vikas Shivappa <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected]
1 parent d6c64a4 commit 19c635a

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

arch/x86/kernel/cpu/intel_rdt.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,14 @@ static inline void cache_alloc_hsw_probe(void)
230230
rdt_alloc_capable = true;
231231
}
232232

233+
bool is_mba_sc(struct rdt_resource *r)
234+
{
235+
if (!r)
236+
return rdt_resources_all[RDT_RESOURCE_MBA].membw.mba_sc;
237+
238+
return r->membw.mba_sc;
239+
}
240+
233241
/*
234242
* rdt_get_mb_table() - get a mapping of bandwidth(b/w) percentage values
235243
* exposed to user interface and the h/w understandable delay values.

arch/x86/kernel/cpu/intel_rdt.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,15 @@ struct rdt_cache {
259259
* @min_bw: Minimum memory bandwidth percentage user can request
260260
* @bw_gran: Granularity at which the memory bandwidth is allocated
261261
* @delay_linear: True if memory B/W delay is in linear scale
262+
* @mba_sc: True if MBA software controller(mba_sc) is enabled
262263
* @mb_map: Mapping of memory B/W percentage to memory B/W delay
263264
*/
264265
struct rdt_membw {
265266
u32 max_delay;
266267
u32 min_bw;
267268
u32 bw_gran;
268269
u32 delay_linear;
270+
bool mba_sc;
269271
u32 *mb_map;
270272
};
271273

@@ -445,6 +447,7 @@ void mon_event_read(struct rmid_read *rr, struct rdt_domain *d,
445447
void mbm_setup_overflow_handler(struct rdt_domain *dom,
446448
unsigned long delay_ms);
447449
void mbm_handle_overflow(struct work_struct *work);
450+
bool is_mba_sc(struct rdt_resource *r);
448451
void cqm_setup_limbo_handler(struct rdt_domain *dom, unsigned long delay_ms);
449452
void cqm_handle_limbo(struct work_struct *work);
450453
bool has_busy_rmid(struct rdt_resource *r, struct rdt_domain *d);

arch/x86/kernel/cpu/intel_rdt_rdtgroup.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,11 @@ static void l2_qos_cfg_update(void *arg)
10051005
wrmsrl(IA32_L2_QOS_CFG, *enable ? L2_QOS_CDP_ENABLE : 0ULL);
10061006
}
10071007

1008+
static inline bool is_mba_linear(void)
1009+
{
1010+
return rdt_resources_all[RDT_RESOURCE_MBA].membw.delay_linear;
1011+
}
1012+
10081013
static int set_cache_qos_cfg(int level, bool enable)
10091014
{
10101015
void (*update)(void *arg);
@@ -1041,6 +1046,25 @@ static int set_cache_qos_cfg(int level, bool enable)
10411046
return 0;
10421047
}
10431048

1049+
/*
1050+
* Enable or disable the MBA software controller
1051+
* which helps user specify bandwidth in MBps.
1052+
* MBA software controller is supported only if
1053+
* MBM is supported and MBA is in linear scale.
1054+
*/
1055+
static int set_mba_sc(bool mba_sc)
1056+
{
1057+
struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_MBA];
1058+
1059+
if (!is_mbm_enabled() || !is_mba_linear() ||
1060+
mba_sc == is_mba_sc(r))
1061+
return -EINVAL;
1062+
1063+
r->membw.mba_sc = mba_sc;
1064+
1065+
return 0;
1066+
}
1067+
10441068
static int cdp_enable(int level, int data_type, int code_type)
10451069
{
10461070
struct rdt_resource *r_ldata = &rdt_resources_all[data_type];
@@ -1123,6 +1147,10 @@ static int parse_rdtgroupfs_options(char *data)
11231147
ret = cdpl2_enable();
11241148
if (ret)
11251149
goto out;
1150+
} else if (!strcmp(token, "mba_MBps")) {
1151+
ret = set_mba_sc(true);
1152+
if (ret)
1153+
goto out;
11261154
} else {
11271155
ret = -EINVAL;
11281156
goto out;
@@ -1445,6 +1473,8 @@ static void rdt_kill_sb(struct super_block *sb)
14451473
cpus_read_lock();
14461474
mutex_lock(&rdtgroup_mutex);
14471475

1476+
set_mba_sc(false);
1477+
14481478
/*Put everything back to default values. */
14491479
for_each_alloc_enabled_rdt_resource(r)
14501480
reset_all_ctrls(r);

0 commit comments

Comments
 (0)