Skip to content

Commit cb07d71

Browse files
babumogerbp3tk0v
authored andcommitted
x86/resctrl: Introduce "-o debug" mount option
Add "-o debug" option to mount resctrl filesystem in debug mode. When in debug mode resctrl displays files that have the new RFTYPE_DEBUG flag to help resctrl debugging. Signed-off-by: Babu Moger <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Peter Newman <[email protected]> Reviewed-by: Tan Shaopeng <[email protected]> Reviewed-by: Fenghua Yu <[email protected]> Reviewed-by: Reinette Chatre <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]> Tested-by: Peter Newman <[email protected]> Tested-by: Tan Shaopeng <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d27567a commit cb07d71

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

Documentation/arch/x86/resctrl.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ about the feature from resctrl's info directory.
3535

3636
To use the feature mount the file system::
3737

38-
# mount -t resctrl resctrl [-o cdp[,cdpl2][,mba_MBps]] /sys/fs/resctrl
38+
# mount -t resctrl resctrl [-o cdp[,cdpl2][,mba_MBps][,debug]] /sys/fs/resctrl
3939

4040
mount options are:
4141

@@ -46,6 +46,9 @@ mount options are:
4646
"mba_MBps":
4747
Enable the MBA Software Controller(mba_sc) to specify MBA
4848
bandwidth in MBps
49+
"debug":
50+
Make debug files accessible. Available debug files are annotated with
51+
"Available only with debug option".
4952

5053
L2 and L3 CDP are controlled separately.
5154

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ struct rdt_fs_context {
5959
bool enable_cdpl2;
6060
bool enable_cdpl3;
6161
bool enable_mba_mbps;
62+
bool enable_debug;
6263
};
6364

6465
static inline struct rdt_fs_context *rdt_fc2context(struct fs_context *fc)
@@ -248,6 +249,7 @@ struct rdtgroup {
248249
#define RFTYPE_TOP BIT(6)
249250
#define RFTYPE_RES_CACHE BIT(8)
250251
#define RFTYPE_RES_MB BIT(9)
252+
#define RFTYPE_DEBUG BIT(10)
251253
#define RFTYPE_CTRL_INFO (RFTYPE_INFO | RFTYPE_CTRL)
252254
#define RFTYPE_MON_INFO (RFTYPE_INFO | RFTYPE_MON)
253255
#define RFTYPE_TOP_INFO (RFTYPE_INFO | RFTYPE_TOP)

arch/x86/kernel/cpu/resctrl/rdtgroup.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ static void rdtgroup_destroy_root(void);
5959

6060
struct dentry *debugfs_resctrl;
6161

62+
static bool resctrl_debug;
63+
6264
void rdt_last_cmd_clear(void)
6365
{
6466
lockdep_assert_held(&rdtgroup_mutex);
@@ -1892,6 +1894,9 @@ static int rdtgroup_add_files(struct kernfs_node *kn, unsigned long fflags)
18921894

18931895
lockdep_assert_held(&rdtgroup_mutex);
18941896

1897+
if (resctrl_debug)
1898+
fflags |= RFTYPE_DEBUG;
1899+
18951900
for (rft = rfts; rft < rfts + len; rft++) {
18961901
if (rft->fflags && ((fflags & rft->fflags) == rft->fflags)) {
18971902
ret = rdtgroup_add_file(kn, rft);
@@ -2395,6 +2400,8 @@ static void rdt_disable_ctx(void)
23952400
resctrl_arch_set_cdp_enabled(RDT_RESOURCE_L3, false);
23962401
resctrl_arch_set_cdp_enabled(RDT_RESOURCE_L2, false);
23972402
set_mba_sc(false);
2403+
2404+
resctrl_debug = false;
23982405
}
23992406

24002407
static int rdt_enable_ctx(struct rdt_fs_context *ctx)
@@ -2419,6 +2426,9 @@ static int rdt_enable_ctx(struct rdt_fs_context *ctx)
24192426
goto out_cdpl3;
24202427
}
24212428

2429+
if (ctx->enable_debug)
2430+
resctrl_debug = true;
2431+
24222432
return 0;
24232433

24242434
out_cdpl3:
@@ -2623,13 +2633,15 @@ enum rdt_param {
26232633
Opt_cdp,
26242634
Opt_cdpl2,
26252635
Opt_mba_mbps,
2636+
Opt_debug,
26262637
nr__rdt_params
26272638
};
26282639

26292640
static const struct fs_parameter_spec rdt_fs_parameters[] = {
26302641
fsparam_flag("cdp", Opt_cdp),
26312642
fsparam_flag("cdpl2", Opt_cdpl2),
26322643
fsparam_flag("mba_MBps", Opt_mba_mbps),
2644+
fsparam_flag("debug", Opt_debug),
26332645
{}
26342646
};
26352647

@@ -2655,6 +2667,9 @@ static int rdt_parse_param(struct fs_context *fc, struct fs_parameter *param)
26552667
return -EINVAL;
26562668
ctx->enable_mba_mbps = true;
26572669
return 0;
2670+
case Opt_debug:
2671+
ctx->enable_debug = true;
2672+
return 0;
26582673
}
26592674

26602675
return -EINVAL;
@@ -3723,6 +3738,9 @@ static int rdtgroup_show_options(struct seq_file *seq, struct kernfs_root *kf)
37233738
if (is_mba_sc(&rdt_resources_all[RDT_RESOURCE_MBA].r_resctrl))
37243739
seq_puts(seq, ",mba_MBps");
37253740

3741+
if (resctrl_debug)
3742+
seq_puts(seq, ",debug");
3743+
37263744
return 0;
37273745
}
37283746

0 commit comments

Comments
 (0)