Skip to content

Commit 1bd2a63

Browse files
Vikas ShivappaKAGA-KOKO
authored andcommitted
x86/intel_rdt/mba_sc: Add initialization support
When MBA software controller is enabled, a per domain storage is required for user specified bandwidth in "MBps" and the "percentage" values which are programmed into the IA32_MBA_THRTL_MSR. Add support for these data structures and initialization. The MBA percentage values have a default max value of 100 but however the max value in MBps is not available from the hardware so it's set to U32_MAX. This simply says that the control group can use all bandwidth by default but does not say what is the actual max bandwidth available. The actual bandwidth that is available may depend on lot of factors like QPI link, number of memory channels, memory channel frequency, its width and memory speed, how many channels are configured and also if memory interleaving is enabled. So there is no way to determine the maximum at runtime reliably. 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 19c635a commit 1bd2a63

File tree

3 files changed

+33
-10
lines changed

3 files changed

+33
-10
lines changed

arch/x86/kernel/cpu/intel_rdt.c

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
#define MAX_MBA_BW 100u
3737
#define MBA_IS_LINEAR 0x4
38+
#define MBA_MAX_MBPS U32_MAX
3839

3940
/* Mutex to protect rdtgroup access. */
4041
DEFINE_MUTEX(rdtgroup_mutex);
@@ -439,25 +440,40 @@ struct rdt_domain *rdt_find_domain(struct rdt_resource *r, int id,
439440
return NULL;
440441
}
441442

443+
void setup_default_ctrlval(struct rdt_resource *r, u32 *dc, u32 *dm)
444+
{
445+
int i;
446+
447+
/*
448+
* Initialize the Control MSRs to having no control.
449+
* For Cache Allocation: Set all bits in cbm
450+
* For Memory Allocation: Set b/w requested to 100%
451+
* and the bandwidth in MBps to U32_MAX
452+
*/
453+
for (i = 0; i < r->num_closid; i++, dc++, dm++) {
454+
*dc = r->default_ctrl;
455+
*dm = MBA_MAX_MBPS;
456+
}
457+
}
458+
442459
static int domain_setup_ctrlval(struct rdt_resource *r, struct rdt_domain *d)
443460
{
444461
struct msr_param m;
445-
u32 *dc;
446-
int i;
462+
u32 *dc, *dm;
447463

448464
dc = kmalloc_array(r->num_closid, sizeof(*d->ctrl_val), GFP_KERNEL);
449465
if (!dc)
450466
return -ENOMEM;
451467

452-
d->ctrl_val = dc;
468+
dm = kmalloc_array(r->num_closid, sizeof(*d->mbps_val), GFP_KERNEL);
469+
if (!dm) {
470+
kfree(dc);
471+
return -ENOMEM;
472+
}
453473

454-
/*
455-
* Initialize the Control MSRs to having no control.
456-
* For Cache Allocation: Set all bits in cbm
457-
* For Memory Allocation: Set b/w requested to 100
458-
*/
459-
for (i = 0; i < r->num_closid; i++, dc++)
460-
*dc = r->default_ctrl;
474+
d->ctrl_val = dc;
475+
d->mbps_val = dm;
476+
setup_default_ctrlval(r, dc, dm);
461477

462478
m.low = 0;
463479
m.high = r->num_closid;
@@ -596,6 +612,7 @@ static void domain_remove_cpu(int cpu, struct rdt_resource *r)
596612
}
597613

598614
kfree(d->ctrl_val);
615+
kfree(d->mbps_val);
599616
kfree(d->rmid_busy_llc);
600617
kfree(d->mbm_total);
601618
kfree(d->mbm_local);

arch/x86/kernel/cpu/intel_rdt.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ struct mbm_state {
202202
* @cqm_work_cpu:
203203
* worker cpu for CQM h/w counters
204204
* @ctrl_val: array of cache or mem ctrl values (indexed by CLOSID)
205+
* @mbps_val: When mba_sc is enabled, this holds the bandwidth in MBps
205206
* @new_ctrl: new ctrl value to be loaded
206207
* @have_new_ctrl: did user provide new_ctrl for this domain
207208
*/
@@ -217,6 +218,7 @@ struct rdt_domain {
217218
int mbm_work_cpu;
218219
int cqm_work_cpu;
219220
u32 *ctrl_val;
221+
u32 *mbps_val;
220222
u32 new_ctrl;
221223
bool have_new_ctrl;
222224
};
@@ -448,6 +450,7 @@ void mbm_setup_overflow_handler(struct rdt_domain *dom,
448450
unsigned long delay_ms);
449451
void mbm_handle_overflow(struct work_struct *work);
450452
bool is_mba_sc(struct rdt_resource *r);
453+
void setup_default_ctrlval(struct rdt_resource *r, u32 *dc, u32 *dm);
451454
void cqm_setup_limbo_handler(struct rdt_domain *dom, unsigned long delay_ms);
452455
void cqm_handle_limbo(struct work_struct *work);
453456
bool has_busy_rmid(struct rdt_resource *r, struct rdt_domain *d);

arch/x86/kernel/cpu/intel_rdt_rdtgroup.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,12 +1055,15 @@ static int set_cache_qos_cfg(int level, bool enable)
10551055
static int set_mba_sc(bool mba_sc)
10561056
{
10571057
struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_MBA];
1058+
struct rdt_domain *d;
10581059

10591060
if (!is_mbm_enabled() || !is_mba_linear() ||
10601061
mba_sc == is_mba_sc(r))
10611062
return -EINVAL;
10621063

10631064
r->membw.mba_sc = mba_sc;
1065+
list_for_each_entry(d, &r->domains, list)
1066+
setup_default_ctrlval(r, d->ctrl_val, d->mbps_val);
10641067

10651068
return 0;
10661069
}

0 commit comments

Comments
 (0)