#define pr_fmt(fmt) …
#include <linux/cpu.h>
#include <linux/debugfs.h>
#include <linux/fs.h>
#include <linux/fs_parser.h>
#include <linux/sysfs.h>
#include <linux/kernfs.h>
#include <linux/seq_buf.h>
#include <linux/seq_file.h>
#include <linux/sched/signal.h>
#include <linux/sched/task.h>
#include <linux/slab.h>
#include <linux/task_work.h>
#include <linux/user_namespace.h>
#include <uapi/linux/magic.h>
#include <asm/resctrl.h>
#include "internal.h"
DEFINE_STATIC_KEY_FALSE(rdt_enable_key);
DEFINE_STATIC_KEY_FALSE(rdt_mon_enable_key);
DEFINE_STATIC_KEY_FALSE(rdt_alloc_enable_key);
DEFINE_MUTEX(…) …;
static struct kernfs_root *rdt_root;
struct rdtgroup rdtgroup_default;
LIST_HEAD(…);
LIST_HEAD(…);
bool resctrl_mounted;
static struct kernfs_node *kn_info;
static struct kernfs_node *kn_mongrp;
static struct kernfs_node *kn_mondata;
static struct seq_buf last_cmd_status;
static char last_cmd_status_buf[512];
static int rdtgroup_setup_root(struct rdt_fs_context *ctx);
static void rdtgroup_destroy_root(void);
struct dentry *debugfs_resctrl;
static bool resctrl_debug;
void rdt_last_cmd_clear(void)
{ … }
void rdt_last_cmd_puts(const char *s)
{ … }
void rdt_last_cmd_printf(const char *fmt, ...)
{ … }
void rdt_staged_configs_clear(void)
{ … }
static unsigned long closid_free_map;
static int closid_free_map_len;
int closids_supported(void)
{ … }
static void closid_init(void)
{ … }
static int closid_alloc(void)
{ … }
void closid_free(int closid)
{ … }
bool closid_allocated(unsigned int closid)
{ … }
enum rdtgrp_mode rdtgroup_mode_by_closid(int closid)
{ … }
static const char * const rdt_mode_str[] = …;
static const char *rdtgroup_mode_str(enum rdtgrp_mode mode)
{ … }
static int rdtgroup_kn_set_ugid(struct kernfs_node *kn)
{ … }
static int rdtgroup_add_file(struct kernfs_node *parent_kn, struct rftype *rft)
{ … }
static int rdtgroup_seqfile_show(struct seq_file *m, void *arg)
{ … }
static ssize_t rdtgroup_file_write(struct kernfs_open_file *of, char *buf,
size_t nbytes, loff_t off)
{ … }
static const struct kernfs_ops rdtgroup_kf_single_ops = …;
static const struct kernfs_ops kf_mondata_ops = …;
static bool is_cpu_list(struct kernfs_open_file *of)
{ … }
static int rdtgroup_cpus_show(struct kernfs_open_file *of,
struct seq_file *s, void *v)
{ … }
static void update_cpu_closid_rmid(void *info)
{ … }
static void
update_closid_rmid(const struct cpumask *cpu_mask, struct rdtgroup *r)
{ … }
static int cpus_mon_write(struct rdtgroup *rdtgrp, cpumask_var_t newmask,
cpumask_var_t tmpmask)
{ … }
static void cpumask_rdtgrp_clear(struct rdtgroup *r, struct cpumask *m)
{ … }
static int cpus_ctrl_write(struct rdtgroup *rdtgrp, cpumask_var_t newmask,
cpumask_var_t tmpmask, cpumask_var_t tmpmask1)
{ … }
static ssize_t rdtgroup_cpus_write(struct kernfs_open_file *of,
char *buf, size_t nbytes, loff_t off)
{ … }
static void rdtgroup_remove(struct rdtgroup *rdtgrp)
{ … }
static void _update_task_closid_rmid(void *task)
{ … }
static void update_task_closid_rmid(struct task_struct *t)
{ … }
static bool task_in_rdtgroup(struct task_struct *tsk, struct rdtgroup *rdtgrp)
{ … }
static int __rdtgroup_move_task(struct task_struct *tsk,
struct rdtgroup *rdtgrp)
{ … }
static bool is_closid_match(struct task_struct *t, struct rdtgroup *r)
{ … }
static bool is_rmid_match(struct task_struct *t, struct rdtgroup *r)
{ … }
int rdtgroup_tasks_assigned(struct rdtgroup *r)
{ … }
static int rdtgroup_task_write_permission(struct task_struct *task,
struct kernfs_open_file *of)
{ … }
static int rdtgroup_move_task(pid_t pid, struct rdtgroup *rdtgrp,
struct kernfs_open_file *of)
{ … }
static ssize_t rdtgroup_tasks_write(struct kernfs_open_file *of,
char *buf, size_t nbytes, loff_t off)
{ … }
static void show_rdt_tasks(struct rdtgroup *r, struct seq_file *s)
{ … }
static int rdtgroup_tasks_show(struct kernfs_open_file *of,
struct seq_file *s, void *v)
{ … }
static int rdtgroup_closid_show(struct kernfs_open_file *of,
struct seq_file *s, void *v)
{ … }
static int rdtgroup_rmid_show(struct kernfs_open_file *of,
struct seq_file *s, void *v)
{ … }
#ifdef CONFIG_PROC_CPU_RESCTRL
int proc_resctrl_show(struct seq_file *s, struct pid_namespace *ns,
struct pid *pid, struct task_struct *tsk)
{ … }
#endif
static int rdt_last_cmd_status_show(struct kernfs_open_file *of,
struct seq_file *seq, void *v)
{ … }
static int rdt_num_closids_show(struct kernfs_open_file *of,
struct seq_file *seq, void *v)
{ … }
static int rdt_default_ctrl_show(struct kernfs_open_file *of,
struct seq_file *seq, void *v)
{ … }
static int rdt_min_cbm_bits_show(struct kernfs_open_file *of,
struct seq_file *seq, void *v)
{ … }
static int rdt_shareable_bits_show(struct kernfs_open_file *of,
struct seq_file *seq, void *v)
{ … }
static int rdt_bit_usage_show(struct kernfs_open_file *of,
struct seq_file *seq, void *v)
{ … }
static int rdt_min_bw_show(struct kernfs_open_file *of,
struct seq_file *seq, void *v)
{ … }
static int rdt_num_rmids_show(struct kernfs_open_file *of,
struct seq_file *seq, void *v)
{ … }
static int rdt_mon_features_show(struct kernfs_open_file *of,
struct seq_file *seq, void *v)
{ … }
static int rdt_bw_gran_show(struct kernfs_open_file *of,
struct seq_file *seq, void *v)
{ … }
static int rdt_delay_linear_show(struct kernfs_open_file *of,
struct seq_file *seq, void *v)
{ … }
static int max_threshold_occ_show(struct kernfs_open_file *of,
struct seq_file *seq, void *v)
{ … }
static int rdt_thread_throttle_mode_show(struct kernfs_open_file *of,
struct seq_file *seq, void *v)
{ … }
static ssize_t max_threshold_occ_write(struct kernfs_open_file *of,
char *buf, size_t nbytes, loff_t off)
{ … }
static int rdtgroup_mode_show(struct kernfs_open_file *of,
struct seq_file *s, void *v)
{ … }
static enum resctrl_conf_type resctrl_peer_type(enum resctrl_conf_type my_type)
{ … }
static int rdt_has_sparse_bitmasks_show(struct kernfs_open_file *of,
struct seq_file *seq, void *v)
{ … }
static bool __rdtgroup_cbm_overlaps(struct rdt_resource *r, struct rdt_ctrl_domain *d,
unsigned long cbm, int closid,
enum resctrl_conf_type type, bool exclusive)
{ … }
bool rdtgroup_cbm_overlaps(struct resctrl_schema *s, struct rdt_ctrl_domain *d,
unsigned long cbm, int closid, bool exclusive)
{ … }
static bool rdtgroup_mode_test_exclusive(struct rdtgroup *rdtgrp)
{ … }
static ssize_t rdtgroup_mode_write(struct kernfs_open_file *of,
char *buf, size_t nbytes, loff_t off)
{ … }
unsigned int rdtgroup_cbm_to_size(struct rdt_resource *r,
struct rdt_ctrl_domain *d, unsigned long cbm)
{ … }
static int rdtgroup_size_show(struct kernfs_open_file *of,
struct seq_file *s, void *v)
{ … }
struct mon_config_info { … };
#define INVALID_CONFIG_INDEX …
static inline unsigned int mon_event_config_index_get(u32 evtid)
{ … }
static void mon_event_config_read(void *info)
{ … }
static void mondata_config_read(struct rdt_mon_domain *d, struct mon_config_info *mon_info)
{ … }
static int mbm_config_show(struct seq_file *s, struct rdt_resource *r, u32 evtid)
{ … }
static int mbm_total_bytes_config_show(struct kernfs_open_file *of,
struct seq_file *seq, void *v)
{ … }
static int mbm_local_bytes_config_show(struct kernfs_open_file *of,
struct seq_file *seq, void *v)
{ … }
static void mon_event_config_write(void *info)
{ … }
static void mbm_config_write_domain(struct rdt_resource *r,
struct rdt_mon_domain *d, u32 evtid, u32 val)
{ … }
static int mon_config_write(struct rdt_resource *r, char *tok, u32 evtid)
{ … }
static ssize_t mbm_total_bytes_config_write(struct kernfs_open_file *of,
char *buf, size_t nbytes,
loff_t off)
{ … }
static ssize_t mbm_local_bytes_config_write(struct kernfs_open_file *of,
char *buf, size_t nbytes,
loff_t off)
{ … }
static struct rftype res_common_files[] = …;
static int rdtgroup_add_files(struct kernfs_node *kn, unsigned long fflags)
{ … }
static struct rftype *rdtgroup_get_rftype_by_name(const char *name)
{ … }
void __init thread_throttle_mode_init(void)
{ … }
void __init mbm_config_rftype_init(const char *config)
{ … }
int rdtgroup_kn_mode_restrict(struct rdtgroup *r, const char *name)
{ … }
int rdtgroup_kn_mode_restore(struct rdtgroup *r, const char *name,
umode_t mask)
{ … }
static int rdtgroup_mkdir_info_resdir(void *priv, char *name,
unsigned long fflags)
{ … }
static int rdtgroup_create_info_dir(struct kernfs_node *parent_kn)
{ … }
static int
mongroup_create_dir(struct kernfs_node *parent_kn, struct rdtgroup *prgrp,
char *name, struct kernfs_node **dest_kn)
{ … }
static void l3_qos_cfg_update(void *arg)
{ … }
static void l2_qos_cfg_update(void *arg)
{ … }
static inline bool is_mba_linear(void)
{ … }
static int set_cache_qos_cfg(int level, bool enable)
{ … }
void rdt_domain_reconfigure_cdp(struct rdt_resource *r)
{ … }
static int mba_sc_domain_allocate(struct rdt_resource *r, struct rdt_ctrl_domain *d)
{ … }
static void mba_sc_domain_destroy(struct rdt_resource *r,
struct rdt_ctrl_domain *d)
{ … }
static bool supports_mba_mbps(void)
{ … }
static int set_mba_sc(bool mba_sc)
{ … }
static int cdp_enable(int level)
{ … }
static void cdp_disable(int level)
{ … }
int resctrl_arch_set_cdp_enabled(enum resctrl_res_level l, bool enable)
{ … }
static struct rdtgroup *kernfs_to_rdtgroup(struct kernfs_node *kn)
{ … }
static void rdtgroup_kn_get(struct rdtgroup *rdtgrp, struct kernfs_node *kn)
{ … }
static void rdtgroup_kn_put(struct rdtgroup *rdtgrp, struct kernfs_node *kn)
{ … }
struct rdtgroup *rdtgroup_kn_lock_live(struct kernfs_node *kn)
{ … }
void rdtgroup_kn_unlock(struct kernfs_node *kn)
{ … }
static int mkdir_mondata_all(struct kernfs_node *parent_kn,
struct rdtgroup *prgrp,
struct kernfs_node **mon_data_kn);
static void rdt_disable_ctx(void)
{ … }
static int rdt_enable_ctx(struct rdt_fs_context *ctx)
{ … }
static int schemata_list_add(struct rdt_resource *r, enum resctrl_conf_type type)
{ … }
static int schemata_list_create(void)
{ … }
static void schemata_list_destroy(void)
{ … }
static int rdt_get_tree(struct fs_context *fc)
{ … }
enum rdt_param { … };
static const struct fs_parameter_spec rdt_fs_parameters[] = …;
static int rdt_parse_param(struct fs_context *fc, struct fs_parameter *param)
{ … }
static void rdt_fs_context_free(struct fs_context *fc)
{ … }
static const struct fs_context_operations rdt_fs_context_ops = …;
static int rdt_init_fs_context(struct fs_context *fc)
{ … }
static int reset_all_ctrls(struct rdt_resource *r)
{ … }
static void rdt_move_group_tasks(struct rdtgroup *from, struct rdtgroup *to,
struct cpumask *mask)
{ … }
static void free_all_child_rdtgrp(struct rdtgroup *rdtgrp)
{ … }
static void rmdir_all_sub(void)
{ … }
static void rdt_kill_sb(struct super_block *sb)
{ … }
static struct file_system_type rdt_fs_type = …;
static int mon_addfile(struct kernfs_node *parent_kn, const char *name,
void *priv)
{ … }
static void mon_rmdir_one_subdir(struct kernfs_node *pkn, char *name, char *subname)
{ … }
static void rmdir_mondata_subdir_allrdtgrp(struct rdt_resource *r,
struct rdt_mon_domain *d)
{ … }
static int mon_add_all_files(struct kernfs_node *kn, struct rdt_mon_domain *d,
struct rdt_resource *r, struct rdtgroup *prgrp,
bool do_sum)
{ … }
static int mkdir_mondata_subdir(struct kernfs_node *parent_kn,
struct rdt_mon_domain *d,
struct rdt_resource *r, struct rdtgroup *prgrp)
{ … }
static void mkdir_mondata_subdir_allrdtgrp(struct rdt_resource *r,
struct rdt_mon_domain *d)
{ … }
static int mkdir_mondata_subdir_alldom(struct kernfs_node *parent_kn,
struct rdt_resource *r,
struct rdtgroup *prgrp)
{ … }
static int mkdir_mondata_all(struct kernfs_node *parent_kn,
struct rdtgroup *prgrp,
struct kernfs_node **dest_kn)
{ … }
static u32 cbm_ensure_valid(u32 _val, struct rdt_resource *r)
{ … }
static int __init_one_rdt_domain(struct rdt_ctrl_domain *d, struct resctrl_schema *s,
u32 closid)
{ … }
static int rdtgroup_init_cat(struct resctrl_schema *s, u32 closid)
{ … }
static void rdtgroup_init_mba(struct rdt_resource *r, u32 closid)
{ … }
static int rdtgroup_init_alloc(struct rdtgroup *rdtgrp)
{ … }
static int mkdir_rdt_prepare_rmid_alloc(struct rdtgroup *rdtgrp)
{ … }
static void mkdir_rdt_prepare_rmid_free(struct rdtgroup *rgrp)
{ … }
static int mkdir_rdt_prepare(struct kernfs_node *parent_kn,
const char *name, umode_t mode,
enum rdt_group_type rtype, struct rdtgroup **r)
{ … }
static void mkdir_rdt_prepare_clean(struct rdtgroup *rgrp)
{ … }
static int rdtgroup_mkdir_mon(struct kernfs_node *parent_kn,
const char *name, umode_t mode)
{ … }
static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node *parent_kn,
const char *name, umode_t mode)
{ … }
static bool is_mon_groups(struct kernfs_node *kn, const char *name)
{ … }
static int rdtgroup_mkdir(struct kernfs_node *parent_kn, const char *name,
umode_t mode)
{ … }
static int rdtgroup_rmdir_mon(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask)
{ … }
static int rdtgroup_ctrl_remove(struct rdtgroup *rdtgrp)
{ … }
static int rdtgroup_rmdir_ctrl(struct rdtgroup *rdtgrp, cpumask_var_t tmpmask)
{ … }
static int rdtgroup_rmdir(struct kernfs_node *kn)
{ … }
static void mongrp_reparent(struct rdtgroup *rdtgrp,
struct rdtgroup *new_prdtgrp,
cpumask_var_t cpus)
{ … }
static int rdtgroup_rename(struct kernfs_node *kn,
struct kernfs_node *new_parent, const char *new_name)
{ … }
static int rdtgroup_show_options(struct seq_file *seq, struct kernfs_root *kf)
{ … }
static struct kernfs_syscall_ops rdtgroup_kf_syscall_ops = …;
static int rdtgroup_setup_root(struct rdt_fs_context *ctx)
{ … }
static void rdtgroup_destroy_root(void)
{ … }
static void __init rdtgroup_setup_default(void)
{ … }
static void domain_destroy_mon_state(struct rdt_mon_domain *d)
{ … }
void resctrl_offline_ctrl_domain(struct rdt_resource *r, struct rdt_ctrl_domain *d)
{ … }
void resctrl_offline_mon_domain(struct rdt_resource *r, struct rdt_mon_domain *d)
{ … }
static int domain_setup_mon_state(struct rdt_resource *r, struct rdt_mon_domain *d)
{ … }
int resctrl_online_ctrl_domain(struct rdt_resource *r, struct rdt_ctrl_domain *d)
{ … }
int resctrl_online_mon_domain(struct rdt_resource *r, struct rdt_mon_domain *d)
{ … }
void resctrl_online_cpu(unsigned int cpu)
{ … }
static void clear_childcpus(struct rdtgroup *r, unsigned int cpu)
{ … }
void resctrl_offline_cpu(unsigned int cpu)
{ … }
int __init rdtgroup_init(void)
{ … }
void __exit rdtgroup_exit(void)
{ … }