Skip to content

Commit 1d9807f

Browse files
aeglKAGA-KOKO
authored andcommitted
x86/intel_rdt: Add command line options for resource director technology
Command line options allow us to ignore features that we don't want. Also we can re-enable options that have been disabled on a platform (so long as the underlying h/w actually supports the option). [ tglx: Marked the option array __initdata and the helper function __init ] Signed-off-by: Tony Luck <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: Fenghua" <[email protected]> Cc: Ravi V" <[email protected]> Cc: "Peter Zijlstra" <[email protected]> Cc: "Stephane Eranian" <[email protected]> Cc: "Andi Kleen" <[email protected]> Cc: "David Carrillo-Cisneros" <[email protected]> Cc: Vikas Shivappa <[email protected]> Link: http://lkml.kernel.org/r/0c37b0d4dbc30977a3c1cee08b66420f83662694.1503512900.git.tony.luck@intel.com
1 parent 0576113 commit 1d9807f

File tree

3 files changed

+95
-8
lines changed

3 files changed

+95
-8
lines changed

Documentation/admin-guide/kernel-parameters.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ parameter is applicable::
138138
PPT Parallel port support is enabled.
139139
PS2 Appropriate PS/2 support is enabled.
140140
RAM RAM disk support is enabled.
141+
RDT Intel Resource Director Technology.
141142
S390 S390 architecture is enabled.
142143
SCSI Appropriate SCSI support is enabled.
143144
A lot of drivers have their options described inside

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3598,6 +3598,12 @@
35983598
Run specified binary instead of /init from the ramdisk,
35993599
used for early userspace startup. See initrd.
36003600

3601+
rdt= [HW,X86,RDT]
3602+
Turn on/off individual RDT features. List is:
3603+
cmt, mbmtotal, mbmlocal, l3cat, l3cdp, l2cat, mba.
3604+
E.g. to turn on cmt and turn off mba use:
3605+
rdt=cmt,!mba
3606+
36013607
reboot= [KNL]
36023608
Format (x86 or x86_64):
36033609
[w[arm] | c[old] | h[ard] | s[oft] | g[pio]] \

arch/x86/kernel/cpu/intel_rdt.c

Lines changed: 88 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,85 @@ static __init void rdt_init_padding(void)
637637
}
638638
}
639639

640+
enum {
641+
RDT_FLAG_CMT,
642+
RDT_FLAG_MBM_TOTAL,
643+
RDT_FLAG_MBM_LOCAL,
644+
RDT_FLAG_L3_CAT,
645+
RDT_FLAG_L3_CDP,
646+
RDT_FLAG_L2_CAT,
647+
RDT_FLAG_MBA,
648+
};
649+
650+
#define RDT_OPT(idx, n, f) \
651+
[idx] = { \
652+
.name = n, \
653+
.flag = f \
654+
}
655+
656+
struct rdt_options {
657+
char *name;
658+
int flag;
659+
bool force_off, force_on;
660+
};
661+
662+
static struct rdt_options rdt_options[] __initdata = {
663+
RDT_OPT(RDT_FLAG_CMT, "cmt", X86_FEATURE_CQM_OCCUP_LLC),
664+
RDT_OPT(RDT_FLAG_MBM_TOTAL, "mbmtotal", X86_FEATURE_CQM_MBM_TOTAL),
665+
RDT_OPT(RDT_FLAG_MBM_LOCAL, "mbmlocal", X86_FEATURE_CQM_MBM_LOCAL),
666+
RDT_OPT(RDT_FLAG_L3_CAT, "l3cat", X86_FEATURE_CAT_L3),
667+
RDT_OPT(RDT_FLAG_L3_CDP, "l3cdp", X86_FEATURE_CDP_L3),
668+
RDT_OPT(RDT_FLAG_L2_CAT, "l2cat", X86_FEATURE_CAT_L2),
669+
RDT_OPT(RDT_FLAG_MBA, "mba", X86_FEATURE_MBA),
670+
};
671+
#define NUM_RDT_OPTIONS ARRAY_SIZE(rdt_options)
672+
673+
static int __init set_rdt_options(char *str)
674+
{
675+
struct rdt_options *o;
676+
bool force_off;
677+
char *tok;
678+
679+
if (*str == '=')
680+
str++;
681+
while ((tok = strsep(&str, ",")) != NULL) {
682+
force_off = *tok == '!';
683+
if (force_off)
684+
tok++;
685+
for (o = rdt_options; o < &rdt_options[NUM_RDT_OPTIONS]; o++) {
686+
if (strcmp(tok, o->name) == 0) {
687+
if (force_off)
688+
o->force_off = true;
689+
else
690+
o->force_on = true;
691+
break;
692+
}
693+
}
694+
}
695+
return 1;
696+
}
697+
__setup("rdt", set_rdt_options);
698+
699+
static bool __init rdt_cpu_has(int flag)
700+
{
701+
bool ret = boot_cpu_has(flag);
702+
struct rdt_options *o;
703+
704+
if (!ret)
705+
return ret;
706+
707+
for (o = rdt_options; o < &rdt_options[NUM_RDT_OPTIONS]; o++) {
708+
if (flag == o->flag) {
709+
if (o->force_off)
710+
ret = false;
711+
if (o->force_on)
712+
ret = true;
713+
break;
714+
}
715+
}
716+
return ret;
717+
}
718+
640719
static __init bool get_rdt_alloc_resources(void)
641720
{
642721
bool ret = false;
@@ -647,21 +726,21 @@ static __init bool get_rdt_alloc_resources(void)
647726
if (!boot_cpu_has(X86_FEATURE_RDT_A))
648727
return false;
649728

650-
if (boot_cpu_has(X86_FEATURE_CAT_L3)) {
729+
if (rdt_cpu_has(X86_FEATURE_CAT_L3)) {
651730
rdt_get_cache_alloc_cfg(1, &rdt_resources_all[RDT_RESOURCE_L3]);
652-
if (boot_cpu_has(X86_FEATURE_CDP_L3)) {
731+
if (rdt_cpu_has(X86_FEATURE_CDP_L3)) {
653732
rdt_get_cdp_l3_config(RDT_RESOURCE_L3DATA);
654733
rdt_get_cdp_l3_config(RDT_RESOURCE_L3CODE);
655734
}
656735
ret = true;
657736
}
658-
if (boot_cpu_has(X86_FEATURE_CAT_L2)) {
737+
if (rdt_cpu_has(X86_FEATURE_CAT_L2)) {
659738
/* CPUID 0x10.2 fields are same format at 0x10.1 */
660739
rdt_get_cache_alloc_cfg(2, &rdt_resources_all[RDT_RESOURCE_L2]);
661740
ret = true;
662741
}
663742

664-
if (boot_cpu_has(X86_FEATURE_MBA)) {
743+
if (rdt_cpu_has(X86_FEATURE_MBA)) {
665744
if (rdt_get_mem_config(&rdt_resources_all[RDT_RESOURCE_MBA]))
666745
ret = true;
667746
}
@@ -670,11 +749,11 @@ static __init bool get_rdt_alloc_resources(void)
670749

671750
static __init bool get_rdt_mon_resources(void)
672751
{
673-
if (boot_cpu_has(X86_FEATURE_CQM_OCCUP_LLC))
752+
if (rdt_cpu_has(X86_FEATURE_CQM_OCCUP_LLC))
674753
rdt_mon_features |= (1 << QOS_L3_OCCUP_EVENT_ID);
675-
if (boot_cpu_has(X86_FEATURE_CQM_MBM_TOTAL))
754+
if (rdt_cpu_has(X86_FEATURE_CQM_MBM_TOTAL))
676755
rdt_mon_features |= (1 << QOS_L3_MBM_TOTAL_EVENT_ID);
677-
if (boot_cpu_has(X86_FEATURE_CQM_MBM_LOCAL))
756+
if (rdt_cpu_has(X86_FEATURE_CQM_MBM_LOCAL))
678757
rdt_mon_features |= (1 << QOS_L3_MBM_LOCAL_EVENT_ID);
679758

680759
if (!rdt_mon_features)
@@ -687,7 +766,8 @@ static __init void rdt_quirks(void)
687766
{
688767
switch (boot_cpu_data.x86_model) {
689768
case INTEL_FAM6_HASWELL_X:
690-
cache_alloc_hsw_probe();
769+
if (!rdt_options[RDT_FLAG_L3_CAT].force_off)
770+
cache_alloc_hsw_probe();
691771
break;
692772
}
693773
}

0 commit comments

Comments
 (0)