x86/resctrl: Move the resctrl filesystem code to /fs/resctrl
Subsystems (4)
Re: [PATCH v7 45/49] x86,fs/resctrl: Move the resctrl filesystem code to live in /fs/resctrl
In reply to James MorseHi, James,
Quoted 2,085 lines · James Morse
Resctrl is a filesystem interface to hardware that provides cache allocation policy and bandwidth control for groups of tasks or CPUs.
To support more than one architecture, resctrl needs to live in /fs/.
Move the code that is concerned with the filesystem interface to /fs/resctrl.
Signed-off-by James Morse <[email protected]>---
Changes since v6:
* This patch is new.--- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 636 --- arch/x86/kernel/cpu/resctrl/internal.h | 373 +- arch/x86/kernel/cpu/resctrl/monitor.c | 905 +--- arch/x86/kernel/cpu/resctrl/monitor_trace.h | 18 +- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 1074 +--- .../kernel/cpu/resctrl/pseudo_lock_trace.h | 2 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4294 +--------------- fs/resctrl/ctrlmondata.c | 660 +++ fs/resctrl/internal.h | 435 ++ fs/resctrl/monitor.c | 935 ++++ fs/resctrl/monitor_trace.h | 33 + fs/resctrl/pseudo_lock.c | 1109 +++++ fs/resctrl/pseudo_lock_trace.h | 17 + fs/resctrl/rdtgroup.c | 4329 +++++++++++++++++ 14 files changed, 7535 insertions(+), 7285 deletions(-)arch/x86/kernel/cpu/resctrl/ctrlmondata.c +0
-636@@ -23,270 +23,6 @@#include "internal.h" -struct rdt_parse_data { -struct rdtgroup *rdtgrp; -char *buf; -}; - -typedef int (ctrlval_parser_t )(struct rdt_parse_data *data, -struct resctrl_schema *s, -struct rdt_ctrl_domain *d); - -/* -* Check whether MBA bandwidth percentage value is correct. The value is -* checked against the minimum and max bandwidth values specified by the -* hardware. The allocated bandwidth percentage is rounded to the next -* control step available on the hardware. -*/ -static bool bw_validate (char *buf,u32 *data,struct rdt_resource *r) -{ -int ret; -u32 bw; - -/* -* Only linear delay values is supported for current Intel SKUs. -*/ -if (!r->membw.delay_linear && r->membw.arch_needs_linear) { -rdt_last_cmd_puts ("No support for non-linear MB domains\n" ); -return false; - } - - ret =kstrtou32 (buf,10 , &bw); -if (ret) { -rdt_last_cmd_printf ("Invalid MB value %s\n" , buf); -return false; - } - -/* Nothing else to do if software controller is enabled. */ -if (is_mba_sc (r)) { - *data = bw; -return true; - } - -if (bw < r->membw.min_bw || bw > r->membw.max_bw) { -rdt_last_cmd_printf ("MB value %u out of range [%d,%d]\n" , - bw, r->membw.min_bw, r->membw.max_bw); -return false; - } - - *data =roundup (bw, (unsigned long )r->membw.bw_gran); -return true; -} - -static int parse_bw (struct rdt_parse_data *data,struct resctrl_schema *s, -struct rdt_ctrl_domain *d) -{ -struct resctrl_staged_config *cfg; -u32 closid = data->rdtgrp->closid; -struct rdt_resource *r = s->res; -u32 bw_val; - - cfg = &d->staged_config[s->conf_type]; -if (cfg->have_new_ctrl) { -rdt_last_cmd_printf ("Duplicate domain %d\n" , d->hdr.id); -return -EINVAL ; - } - -if (!bw_validate (data->buf, &bw_val, r)) -return -EINVAL ; - -if (is_mba_sc (r)) { - d->mbps_val[closid] = bw_val; -return 0 ; - } - - cfg->new_ctrl = bw_val; - cfg->have_new_ctrl = true; - -return 0 ; -} - -/* -* Check whether a cache bit mask is valid. -* On Intel CPUs, non-contiguous 1s value support is indicated by CPUID: -* - CPUID.0x10.1:ECX[3]: L3 non-contiguous 1s value supported if 1 -* - CPUID.0x10.2:ECX[3]: L2 non-contiguous 1s value supported if 1 -* -* Haswell does not support a non-contiguous 1s value and additionally -* requires at least two bits set. -* AMD allows non-contiguous bitmasks. -*/ -static bool cbm_validate (char *buf,u32 *data,struct rdt_resource *r) -{ -u32 supported_bits =BIT_MASK (r->cache.cbm_len) -1 ; -unsigned int cbm_len = r->cache.cbm_len; -unsigned long first_bit, zero_bit, val; -int ret; - - ret =kstrtoul (buf,16 , &val); -if (ret) { -rdt_last_cmd_printf ("Non-hex character in the mask %s\n" , buf); -return false; - } - -if ((r->cache.min_cbm_bits >0 && val ==0 ) || val > supported_bits) { -rdt_last_cmd_puts ("Mask out of range\n" ); -return false; - } - - first_bit =find_first_bit (&val, cbm_len); - zero_bit =find_next_zero_bit (&val, cbm_len, first_bit); - -/* Are non-contiguous bitmasks allowed? */ -if (!r->cache.arch_has_sparse_bitmasks && - (find_next_bit (&val, cbm_len, zero_bit) < cbm_len)) { -rdt_last_cmd_printf ("The mask %lx has non-consecutive 1-bits\n" , val); -return false; - } - -if ((zero_bit - first_bit) < r->cache.min_cbm_bits) { -rdt_last_cmd_printf ("Need at least %d bits in the mask\n" , - r->cache.min_cbm_bits); -return false; - } - - *data = val; -return true; -} - -/* -* Read one cache bit mask (hex). Check that it is valid for the current -* resource type. -*/ -static int parse_cbm (struct rdt_parse_data *data,struct resctrl_schema *s, -struct rdt_ctrl_domain *d) -{ -struct rdtgroup *rdtgrp = data->rdtgrp; -struct resctrl_staged_config *cfg; -struct rdt_resource *r = s->res; -u32 cbm_val; - - cfg = &d->staged_config[s->conf_type]; -if (cfg->have_new_ctrl) { -rdt_last_cmd_printf ("Duplicate domain %d\n" , d->hdr.id); -return -EINVAL ; - } - -/* -* Cannot set up more than one pseudo-locked region in a cache -* hierarchy. -*/ -if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKSETUP && -rdtgroup_pseudo_locked_in_hierarchy (d)) { -rdt_last_cmd_puts ("Pseudo-locked region in hierarchy\n" ); -return -EINVAL ; - } - -if (!cbm_validate (data->buf, &cbm_val, r)) -return -EINVAL ; - -if ((rdtgrp->mode ==RDT_MODE_EXCLUSIVE || - rdtgrp->mode ==RDT_MODE_SHAREABLE ) && -rdtgroup_cbm_overlaps_pseudo_locked (d, cbm_val)) { -rdt_last_cmd_puts ("CBM overlaps with pseudo-locked region\n" ); -return -EINVAL ; - } - -/* -* The CBM may not overlap with the CBM of another closid if -* either is exclusive. -*/ -if (rdtgroup_cbm_overlaps (s, d, cbm_val, rdtgrp->closid, true)) { -rdt_last_cmd_puts ("Overlaps with exclusive group\n" ); -return -EINVAL ; - } - -if (rdtgroup_cbm_overlaps (s, d, cbm_val, rdtgrp->closid, false)) { -if (rdtgrp->mode ==RDT_MODE_EXCLUSIVE || - rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKSETUP ) { -rdt_last_cmd_puts ("Overlaps with other group\n" ); -return -EINVAL ; - } - } - - cfg->new_ctrl = cbm_val; - cfg->have_new_ctrl = true; - -return 0 ; -} - -/* -* For each domain in this resource we expect to find a series of: -* id=mask -* separated by ";". The "id" is in decimal, and must match one of -* the "id"s for this resource. -*/ -static int parse_line (char *line,struct resctrl_schema *s, -struct rdtgroup *rdtgrp) -{ -enum resctrl_conf_type t = s->conf_type; -ctrlval_parser_t *parse_ctrlval =NULL ; -struct resctrl_staged_config *cfg; -struct rdt_resource *r = s->res; -struct rdt_parse_data data; -struct rdt_ctrl_domain *d; -char *dom =NULL , *id; -unsigned long dom_id; - -/* Walking r->domains, ensure it can't race with cpuhp */ -lockdep_assert_cpus_held (); - -switch (r->schema_fmt) { -case RESCTRL_SCHEMA_BITMAP : - parse_ctrlval = &parse_cbm; -break ; -case RESCTRL_SCHEMA_RANGE : - parse_ctrlval = &parse_bw; -break ; - } - -if (WARN_ON_ONCE (!parse_ctrlval)) -return -EINVAL ; - -if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKSETUP && - (r->rid ==RDT_RESOURCE_MBA || r->rid ==RDT_RESOURCE_SMBA )) { -rdt_last_cmd_puts ("Cannot pseudo-lock MBA resource\n" ); -return -EINVAL ; - } - -next: -if (!line || line[0 ] =='\0' ) -return 0 ; - dom =strsep (&line,";" ); - id =strsep (&dom,"=" ); -if (!dom ||kstrtoul (id,10 , &dom_id)) { -rdt_last_cmd_puts ("Missing '=' or non-numeric domain\n" ); -return -EINVAL ; - } - dom =strim (dom); -list_for_each_entry (d, &r->ctrl_domains, hdr.list) { -if (d->hdr.id == dom_id) { - data.buf = dom; - data.rdtgrp = rdtgrp; -if (parse_ctrlval (&data, s, d)) -return -EINVAL ; -if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKSETUP ) { - cfg = &d->staged_config[t]; -/* -* In pseudo-locking setup mode and just -* parsed a valid CBM that should be -* pseudo-locked. Only one locked region per -* resource group and domain so just do -* the required initialization for single -* region and return. -*/ - rdtgrp->plr->s = s; - rdtgrp->plr->d = d; - rdtgrp->plr->cbm = cfg->new_ctrl; - d->plr = rdtgrp->plr; -return 0 ; - } - goto next; - } - } -return -EINVAL ; -} -int resctrl_arch_update_one (struct rdt_resource *r,struct rdt_ctrl_domain *d,u32 closid,enum resctrl_conf_type t,u32 cfg_val) {@@ -351,100 +87,6 @@ int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid)return 0 ; } -static int rdtgroup_parse_resource (char *resname,char *tok, -struct rdtgroup *rdtgrp) -{ -struct resctrl_schema *s; - -list_for_each_entry (s, &resctrl_schema_all, list) { -if (!strcmp (resname, s->name) && rdtgrp->closid < s->num_closid) -return parse_line (tok, s, rdtgrp); - } -rdt_last_cmd_printf ("Unknown or unsupported resource name '%s'\n" , resname); -return -EINVAL ; -} - -ssize_t rdtgroup_schemata_write (struct kernfs_open_file *of, -char *buf,size_t nbytes,loff_t off) -{ -struct resctrl_schema *s; -struct rdtgroup *rdtgrp; -struct rdt_resource *r; -char *tok, *resname; -int ret =0 ; - -/* Valid input requires a trailing newline */ -if (nbytes ==0 || buf[nbytes -1 ] !='\n' ) -return -EINVAL ; - buf[nbytes -1 ] ='\0' ; - - rdtgrp =rdtgroup_kn_lock_live (of->kn); -if (!rdtgrp) { -rdtgroup_kn_unlock (of->kn); -return -ENOENT ; - } -rdt_last_cmd_clear (); - -/* -* No changes to pseudo-locked region allowed. It has to be removed -* and re-created instead. -*/ -if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKED ) { - ret = -EINVAL ; -rdt_last_cmd_puts ("Resource group is pseudo-locked\n" ); - goto out; - } - -rdt_staged_configs_clear (); - -while ((tok =strsep (&buf,"\n" )) !=NULL ) { - resname =strim (strsep (&tok,":" )); -if (!tok) { -rdt_last_cmd_puts ("Missing ':'\n" ); - ret = -EINVAL ; - goto out; - } -if (tok[0 ] =='\0' ) { -rdt_last_cmd_printf ("Missing '%s' value\n" , resname); - ret = -EINVAL ; - goto out; - } - ret =rdtgroup_parse_resource (resname, tok, rdtgrp); -if (ret) - goto out; - } - -list_for_each_entry (s, &resctrl_schema_all, list) { - r = s->res; - -/* -* Writes to mba_sc resources update the software controller, -* not the control MSR. -*/ -if (is_mba_sc (r)) -continue ; - - ret =resctrl_arch_update_domains (r, rdtgrp->closid); -if (ret) - goto out; - } - -if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKSETUP ) { -/* -* If pseudo-locking fails we keep the resource group in -* mode RDT_MODE_PSEUDO_LOCKSETUP with its class of service -* active and updated for just the domain the pseudo-locked -* region was requested for. -*/ - ret =rdtgroup_pseudo_lock_create (rdtgrp); - } - -out: -rdt_staged_configs_clear (); -rdtgroup_kn_unlock (of->kn); -return ret ?: nbytes; -} -u32 resctrl_arch_get_config (struct rdt_resource *r,struct rdt_ctrl_domain *d,u32 closid,enum resctrl_conf_type type) {@@ -453,281 +95,3 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain *d,return hw_dom->ctrl_val[idx]; } - -static void show_doms (struct seq_file *s,struct resctrl_schema *schema,int closid) -{ -struct rdt_resource *r = schema->res; -struct rdt_ctrl_domain *dom; -bool sep = false; -u32 ctrl_val; - -/* Walking r->domains, ensure it can't race with cpuhp */ -lockdep_assert_cpus_held (); - -seq_printf (s,"%*s:" , max_name_width, schema->name); -list_for_each_entry (dom, &r->ctrl_domains, hdr.list) { -if (sep) -seq_puts (s,";" ); - -if (is_mba_sc (r)) - ctrl_val = dom->mbps_val[closid]; -else - ctrl_val =resctrl_arch_get_config (r, dom, closid, - schema->conf_type); - -seq_printf (s, schema->fmt_str, dom->hdr.id, ctrl_val); - sep = true; - } -seq_puts (s,"\n" ); -} - -int rdtgroup_schemata_show (struct kernfs_open_file *of, -struct seq_file *s,void *v) -{ -struct resctrl_schema *schema; -struct rdtgroup *rdtgrp; -int ret =0 ; -u32 closid; - - rdtgrp =rdtgroup_kn_lock_live (of->kn); -if (rdtgrp) { -if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKSETUP ) { -list_for_each_entry (schema, &resctrl_schema_all, list) { -seq_printf (s,"%s:uninitialized\n" , schema->name); - } - }else if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKED ) { -if (!rdtgrp->plr->d) { -rdt_last_cmd_clear (); -rdt_last_cmd_puts ("Cache domain offline\n" ); - ret = -ENODEV ; - }else { -seq_printf (s,"%s:%d=%x\n" , - rdtgrp->plr->s->res->name, - rdtgrp->plr->d->hdr.id, - rdtgrp->plr->cbm); - } - }else { - closid = rdtgrp->closid; -list_for_each_entry (schema, &resctrl_schema_all, list) { -if (closid < schema->num_closid) -show_doms (s, schema, closid); - } - } - }else { - ret = -ENOENT ; - } -rdtgroup_kn_unlock (of->kn); -return ret; -} - -static int smp_mon_event_count (void *arg) -{ -mon_event_count (arg); - -return 0 ; -} - -ssize_t rdtgroup_mba_mbps_event_write (struct kernfs_open_file *of, -char *buf,size_t nbytes,loff_t off) -{ -struct rdtgroup *rdtgrp; -int ret =0 ; - -/* Valid input requires a trailing newline */ -if (nbytes ==0 || buf[nbytes -1 ] !='\n' ) -return -EINVAL ; - buf[nbytes -1 ] ='\0' ; - - rdtgrp =rdtgroup_kn_lock_live (of->kn); -if (!rdtgrp) { -rdtgroup_kn_unlock (of->kn); -return -ENOENT ; - } -rdt_last_cmd_clear (); - -if (!strcmp (buf,"mbm_local_bytes" )) { -if (resctrl_arch_is_mbm_local_enabled ()) - rdtgrp->mba_mbps_event =QOS_L3_MBM_LOCAL_EVENT_ID ; -else - ret = -EINVAL ; - }else if (!strcmp (buf,"mbm_total_bytes" )) { -if (resctrl_arch_is_mbm_total_enabled ()) - rdtgrp->mba_mbps_event =QOS_L3_MBM_TOTAL_EVENT_ID ; -else - ret = -EINVAL ; - }else { - ret = -EINVAL ; - } - -if (ret) -rdt_last_cmd_printf ("Unsupported event id '%s'\n" , buf); - -rdtgroup_kn_unlock (of->kn); - -return ret ?: nbytes; -} - -int rdtgroup_mba_mbps_event_show (struct kernfs_open_file *of, -struct seq_file *s,void *v) -{ -struct rdtgroup *rdtgrp; -int ret =0 ; - - rdtgrp =rdtgroup_kn_lock_live (of->kn); - -if (rdtgrp) { -switch (rdtgrp->mba_mbps_event) { -case QOS_L3_MBM_LOCAL_EVENT_ID : -seq_puts (s,"mbm_local_bytes\n" ); -break ; -case QOS_L3_MBM_TOTAL_EVENT_ID : -seq_puts (s,"mbm_total_bytes\n" ); -break ; -default : -pr_warn_once ("Bad event %d\n" , rdtgrp->mba_mbps_event); - ret = -EINVAL ; -break ; - } - }else { - ret = -ENOENT ; - } - -rdtgroup_kn_unlock (of->kn); - -return ret; -} - -struct rdt_domain_hdr *resctrl_find_domain (struct list_head *h,int id, -struct list_head **pos) -{ -struct rdt_domain_hdr *d; -struct list_head *l; - -list_for_each (l, h) { - d = list_entry(l, struct rdt_domain_hdr, list); -/* When id is found, return its domain. */ -if (id == d->id) -return d; -/* Stop searching when finding id's position in sorted list. */ -if (id < d->id) -break ; - } - -if (pos) - *pos = l; - -return NULL ; -} - -void mon_event_read (struct rmid_read *rr,struct rdt_resource *r, -struct rdt_mon_domain *d,struct rdtgroup *rdtgrp, -cpumask_t *cpumask,int evtid,int first) -{ -int cpu; - -/* When picking a CPU from cpu_mask, ensure it can't race with cpuhp */ -lockdep_assert_cpus_held (); - -/* -* Setup the parameters to pass to mon_event_count() to read the data. -*/ - rr->rgrp = rdtgrp; - rr->evtid = evtid; - rr->r = r; - rr->d = d; - rr->first = first; - rr->arch_mon_ctx =resctrl_arch_mon_ctx_alloc (r, evtid); -if (IS_ERR (rr->arch_mon_ctx)) { - rr->err = -EINVAL ; -return ; - } - - cpu =cpumask_any_housekeeping (cpumask,RESCTRL_PICK_ANY_CPU ); - -/* -* cpumask_any_housekeeping() prefers housekeeping CPUs, but -* are all the CPUs nohz_full? If yes, pick a CPU to IPI. -* MPAM's resctrl_arch_rmid_read() is unable to read the -* counters on some platforms if its called in IRQ context. -*/ -if (tick_nohz_full_cpu (cpu)) -smp_call_function_any (cpumask, mon_event_count, rr,1 ); -else -smp_call_on_cpu (cpu, smp_mon_event_count, rr, false); - -resctrl_arch_mon_ctx_free (r, evtid, rr->arch_mon_ctx); -} - -int rdtgroup_mondata_show (struct seq_file *m,void *arg) -{ -struct kernfs_open_file *of = m->private; -struct rdt_domain_hdr *hdr; -struct rmid_read rr = {0 }; -struct rdt_mon_domain *d; -u32 resid, evtid, domid; -struct rdtgroup *rdtgrp; -struct rdt_resource *r; -struct mon_data *md; -int ret =0 ; - - rdtgrp =rdtgroup_kn_lock_live (of->kn); -if (!rdtgrp) { - ret = -ENOENT ; - goto out; - } - - md = of->kn->priv; -if (WARN_ON_ONCE (!md)) { - ret = -EIO ; - goto out; - } - - resid = md->rid; - domid = md->domid; - evtid = md->evtid; - r =resctrl_arch_get_resource (resid); - -if (md->sum) { -/* -* This file requires summing across all domains that share -* the L3 cache id that was provided in the "domid" field of the -* struct mon_data. Search all domains in the resource for -* one that matches this cache id. -*/ -list_for_each_entry (d, &r->mon_domains, hdr.list) { -if (d->ci->id == domid) { - rr.ci = d->ci; -mon_event_read (&rr, r,NULL , rdtgrp, - &d->ci->shared_cpu_map, evtid, false); - goto checkresult; - } - } - ret = -ENOENT ; - goto out; - }else { -/* -* This file provides data from a single domain. Search -* the resource to find the domain with "domid". -*/ - hdr =resctrl_find_domain (&r->mon_domains, domid,NULL ); -if (!hdr ||WARN_ON_ONCE (hdr->type !=RESCTRL_MON_DOMAIN )) { - ret = -ENOENT ; - goto out; - } - d = container_of(hdr, struct rdt_mon_domain, hdr); -mon_event_read (&rr, r, d, rdtgrp, &d->hdr.cpu_mask, evtid, false); - } - -checkresult: - -if (rr.err == -EIO ) -seq_puts (m,"Error\n" ); -else if (rr.err == -EINVAL ) -seq_puts (m,"Unavailable\n" ); -else -seq_printf (m,"%llu\n" , rr.val); - -out: -rdtgroup_kn_unlock (of->kn); -return ret; -}arch/x86/kernel/cpu/resctrl/internal.h +8
-365@@ -13,14 +13,16 @@#define L2_QOS_CDP_ENABLE 0x01ULL -#define CQM_LIMBOCHECK_INTERVAL 1000 -#define MBM_CNTR_WIDTH_BASE 24 +#define MBA_IS_LINEAR 0x4 +#define MBM_CNTR_WIDTH_OFFSET_AMD 20#define RMID_VAL_ERROR BIT_ULL(63) +#define RMID_VAL_UNAVAIL BIT_ULL(62) +/* * With the above fields in use 62 bits remain in MSR_IA32_QM_CTR for * data to be returned. The counter width is discovered from the hardware @@ -28,275 +30,6 @@*/ #define MBM_CNTR_WIDTH_OFFSET_MAX (62 - MBM_CNTR_WIDTH_BASE) -/** -* cpumask_any_housekeeping() - Choose any CPU in @mask, preferring those that -* aren't marked nohz_full -* @mask: The mask to pick a CPU from. -* @exclude_cpu:The CPU to avoid picking. -* -* Returns a CPU from @mask, but not @exclude_cpu. If there are housekeeping -* CPUs that don't use nohz_full, these are preferred. Pass -* RESCTRL_PICK_ANY_CPU to avoid excluding any CPUs. -* -* When a CPU is excluded, returns >= nr_cpu_ids if no CPUs are available. -*/ -static inline unsigned int -cpumask_any_housekeeping (const struct cpumask *mask,int exclude_cpu) -{ -unsigned int cpu, hk_cpu; - -if (exclude_cpu ==RESCTRL_PICK_ANY_CPU ) - cpu =cpumask_any (mask); -else - cpu =cpumask_any_but (mask, exclude_cpu); - -/* Only continue if tick_nohz_full_mask has been initialized. */ -if (!tick_nohz_full_enabled ()) -return cpu; - -/* If the CPU picked isn't marked nohz_full nothing more needs doing. */ -if (cpu < nr_cpu_ids && !tick_nohz_full_cpu (cpu)) -return cpu; - -/* Try to find a CPU that isn't nohz_full to use in preference */ - hk_cpu =cpumask_nth_andnot (0 , mask, tick_nohz_full_mask); -if (hk_cpu == exclude_cpu) - hk_cpu =cpumask_nth_andnot (1 , mask, tick_nohz_full_mask); - -if (hk_cpu < nr_cpu_ids) - cpu = hk_cpu; - -return cpu; -} - -struct rdt_fs_context { -struct kernfs_fs_context kfc; -bool enable_cdpl2; -bool enable_cdpl3; -bool enable_mba_mbps; -bool enable_debug; -}; - -static inline struct rdt_fs_context *rdt_fc2context (struct fs_context *fc) -{ -struct kernfs_fs_context *kfc = fc->fs_private; - - return container_of(kfc, struct rdt_fs_context, kfc); -} - -/** -* struct mon_evt - Entry in the event list of a resource -* @evtid: event id -* @name: name of the event -* @configurable: true if the event is configurable -* @list: entry in &rdt_resource->evt_list -*/ -struct mon_evt { -enum resctrl_event_id evtid; -char *name; -bool configurable; -struct list_head list; -}; - -/** -* struct mon_data - Monitoring details for each event file. -* @rid: Resource id associated with the event file. -* @evtid: Event id associated with the event file. -* @sum: Set when event must be summed across multiple -* domains. -* @domid: When @sum is zero this is the domain to which -* the event file belongs. When @sum is one this -* is the id of the L3 cache that all domains to be -* summed share. -* -* Stored in the kernfs kn->priv field, readers and writers must hold -* rdtgroup_mutex. -*/ -struct mon_data { -unsigned int rid; -enum resctrl_event_id evtid; -unsigned int sum; -unsigned int domid; -}; - -/** -* struct rmid_read - Data passed across smp_call*() to read event count. -* @rgrp: Resource group for which the counter is being read. If it is a parent -* resource group then its event count is summed with the count from all -* its child resource groups. -* @r: Resource describing the properties of the event being read. -* @d: Domain that the counter should be read from. If NULL then sum all -* domains in @r sharing L3 @ci.id -* @evtid: Which monitor event to read. -* @first: Initialize MBM counter when true. -* @ci: Cacheinfo for L3. Only set when @d is NULL. Used when summing domains. -* @err: Error encountered when reading counter. -* @val: Returned value of event counter. If @rgrp is a parent resource group, -* @val includes the sum of event counts from its child resource groups. -* If @d is NULL, @val includes the sum of all domains in @r sharing @ci.id, -* (summed across child resource groups if @rgrp is a parent resource group). -* @arch_mon_ctx: Hardware monitor allocated for this read request (MPAM only). -*/ -struct rmid_read { -struct rdtgroup *rgrp; -struct rdt_resource *r; -struct rdt_mon_domain *d; -enum resctrl_event_id evtid; -bool first; -struct cacheinfo *ci; -int err; -u64 val; -void *arch_mon_ctx; -}; - -extern struct list_head resctrl_schema_all; -extern bool resctrl_mounted; - -enum rdt_group_type { -RDTCTRL_GROUP =0 , -RDTMON_GROUP , -RDT_NUM_GROUP , -}; - -/** -* enum rdtgrp_mode - Mode of a RDT resource group -* @RDT_MODE_SHAREABLE: This resource group allows sharing of its allocations -* @RDT_MODE_EXCLUSIVE: No sharing of this resource group's allocations allowed -* @RDT_MODE_PSEUDO_LOCKSETUP: Resource group will be used for Pseudo-Locking -* @RDT_MODE_PSEUDO_LOCKED: No sharing of this resource group's allocations -* allowed AND the allocations are Cache Pseudo-Locked -* @RDT_NUM_MODES: Total number of modes -* -* The mode of a resource group enables control over the allowed overlap -* between allocations associated with different resource groups (classes -* of service). User is able to modify the mode of a resource group by -* writing to the "mode" resctrl file associated with the resource group. -* -* The "shareable", "exclusive", and "pseudo-locksetup" modes are set by -* writing the appropriate text to the "mode" file. A resource group enters -* "pseudo-locked" mode after the schemata is written while the resource -* group is in "pseudo-locksetup" mode. -*/ -enum rdtgrp_mode { -RDT_MODE_SHAREABLE =0 , -RDT_MODE_EXCLUSIVE , -RDT_MODE_PSEUDO_LOCKSETUP , -RDT_MODE_PSEUDO_LOCKED , - -/* Must be last */ -RDT_NUM_MODES , -}; - -/** -* struct mongroup - store mon group's data in resctrl fs. -* @mon_data_kn: kernfs node for the mon_data directory -* @parent: parent rdtgrp -* @crdtgrp_list: child rdtgroup node list -* @rmid: rmid for this rdtgroup -*/ -struct mongroup { -struct kernfs_node *mon_data_kn; -struct rdtgroup *parent; -struct list_head crdtgrp_list; -u32 rmid; -}; - -/** -* struct rdtgroup - store rdtgroup's data in resctrl file system. -* @kn: kernfs node -* @rdtgroup_list: linked list for all rdtgroups -* @closid: closid for this rdtgroup -* @cpu_mask: CPUs assigned to this rdtgroup -* @flags: status bits -* @waitcount: how many cpus expect to find this -* group when they acquire rdtgroup_mutex -* @type: indicates type of this rdtgroup - either -* monitor only or ctrl_mon group -* @mon: mongroup related data -* @mode: mode of resource group -* @mba_mbps_event: input monitoring event id when mba_sc is enabled -* @plr: pseudo-locked region -*/ -struct rdtgroup { -struct kernfs_node *kn; -struct list_head rdtgroup_list; -u32 closid; -struct cpumask cpu_mask; -int flags; -atomic_t waitcount; -enum rdt_group_type type; -struct mongroup mon; -enum rdtgrp_mode mode; -enum resctrl_event_id mba_mbps_event; -struct pseudo_lock_region *plr; -}; - -/* rdtgroup.flags */ -#define RDT_DELETED 1 - -/* rftype.flags */ -#define RFTYPE_FLAGS_CPUS_LIST 1 - -/* -* Define the file type flags for base and info directories. -*/ -#define RFTYPE_INFO BIT(0) -#define RFTYPE_BASE BIT(1) -#define RFTYPE_CTRL BIT(4) -#define RFTYPE_MON BIT(5) -#define RFTYPE_TOP BIT(6) -#define RFTYPE_RES_CACHE BIT(8) -#define RFTYPE_RES_MB BIT(9) -#define RFTYPE_DEBUG BIT(10) -#define RFTYPE_CTRL_INFO (RFTYPE_INFO | RFTYPE_CTRL) -#define RFTYPE_MON_INFO (RFTYPE_INFO | RFTYPE_MON) -#define RFTYPE_TOP_INFO (RFTYPE_INFO | RFTYPE_TOP) -#define RFTYPE_CTRL_BASE (RFTYPE_BASE | RFTYPE_CTRL) -#define RFTYPE_MON_BASE (RFTYPE_BASE | RFTYPE_MON) - -/* List of all resource groups */ -extern struct list_head rdt_all_groups; - -extern int max_name_width; - -/** -* struct rftype - describe each file in the resctrl file system -* @name: File name -* @mode: Access mode -* @kf_ops: File operations -* @flags: File specific RFTYPE_FLAGS_* flags -* @fflags: File specific RFTYPE_* flags -* @seq_show: Show content of the file -* @write: Write to the file -*/ -struct rftype { -char *name; -umode_t mode; -const struct kernfs_ops *kf_ops; -unsigned long flags; -unsigned long fflags; - -int (*seq_show)(struct kernfs_open_file *of, -struct seq_file *sf,void *v); -/* -* write() is the generic write callback which maps directly to -* kernfs write operation and overrides all other operations. -* Maximum write size is determined by ->max_write_len. -*/ -ssize_t (*write)(struct kernfs_open_file *of, -char *buf,size_t nbytes,loff_t off); -}; - -/** -* struct mbm_state - status for each MBM counter in each domain -* @prev_bw_bytes: Previous bytes value read for bandwidth calculation -* @prev_bw: The most recent bandwidth in MBps -*/ -struct mbm_state { -u64 prev_bw_bytes; -u32 prev_bw; -}; -/** * struct arch_mbm_state - values used to compute resctrl_arch_rmid_read()s * return value. @@ -394,12 +127,7 @@ static inline struct rdt_hw_resource *resctrl_to_arch_res(struct rdt_resource *r return container_of(r, struct rdt_hw_resource, r_resctrl); } -extern struct mutex rdtgroup_mutex; -extern struct rdt_hw_resource rdt_resources_all[]; -extern struct rdtgroup rdtgroup_default; -extern struct dentry *debugfs_resctrl; -extern enum resctrl_event_id mba_mbps_default_event;void arch_mon_domain_online (struct rdt_resource *r,struct rdt_mon_domain *d);@@ -436,99 +164,14 @@ union cpuid_0x10_x_edx { unsigned int full; }; -void rdt_last_cmd_clear (void ); -void rdt_last_cmd_puts (const char *s); -__printf(1, 2) -void rdt_last_cmd_printf (const char *fmt, ...); -void rdt_ctrl_update (void *arg); -struct rdtgroup *rdtgroup_kn_lock_live (struct kernfs_node *kn); -void rdtgroup_kn_unlock (struct kernfs_node *kn); -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); -ssize_t rdtgroup_schemata_write (struct kernfs_open_file *of, -char *buf,size_t nbytes,loff_t off); -int rdtgroup_schemata_show (struct kernfs_open_file *of, -struct seq_file *s,void *v); -ssize_t rdtgroup_mba_mbps_event_write (struct kernfs_open_file *of, -char *buf,size_t nbytes,loff_t off); -int rdtgroup_mba_mbps_event_show (struct kernfs_open_file *of, -struct seq_file *s,void *v); -bool rdtgroup_cbm_overlaps (struct resctrl_schema *s,struct rdt_ctrl_domain *d, -unsigned long cbm,int closid,bool exclusive); -unsigned int rdtgroup_cbm_to_size (struct rdt_resource *r,struct rdt_ctrl_domain *d, -unsigned long cbm); -enum rdtgrp_mode rdtgroup_mode_by_closid (int closid); -int rdtgroup_tasks_assigned (struct rdtgroup *r); -int closids_supported (void ); -void closid_free (int closid); -int alloc_rmid (u32 closid); -void free_rmid (u32 closid,u32 rmid); +int rdt_get_mon_l3_config (struct rdt_resource *r); -void resctrl_mon_resource_exit (void ); +bool rdt_cpu_has (int flag); -void mon_event_count (void *info); -int rdtgroup_mondata_show (struct seq_file *m,void *arg); -void mon_event_read (struct rmid_read *rr,struct rdt_resource *r, -struct rdt_mon_domain *d,struct rdtgroup *rdtgrp, -cpumask_t *cpumask,int evtid,int first); -int resctrl_mon_resource_init (void ); -void mbm_setup_overflow_handler (struct rdt_mon_domain *dom, -unsigned long delay_ms, -int exclude_cpu); -void mbm_handle_overflow (struct work_struct *work); +void __init intel_rdt_mbm_apply_quirk (void ); -bool is_mba_sc (struct rdt_resource *r); -void cqm_setup_limbo_handler (struct rdt_mon_domain *dom,unsigned long delay_ms, -int exclude_cpu); -void cqm_handle_limbo (struct work_struct *work); -bool has_busy_rmid (struct rdt_mon_domain *d); -void __check_limbo (struct rdt_mon_domain *d,bool force_free); +void rdt_domain_reconfigure_cdp (struct rdt_resource *r); -void resctrl_file_fflags_init (const char *config,unsigned long fflags); -void rdt_staged_configs_clear (void ); -bool closid_allocated (unsigned int closid); -int resctrl_find_cleanest_closid (void ); - -#ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK -int rdtgroup_locksetup_enter (struct rdtgroup *rdtgrp); -int rdtgroup_locksetup_exit (struct rdtgroup *rdtgrp); -bool rdtgroup_cbm_overlaps_pseudo_locked (struct rdt_ctrl_domain *d,unsigned long cbm); -bool rdtgroup_pseudo_locked_in_hierarchy (struct rdt_ctrl_domain *d); -int rdt_pseudo_lock_init (void ); -void rdt_pseudo_lock_release (void ); -int rdtgroup_pseudo_lock_create (struct rdtgroup *rdtgrp); -void rdtgroup_pseudo_lock_remove (struct rdtgroup *rdtgrp); -#else -static inline int rdtgroup_locksetup_enter (struct rdtgroup *rdtgrp) -{ -return -EOPNOTSUPP ; -} - -static inline int rdtgroup_locksetup_exit (struct rdtgroup *rdtgrp) -{ -return -EOPNOTSUPP ; -} - -static inline bool rdtgroup_cbm_overlaps_pseudo_locked (struct rdt_ctrl_domain *d,unsigned long cbm) -{ -return false; -} - -static inline bool rdtgroup_pseudo_locked_in_hierarchy (struct rdt_ctrl_domain *d) -{ -return false; -} - -static inline int rdt_pseudo_lock_init (void ) {return 0 ; } -static inline void rdt_pseudo_lock_release (void ) { } -static inline int rdtgroup_pseudo_lock_create (struct rdtgroup *rdtgrp) -{ -return -EOPNOTSUPP ; -} - -static inline void rdtgroup_pseudo_lock_remove (struct rdtgroup *rdtgrp) { } -#endif /* CONFIG_RESCTRL_FS_PSEUDO_LOCK */ #endif /* _ASM_X86_RESCTRL_INTERNAL_H */ arch/x86/kernel/cpu/resctrl/monitor.c +2
-903@@ -28,55 +28,9 @@#include "internal.h" #define CREATE_TRACE_POINTS +#include "monitor_trace.h" -/** -* struct rmid_entry - dirty tracking for all RMID. -* @closid: The CLOSID for this entry. -* @rmid: The RMID for this entry. -* @busy: The number of domains with cached data using this RMID. -* @list: Member of the rmid_free_lru list when busy == 0. -* -* Depending on the architecture the correct monitor is accessed using -* both @closid and @rmid, or @rmid only. -* -* Take the rdtgroup_mutex when accessing. -*/ -struct rmid_entry { -u32 closid; -u32 rmid; -int busy; -struct list_head list; -}; - -/* -* @rmid_free_lru - A least recently used list of free RMIDs -* These RMIDs are guaranteed to have an occupancy less than the -* threshold occupancy -*/ -static LIST_HEAD (rmid_free_lru); - -/* -* @closid_num_dirty_rmid The number of dirty RMID each CLOSID has. -* Only allocated when CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID is defined. -* Indexed by CLOSID. Protected by rdtgroup_mutex. -*/ -static u32 *closid_num_dirty_rmid; - -/* -* @rmid_limbo_count - count of currently unused but (potentially) -* dirty RMIDs. -* This counts RMIDs that no one is currently using but that -* may have a occupancy value > resctrl_rmid_realloc_threshold. User can -* change the threshold occupancy value. -*/ -static unsigned int rmid_limbo_count; - -/* -* @rmid_entry - The entry in the limbo and free lists. -*/ -static struct rmid_entry *rmid_ptrs; -/* * Global boolean for rdt_monitor which is true if any * resource monitoring is enabled. @@ -88,17 +42,6 @@ bool rdt_mon_capable;*/ unsigned int rdt_mon_features; -/* -* This is the threshold cache occupancy in bytes at which we will consider an -* RMID available for re-allocation. -*/ -unsigned int resctrl_rmid_realloc_threshold; - -/* -* This is the maximum value for the reallocation threshold, in bytes. -*/ -unsigned int resctrl_rmid_realloc_limit; -#define CF (cf) ((unsigned long)(1048576 * (cf) + 0.5))static int snc_nodes_per_l3_cache =1 ;@@ -153,6 +96,7 @@ static const struct mbm_correction_factor_table { };static u32 mbm_cf_rmidthreshold__read_mostly =UINT_MAX ; +static u64 mbm_cf__read_mostly ;static inline u64 get_corrected_mbm_count (u32 rmid,unsigned long val)@@ -164,33 +108,6 @@ static inline u64 get_corrected_mbm_count(u32 rmid, unsigned long val)return val; } -/* -* x86 and arm64 differ in their handling of monitoring. -* x86's RMID are independent numbers, there is only one source of traffic -* with an RMID value of '1'. -* arm64's PMG extends the PARTID/CLOSID space, there are multiple sources of -* traffic with a PMG value of '1', one for each CLOSID, meaning the RMID -* value is no longer unique. -* To account for this, resctrl uses an index. On x86 this is just the RMID, -* on arm64 it encodes the CLOSID and RMID. This gives a unique number. -* -* The domain's rmid_busy_llc and rmid_ptrs[] are sized by index. The arch code -* must accept an attempt to read every index. -*/ -static inline struct rmid_entry *__rmid_entry (u32 idx) -{ -struct rmid_entry *entry; -u32 closid, rmid; - - entry = &rmid_ptrs[idx]; -resctrl_arch_rmid_idx_decode (idx, &closid, &rmid); - -WARN_ON_ONCE (entry->closid != closid); -WARN_ON_ONCE (entry->rmid != rmid); - -return entry; -} -/* * When Sub-NUMA Cluster (SNC) mode is not enabled (as indicated by * "snc_nodes_per_l3_cache == 1") no translation of the RMID value is @@ -348,772 +265,6 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_mon_domain *d,return 0 ; } -static void limbo_release_entry (struct rmid_entry *entry) -{ -lockdep_assert_held (&rdtgroup_mutex); - - rmid_limbo_count--; -list_add_tail (&entry->list, &rmid_free_lru); - -if (IS_ENABLED (CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID )) - closid_num_dirty_rmid[entry->closid]--; -} - -/* -* Check the RMIDs that are marked as busy for this domain. If the -* reported LLC occupancy is below the threshold clear the busy bit and -* decrement the count. If the busy count gets to zero on an RMID, we -* free the RMID -*/ -void __check_limbo (struct rdt_mon_domain *d,bool force_free) -{ -struct rdt_resource *r =resctrl_arch_get_resource (RDT_RESOURCE_L3 ); -u32 idx_limit =resctrl_arch_system_num_rmid_idx (); -struct rmid_entry *entry; -u32 idx, cur_idx =1 ; -void *arch_mon_ctx; -bool rmid_dirty; -u64 val =0 ; - - arch_mon_ctx =resctrl_arch_mon_ctx_alloc (r,QOS_L3_OCCUP_EVENT_ID ); -if (IS_ERR (arch_mon_ctx)) { -pr_warn_ratelimited ("Failed to allocate monitor context: %ld" , -PTR_ERR (arch_mon_ctx)); -return ; - } - -/* -* Skip RMID 0 and start from RMID 1 and check all the RMIDs that -* are marked as busy for occupancy < threshold. If the occupancy -* is less than the threshold decrement the busy counter of the -* RMID and move it to the free list when the counter reaches 0. -*/ -for (;;) { - idx =find_next_bit (d->rmid_busy_llc, idx_limit, cur_idx); -if (idx >= idx_limit) -break ; - - entry =__rmid_entry (idx); -if (resctrl_arch_rmid_read (r, d, entry->closid, entry->rmid, -QOS_L3_OCCUP_EVENT_ID , &val, - arch_mon_ctx)) { - rmid_dirty = true; - }else { - rmid_dirty = (val >= resctrl_rmid_realloc_threshold); - -/* -* x86's CLOSID and RMID are independent numbers, so the entry's -* CLOSID is an empty CLOSID (X86_RESCTRL_EMPTY_CLOSID). On Arm the -* RMID (PMG) extends the CLOSID (PARTID) space with bits that aren't -* used to select the configuration. It is thus necessary to track both -* CLOSID and RMID because there may be dependencies between them -* on some architectures. -*/ -trace_mon_llc_occupancy_limbo (entry->closid, entry->rmid, d->hdr.id, val); - } - -if (force_free || !rmid_dirty) { -clear_bit (idx, d->rmid_busy_llc); -if (!--entry->busy) -limbo_release_entry (entry); - } - cur_idx = idx +1 ; - } - -resctrl_arch_mon_ctx_free (r,QOS_L3_OCCUP_EVENT_ID , arch_mon_ctx); -} - -bool has_busy_rmid (struct rdt_mon_domain *d) -{ -u32 idx_limit =resctrl_arch_system_num_rmid_idx (); - -return find_first_bit (d->rmid_busy_llc, idx_limit) != idx_limit; -} - -static struct rmid_entry *resctrl_find_free_rmid (u32 closid) -{ -struct rmid_entry *itr; -u32 itr_idx, cmp_idx; - -if (list_empty (&rmid_free_lru)) -return rmid_limbo_count ?ERR_PTR (-EBUSY ) :ERR_PTR (-ENOSPC ); - -list_for_each_entry (itr, &rmid_free_lru, list) { -/* -* Get the index of this free RMID, and the index it would need -* to be if it were used with this CLOSID. -* If the CLOSID is irrelevant on this architecture, the two -* index values are always the same on every entry and thus the -* very first entry will be returned. -*/ - itr_idx =resctrl_arch_rmid_idx_encode (itr->closid, itr->rmid); - cmp_idx =resctrl_arch_rmid_idx_encode (closid, itr->rmid); - -if (itr_idx == cmp_idx) -return itr; - } - -return ERR_PTR (-ENOSPC ); -} - -/** -* resctrl_find_cleanest_closid() - Find a CLOSID where all the associated -* RMID are clean, or the CLOSID that has -* the most clean RMID. -* -* MPAM's equivalent of RMID are per-CLOSID, meaning a freshly allocated CLOSID -* may not be able to allocate clean RMID. To avoid this the allocator will -* choose the CLOSID with the most clean RMID. -* -* When the CLOSID and RMID are independent numbers, the first free CLOSID will -* be returned. -*/ -int resctrl_find_cleanest_closid (void ) -{ -u32 cleanest_closid = ~0 ; -int i =0 ; - -lockdep_assert_held (&rdtgroup_mutex); - -if (!IS_ENABLED (CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID )) -return -EIO ; - -for (i =0 ; i <closids_supported (); i++) { -int num_dirty; - -if (closid_allocated (i)) -continue ; - - num_dirty = closid_num_dirty_rmid[i]; -if (num_dirty ==0 ) -return i; - -if (cleanest_closid == ~0 ) - cleanest_closid = i; - -if (num_dirty < closid_num_dirty_rmid[cleanest_closid]) - cleanest_closid = i; - } - -if (cleanest_closid == ~0 ) -return -ENOSPC ; - -return cleanest_closid; -} - -/* -* For MPAM the RMID value is not unique, and has to be considered with -* the CLOSID. The (CLOSID, RMID) pair is allocated on all domains, which -* allows all domains to be managed by a single free list. -* Each domain also has a rmid_busy_llc to reduce the work of the limbo handler. -*/ -int alloc_rmid (u32 closid) -{ -struct rmid_entry *entry; - -lockdep_assert_held (&rdtgroup_mutex); - - entry =resctrl_find_free_rmid (closid); -if (IS_ERR (entry)) -return PTR_ERR (entry); - -list_del (&entry->list); -return entry->rmid; -} - -static void add_rmid_to_limbo (struct rmid_entry *entry) -{ -struct rdt_resource *r =resctrl_arch_get_resource (RDT_RESOURCE_L3 ); -struct rdt_mon_domain *d; -u32 idx; - -lockdep_assert_held (&rdtgroup_mutex); - -/* Walking r->domains, ensure it can't race with cpuhp */ -lockdep_assert_cpus_held (); - - idx =resctrl_arch_rmid_idx_encode (entry->closid, entry->rmid); - - entry->busy =0 ; -list_for_each_entry (d, &r->mon_domains, hdr.list) { -/* -* For the first limbo RMID in the domain, -* setup up the limbo worker. -*/ -if (!has_busy_rmid (d)) -cqm_setup_limbo_handler (d,CQM_LIMBOCHECK_INTERVAL , -RESCTRL_PICK_ANY_CPU ); -set_bit (idx, d->rmid_busy_llc); - entry->busy++; - } - - rmid_limbo_count++; -if (IS_ENABLED (CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID )) - closid_num_dirty_rmid[entry->closid]++; -} - -void free_rmid (u32 closid,u32 rmid) -{ -u32 idx =resctrl_arch_rmid_idx_encode (closid, rmid); -struct rmid_entry *entry; - -lockdep_assert_held (&rdtgroup_mutex); - -/* -* Do not allow the default rmid to be free'd. Comparing by index -* allows architectures that ignore the closid parameter to avoid an -* unnecessary check. -*/ -if (!resctrl_arch_mon_capable () || - idx ==resctrl_arch_rmid_idx_encode (RESCTRL_RESERVED_CLOSID , -RESCTRL_RESERVED_RMID )) -return ; - - entry =__rmid_entry (idx); - -if (resctrl_arch_is_llc_occupancy_enabled ()) -add_rmid_to_limbo (entry); -else -list_add_tail (&entry->list, &rmid_free_lru); -} - -static struct mbm_state *get_mbm_state (struct rdt_mon_domain *d,u32 closid, -u32 rmid,enum resctrl_event_id evtid) -{ -u32 idx =resctrl_arch_rmid_idx_encode (closid, rmid); - -switch (evtid) { -case QOS_L3_MBM_TOTAL_EVENT_ID : -return &d->mbm_total[idx]; -case QOS_L3_MBM_LOCAL_EVENT_ID : -return &d->mbm_local[idx]; -default : -return NULL ; - } -} - -static int __mon_event_count (u32 closid,u32 rmid,struct rmid_read *rr) -{ -int cpu =smp_processor_id (); -struct rdt_mon_domain *d; -struct mbm_state *m; -int err, ret; -u64 tval =0 ; - -if (rr->first) { -resctrl_arch_reset_rmid (rr->r, rr->d, closid, rmid, rr->evtid); - m =get_mbm_state (rr->d, closid, rmid, rr->evtid); -if (m) -memset (m,0 ,sizeof (struct mbm_state )); -return 0 ; - } - -if (rr->d) { -/* Reading a single domain, must be on a CPU in that domain. */ -if (!cpumask_test_cpu (cpu, &rr->d->hdr.cpu_mask)) -return -EINVAL ; - rr->err =resctrl_arch_rmid_read (rr->r, rr->d, closid, rmid, - rr->evtid, &tval, rr->arch_mon_ctx); -if (rr->err) -return rr->err; - - rr->val += tval; - -return 0 ; - } - -/* Summing domains that share a cache, must be on a CPU for that cache. */ -if (!cpumask_test_cpu (cpu, &rr->ci->shared_cpu_map)) -return -EINVAL ; - -/* -* Legacy files must report the sum of an event across all -* domains that share the same L3 cache instance. -* Report success if a read from any domain succeeds, -EINVAL -* (translated to "Unavailable" for user space) if reading from -* all domains fail for any reason. -*/ - ret = -EINVAL ; -list_for_each_entry (d, &rr->r->mon_domains, hdr.list) { -if (d->ci->id != rr->ci->id) -continue ; - err =resctrl_arch_rmid_read (rr->r, d, closid, rmid, - rr->evtid, &tval, rr->arch_mon_ctx); -if (!err) { - rr->val += tval; - ret =0 ; - } - } - -if (ret) - rr->err = ret; - -return ret; -} - -/* -* mbm_bw_count() - Update bw count from values previously read by -* __mon_event_count(). -* @closid: The closid used to identify the cached mbm_state. -* @rmid: The rmid used to identify the cached mbm_state. -* @rr: The struct rmid_read populated by __mon_event_count(). -* -* Supporting function to calculate the memory bandwidth -* and delta bandwidth in MBps. The chunks value previously read by -* __mon_event_count() is compared with the chunks value from the previous -* invocation. This must be called once per second to maintain values in MBps. -*/ -static void mbm_bw_count (u32 closid,u32 rmid,struct rmid_read *rr) -{ -u64 cur_bw, bytes, cur_bytes; -struct mbm_state *m; - - m =get_mbm_state (rr->d, closid, rmid, rr->evtid); -if (WARN_ON_ONCE (!m)) -return ; - - cur_bytes = rr->val; - bytes = cur_bytes - m->prev_bw_bytes; - m->prev_bw_bytes = cur_bytes; - - cur_bw = bytes /SZ_1M ; - - m->prev_bw = cur_bw; -} - -/* -* This is scheduled by mon_event_read() to read the CQM/MBM counters -* on a domain. -*/ -void mon_event_count (void *info) -{ -struct rdtgroup *rdtgrp, *entry; -struct rmid_read *rr = info; -struct list_head *head; -int ret; - - rdtgrp = rr->rgrp; - - ret =__mon_event_count (rdtgrp->closid, rdtgrp->mon.rmid, rr); - -/* -* For Ctrl groups read data from child monitor groups and -* add them together. Count events which are read successfully. -* Discard the rmid_read's reporting errors. -*/ - head = &rdtgrp->mon.crdtgrp_list; - -if (rdtgrp->type ==RDTCTRL_GROUP ) { -list_for_each_entry (entry, head, mon.crdtgrp_list) { -if (__mon_event_count (entry->closid, entry->mon.rmid, - rr) ==0 ) - ret =0 ; - } - } - -/* -* __mon_event_count() calls for newly created monitor groups may -* report -EINVAL/Unavailable if the monitor hasn't seen any traffic. -* Discard error if any of the monitor event reads succeeded. -*/ -if (ret ==0 ) - rr->err =0 ; -} - -static struct rdt_ctrl_domain *get_ctrl_domain_from_cpu (int cpu, -struct rdt_resource *r) -{ -struct rdt_ctrl_domain *d; - -lockdep_assert_cpus_held (); - -list_for_each_entry (d, &r->ctrl_domains, hdr.list) { -/* Find the domain that contains this CPU */ -if (cpumask_test_cpu (cpu, &d->hdr.cpu_mask)) -return d; - } - -return NULL ; -} - -/* -* Feedback loop for MBA software controller (mba_sc) -* -* mba_sc is a feedback loop where we periodically read MBM counters and -* adjust the bandwidth percentage values via the IA32_MBA_THRTL_MSRs so -* that: -* -* current bandwidth(cur_bw) < user specified bandwidth(user_bw) -* -* This uses the MBM counters to measure the bandwidth and MBA throttle -* MSRs to control the bandwidth for a particular rdtgrp. It builds on the -* fact that resctrl rdtgroups have both monitoring and control. -* -* The frequency of the checks is 1s and we just tag along the MBM overflow -* timer. Having 1s interval makes the calculation of bandwidth simpler. -* -* Although MBA's goal is to restrict the bandwidth to a maximum, there may -* be a need to increase the bandwidth to avoid unnecessarily restricting -* the L2 <-> L3 traffic. -* -* Since MBA controls the L2 external bandwidth where as MBM measures the -* L3 external bandwidth the following sequence could lead to such a -* situation. -* -* Consider an rdtgroup which had high L3 <-> memory traffic in initial -* phases -> mba_sc kicks in and reduced bandwidth percentage values -> but -* after some time rdtgroup has mostly L2 <-> L3 traffic. -* -* In this case we may restrict the rdtgroup's L2 <-> L3 traffic as its -* throttle MSRs already have low percentage values. To avoid -* unnecessarily restricting such rdtgroups, we also increase the bandwidth. -*/ -static void update_mba_bw (struct rdtgroup *rgrp,struct rdt_mon_domain *dom_mbm) -{ -u32 closid, rmid, cur_msr_val, new_msr_val; -struct mbm_state *pmbm_data, *cmbm_data; -struct rdt_ctrl_domain *dom_mba; -enum resctrl_event_id evt_id; -struct rdt_resource *r_mba; -struct list_head *head; -struct rdtgroup *entry; -u32 cur_bw, user_bw; - - r_mba =resctrl_arch_get_resource (RDT_RESOURCE_MBA ); - evt_id = rgrp->mba_mbps_event; - - closid = rgrp->closid; - rmid = rgrp->mon.rmid; - pmbm_data =get_mbm_state (dom_mbm, closid, rmid, evt_id); -if (WARN_ON_ONCE (!pmbm_data)) -return ; - - dom_mba =get_ctrl_domain_from_cpu (smp_processor_id (), r_mba); -if (!dom_mba) { -pr_warn_once ("Failure to get domain for MBA update\n" ); -return ; - } - - cur_bw = pmbm_data->prev_bw; - user_bw = dom_mba->mbps_val[closid]; - -/* MBA resource doesn't support CDP */ - cur_msr_val =resctrl_arch_get_config (r_mba, dom_mba, closid,CDP_NONE ); - -/* -* For Ctrl groups read data from child monitor groups. -*/ - head = &rgrp->mon.crdtgrp_list; -list_for_each_entry (entry, head, mon.crdtgrp_list) { - cmbm_data =get_mbm_state (dom_mbm, entry->closid, entry->mon.rmid, evt_id); -if (WARN_ON_ONCE (!cmbm_data)) -return ; - cur_bw += cmbm_data->prev_bw; - } - -/* -* Scale up/down the bandwidth linearly for the ctrl group. The -* bandwidth step is the bandwidth granularity specified by the -* hardware. -* Always increase throttling if current bandwidth is above the -* target set by user. -* But avoid thrashing up and down on every poll by checking -* whether a decrease in throttling is likely to push the group -* back over target. E.g. if currently throttling to 30% of bandwidth -* on a system with 10% granularity steps, check whether moving to -* 40% would go past the limit by multiplying current bandwidth by -* "(30 + 10) / 30". -*/ -if (cur_msr_val > r_mba->membw.min_bw && user_bw < cur_bw) { - new_msr_val = cur_msr_val - r_mba->membw.bw_gran; - }else if (cur_msr_val <MAX_MBA_BW && - (user_bw > (cur_bw * (cur_msr_val + r_mba->membw.min_bw) / cur_msr_val))) { - new_msr_val = cur_msr_val + r_mba->membw.bw_gran; - }else { -return ; - } - -resctrl_arch_update_one (r_mba, dom_mba, closid,CDP_NONE , new_msr_val); -} - -static void mbm_update_one_event (struct rdt_resource *r,struct rdt_mon_domain *d, -u32 closid,u32 rmid,enum resctrl_event_id evtid) -{ -struct rmid_read rr = {0 }; - - rr.r = r; - rr.d = d; - rr.evtid = evtid; - rr.arch_mon_ctx =resctrl_arch_mon_ctx_alloc (rr.r, rr.evtid); -if (IS_ERR (rr.arch_mon_ctx)) { -pr_warn_ratelimited ("Failed to allocate monitor context: %ld" , -PTR_ERR (rr.arch_mon_ctx)); -return ; - } - -__mon_event_count (closid, rmid, &rr); - -/* -* If the software controller is enabled, compute the -* bandwidth for this event id. -*/ -if (is_mba_sc (NULL )) -mbm_bw_count (closid, rmid, &rr); - -resctrl_arch_mon_ctx_free (rr.r, rr.evtid, rr.arch_mon_ctx); -} - -static void mbm_update (struct rdt_resource *r,struct rdt_mon_domain *d, -u32 closid,u32 rmid) -{ -/* -* This is protected from concurrent reads from user as both -* the user and overflow handler hold the global mutex. -*/ -if (resctrl_arch_is_mbm_total_enabled ()) -mbm_update_one_event (r, d, closid, rmid,QOS_L3_MBM_TOTAL_EVENT_ID ); - -if (resctrl_arch_is_mbm_local_enabled ()) -mbm_update_one_event (r, d, closid, rmid,QOS_L3_MBM_LOCAL_EVENT_ID ); -} - -/* -* Handler to scan the limbo list and move the RMIDs -* to free list whose occupancy < threshold_occupancy. -*/ -void cqm_handle_limbo (struct work_struct *work) -{ -unsigned long delay =msecs_to_jiffies (CQM_LIMBOCHECK_INTERVAL ); -struct rdt_mon_domain *d; - -cpus_read_lock (); -mutex_lock (&rdtgroup_mutex); - - d = container_of(work, struct rdt_mon_domain, cqm_limbo.work); - -__check_limbo (d, false); - -if (has_busy_rmid (d)) { - d->cqm_work_cpu =cpumask_any_housekeeping (&d->hdr.cpu_mask, -RESCTRL_PICK_ANY_CPU ); -schedule_delayed_work_on (d->cqm_work_cpu, &d->cqm_limbo, - delay); - } - -mutex_unlock (&rdtgroup_mutex); -cpus_read_unlock (); -} - -/** -* cqm_setup_limbo_handler() - Schedule the limbo handler to run for this -* domain. -* @dom: The domain the limbo handler should run for. -* @delay_ms: How far in the future the handler should run. -* @exclude_cpu: Which CPU the handler should not run on, -* RESCTRL_PICK_ANY_CPU to pick any CPU. -*/ -void cqm_setup_limbo_handler (struct rdt_mon_domain *dom,unsigned long delay_ms, -int exclude_cpu) -{ -unsigned long delay =msecs_to_jiffies (delay_ms); -int cpu; - - cpu =cpumask_any_housekeeping (&dom->hdr.cpu_mask, exclude_cpu); - dom->cqm_work_cpu = cpu; - -if (cpu < nr_cpu_ids) -schedule_delayed_work_on (cpu, &dom->cqm_limbo, delay); -} - -void mbm_handle_overflow (struct work_struct *work) -{ -unsigned long delay =msecs_to_jiffies (MBM_OVERFLOW_INTERVAL ); -struct rdtgroup *prgrp, *crgrp; -struct rdt_mon_domain *d; -struct list_head *head; -struct rdt_resource *r; - -cpus_read_lock (); -mutex_lock (&rdtgroup_mutex); - -/* -* If the filesystem has been unmounted this work no longer needs to -* run. -*/ -if (!resctrl_mounted || !resctrl_arch_mon_capable ()) - goto out_unlock; - - r =resctrl_arch_get_resource (RDT_RESOURCE_L3 ); - d = container_of(work, struct rdt_mon_domain, mbm_over.work); - -list_for_each_entry (prgrp, &rdt_all_groups, rdtgroup_list) { -mbm_update (r, d, prgrp->closid, prgrp->mon.rmid); - - head = &prgrp->mon.crdtgrp_list; -list_for_each_entry (crgrp, head, mon.crdtgrp_list) -mbm_update (r, d, crgrp->closid, crgrp->mon.rmid); - -if (is_mba_sc (NULL )) -update_mba_bw (prgrp, d); - } - -/* -* Re-check for housekeeping CPUs. This allows the overflow handler to -* move off a nohz_full CPU quickly. -*/ - d->mbm_work_cpu =cpumask_any_housekeeping (&d->hdr.cpu_mask, -RESCTRL_PICK_ANY_CPU ); -schedule_delayed_work_on (d->mbm_work_cpu, &d->mbm_over, delay); - -out_unlock: -mutex_unlock (&rdtgroup_mutex); -cpus_read_unlock (); -} - -/** -* mbm_setup_overflow_handler() - Schedule the overflow handler to run for this -* domain. -* @dom: The domain the overflow handler should run for. -* @delay_ms: How far in the future the handler should run. -* @exclude_cpu: Which CPU the handler should not run on, -* RESCTRL_PICK_ANY_CPU to pick any CPU. -*/ -void mbm_setup_overflow_handler (struct rdt_mon_domain *dom,unsigned long delay_ms, -int exclude_cpu) -{ -unsigned long delay =msecs_to_jiffies (delay_ms); -int cpu; - -/* -* When a domain comes online there is no guarantee the filesystem is -* mounted. If not, there is no need to catch counter overflow. -*/ -if (!resctrl_mounted || !resctrl_arch_mon_capable ()) -return ; - cpu =cpumask_any_housekeeping (&dom->hdr.cpu_mask, exclude_cpu); - dom->mbm_work_cpu = cpu; - -if (cpu < nr_cpu_ids) -schedule_delayed_work_on (cpu, &dom->mbm_over, delay); -} - -static int dom_data_init (struct rdt_resource *r) -{ -u32 idx_limit =resctrl_arch_system_num_rmid_idx (); -u32 num_closid =resctrl_arch_get_num_closid (r); -struct rmid_entry *entry =NULL ; -int err =0 , i; -u32 idx; - -mutex_lock (&rdtgroup_mutex); -if (IS_ENABLED (CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID )) { -u32 *tmp; - -/* -* If the architecture hasn't provided a sanitised value here, -* this may result in larger arrays than necessary. Resctrl will -* use a smaller system wide value based on the resources in -* use. -*/ - tmp =kcalloc (num_closid,sizeof (*tmp),GFP_KERNEL ); -if (!tmp) { - err = -ENOMEM ; - goto out_unlock; - } - - closid_num_dirty_rmid = tmp; - } - - rmid_ptrs =kcalloc (idx_limit,sizeof (struct rmid_entry ),GFP_KERNEL ); -if (!rmid_ptrs) { -if (IS_ENABLED (CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID )) { -kfree (closid_num_dirty_rmid); - closid_num_dirty_rmid =NULL ; - } - err = -ENOMEM ; - goto out_unlock; - } - -for (i =0 ; i < idx_limit; i++) { - entry = &rmid_ptrs[i]; -INIT_LIST_HEAD (&entry->list); - -resctrl_arch_rmid_idx_decode (i, &entry->closid, &entry->rmid); -list_add_tail (&entry->list, &rmid_free_lru); - } - -/* -* RESCTRL_RESERVED_CLOSID and RESCTRL_RESERVED_RMID are special and -* are always allocated. These are used for the rdtgroup_default -* control group, which will be setup later in resctrl_init(). -*/ - idx =resctrl_arch_rmid_idx_encode (RESCTRL_RESERVED_CLOSID , -RESCTRL_RESERVED_RMID ); - entry =__rmid_entry (idx); -list_del (&entry->list); - -out_unlock: -mutex_unlock (&rdtgroup_mutex); - -return err; -} - -static void dom_data_exit (struct rdt_resource *r) -{ -mutex_lock (&rdtgroup_mutex); - -if (!r->mon_capable) - goto out_unlock; - -if (IS_ENABLED (CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID )) { -kfree (closid_num_dirty_rmid); - closid_num_dirty_rmid =NULL ; - } - -kfree (rmid_ptrs); - rmid_ptrs =NULL ; - -out_unlock: -mutex_unlock (&rdtgroup_mutex); -} - -static struct mon_evt llc_occupancy_event = { - .name ="llc_occupancy" , - .evtid =QOS_L3_OCCUP_EVENT_ID , -}; - -static struct mon_evt mbm_total_event = { - .name ="mbm_total_bytes" , - .evtid =QOS_L3_MBM_TOTAL_EVENT_ID , -}; - -static struct mon_evt mbm_local_event = { - .name ="mbm_local_bytes" , - .evtid =QOS_L3_MBM_LOCAL_EVENT_ID , -}; - -/* -* Initialize the event list for the resource. -* -* Note that MBM events are also part of RDT_RESOURCE_L3 resource -* because as per the SDM the total and local memory bandwidth -* are enumerated as part of L3 monitoring. -* -* mon_put_default_kn_priv_all() also assumes monitor events are only supported -* on the L3 resource. -*/ -static void l3_mon_evt_init (struct rdt_resource *r) -{ -INIT_LIST_HEAD (&r->evt_list); - -if (resctrl_arch_is_llc_occupancy_enabled ()) -list_add_tail (&llc_occupancy_event.list, &r->evt_list); -if (resctrl_arch_is_mbm_total_enabled ()) -list_add_tail (&mbm_total_event.list, &r->evt_list); -if (resctrl_arch_is_mbm_local_enabled ()) -list_add_tail (&mbm_local_event.list, &r->evt_list); -} -/* * The power-on reset value of MSR_RMID_SNC_CONFIG is 0x1 * which indicates that RMIDs are configured in legacy mode. @@ -1197,51 +348,6 @@ static __init int snc_get_config(void)return ret; } -/** -* resctrl_mon_resource_init() - Initialise global monitoring structures. -* -* Allocate and initialise global monitor resources that do not belong to a -* specific domain. i.e. the rmid_ptrs[] used for the limbo and free lists. -* Called once during boot after the struct rdt_resource's have been configured -* but before the filesystem is mounted. -* Resctrl's cpuhp callbacks may be called before this point to bring a domain -* online. -* -* Returns 0 for success, or -ENOMEM. -*/ -int resctrl_mon_resource_init (void ) -{ -struct rdt_resource *r =resctrl_arch_get_resource (RDT_RESOURCE_L3 ); -int ret; - -if (!r->mon_capable) -return 0 ; - - ret =dom_data_init (r); -if (ret) -return ret; - -l3_mon_evt_init (r); - -if (resctrl_arch_is_evt_configurable (QOS_L3_MBM_TOTAL_EVENT_ID )) { - mbm_total_event.configurable = true; -resctrl_file_fflags_init ("mbm_total_bytes_config" , -RFTYPE_MON_INFO |RFTYPE_RES_CACHE ); - } -if (resctrl_arch_is_evt_configurable (QOS_L3_MBM_LOCAL_EVENT_ID )) { - mbm_local_event.configurable = true; -resctrl_file_fflags_init ("mbm_local_bytes_config" , -RFTYPE_MON_INFO |RFTYPE_RES_CACHE ); - } - -if (resctrl_arch_is_mbm_local_enabled ()) - mba_mbps_default_event =QOS_L3_MBM_LOCAL_EVENT_ID ; -else if (resctrl_arch_is_mbm_total_enabled ()) - mba_mbps_default_event =QOS_L3_MBM_TOTAL_EVENT_ID ; - -return 0 ; -} -int __init rdt_get_mon_l3_config (struct rdt_resource *r) {unsigned int mbm_offset = boot_cpu_data.x86_cache_mbm_width_offset;@@ -1289,13 +395,6 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)return 0 ; } -void resctrl_mon_resource_exit (void ) -{ -struct rdt_resource *r =resctrl_arch_get_resource (RDT_RESOURCE_L3 ); - -dom_data_exit (r); -} -void __init intel_rdt_mbm_apply_quirk (void ) {int cf_index;arch/x86/kernel/cpu/resctrl/monitor_trace.h +0
-14@@ -7,25 +7,11 @@#include <linux/tracepoint.h> -TRACE_EVENT (mon_llc_occupancy_limbo, - TP_PROTO(u32 ctrl_hw_id, u32 mon_hw_id, int domain_id, u64 llc_occupancy_bytes), -TP_ARGS (ctrl_hw_id, mon_hw_id, domain_id, llc_occupancy_bytes), - TP_STRUCT__entry(__field(u32, ctrl_hw_id) - __field(u32, mon_hw_id) - __field(int, domain_id) -__field (u64, llc_occupancy_bytes)), - TP_fast_assign(__entry->ctrl_hw_id = ctrl_hw_id; - __entry->mon_hw_id = mon_hw_id; - __entry->domain_id = domain_id; - __entry->llc_occupancy_bytes = llc_occupancy_bytes;), -TP_printk ("ctrl_hw_id=%u mon_hw_id=%u domain_id=%d llc_occupancy_bytes=%llu" , - __entry->ctrl_hw_id, __entry->mon_hw_id, __entry->domain_id, - __entry->llc_occupancy_bytes)
arch/x86/kernel/cpu/resctrl/monitor_trace.h line 17
Quoted 10 lines
arch/x86/kernel/cpu/resctrl/monitor_trace.h +2
-2- ); -#endif /* _FS_RESCTRL_MONITOR_TRACE_H */ #undef TRACE_INCLUDE_PATH#define TRACE_INCLUDE_PATH . +#define TRACE_INCLUDE_FILE monitor_trace +#include <trace/define_trace.h>
Similarly this file doesn't define any trace event. make W=1 complains it:
from arch/x86/kernel/cpu/resctrl/monitor.c:32:./include/trace/stages/init.h:2:23: error: ‘str__resctrl__trace_system_name’ defined but not used [-Werror=unused-const-variable=] 2 | #define __app__(x, y) str__##x##y
| ^~~~~./include/trace/stages/init.h:3:21: note: in expansion of macro ‘__app__’
3 | #define __app(x, y) __app__(x, y)
| ^~~~~~~./include/trace/stages/init.h:5:29: note: in expansion of macro ‘__app’
5 | #define TRACE_SYSTEM_STRING __app(TRACE_SYSTEM_VAR,__trace_system_name)
| ^~~~~./include/trace/stages/init.h:8:27: note: in expansion of macro ‘TRACE_SYSTEM_STRING’
8 | static const char TRACE_SYSTEM_STRING[] = \
| ^~~~~~~~~~~~~~~~~~~./include/trace/stages/init.h:11:1: note: in expansion of macro ‘TRACE_MAKE_SYSTEM_STR’
11 | TRACE_MAKE_SYSTEM_STR();
| ^~~~~~~~~~~~~~~~~~~~~
CC fs/proc/consoles.o
cc1: all warnings being treated as errors
make[6]: *** [scripts/Makefile.build:207: arch/x86/kernel/cpu/resctrl/monitor.o] Error 1
make[6]: *** Waiting for unfinished jobs....
The above two compilation errors only happen when first 45 patches are applied. The whole patch set won't have the errors because patch 46 removes these empty trace events.
The fix is simple: just merge this patch and patch 46 together. Then there is no empty trace event in trace.h files and thus no compilation errors.
Thanks.
-Fenghua
James Morse
reviewerRe: [PATCH v7 45/49] x86,fs/resctrl: Move the resctrl filesystem code to live in /fs/resctrl
Hi Fenghua,
Quoted 10 lines · Fenghua Yu
Quoted 9 lines · James Morse
Resctrl is a filesystem interface to hardware that provides cache allocation policy and bandwidth control for groups of tasks or CPUs.
To support more than one architecture, resctrl needs to live in /fs/.
Move the code that is concerned with the filesystem interface to /fs/resctrl.
14 files changed, 7535 insertions(+), 7285 deletions(-)
(this patch is large - please trim it in your reply!)
[...]
Quoted 56 lines
Quoted 22 lines
arch/x86/kernel/cpu/resctrl/ renamed from arch/x86/kernel/cpu/resctrl/monitor_trace.h +0
-0
monitor_trace.h
indexade67daf42c2..b5a142dd0f0e100644arch/x86/kernel/cpu/resctrl/monitor_trace.h +0
-0@@ -7,2m5 +7,11 @@
#include <linux/tracepoint.h>
-TRACE_EVENT(mon_llc_occupancy_limbo,
-TP_PROTO(u32 ctrl_hw_id, u32 mon_hw_id, int domain_id, u64 llc_occupancy_bytes), -TP_ARGS(ctrl_hw_id, mon_hw_id, domain_id, llc_occupancy_bytes),
- TP_STRUCT__entry(__field(u32,ctrl_hw_id)
-__field(u32, mon_hw_id)
-__field(int, domain_id)
-__field(u64, llc_occupancy_bytes)),
- TP_fast_assign(__entry->ctrl_hw_id =ctrl_hw_id;
-__entry->mon_hw_id=mon_hw_id;
-__entry->domain_id=domain_id;
-__entry->llc_occupancy_bytes=llc_occupancy_bytes;),
- TP_printk("ctrl_hw_id=%u mon_hw_id=%u domain_id=%d llc_occupancy_bytes=%llu", -__entry->ctrl_hw_id,__entry->mon_hw_id,__entry->domain_id, -__entry->llc_occupancy_bytes)
- );Quoted 8 lines
-
#endif /*_FS_RESCTRL_MONITOR_TRACE_H*/
#undefTRACE_INCLUDE_PATH
#defineTRACE_INCLUDE_PATH.
+
#defineTRACE_INCLUDE_FILEmonitor_trace
+
#include <trace/define_trace.h>Similarly this file doesn't define any trace event. make W=1 complains it:
from
arch/x86/kernel/cpu/resctrl/monitor.c:32:./include/trace/stages/init.h:2:23: error: ‘str__resctrl__trace_system_name’ defined but not used [-Werror=unused-const-variable=]
2 | #define__app__(x, y)str__##x##y
| ^~~~~./include/trace/stages/init.h:3:21: note: in expansion of macro ‘__app__’ 3 | #define__app(x, y)__app__(x, y)
| ^~~~~~~./include/trace/stages/init.h:5:29: note: in expansion of macro ‘__app’
5 | #defineTRACE_SYSTEM_STRING__app(TRACE_SYSTEM_VAR,__trace_system_name)| ^~~~~./include/trace/stages/init.h:8:27: note: in expansion of macro ‘TRACE_SYSTEM_STRING’ 8 | static const char TRACE_SYSTEM_STRING[] = \
| ^~~~~~~~~~~~~~~~~~~./include/trace/stages/init.h:11:1: note: in expansion of macro ‘TRACE_MAKE_SYSTEM_STR’ 11 |TRACE_MAKE_SYSTEM_STR();
| ^~~~~~~~~~~~~~~~~~~~~
CCfs/proc/consoles.o
cc1: all warnings being treated as errors
make[6]: *** [scripts/Makefile.build:207:arch/x86/kernel/cpu/resctrl/monitor.o] Error 1 make[6]: *** Waiting for unfinished jobs....
Quoted 5 lines
The above two compilation errors only happen when first 45 patches are applied. The whole patch set won't have the errors because patch 46 removes these empty trace events.
The fix is simple: just merge this patch and patch 46 together. Then there is no empty trace event in
trace.hfiles and thus no compilation errors.
The intent is that these last few patches are merged together by the person that applies them. I thought I'd described that in the cover-letter, but that text got lost.
It's like this because this patch is too large to review - but it is generated by a script. If I merge these patches together, then its even harder to have confidence that some hunk isn't getting reverted to an older version.
Thanks,
James
Re: [PATCH v7 45/49] x86,fs/resctrl: Move the resctrl filesystem code to live in /fs/resctrl
In reply to James MorseHi, James,
fs/resctrl/pseudo_lock_trace.h
Quoted 10,790 lines · James Morse
Resctrl is a filesystem interface to hardware that provides cache allocation policy and bandwidth control for groups of tasks or CPUs.
To support more than one architecture, resctrl needs to live in /fs/.
Move the code that is concerned with the filesystem interface to /fs/resctrl.
Signed-off-by James Morse <[email protected]>---
Changes since v6:
* This patch is new.--- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 636 --- arch/x86/kernel/cpu/resctrl/internal.h | 373 +- arch/x86/kernel/cpu/resctrl/monitor.c | 905 +--- arch/x86/kernel/cpu/resctrl/monitor_trace.h | 18 +- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 1074 +--- .../kernel/cpu/resctrl/pseudo_lock_trace.h | 2 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4294 +--------------- fs/resctrl/ctrlmondata.c | 660 +++ fs/resctrl/internal.h | 435 ++ fs/resctrl/monitor.c | 935 ++++ fs/resctrl/monitor_trace.h | 33 + fs/resctrl/pseudo_lock.c | 1109 +++++ fs/resctrl/pseudo_lock_trace.h | 17 + fs/resctrl/rdtgroup.c | 4329 +++++++++++++++++ 14 files changed, 7535 insertions(+), 7285 deletions(-)arch/x86/kernel/cpu/resctrl/ctrlmondata.c +0
-636@@ -23,270 +23,6 @@#include "internal.h" -struct rdt_parse_data { -struct rdtgroup *rdtgrp; -char *buf; -}; - -typedef int (ctrlval_parser_t )(struct rdt_parse_data *data, -struct resctrl_schema *s, -struct rdt_ctrl_domain *d); - -/* -* Check whether MBA bandwidth percentage value is correct. The value is -* checked against the minimum and max bandwidth values specified by the -* hardware. The allocated bandwidth percentage is rounded to the next -* control step available on the hardware. -*/ -static bool bw_validate (char *buf,u32 *data,struct rdt_resource *r) -{ -int ret; -u32 bw; - -/* -* Only linear delay values is supported for current Intel SKUs. -*/ -if (!r->membw.delay_linear && r->membw.arch_needs_linear) { -rdt_last_cmd_puts ("No support for non-linear MB domains\n" ); -return false; - } - - ret =kstrtou32 (buf,10 , &bw); -if (ret) { -rdt_last_cmd_printf ("Invalid MB value %s\n" , buf); -return false; - } - -/* Nothing else to do if software controller is enabled. */ -if (is_mba_sc (r)) { - *data = bw; -return true; - } - -if (bw < r->membw.min_bw || bw > r->membw.max_bw) { -rdt_last_cmd_printf ("MB value %u out of range [%d,%d]\n" , - bw, r->membw.min_bw, r->membw.max_bw); -return false; - } - - *data =roundup (bw, (unsigned long )r->membw.bw_gran); -return true; -} - -static int parse_bw (struct rdt_parse_data *data,struct resctrl_schema *s, -struct rdt_ctrl_domain *d) -{ -struct resctrl_staged_config *cfg; -u32 closid = data->rdtgrp->closid; -struct rdt_resource *r = s->res; -u32 bw_val; - - cfg = &d->staged_config[s->conf_type]; -if (cfg->have_new_ctrl) { -rdt_last_cmd_printf ("Duplicate domain %d\n" , d->hdr.id); -return -EINVAL ; - } - -if (!bw_validate (data->buf, &bw_val, r)) -return -EINVAL ; - -if (is_mba_sc (r)) { - d->mbps_val[closid] = bw_val; -return 0 ; - } - - cfg->new_ctrl = bw_val; - cfg->have_new_ctrl = true; - -return 0 ; -} - -/* -* Check whether a cache bit mask is valid. -* On Intel CPUs, non-contiguous 1s value support is indicated by CPUID: -* - CPUID.0x10.1:ECX[3]: L3 non-contiguous 1s value supported if 1 -* - CPUID.0x10.2:ECX[3]: L2 non-contiguous 1s value supported if 1 -* -* Haswell does not support a non-contiguous 1s value and additionally -* requires at least two bits set. -* AMD allows non-contiguous bitmasks. -*/ -static bool cbm_validate (char *buf,u32 *data,struct rdt_resource *r) -{ -u32 supported_bits =BIT_MASK (r->cache.cbm_len) -1 ; -unsigned int cbm_len = r->cache.cbm_len; -unsigned long first_bit, zero_bit, val; -int ret; - - ret =kstrtoul (buf,16 , &val); -if (ret) { -rdt_last_cmd_printf ("Non-hex character in the mask %s\n" , buf); -return false; - } - -if ((r->cache.min_cbm_bits >0 && val ==0 ) || val > supported_bits) { -rdt_last_cmd_puts ("Mask out of range\n" ); -return false; - } - - first_bit =find_first_bit (&val, cbm_len); - zero_bit =find_next_zero_bit (&val, cbm_len, first_bit); - -/* Are non-contiguous bitmasks allowed? */ -if (!r->cache.arch_has_sparse_bitmasks && - (find_next_bit (&val, cbm_len, zero_bit) < cbm_len)) { -rdt_last_cmd_printf ("The mask %lx has non-consecutive 1-bits\n" , val); -return false; - } - -if ((zero_bit - first_bit) < r->cache.min_cbm_bits) { -rdt_last_cmd_printf ("Need at least %d bits in the mask\n" , - r->cache.min_cbm_bits); -return false; - } - - *data = val; -return true; -} - -/* -* Read one cache bit mask (hex). Check that it is valid for the current -* resource type. -*/ -static int parse_cbm (struct rdt_parse_data *data,struct resctrl_schema *s, -struct rdt_ctrl_domain *d) -{ -struct rdtgroup *rdtgrp = data->rdtgrp; -struct resctrl_staged_config *cfg; -struct rdt_resource *r = s->res; -u32 cbm_val; - - cfg = &d->staged_config[s->conf_type]; -if (cfg->have_new_ctrl) { -rdt_last_cmd_printf ("Duplicate domain %d\n" , d->hdr.id); -return -EINVAL ; - } - -/* -* Cannot set up more than one pseudo-locked region in a cache -* hierarchy. -*/ -if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKSETUP && -rdtgroup_pseudo_locked_in_hierarchy (d)) { -rdt_last_cmd_puts ("Pseudo-locked region in hierarchy\n" ); -return -EINVAL ; - } - -if (!cbm_validate (data->buf, &cbm_val, r)) -return -EINVAL ; - -if ((rdtgrp->mode ==RDT_MODE_EXCLUSIVE || - rdtgrp->mode ==RDT_MODE_SHAREABLE ) && -rdtgroup_cbm_overlaps_pseudo_locked (d, cbm_val)) { -rdt_last_cmd_puts ("CBM overlaps with pseudo-locked region\n" ); -return -EINVAL ; - } - -/* -* The CBM may not overlap with the CBM of another closid if -* either is exclusive. -*/ -if (rdtgroup_cbm_overlaps (s, d, cbm_val, rdtgrp->closid, true)) { -rdt_last_cmd_puts ("Overlaps with exclusive group\n" ); -return -EINVAL ; - } - -if (rdtgroup_cbm_overlaps (s, d, cbm_val, rdtgrp->closid, false)) { -if (rdtgrp->mode ==RDT_MODE_EXCLUSIVE || - rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKSETUP ) { -rdt_last_cmd_puts ("Overlaps with other group\n" ); -return -EINVAL ; - } - } - - cfg->new_ctrl = cbm_val; - cfg->have_new_ctrl = true; - -return 0 ; -} - -/* -* For each domain in this resource we expect to find a series of: -* id=mask -* separated by ";". The "id" is in decimal, and must match one of -* the "id"s for this resource. -*/ -static int parse_line (char *line,struct resctrl_schema *s, -struct rdtgroup *rdtgrp) -{ -enum resctrl_conf_type t = s->conf_type; -ctrlval_parser_t *parse_ctrlval =NULL ; -struct resctrl_staged_config *cfg; -struct rdt_resource *r = s->res; -struct rdt_parse_data data; -struct rdt_ctrl_domain *d; -char *dom =NULL , *id; -unsigned long dom_id; - -/* Walking r->domains, ensure it can't race with cpuhp */ -lockdep_assert_cpus_held (); - -switch (r->schema_fmt) { -case RESCTRL_SCHEMA_BITMAP : - parse_ctrlval = &parse_cbm; -break ; -case RESCTRL_SCHEMA_RANGE : - parse_ctrlval = &parse_bw; -break ; - } - -if (WARN_ON_ONCE (!parse_ctrlval)) -return -EINVAL ; - -if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKSETUP && - (r->rid ==RDT_RESOURCE_MBA || r->rid ==RDT_RESOURCE_SMBA )) { -rdt_last_cmd_puts ("Cannot pseudo-lock MBA resource\n" ); -return -EINVAL ; - } - -next: -if (!line || line[0 ] =='\0' ) -return 0 ; - dom =strsep (&line,";" ); - id =strsep (&dom,"=" ); -if (!dom ||kstrtoul (id,10 , &dom_id)) { -rdt_last_cmd_puts ("Missing '=' or non-numeric domain\n" ); -return -EINVAL ; - } - dom =strim (dom); -list_for_each_entry (d, &r->ctrl_domains, hdr.list) { -if (d->hdr.id == dom_id) { - data.buf = dom; - data.rdtgrp = rdtgrp; -if (parse_ctrlval (&data, s, d)) -return -EINVAL ; -if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKSETUP ) { - cfg = &d->staged_config[t]; -/* -* In pseudo-locking setup mode and just -* parsed a valid CBM that should be -* pseudo-locked. Only one locked region per -* resource group and domain so just do -* the required initialization for single -* region and return. -*/ - rdtgrp->plr->s = s; - rdtgrp->plr->d = d; - rdtgrp->plr->cbm = cfg->new_ctrl; - d->plr = rdtgrp->plr; -return 0 ; - } - goto next; - } - } -return -EINVAL ; -} -int resctrl_arch_update_one (struct rdt_resource *r,struct rdt_ctrl_domain *d,u32 closid,enum resctrl_conf_type t,u32 cfg_val) {@@ -351,100 +87,6 @@ int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid)return 0 ; } -static int rdtgroup_parse_resource (char *resname,char *tok, -struct rdtgroup *rdtgrp) -{ -struct resctrl_schema *s; - -list_for_each_entry (s, &resctrl_schema_all, list) { -if (!strcmp (resname, s->name) && rdtgrp->closid < s->num_closid) -return parse_line (tok, s, rdtgrp); - } -rdt_last_cmd_printf ("Unknown or unsupported resource name '%s'\n" , resname); -return -EINVAL ; -} - -ssize_t rdtgroup_schemata_write (struct kernfs_open_file *of, -char *buf,size_t nbytes,loff_t off) -{ -struct resctrl_schema *s; -struct rdtgroup *rdtgrp; -struct rdt_resource *r; -char *tok, *resname; -int ret =0 ; - -/* Valid input requires a trailing newline */ -if (nbytes ==0 || buf[nbytes -1 ] !='\n' ) -return -EINVAL ; - buf[nbytes -1 ] ='\0' ; - - rdtgrp =rdtgroup_kn_lock_live (of->kn); -if (!rdtgrp) { -rdtgroup_kn_unlock (of->kn); -return -ENOENT ; - } -rdt_last_cmd_clear (); - -/* -* No changes to pseudo-locked region allowed. It has to be removed -* and re-created instead. -*/ -if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKED ) { - ret = -EINVAL ; -rdt_last_cmd_puts ("Resource group is pseudo-locked\n" ); - goto out; - } - -rdt_staged_configs_clear (); - -while ((tok =strsep (&buf,"\n" )) !=NULL ) { - resname =strim (strsep (&tok,":" )); -if (!tok) { -rdt_last_cmd_puts ("Missing ':'\n" ); - ret = -EINVAL ; - goto out; - } -if (tok[0 ] =='\0' ) { -rdt_last_cmd_printf ("Missing '%s' value\n" , resname); - ret = -EINVAL ; - goto out; - } - ret =rdtgroup_parse_resource (resname, tok, rdtgrp); -if (ret) - goto out; - } - -list_for_each_entry (s, &resctrl_schema_all, list) { - r = s->res; - -/* -* Writes to mba_sc resources update the software controller, -* not the control MSR. -*/ -if (is_mba_sc (r)) -continue ; - - ret =resctrl_arch_update_domains (r, rdtgrp->closid); -if (ret) - goto out; - } - -if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKSETUP ) { -/* -* If pseudo-locking fails we keep the resource group in -* mode RDT_MODE_PSEUDO_LOCKSETUP with its class of service -* active and updated for just the domain the pseudo-locked -* region was requested for. -*/ - ret =rdtgroup_pseudo_lock_create (rdtgrp); - } - -out: -rdt_staged_configs_clear (); -rdtgroup_kn_unlock (of->kn); -return ret ?: nbytes; -} -u32 resctrl_arch_get_config (struct rdt_resource *r,struct rdt_ctrl_domain *d,u32 closid,enum resctrl_conf_type type) {@@ -453,281 +95,3 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain *d,return hw_dom->ctrl_val[idx]; } - -static void show_doms (struct seq_file *s,struct resctrl_schema *schema,int closid) -{ -struct rdt_resource *r = schema->res; -struct rdt_ctrl_domain *dom; -bool sep = false; -u32 ctrl_val; - -/* Walking r->domains, ensure it can't race with cpuhp */ -lockdep_assert_cpus_held (); - -seq_printf (s,"%*s:" , max_name_width, schema->name); -list_for_each_entry (dom, &r->ctrl_domains, hdr.list) { -if (sep) -seq_puts (s,";" ); - -if (is_mba_sc (r)) - ctrl_val = dom->mbps_val[closid]; -else - ctrl_val =resctrl_arch_get_config (r, dom, closid, - schema->conf_type); - -seq_printf (s, schema->fmt_str, dom->hdr.id, ctrl_val); - sep = true; - } -seq_puts (s,"\n" ); -} - -int rdtgroup_schemata_show (struct kernfs_open_file *of, -struct seq_file *s,void *v) -{ -struct resctrl_schema *schema; -struct rdtgroup *rdtgrp; -int ret =0 ; -u32 closid; - - rdtgrp =rdtgroup_kn_lock_live (of->kn); -if (rdtgrp) { -if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKSETUP ) { -list_for_each_entry (schema, &resctrl_schema_all, list) { -seq_printf (s,"%s:uninitialized\n" , schema->name); - } - }else if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKED ) { -if (!rdtgrp->plr->d) { -rdt_last_cmd_clear (); -rdt_last_cmd_puts ("Cache domain offline\n" ); - ret = -ENODEV ; - }else { -seq_printf (s,"%s:%d=%x\n" , - rdtgrp->plr->s->res->name, - rdtgrp->plr->d->hdr.id, - rdtgrp->plr->cbm); - } - }else { - closid = rdtgrp->closid; -list_for_each_entry (schema, &resctrl_schema_all, list) { -if (closid < schema->num_closid) -show_doms (s, schema, closid); - } - } - }else { - ret = -ENOENT ; - } -rdtgroup_kn_unlock (of->kn); -return ret; -} - -static int smp_mon_event_count (void *arg) -{ -mon_event_count (arg); - -return 0 ; -} - -ssize_t rdtgroup_mba_mbps_event_write (struct kernfs_open_file *of, -char *buf,size_t nbytes,loff_t off) -{ -struct rdtgroup *rdtgrp; -int ret =0 ; - -/* Valid input requires a trailing newline */ -if (nbytes ==0 || buf[nbytes -1 ] !='\n' ) -return -EINVAL ; - buf[nbytes -1 ] ='\0' ; - - rdtgrp =rdtgroup_kn_lock_live (of->kn); -if (!rdtgrp) { -rdtgroup_kn_unlock (of->kn); -return -ENOENT ; - } -rdt_last_cmd_clear (); - -if (!strcmp (buf,"mbm_local_bytes" )) { -if (resctrl_arch_is_mbm_local_enabled ()) - rdtgrp->mba_mbps_event =QOS_L3_MBM_LOCAL_EVENT_ID ; -else - ret = -EINVAL ; - }else if (!strcmp (buf,"mbm_total_bytes" )) { -if (resctrl_arch_is_mbm_total_enabled ()) - rdtgrp->mba_mbps_event =QOS_L3_MBM_TOTAL_EVENT_ID ; -else - ret = -EINVAL ; - }else { - ret = -EINVAL ; - } - -if (ret) -rdt_last_cmd_printf ("Unsupported event id '%s'\n" , buf); - -rdtgroup_kn_unlock (of->kn); - -return ret ?: nbytes; -} - -int rdtgroup_mba_mbps_event_show (struct kernfs_open_file *of, -struct seq_file *s,void *v) -{ -struct rdtgroup *rdtgrp; -int ret =0 ; - - rdtgrp =rdtgroup_kn_lock_live (of->kn); - -if (rdtgrp) { -switch (rdtgrp->mba_mbps_event) { -case QOS_L3_MBM_LOCAL_EVENT_ID : -seq_puts (s,"mbm_local_bytes\n" ); -break ; -case QOS_L3_MBM_TOTAL_EVENT_ID : -seq_puts (s,"mbm_total_bytes\n" ); -break ; -default : -pr_warn_once ("Bad event %d\n" , rdtgrp->mba_mbps_event); - ret = -EINVAL ; -break ; - } - }else { - ret = -ENOENT ; - } - -rdtgroup_kn_unlock (of->kn); - -return ret; -} - -struct rdt_domain_hdr *resctrl_find_domain (struct list_head *h,int id, -struct list_head **pos) -{ -struct rdt_domain_hdr *d; -struct list_head *l; - -list_for_each (l, h) { - d = list_entry(l, struct rdt_domain_hdr, list); -/* When id is found, return its domain. */ -if (id == d->id) -return d; -/* Stop searching when finding id's position in sorted list. */ -if (id < d->id) -break ; - } - -if (pos) - *pos = l; - -return NULL ; -} - -void mon_event_read (struct rmid_read *rr,struct rdt_resource *r, -struct rdt_mon_domain *d,struct rdtgroup *rdtgrp, -cpumask_t *cpumask,int evtid,int first) -{ -int cpu; - -/* When picking a CPU from cpu_mask, ensure it can't race with cpuhp */ -lockdep_assert_cpus_held (); - -/* -* Setup the parameters to pass to mon_event_count() to read the data. -*/ - rr->rgrp = rdtgrp; - rr->evtid = evtid; - rr->r = r; - rr->d = d; - rr->first = first; - rr->arch_mon_ctx =resctrl_arch_mon_ctx_alloc (r, evtid); -if (IS_ERR (rr->arch_mon_ctx)) { - rr->err = -EINVAL ; -return ; - } - - cpu =cpumask_any_housekeeping (cpumask,RESCTRL_PICK_ANY_CPU ); - -/* -* cpumask_any_housekeeping() prefers housekeeping CPUs, but -* are all the CPUs nohz_full? If yes, pick a CPU to IPI. -* MPAM's resctrl_arch_rmid_read() is unable to read the -* counters on some platforms if its called in IRQ context. -*/ -if (tick_nohz_full_cpu (cpu)) -smp_call_function_any (cpumask, mon_event_count, rr,1 ); -else -smp_call_on_cpu (cpu, smp_mon_event_count, rr, false); - -resctrl_arch_mon_ctx_free (r, evtid, rr->arch_mon_ctx); -} - -int rdtgroup_mondata_show (struct seq_file *m,void *arg) -{ -struct kernfs_open_file *of = m->private; -struct rdt_domain_hdr *hdr; -struct rmid_read rr = {0 }; -struct rdt_mon_domain *d; -u32 resid, evtid, domid; -struct rdtgroup *rdtgrp; -struct rdt_resource *r; -struct mon_data *md; -int ret =0 ; - - rdtgrp =rdtgroup_kn_lock_live (of->kn); -if (!rdtgrp) { - ret = -ENOENT ; - goto out; - } - - md = of->kn->priv; -if (WARN_ON_ONCE (!md)) { - ret = -EIO ; - goto out; - } - - resid = md->rid; - domid = md->domid; - evtid = md->evtid; - r =resctrl_arch_get_resource (resid); - -if (md->sum) { -/* -* This file requires summing across all domains that share -* the L3 cache id that was provided in the "domid" field of the -* struct mon_data. Search all domains in the resource for -* one that matches this cache id. -*/ -list_for_each_entry (d, &r->mon_domains, hdr.list) { -if (d->ci->id == domid) { - rr.ci = d->ci; -mon_event_read (&rr, r,NULL , rdtgrp, - &d->ci->shared_cpu_map, evtid, false); - goto checkresult; - } - } - ret = -ENOENT ; - goto out; - }else { -/* -* This file provides data from a single domain. Search -* the resource to find the domain with "domid". -*/ - hdr =resctrl_find_domain (&r->mon_domains, domid,NULL ); -if (!hdr ||WARN_ON_ONCE (hdr->type !=RESCTRL_MON_DOMAIN )) { - ret = -ENOENT ; - goto out; - } - d = container_of(hdr, struct rdt_mon_domain, hdr); -mon_event_read (&rr, r, d, rdtgrp, &d->hdr.cpu_mask, evtid, false); - } - -checkresult: - -if (rr.err == -EIO ) -seq_puts (m,"Error\n" ); -else if (rr.err == -EINVAL ) -seq_puts (m,"Unavailable\n" ); -else -seq_printf (m,"%llu\n" , rr.val); - -out: -rdtgroup_kn_unlock (of->kn); -return ret; -}arch/x86/kernel/cpu/resctrl/internal.h +8
-365@@ -13,14 +13,16 @@#define L2_QOS_CDP_ENABLE 0x01ULL -#define CQM_LIMBOCHECK_INTERVAL 1000 -#define MBM_CNTR_WIDTH_BASE 24 +#define MBA_IS_LINEAR 0x4 +#define MBM_CNTR_WIDTH_OFFSET_AMD 20#define RMID_VAL_ERROR BIT_ULL(63) +#define RMID_VAL_UNAVAIL BIT_ULL(62) +/* * With the above fields in use 62 bits remain in MSR_IA32_QM_CTR for * data to be returned. The counter width is discovered from the hardware @@ -28,275 +30,6 @@*/ #define MBM_CNTR_WIDTH_OFFSET_MAX (62 - MBM_CNTR_WIDTH_BASE) -/** -* cpumask_any_housekeeping() - Choose any CPU in @mask, preferring those that -* aren't marked nohz_full -* @mask: The mask to pick a CPU from. -* @exclude_cpu:The CPU to avoid picking. -* -* Returns a CPU from @mask, but not @exclude_cpu. If there are housekeeping -* CPUs that don't use nohz_full, these are preferred. Pass -* RESCTRL_PICK_ANY_CPU to avoid excluding any CPUs. -* -* When a CPU is excluded, returns >= nr_cpu_ids if no CPUs are available. -*/ -static inline unsigned int -cpumask_any_housekeeping (const struct cpumask *mask,int exclude_cpu) -{ -unsigned int cpu, hk_cpu; - -if (exclude_cpu ==RESCTRL_PICK_ANY_CPU ) - cpu =cpumask_any (mask); -else - cpu =cpumask_any_but (mask, exclude_cpu); - -/* Only continue if tick_nohz_full_mask has been initialized. */ -if (!tick_nohz_full_enabled ()) -return cpu; - -/* If the CPU picked isn't marked nohz_full nothing more needs doing. */ -if (cpu < nr_cpu_ids && !tick_nohz_full_cpu (cpu)) -return cpu; - -/* Try to find a CPU that isn't nohz_full to use in preference */ - hk_cpu =cpumask_nth_andnot (0 , mask, tick_nohz_full_mask); -if (hk_cpu == exclude_cpu) - hk_cpu =cpumask_nth_andnot (1 , mask, tick_nohz_full_mask); - -if (hk_cpu < nr_cpu_ids) - cpu = hk_cpu; - -return cpu; -} - -struct rdt_fs_context { -struct kernfs_fs_context kfc; -bool enable_cdpl2; -bool enable_cdpl3; -bool enable_mba_mbps; -bool enable_debug; -}; - -static inline struct rdt_fs_context *rdt_fc2context (struct fs_context *fc) -{ -struct kernfs_fs_context *kfc = fc->fs_private; - - return container_of(kfc, struct rdt_fs_context, kfc); -} - -/** -* struct mon_evt - Entry in the event list of a resource -* @evtid: event id -* @name: name of the event -* @configurable: true if the event is configurable -* @list: entry in &rdt_resource->evt_list -*/ -struct mon_evt { -enum resctrl_event_id evtid; -char *name; -bool configurable; -struct list_head list; -}; - -/** -* struct mon_data - Monitoring details for each event file. -* @rid: Resource id associated with the event file. -* @evtid: Event id associated with the event file. -* @sum: Set when event must be summed across multiple -* domains. -* @domid: When @sum is zero this is the domain to which -* the event file belongs. When @sum is one this -* is the id of the L3 cache that all domains to be -* summed share. -* -* Stored in the kernfs kn->priv field, readers and writers must hold -* rdtgroup_mutex. -*/ -struct mon_data { -unsigned int rid; -enum resctrl_event_id evtid; -unsigned int sum; -unsigned int domid; -}; - -/** -* struct rmid_read - Data passed across smp_call*() to read event count. -* @rgrp: Resource group for which the counter is being read. If it is a parent -* resource group then its event count is summed with the count from all -* its child resource groups. -* @r: Resource describing the properties of the event being read. -* @d: Domain that the counter should be read from. If NULL then sum all -* domains in @r sharing L3 @ci.id -* @evtid: Which monitor event to read. -* @first: Initialize MBM counter when true. -* @ci: Cacheinfo for L3. Only set when @d is NULL. Used when summing domains. -* @err: Error encountered when reading counter. -* @val: Returned value of event counter. If @rgrp is a parent resource group, -* @val includes the sum of event counts from its child resource groups. -* If @d is NULL, @val includes the sum of all domains in @r sharing @ci.id, -* (summed across child resource groups if @rgrp is a parent resource group). -* @arch_mon_ctx: Hardware monitor allocated for this read request (MPAM only). -*/ -struct rmid_read { -struct rdtgroup *rgrp; -struct rdt_resource *r; -struct rdt_mon_domain *d; -enum resctrl_event_id evtid; -bool first; -struct cacheinfo *ci; -int err; -u64 val; -void *arch_mon_ctx; -}; - -extern struct list_head resctrl_schema_all; -extern bool resctrl_mounted; - -enum rdt_group_type { -RDTCTRL_GROUP =0 , -RDTMON_GROUP , -RDT_NUM_GROUP , -}; - -/** -* enum rdtgrp_mode - Mode of a RDT resource group -* @RDT_MODE_SHAREABLE: This resource group allows sharing of its allocations -* @RDT_MODE_EXCLUSIVE: No sharing of this resource group's allocations allowed -* @RDT_MODE_PSEUDO_LOCKSETUP: Resource group will be used for Pseudo-Locking -* @RDT_MODE_PSEUDO_LOCKED: No sharing of this resource group's allocations -* allowed AND the allocations are Cache Pseudo-Locked -* @RDT_NUM_MODES: Total number of modes -* -* The mode of a resource group enables control over the allowed overlap -* between allocations associated with different resource groups (classes -* of service). User is able to modify the mode of a resource group by -* writing to the "mode" resctrl file associated with the resource group. -* -* The "shareable", "exclusive", and "pseudo-locksetup" modes are set by -* writing the appropriate text to the "mode" file. A resource group enters -* "pseudo-locked" mode after the schemata is written while the resource -* group is in "pseudo-locksetup" mode. -*/ -enum rdtgrp_mode { -RDT_MODE_SHAREABLE =0 , -RDT_MODE_EXCLUSIVE , -RDT_MODE_PSEUDO_LOCKSETUP , -RDT_MODE_PSEUDO_LOCKED , - -/* Must be last */ -RDT_NUM_MODES , -}; - -/** -* struct mongroup - store mon group's data in resctrl fs. -* @mon_data_kn: kernfs node for the mon_data directory -* @parent: parent rdtgrp -* @crdtgrp_list: child rdtgroup node list -* @rmid: rmid for this rdtgroup -*/ -struct mongroup { -struct kernfs_node *mon_data_kn; -struct rdtgroup *parent; -struct list_head crdtgrp_list; -u32 rmid; -}; - -/** -* struct rdtgroup - store rdtgroup's data in resctrl file system. -* @kn: kernfs node -* @rdtgroup_list: linked list for all rdtgroups -* @closid: closid for this rdtgroup -* @cpu_mask: CPUs assigned to this rdtgroup -* @flags: status bits -* @waitcount: how many cpus expect to find this -* group when they acquire rdtgroup_mutex -* @type: indicates type of this rdtgroup - either -* monitor only or ctrl_mon group -* @mon: mongroup related data -* @mode: mode of resource group -* @mba_mbps_event: input monitoring event id when mba_sc is enabled -* @plr: pseudo-locked region -*/ -struct rdtgroup { -struct kernfs_node *kn; -struct list_head rdtgroup_list; -u32 closid; -struct cpumask cpu_mask; -int flags; -atomic_t waitcount; -enum rdt_group_type type; -struct mongroup mon; -enum rdtgrp_mode mode; -enum resctrl_event_id mba_mbps_event; -struct pseudo_lock_region *plr; -}; - -/* rdtgroup.flags */ -#define RDT_DELETED 1 - -/* rftype.flags */ -#define RFTYPE_FLAGS_CPUS_LIST 1 - -/* -* Define the file type flags for base and info directories. -*/ -#define RFTYPE_INFO BIT(0) -#define RFTYPE_BASE BIT(1) -#define RFTYPE_CTRL BIT(4) -#define RFTYPE_MON BIT(5) -#define RFTYPE_TOP BIT(6) -#define RFTYPE_RES_CACHE BIT(8) -#define RFTYPE_RES_MB BIT(9) -#define RFTYPE_DEBUG BIT(10) -#define RFTYPE_CTRL_INFO (RFTYPE_INFO | RFTYPE_CTRL) -#define RFTYPE_MON_INFO (RFTYPE_INFO | RFTYPE_MON) -#define RFTYPE_TOP_INFO (RFTYPE_INFO | RFTYPE_TOP) -#define RFTYPE_CTRL_BASE (RFTYPE_BASE | RFTYPE_CTRL) -#define RFTYPE_MON_BASE (RFTYPE_BASE | RFTYPE_MON) - -/* List of all resource groups */ -extern struct list_head rdt_all_groups; - -extern int max_name_width; - -/** -* struct rftype - describe each file in the resctrl file system -* @name: File name -* @mode: Access mode -* @kf_ops: File operations -* @flags: File specific RFTYPE_FLAGS_* flags -* @fflags: File specific RFTYPE_* flags -* @seq_show: Show content of the file -* @write: Write to the file -*/ -struct rftype { -char *name; -umode_t mode; -const struct kernfs_ops *kf_ops; -unsigned long flags; -unsigned long fflags; - -int (*seq_show)(struct kernfs_open_file *of, -struct seq_file *sf,void *v); -/* -* write() is the generic write callback which maps directly to -* kernfs write operation and overrides all other operations. -* Maximum write size is determined by ->max_write_len. -*/ -ssize_t (*write)(struct kernfs_open_file *of, -char *buf,size_t nbytes,loff_t off); -}; - -/** -* struct mbm_state - status for each MBM counter in each domain -* @prev_bw_bytes: Previous bytes value read for bandwidth calculation -* @prev_bw: The most recent bandwidth in MBps -*/ -struct mbm_state { -u64 prev_bw_bytes; -u32 prev_bw; -}; -/** * struct arch_mbm_state - values used to compute resctrl_arch_rmid_read()s * return value. @@ -394,12 +127,7 @@ static inline struct rdt_hw_resource *resctrl_to_arch_res(struct rdt_resource *r return container_of(r, struct rdt_hw_resource, r_resctrl); } -extern struct mutex rdtgroup_mutex; -extern struct rdt_hw_resource rdt_resources_all[]; -extern struct rdtgroup rdtgroup_default; -extern struct dentry *debugfs_resctrl; -extern enum resctrl_event_id mba_mbps_default_event;void arch_mon_domain_online (struct rdt_resource *r,struct rdt_mon_domain *d);@@ -436,99 +164,14 @@ union cpuid_0x10_x_edx { unsigned int full; }; -void rdt_last_cmd_clear (void ); -void rdt_last_cmd_puts (const char *s); -__printf(1, 2) -void rdt_last_cmd_printf (const char *fmt, ...); -void rdt_ctrl_update (void *arg); -struct rdtgroup *rdtgroup_kn_lock_live (struct kernfs_node *kn); -void rdtgroup_kn_unlock (struct kernfs_node *kn); -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); -ssize_t rdtgroup_schemata_write (struct kernfs_open_file *of, -char *buf,size_t nbytes,loff_t off); -int rdtgroup_schemata_show (struct kernfs_open_file *of, -struct seq_file *s,void *v); -ssize_t rdtgroup_mba_mbps_event_write (struct kernfs_open_file *of, -char *buf,size_t nbytes,loff_t off); -int rdtgroup_mba_mbps_event_show (struct kernfs_open_file *of, -struct seq_file *s,void *v); -bool rdtgroup_cbm_overlaps (struct resctrl_schema *s,struct rdt_ctrl_domain *d, -unsigned long cbm,int closid,bool exclusive); -unsigned int rdtgroup_cbm_to_size (struct rdt_resource *r,struct rdt_ctrl_domain *d, -unsigned long cbm); -enum rdtgrp_mode rdtgroup_mode_by_closid (int closid); -int rdtgroup_tasks_assigned (struct rdtgroup *r); -int closids_supported (void ); -void closid_free (int closid); -int alloc_rmid (u32 closid); -void free_rmid (u32 closid,u32 rmid); +int rdt_get_mon_l3_config (struct rdt_resource *r); -void resctrl_mon_resource_exit (void ); +bool rdt_cpu_has (int flag); -void mon_event_count (void *info); -int rdtgroup_mondata_show (struct seq_file *m,void *arg); -void mon_event_read (struct rmid_read *rr,struct rdt_resource *r, -struct rdt_mon_domain *d,struct rdtgroup *rdtgrp, -cpumask_t *cpumask,int evtid,int first); -int resctrl_mon_resource_init (void ); -void mbm_setup_overflow_handler (struct rdt_mon_domain *dom, -unsigned long delay_ms, -int exclude_cpu); -void mbm_handle_overflow (struct work_struct *work); +void __init intel_rdt_mbm_apply_quirk (void ); -bool is_mba_sc (struct rdt_resource *r); -void cqm_setup_limbo_handler (struct rdt_mon_domain *dom,unsigned long delay_ms, -int exclude_cpu); -void cqm_handle_limbo (struct work_struct *work); -bool has_busy_rmid (struct rdt_mon_domain *d); -void __check_limbo (struct rdt_mon_domain *d,bool force_free); +void rdt_domain_reconfigure_cdp (struct rdt_resource *r); -void resctrl_file_fflags_init (const char *config,unsigned long fflags); -void rdt_staged_configs_clear (void ); -bool closid_allocated (unsigned int closid); -int resctrl_find_cleanest_closid (void ); - -#ifdef CONFIG_RESCTRL_FS_PSEUDO_LOCK -int rdtgroup_locksetup_enter (struct rdtgroup *rdtgrp); -int rdtgroup_locksetup_exit (struct rdtgroup *rdtgrp); -bool rdtgroup_cbm_overlaps_pseudo_locked (struct rdt_ctrl_domain *d,unsigned long cbm); -bool rdtgroup_pseudo_locked_in_hierarchy (struct rdt_ctrl_domain *d); -int rdt_pseudo_lock_init (void ); -void rdt_pseudo_lock_release (void ); -int rdtgroup_pseudo_lock_create (struct rdtgroup *rdtgrp); -void rdtgroup_pseudo_lock_remove (struct rdtgroup *rdtgrp); -#else -static inline int rdtgroup_locksetup_enter (struct rdtgroup *rdtgrp) -{ -return -EOPNOTSUPP ; -} - -static inline int rdtgroup_locksetup_exit (struct rdtgroup *rdtgrp) -{ -return -EOPNOTSUPP ; -} - -static inline bool rdtgroup_cbm_overlaps_pseudo_locked (struct rdt_ctrl_domain *d,unsigned long cbm) -{ -return false; -} - -static inline bool rdtgroup_pseudo_locked_in_hierarchy (struct rdt_ctrl_domain *d) -{ -return false; -} - -static inline int rdt_pseudo_lock_init (void ) {return 0 ; } -static inline void rdt_pseudo_lock_release (void ) { } -static inline int rdtgroup_pseudo_lock_create (struct rdtgroup *rdtgrp) -{ -return -EOPNOTSUPP ; -} - -static inline void rdtgroup_pseudo_lock_remove (struct rdtgroup *rdtgrp) { } -#endif /* CONFIG_RESCTRL_FS_PSEUDO_LOCK */ #endif /* _ASM_X86_RESCTRL_INTERNAL_H */ arch/x86/kernel/cpu/resctrl/monitor.c +2
-903@@ -28,55 +28,9 @@#include "internal.h" #define CREATE_TRACE_POINTS +#include "monitor_trace.h" -/** -* struct rmid_entry - dirty tracking for all RMID. -* @closid: The CLOSID for this entry. -* @rmid: The RMID for this entry. -* @busy: The number of domains with cached data using this RMID. -* @list: Member of the rmid_free_lru list when busy == 0. -* -* Depending on the architecture the correct monitor is accessed using -* both @closid and @rmid, or @rmid only. -* -* Take the rdtgroup_mutex when accessing. -*/ -struct rmid_entry { -u32 closid; -u32 rmid; -int busy; -struct list_head list; -}; - -/* -* @rmid_free_lru - A least recently used list of free RMIDs -* These RMIDs are guaranteed to have an occupancy less than the -* threshold occupancy -*/ -static LIST_HEAD (rmid_free_lru); - -/* -* @closid_num_dirty_rmid The number of dirty RMID each CLOSID has. -* Only allocated when CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID is defined. -* Indexed by CLOSID. Protected by rdtgroup_mutex. -*/ -static u32 *closid_num_dirty_rmid; - -/* -* @rmid_limbo_count - count of currently unused but (potentially) -* dirty RMIDs. -* This counts RMIDs that no one is currently using but that -* may have a occupancy value > resctrl_rmid_realloc_threshold. User can -* change the threshold occupancy value. -*/ -static unsigned int rmid_limbo_count; - -/* -* @rmid_entry - The entry in the limbo and free lists. -*/ -static struct rmid_entry *rmid_ptrs; -/* * Global boolean for rdt_monitor which is true if any * resource monitoring is enabled. @@ -88,17 +42,6 @@ bool rdt_mon_capable;*/ unsigned int rdt_mon_features; -/* -* This is the threshold cache occupancy in bytes at which we will consider an -* RMID available for re-allocation. -*/ -unsigned int resctrl_rmid_realloc_threshold; - -/* -* This is the maximum value for the reallocation threshold, in bytes. -*/ -unsigned int resctrl_rmid_realloc_limit; -#define CF (cf) ((unsigned long)(1048576 * (cf) + 0.5))static int snc_nodes_per_l3_cache =1 ;@@ -153,6 +96,7 @@ static const struct mbm_correction_factor_table { };static u32 mbm_cf_rmidthreshold__read_mostly =UINT_MAX ; +static u64 mbm_cf__read_mostly ;static inline u64 get_corrected_mbm_count (u32 rmid,unsigned long val)@@ -164,33 +108,6 @@ static inline u64 get_corrected_mbm_count(u32 rmid, unsigned long val)return val; } -/* -* x86 and arm64 differ in their handling of monitoring. -* x86's RMID are independent numbers, there is only one source of traffic -* with an RMID value of '1'. -* arm64's PMG extends the PARTID/CLOSID space, there are multiple sources of -* traffic with a PMG value of '1', one for each CLOSID, meaning the RMID -* value is no longer unique. -* To account for this, resctrl uses an index. On x86 this is just the RMID, -* on arm64 it encodes the CLOSID and RMID. This gives a unique number. -* -* The domain's rmid_busy_llc and rmid_ptrs[] are sized by index. The arch code -* must accept an attempt to read every index. -*/ -static inline struct rmid_entry *__rmid_entry (u32 idx) -{ -struct rmid_entry *entry; -u32 closid, rmid; - - entry = &rmid_ptrs[idx]; -resctrl_arch_rmid_idx_decode (idx, &closid, &rmid); - -WARN_ON_ONCE (entry->closid != closid); -WARN_ON_ONCE (entry->rmid != rmid); - -return entry; -} -/* * When Sub-NUMA Cluster (SNC) mode is not enabled (as indicated by * "snc_nodes_per_l3_cache == 1") no translation of the RMID value is @@ -348,772 +265,6 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_mon_domain *d,return 0 ; } -static void limbo_release_entry (struct rmid_entry *entry) -{ -lockdep_assert_held (&rdtgroup_mutex); - - rmid_limbo_count--; -list_add_tail (&entry->list, &rmid_free_lru); - -if (IS_ENABLED (CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID )) - closid_num_dirty_rmid[entry->closid]--; -} - -/* -* Check the RMIDs that are marked as busy for this domain. If the -* reported LLC occupancy is below the threshold clear the busy bit and -* decrement the count. If the busy count gets to zero on an RMID, we -* free the RMID -*/ -void __check_limbo (struct rdt_mon_domain *d,bool force_free) -{ -struct rdt_resource *r =resctrl_arch_get_resource (RDT_RESOURCE_L3 ); -u32 idx_limit =resctrl_arch_system_num_rmid_idx (); -struct rmid_entry *entry; -u32 idx, cur_idx =1 ; -void *arch_mon_ctx; -bool rmid_dirty; -u64 val =0 ; - - arch_mon_ctx =resctrl_arch_mon_ctx_alloc (r,QOS_L3_OCCUP_EVENT_ID ); -if (IS_ERR (arch_mon_ctx)) { -pr_warn_ratelimited ("Failed to allocate monitor context: %ld" , -PTR_ERR (arch_mon_ctx)); -return ; - } - -/* -* Skip RMID 0 and start from RMID 1 and check all the RMIDs that -* are marked as busy for occupancy < threshold. If the occupancy -* is less than the threshold decrement the busy counter of the -* RMID and move it to the free list when the counter reaches 0. -*/ -for (;;) { - idx =find_next_bit (d->rmid_busy_llc, idx_limit, cur_idx); -if (idx >= idx_limit) -break ; - - entry =__rmid_entry (idx); -if (resctrl_arch_rmid_read (r, d, entry->closid, entry->rmid, -QOS_L3_OCCUP_EVENT_ID , &val, - arch_mon_ctx)) { - rmid_dirty = true; - }else { - rmid_dirty = (val >= resctrl_rmid_realloc_threshold); - -/* -* x86's CLOSID and RMID are independent numbers, so the entry's -* CLOSID is an empty CLOSID (X86_RESCTRL_EMPTY_CLOSID). On Arm the -* RMID (PMG) extends the CLOSID (PARTID) space with bits that aren't -* used to select the configuration. It is thus necessary to track both -* CLOSID and RMID because there may be dependencies between them -* on some architectures. -*/ -trace_mon_llc_occupancy_limbo (entry->closid, entry->rmid, d->hdr.id, val); - } - -if (force_free || !rmid_dirty) { -clear_bit (idx, d->rmid_busy_llc); -if (!--entry->busy) -limbo_release_entry (entry); - } - cur_idx = idx +1 ; - } - -resctrl_arch_mon_ctx_free (r,QOS_L3_OCCUP_EVENT_ID , arch_mon_ctx); -} - -bool has_busy_rmid (struct rdt_mon_domain *d) -{ -u32 idx_limit =resctrl_arch_system_num_rmid_idx (); - -return find_first_bit (d->rmid_busy_llc, idx_limit) != idx_limit; -} - -static struct rmid_entry *resctrl_find_free_rmid (u32 closid) -{ -struct rmid_entry *itr; -u32 itr_idx, cmp_idx; - -if (list_empty (&rmid_free_lru)) -return rmid_limbo_count ?ERR_PTR (-EBUSY ) :ERR_PTR (-ENOSPC ); - -list_for_each_entry (itr, &rmid_free_lru, list) { -/* -* Get the index of this free RMID, and the index it would need -* to be if it were used with this CLOSID. -* If the CLOSID is irrelevant on this architecture, the two -* index values are always the same on every entry and thus the -* very first entry will be returned. -*/ - itr_idx =resctrl_arch_rmid_idx_encode (itr->closid, itr->rmid); - cmp_idx =resctrl_arch_rmid_idx_encode (closid, itr->rmid); - -if (itr_idx == cmp_idx) -return itr; - } - -return ERR_PTR (-ENOSPC ); -} - -/** -* resctrl_find_cleanest_closid() - Find a CLOSID where all the associated -* RMID are clean, or the CLOSID that has -* the most clean RMID. -* -* MPAM's equivalent of RMID are per-CLOSID, meaning a freshly allocated CLOSID -* may not be able to allocate clean RMID. To avoid this the allocator will -* choose the CLOSID with the most clean RMID. -* -* When the CLOSID and RMID are independent numbers, the first free CLOSID will -* be returned. -*/ -int resctrl_find_cleanest_closid (void ) -{ -u32 cleanest_closid = ~0 ; -int i =0 ; - -lockdep_assert_held (&rdtgroup_mutex); - -if (!IS_ENABLED (CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID )) -return -EIO ; - -for (i =0 ; i <closids_supported (); i++) { -int num_dirty; - -if (closid_allocated (i)) -continue ; - - num_dirty = closid_num_dirty_rmid[i]; -if (num_dirty ==0 ) -return i; - -if (cleanest_closid == ~0 ) - cleanest_closid = i; - -if (num_dirty < closid_num_dirty_rmid[cleanest_closid]) - cleanest_closid = i; - } - -if (cleanest_closid == ~0 ) -return -ENOSPC ; - -return cleanest_closid; -} - -/* -* For MPAM the RMID value is not unique, and has to be considered with -* the CLOSID. The (CLOSID, RMID) pair is allocated on all domains, which -* allows all domains to be managed by a single free list. -* Each domain also has a rmid_busy_llc to reduce the work of the limbo handler. -*/ -int alloc_rmid (u32 closid) -{ -struct rmid_entry *entry; - -lockdep_assert_held (&rdtgroup_mutex); - - entry =resctrl_find_free_rmid (closid); -if (IS_ERR (entry)) -return PTR_ERR (entry); - -list_del (&entry->list); -return entry->rmid; -} - -static void add_rmid_to_limbo (struct rmid_entry *entry) -{ -struct rdt_resource *r =resctrl_arch_get_resource (RDT_RESOURCE_L3 ); -struct rdt_mon_domain *d; -u32 idx; - -lockdep_assert_held (&rdtgroup_mutex); - -/* Walking r->domains, ensure it can't race with cpuhp */ -lockdep_assert_cpus_held (); - - idx =resctrl_arch_rmid_idx_encode (entry->closid, entry->rmid); - - entry->busy =0 ; -list_for_each_entry (d, &r->mon_domains, hdr.list) { -/* -* For the first limbo RMID in the domain, -* setup up the limbo worker. -*/ -if (!has_busy_rmid (d)) -cqm_setup_limbo_handler (d,CQM_LIMBOCHECK_INTERVAL , -RESCTRL_PICK_ANY_CPU ); -set_bit (idx, d->rmid_busy_llc); - entry->busy++; - } - - rmid_limbo_count++; -if (IS_ENABLED (CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID )) - closid_num_dirty_rmid[entry->closid]++; -} - -void free_rmid (u32 closid,u32 rmid) -{ -u32 idx =resctrl_arch_rmid_idx_encode (closid, rmid); -struct rmid_entry *entry; - -lockdep_assert_held (&rdtgroup_mutex); - -/* -* Do not allow the default rmid to be free'd. Comparing by index -* allows architectures that ignore the closid parameter to avoid an -* unnecessary check. -*/ -if (!resctrl_arch_mon_capable () || - idx ==resctrl_arch_rmid_idx_encode (RESCTRL_RESERVED_CLOSID , -RESCTRL_RESERVED_RMID )) -return ; - - entry =__rmid_entry (idx); - -if (resctrl_arch_is_llc_occupancy_enabled ()) -add_rmid_to_limbo (entry); -else -list_add_tail (&entry->list, &rmid_free_lru); -} - -static struct mbm_state *get_mbm_state (struct rdt_mon_domain *d,u32 closid, -u32 rmid,enum resctrl_event_id evtid) -{ -u32 idx =resctrl_arch_rmid_idx_encode (closid, rmid); - -switch (evtid) { -case QOS_L3_MBM_TOTAL_EVENT_ID : -return &d->mbm_total[idx]; -case QOS_L3_MBM_LOCAL_EVENT_ID : -return &d->mbm_local[idx]; -default : -return NULL ; - } -} - -static int __mon_event_count (u32 closid,u32 rmid,struct rmid_read *rr) -{ -int cpu =smp_processor_id (); -struct rdt_mon_domain *d; -struct mbm_state *m; -int err, ret; -u64 tval =0 ; - -if (rr->first) { -resctrl_arch_reset_rmid (rr->r, rr->d, closid, rmid, rr->evtid); - m =get_mbm_state (rr->d, closid, rmid, rr->evtid); -if (m) -memset (m,0 ,sizeof (struct mbm_state )); -return 0 ; - } - -if (rr->d) { -/* Reading a single domain, must be on a CPU in that domain. */ -if (!cpumask_test_cpu (cpu, &rr->d->hdr.cpu_mask)) -return -EINVAL ; - rr->err =resctrl_arch_rmid_read (rr->r, rr->d, closid, rmid, - rr->evtid, &tval, rr->arch_mon_ctx); -if (rr->err) -return rr->err; - - rr->val += tval; - -return 0 ; - } - -/* Summing domains that share a cache, must be on a CPU for that cache. */ -if (!cpumask_test_cpu (cpu, &rr->ci->shared_cpu_map)) -return -EINVAL ; - -/* -* Legacy files must report the sum of an event across all -* domains that share the same L3 cache instance. -* Report success if a read from any domain succeeds, -EINVAL -* (translated to "Unavailable" for user space) if reading from -* all domains fail for any reason. -*/ - ret = -EINVAL ; -list_for_each_entry (d, &rr->r->mon_domains, hdr.list) { -if (d->ci->id != rr->ci->id) -continue ; - err =resctrl_arch_rmid_read (rr->r, d, closid, rmid, - rr->evtid, &tval, rr->arch_mon_ctx); -if (!err) { - rr->val += tval; - ret =0 ; - } - } - -if (ret) - rr->err = ret; - -return ret; -} - -/* -* mbm_bw_count() - Update bw count from values previously read by -* __mon_event_count(). -* @closid: The closid used to identify the cached mbm_state. -* @rmid: The rmid used to identify the cached mbm_state. -* @rr: The struct rmid_read populated by __mon_event_count(). -* -* Supporting function to calculate the memory bandwidth -* and delta bandwidth in MBps. The chunks value previously read by -* __mon_event_count() is compared with the chunks value from the previous -* invocation. This must be called once per second to maintain values in MBps. -*/ -static void mbm_bw_count (u32 closid,u32 rmid,struct rmid_read *rr) -{ -u64 cur_bw, bytes, cur_bytes; -struct mbm_state *m; - - m =get_mbm_state (rr->d, closid, rmid, rr->evtid); -if (WARN_ON_ONCE (!m)) -return ; - - cur_bytes = rr->val; - bytes = cur_bytes - m->prev_bw_bytes; - m->prev_bw_bytes = cur_bytes; - - cur_bw = bytes /SZ_1M ; - - m->prev_bw = cur_bw; -} - -/* -* This is scheduled by mon_event_read() to read the CQM/MBM counters -* on a domain. -*/ -void mon_event_count (void *info) -{ -struct rdtgroup *rdtgrp, *entry; -struct rmid_read *rr = info; -struct list_head *head; -int ret; - - rdtgrp = rr->rgrp; - - ret =__mon_event_count (rdtgrp->closid, rdtgrp->mon.rmid, rr); - -/* -* For Ctrl groups read data from child monitor groups and -* add them together. Count events which are read successfully. -* Discard the rmid_read's reporting errors. -*/ - head = &rdtgrp->mon.crdtgrp_list; - -if (rdtgrp->type ==RDTCTRL_GROUP ) { -list_for_each_entry (entry, head, mon.crdtgrp_list) { -if (__mon_event_count (entry->closid, entry->mon.rmid, - rr) ==0 ) - ret =0 ; - } - } - -/* -* __mon_event_count() calls for newly created monitor groups may -* report -EINVAL/Unavailable if the monitor hasn't seen any traffic. -* Discard error if any of the monitor event reads succeeded. -*/ -if (ret ==0 ) - rr->err =0 ; -} - -static struct rdt_ctrl_domain *get_ctrl_domain_from_cpu (int cpu, -struct rdt_resource *r) -{ -struct rdt_ctrl_domain *d; - -lockdep_assert_cpus_held (); - -list_for_each_entry (d, &r->ctrl_domains, hdr.list) { -/* Find the domain that contains this CPU */ -if (cpumask_test_cpu (cpu, &d->hdr.cpu_mask)) -return d; - } - -return NULL ; -} - -/* -* Feedback loop for MBA software controller (mba_sc) -* -* mba_sc is a feedback loop where we periodically read MBM counters and -* adjust the bandwidth percentage values via the IA32_MBA_THRTL_MSRs so -* that: -* -* current bandwidth(cur_bw) < user specified bandwidth(user_bw) -* -* This uses the MBM counters to measure the bandwidth and MBA throttle -* MSRs to control the bandwidth for a particular rdtgrp. It builds on the -* fact that resctrl rdtgroups have both monitoring and control. -* -* The frequency of the checks is 1s and we just tag along the MBM overflow -* timer. Having 1s interval makes the calculation of bandwidth simpler. -* -* Although MBA's goal is to restrict the bandwidth to a maximum, there may -* be a need to increase the bandwidth to avoid unnecessarily restricting -* the L2 <-> L3 traffic. -* -* Since MBA controls the L2 external bandwidth where as MBM measures the -* L3 external bandwidth the following sequence could lead to such a -* situation. -* -* Consider an rdtgroup which had high L3 <-> memory traffic in initial -* phases -> mba_sc kicks in and reduced bandwidth percentage values -> but -* after some time rdtgroup has mostly L2 <-> L3 traffic. -* -* In this case we may restrict the rdtgroup's L2 <-> L3 traffic as its -* throttle MSRs already have low percentage values. To avoid -* unnecessarily restricting such rdtgroups, we also increase the bandwidth. -*/ -static void update_mba_bw (struct rdtgroup *rgrp,struct rdt_mon_domain *dom_mbm) -{ -u32 closid, rmid, cur_msr_val, new_msr_val; -struct mbm_state *pmbm_data, *cmbm_data; -struct rdt_ctrl_domain *dom_mba; -enum resctrl_event_id evt_id; -struct rdt_resource *r_mba; -struct list_head *head; -struct rdtgroup *entry; -u32 cur_bw, user_bw; - - r_mba =resctrl_arch_get_resource (RDT_RESOURCE_MBA ); - evt_id = rgrp->mba_mbps_event; - - closid = rgrp->closid; - rmid = rgrp->mon.rmid; - pmbm_data =get_mbm_state (dom_mbm, closid, rmid, evt_id); -if (WARN_ON_ONCE (!pmbm_data)) -return ; - - dom_mba =get_ctrl_domain_from_cpu (smp_processor_id (), r_mba); -if (!dom_mba) { -pr_warn_once ("Failure to get domain for MBA update\n" ); -return ; - } - - cur_bw = pmbm_data->prev_bw; - user_bw = dom_mba->mbps_val[closid]; - -/* MBA resource doesn't support CDP */ - cur_msr_val =resctrl_arch_get_config (r_mba, dom_mba, closid,CDP_NONE ); - -/* -* For Ctrl groups read data from child monitor groups. -*/ - head = &rgrp->mon.crdtgrp_list; -list_for_each_entry (entry, head, mon.crdtgrp_list) { - cmbm_data =get_mbm_state (dom_mbm, entry->closid, entry->mon.rmid, evt_id); -if (WARN_ON_ONCE (!cmbm_data)) -return ; - cur_bw += cmbm_data->prev_bw; - } - -/* -* Scale up/down the bandwidth linearly for the ctrl group. The -* bandwidth step is the bandwidth granularity specified by the -* hardware. -* Always increase throttling if current bandwidth is above the -* target set by user. -* But avoid thrashing up and down on every poll by checking -* whether a decrease in throttling is likely to push the group -* back over target. E.g. if currently throttling to 30% of bandwidth -* on a system with 10% granularity steps, check whether moving to -* 40% would go past the limit by multiplying current bandwidth by -* "(30 + 10) / 30". -*/ -if (cur_msr_val > r_mba->membw.min_bw && user_bw < cur_bw) { - new_msr_val = cur_msr_val - r_mba->membw.bw_gran; - }else if (cur_msr_val <MAX_MBA_BW && - (user_bw > (cur_bw * (cur_msr_val + r_mba->membw.min_bw) / cur_msr_val))) { - new_msr_val = cur_msr_val + r_mba->membw.bw_gran; - }else { -return ; - } - -resctrl_arch_update_one (r_mba, dom_mba, closid,CDP_NONE , new_msr_val); -} - -static void mbm_update_one_event (struct rdt_resource *r,struct rdt_mon_domain *d, -u32 closid,u32 rmid,enum resctrl_event_id evtid) -{ -struct rmid_read rr = {0 }; - - rr.r = r; - rr.d = d; - rr.evtid = evtid; - rr.arch_mon_ctx =resctrl_arch_mon_ctx_alloc (rr.r, rr.evtid); -if (IS_ERR (rr.arch_mon_ctx)) { -pr_warn_ratelimited ("Failed to allocate monitor context: %ld" , -PTR_ERR (rr.arch_mon_ctx)); -return ; - } - -__mon_event_count (closid, rmid, &rr); - -/* -* If the software controller is enabled, compute the -* bandwidth for this event id. -*/ -if (is_mba_sc (NULL )) -mbm_bw_count (closid, rmid, &rr); - -resctrl_arch_mon_ctx_free (rr.r, rr.evtid, rr.arch_mon_ctx); -} - -static void mbm_update (struct rdt_resource *r,struct rdt_mon_domain *d, -u32 closid,u32 rmid) -{ -/* -* This is protected from concurrent reads from user as both -* the user and overflow handler hold the global mutex. -*/ -if (resctrl_arch_is_mbm_total_enabled ()) -mbm_update_one_event (r, d, closid, rmid,QOS_L3_MBM_TOTAL_EVENT_ID ); - -if (resctrl_arch_is_mbm_local_enabled ()) -mbm_update_one_event (r, d, closid, rmid,QOS_L3_MBM_LOCAL_EVENT_ID ); -} - -/* -* Handler to scan the limbo list and move the RMIDs -* to free list whose occupancy < threshold_occupancy. -*/ -void cqm_handle_limbo (struct work_struct *work) -{ -unsigned long delay =msecs_to_jiffies (CQM_LIMBOCHECK_INTERVAL ); -struct rdt_mon_domain *d; - -cpus_read_lock (); -mutex_lock (&rdtgroup_mutex); - - d = container_of(work, struct rdt_mon_domain, cqm_limbo.work); - -__check_limbo (d, false); - -if (has_busy_rmid (d)) { - d->cqm_work_cpu =cpumask_any_housekeeping (&d->hdr.cpu_mask, -RESCTRL_PICK_ANY_CPU ); -schedule_delayed_work_on (d->cqm_work_cpu, &d->cqm_limbo, - delay); - } - -mutex_unlock (&rdtgroup_mutex); -cpus_read_unlock (); -} - -/** -* cqm_setup_limbo_handler() - Schedule the limbo handler to run for this -* domain. -* @dom: The domain the limbo handler should run for. -* @delay_ms: How far in the future the handler should run. -* @exclude_cpu: Which CPU the handler should not run on, -* RESCTRL_PICK_ANY_CPU to pick any CPU. -*/ -void cqm_setup_limbo_handler (struct rdt_mon_domain *dom,unsigned long delay_ms, -int exclude_cpu) -{ -unsigned long delay =msecs_to_jiffies (delay_ms); -int cpu; - - cpu =cpumask_any_housekeeping (&dom->hdr.cpu_mask, exclude_cpu); - dom->cqm_work_cpu = cpu; - -if (cpu < nr_cpu_ids) -schedule_delayed_work_on (cpu, &dom->cqm_limbo, delay); -} - -void mbm_handle_overflow (struct work_struct *work) -{ -unsigned long delay =msecs_to_jiffies (MBM_OVERFLOW_INTERVAL ); -struct rdtgroup *prgrp, *crgrp; -struct rdt_mon_domain *d; -struct list_head *head; -struct rdt_resource *r; - -cpus_read_lock (); -mutex_lock (&rdtgroup_mutex); - -/* -* If the filesystem has been unmounted this work no longer needs to -* run. -*/ -if (!resctrl_mounted || !resctrl_arch_mon_capable ()) - goto out_unlock; - - r =resctrl_arch_get_resource (RDT_RESOURCE_L3 ); - d = container_of(work, struct rdt_mon_domain, mbm_over.work); - -list_for_each_entry (prgrp, &rdt_all_groups, rdtgroup_list) { -mbm_update (r, d, prgrp->closid, prgrp->mon.rmid); - - head = &prgrp->mon.crdtgrp_list; -list_for_each_entry (crgrp, head, mon.crdtgrp_list) -mbm_update (r, d, crgrp->closid, crgrp->mon.rmid); - -if (is_mba_sc (NULL )) -update_mba_bw (prgrp, d); - } - -/* -* Re-check for housekeeping CPUs. This allows the overflow handler to -* move off a nohz_full CPU quickly. -*/ - d->mbm_work_cpu =cpumask_any_housekeeping (&d->hdr.cpu_mask, -RESCTRL_PICK_ANY_CPU ); -schedule_delayed_work_on (d->mbm_work_cpu, &d->mbm_over, delay); - -out_unlock: -mutex_unlock (&rdtgroup_mutex); -cpus_read_unlock (); -} - -/** -* mbm_setup_overflow_handler() - Schedule the overflow handler to run for this -* domain. -* @dom: The domain the overflow handler should run for. -* @delay_ms: How far in the future the handler should run. -* @exclude_cpu: Which CPU the handler should not run on, -* RESCTRL_PICK_ANY_CPU to pick any CPU. -*/ -void mbm_setup_overflow_handler (struct rdt_mon_domain *dom,unsigned long delay_ms, -int exclude_cpu) -{ -unsigned long delay =msecs_to_jiffies (delay_ms); -int cpu; - -/* -* When a domain comes online there is no guarantee the filesystem is -* mounted. If not, there is no need to catch counter overflow. -*/ -if (!resctrl_mounted || !resctrl_arch_mon_capable ()) -return ; - cpu =cpumask_any_housekeeping (&dom->hdr.cpu_mask, exclude_cpu); - dom->mbm_work_cpu = cpu; - -if (cpu < nr_cpu_ids) -schedule_delayed_work_on (cpu, &dom->mbm_over, delay); -} - -static int dom_data_init (struct rdt_resource *r) -{ -u32 idx_limit =resctrl_arch_system_num_rmid_idx (); -u32 num_closid =resctrl_arch_get_num_closid (r); -struct rmid_entry *entry =NULL ; -int err =0 , i; -u32 idx; - -mutex_lock (&rdtgroup_mutex); -if (IS_ENABLED (CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID )) { -u32 *tmp; - -/* -* If the architecture hasn't provided a sanitised value here, -* this may result in larger arrays than necessary. Resctrl will -* use a smaller system wide value based on the resources in -* use. -*/ - tmp =kcalloc (num_closid,sizeof (*tmp),GFP_KERNEL ); -if (!tmp) { - err = -ENOMEM ; - goto out_unlock; - } - - closid_num_dirty_rmid = tmp; - } - - rmid_ptrs =kcalloc (idx_limit,sizeof (struct rmid_entry ),GFP_KERNEL ); -if (!rmid_ptrs) { -if (IS_ENABLED (CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID )) { -kfree (closid_num_dirty_rmid); - closid_num_dirty_rmid =NULL ; - } - err = -ENOMEM ; - goto out_unlock; - } - -for (i =0 ; i < idx_limit; i++) { - entry = &rmid_ptrs[i]; -INIT_LIST_HEAD (&entry->list); - -resctrl_arch_rmid_idx_decode (i, &entry->closid, &entry->rmid); -list_add_tail (&entry->list, &rmid_free_lru); - } - -/* -* RESCTRL_RESERVED_CLOSID and RESCTRL_RESERVED_RMID are special and -* are always allocated. These are used for the rdtgroup_default -* control group, which will be setup later in resctrl_init(). -*/ - idx =resctrl_arch_rmid_idx_encode (RESCTRL_RESERVED_CLOSID , -RESCTRL_RESERVED_RMID ); - entry =__rmid_entry (idx); -list_del (&entry->list); - -out_unlock: -mutex_unlock (&rdtgroup_mutex); - -return err; -} - -static void dom_data_exit (struct rdt_resource *r) -{ -mutex_lock (&rdtgroup_mutex); - -if (!r->mon_capable) - goto out_unlock; - -if (IS_ENABLED (CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID )) { -kfree (closid_num_dirty_rmid); - closid_num_dirty_rmid =NULL ; - } - -kfree (rmid_ptrs); - rmid_ptrs =NULL ; - -out_unlock: -mutex_unlock (&rdtgroup_mutex); -} - -static struct mon_evt llc_occupancy_event = { - .name ="llc_occupancy" , - .evtid =QOS_L3_OCCUP_EVENT_ID , -}; - -static struct mon_evt mbm_total_event = { - .name ="mbm_total_bytes" , - .evtid =QOS_L3_MBM_TOTAL_EVENT_ID , -}; - -static struct mon_evt mbm_local_event = { - .name ="mbm_local_bytes" , - .evtid =QOS_L3_MBM_LOCAL_EVENT_ID , -}; - -/* -* Initialize the event list for the resource. -* -* Note that MBM events are also part of RDT_RESOURCE_L3 resource -* because as per the SDM the total and local memory bandwidth -* are enumerated as part of L3 monitoring. -* -* mon_put_default_kn_priv_all() also assumes monitor events are only supported -* on the L3 resource. -*/ -static void l3_mon_evt_init (struct rdt_resource *r) -{ -INIT_LIST_HEAD (&r->evt_list); - -if (resctrl_arch_is_llc_occupancy_enabled ()) -list_add_tail (&llc_occupancy_event.list, &r->evt_list); -if (resctrl_arch_is_mbm_total_enabled ()) -list_add_tail (&mbm_total_event.list, &r->evt_list); -if (resctrl_arch_is_mbm_local_enabled ()) -list_add_tail (&mbm_local_event.list, &r->evt_list); -} -/* * The power-on reset value of MSR_RMID_SNC_CONFIG is 0x1 * which indicates that RMIDs are configured in legacy mode. @@ -1197,51 +348,6 @@ static __init int snc_get_config(void)return ret; } -/** -* resctrl_mon_resource_init() - Initialise global monitoring structures. -* -* Allocate and initialise global monitor resources that do not belong to a -* specific domain. i.e. the rmid_ptrs[] used for the limbo and free lists. -* Called once during boot after the struct rdt_resource's have been configured -* but before the filesystem is mounted. -* Resctrl's cpuhp callbacks may be called before this point to bring a domain -* online. -* -* Returns 0 for success, or -ENOMEM. -*/ -int resctrl_mon_resource_init (void ) -{ -struct rdt_resource *r =resctrl_arch_get_resource (RDT_RESOURCE_L3 ); -int ret; - -if (!r->mon_capable) -return 0 ; - - ret =dom_data_init (r); -if (ret) -return ret; - -l3_mon_evt_init (r); - -if (resctrl_arch_is_evt_configurable (QOS_L3_MBM_TOTAL_EVENT_ID )) { - mbm_total_event.configurable = true; -resctrl_file_fflags_init ("mbm_total_bytes_config" , -RFTYPE_MON_INFO |RFTYPE_RES_CACHE ); - } -if (resctrl_arch_is_evt_configurable (QOS_L3_MBM_LOCAL_EVENT_ID )) { - mbm_local_event.configurable = true; -resctrl_file_fflags_init ("mbm_local_bytes_config" , -RFTYPE_MON_INFO |RFTYPE_RES_CACHE ); - } - -if (resctrl_arch_is_mbm_local_enabled ()) - mba_mbps_default_event =QOS_L3_MBM_LOCAL_EVENT_ID ; -else if (resctrl_arch_is_mbm_total_enabled ()) - mba_mbps_default_event =QOS_L3_MBM_TOTAL_EVENT_ID ; - -return 0 ; -} -int __init rdt_get_mon_l3_config (struct rdt_resource *r) {unsigned int mbm_offset = boot_cpu_data.x86_cache_mbm_width_offset;@@ -1289,13 +395,6 @@ int __init rdt_get_mon_l3_config(struct rdt_resource *r)return 0 ; } -void resctrl_mon_resource_exit (void ) -{ -struct rdt_resource *r =resctrl_arch_get_resource (RDT_RESOURCE_L3 ); - -dom_data_exit (r); -} -void __init intel_rdt_mbm_apply_quirk (void ) {int cf_index;arch/x86/kernel/cpu/resctrl/monitor_trace.h +2
-16@@ -7,25 +7,11 @@#include <linux/tracepoint.h> -TRACE_EVENT (mon_llc_occupancy_limbo, - TP_PROTO(u32 ctrl_hw_id, u32 mon_hw_id, int domain_id, u64 llc_occupancy_bytes), -TP_ARGS (ctrl_hw_id, mon_hw_id, domain_id, llc_occupancy_bytes), - TP_STRUCT__entry(__field(u32, ctrl_hw_id) - __field(u32, mon_hw_id) - __field(int, domain_id) -__field (u64, llc_occupancy_bytes)), - TP_fast_assign(__entry->ctrl_hw_id = ctrl_hw_id; - __entry->mon_hw_id = mon_hw_id; - __entry->domain_id = domain_id; - __entry->llc_occupancy_bytes = llc_occupancy_bytes;), -TP_printk ("ctrl_hw_id=%u mon_hw_id=%u domain_id=%d llc_occupancy_bytes=%llu" , - __entry->ctrl_hw_id, __entry->mon_hw_id, __entry->domain_id, - __entry->llc_occupancy_bytes) - ); -#endif /* _FS_RESCTRL_MONITOR_TRACE_H */ #undef TRACE_INCLUDE_PATH#define TRACE_INCLUDE_PATH . +#define TRACE_INCLUDE_FILE monitor_trace +#include <trace/define_trace.h> arch/x86/kernel/cpu/resctrl/pseudo_lock.c +1
-1073@@ -31,6 +31,7 @@#include "internal.h" #define CREATE_TRACE_POINTS +#include "pseudo_lock_trace.h" /* @@ -39,28 +40,6 @@*/ static u64 prefetch_disable_bits; -/* -* Major number assigned to and shared by all devices exposing -* pseudo-locked regions. -*/ -static unsigned int pseudo_lock_major; -static unsigned long pseudo_lock_minor_avail =GENMASK (MINORBITS ,0 ); - -static char *pseudo_lock_devnode (const struct device *dev,umode_t *mode) -{ -const struct rdtgroup *rdtgrp; - - rdtgrp =dev_get_drvdata (dev); -if (mode) - *mode =0600 ; -return kasprintf (GFP_KERNEL ,"pseudo_lock/%s" , rdtgrp->kn->name); -} - -static const struct class pseudo_lock_class = { - .name ="pseudo_lock" , - .devnode = pseudo_lock_devnode, -}; -/** * resctrl_arch_get_prefetch_disable_bits - prefetch disable bits of supported * platforms @@ -121,298 +100,6 @@ u64 resctrl_arch_get_prefetch_disable_bits(void)return prefetch_disable_bits; } -/** -* pseudo_lock_minor_get - Obtain available minor number -* @minor: Pointer to where new minor number will be stored -* -* A bitmask is used to track available minor numbers. Here the next free -* minor number is marked as unavailable and returned. -* -* Return: 0 on success, <0 on failure. -*/ -static int pseudo_lock_minor_get (unsigned int *minor) -{ -unsigned long first_bit; - - first_bit =find_first_bit (&pseudo_lock_minor_avail,MINORBITS ); - -if (first_bit ==MINORBITS ) -return -ENOSPC ; - -__clear_bit (first_bit, &pseudo_lock_minor_avail); - *minor = first_bit; - -return 0 ; -} - -/** -* pseudo_lock_minor_release - Return minor number to available -* @minor: The minor number made available -*/ -static void pseudo_lock_minor_release (unsigned int minor) -{ -__set_bit (minor, &pseudo_lock_minor_avail); -} - -/** -* region_find_by_minor - Locate a pseudo-lock region by inode minor number -* @minor: The minor number of the device representing pseudo-locked region -* -* When the character device is accessed we need to determine which -* pseudo-locked region it belongs to. This is done by matching the minor -* number of the device to the pseudo-locked region it belongs. -* -* Minor numbers are assigned at the time a pseudo-locked region is associated -* with a cache instance. -* -* Return: On success return pointer to resource group owning the pseudo-locked -* region, NULL on failure. -*/ -static struct rdtgroup *region_find_by_minor (unsigned int minor) -{ -struct rdtgroup *rdtgrp, *rdtgrp_match =NULL ; - -list_for_each_entry (rdtgrp, &rdt_all_groups, rdtgroup_list) { -if (rdtgrp->plr && rdtgrp->plr->minor == minor) { - rdtgrp_match = rdtgrp; -break ; - } - } -return rdtgrp_match; -} - -/** -* struct pseudo_lock_pm_req - A power management QoS request list entry -* @list: Entry within the @pm_reqs list for a pseudo-locked region -* @req: PM QoS request -*/ -struct pseudo_lock_pm_req { -struct list_head list; -struct dev_pm_qos_request req; -}; - -static void pseudo_lock_cstates_relax (struct pseudo_lock_region *plr) -{ -struct pseudo_lock_pm_req *pm_req, *next; - -list_for_each_entry_safe (pm_req, next, &plr->pm_reqs, list) { -dev_pm_qos_remove_request (&pm_req->req); -list_del (&pm_req->list); -kfree (pm_req); - } -} - -/** -* pseudo_lock_cstates_constrain - Restrict cores from entering C6 -* @plr: Pseudo-locked region -* -* To prevent the cache from being affected by power management entering -* C6 has to be avoided. This is accomplished by requesting a latency -* requirement lower than lowest C6 exit latency of all supported -* platforms as found in the cpuidle state tables in the intel_idle driver. -* At this time it is possible to do so with a single latency requirement -* for all supported platforms. -* -* Since Goldmont is supported, which is affected by X86_BUG_MONITOR, -* the ACPI latencies need to be considered while keeping in mind that C2 -* may be set to map to deeper sleep states. In this case the latency -* requirement needs to prevent entering C2 also. -* -* Return: 0 on success, <0 on failure -*/ -static int pseudo_lock_cstates_constrain (struct pseudo_lock_region *plr) -{ -struct pseudo_lock_pm_req *pm_req; -int cpu; -int ret; - -for_each_cpu (cpu, &plr->d->hdr.cpu_mask) { - pm_req =kzalloc (sizeof (*pm_req),GFP_KERNEL ); -if (!pm_req) { -rdt_last_cmd_puts ("Failure to allocate memory for PM QoS\n" ); - ret = -ENOMEM ; - goto out_err; - } - ret =dev_pm_qos_add_request (get_cpu_device (cpu), - &pm_req->req, -DEV_PM_QOS_RESUME_LATENCY , -30 ); -if (ret <0 ) { -rdt_last_cmd_printf ("Failed to add latency req CPU%d\n" , - cpu); -kfree (pm_req); - ret =-1 ; - goto out_err; - } -list_add (&pm_req->list, &plr->pm_reqs); - } - -return 0 ; - -out_err: -pseudo_lock_cstates_relax (plr); -return ret; -} - -/** -* pseudo_lock_region_clear - Reset pseudo-lock region data -* @plr: pseudo-lock region -* -* All content of the pseudo-locked region is reset - any memory allocated -* freed. -* -* Return: void -*/ -static void pseudo_lock_region_clear (struct pseudo_lock_region *plr) -{ - plr->size =0 ; - plr->line_size =0 ; -kfree (plr->kmem); - plr->kmem =NULL ; - plr->s =NULL ; -if (plr->d) - plr->d->plr =NULL ; - plr->d =NULL ; - plr->cbm =0 ; - plr->debugfs_dir =NULL ; -} - -/** -* pseudo_lock_region_init - Initialize pseudo-lock region information -* @plr: pseudo-lock region -* -* Called after user provided a schemata to be pseudo-locked. From the -* schemata the &struct pseudo_lock_region is on entry already initialized -* with the resource, domain, and capacity bitmask. Here the information -* required for pseudo-locking is deduced from this data and &struct -* pseudo_lock_region initialized further. This information includes: -* - size in bytes of the region to be pseudo-locked -* - cache line size to know the stride with which data needs to be accessed -* to be pseudo-locked -* - a cpu associated with the cache instance on which the pseudo-locking -* flow can be executed -* -* Return: 0 on success, <0 on failure. Descriptive error will be written -* to last_cmd_status buffer. -*/ -static int pseudo_lock_region_init (struct pseudo_lock_region *plr) -{ -enum resctrl_scope scope = plr->s->res->ctrl_scope; -struct cacheinfo *ci; -int ret; - -if (WARN_ON_ONCE (scope !=RESCTRL_L2_CACHE && scope !=RESCTRL_L3_CACHE )) -return -ENODEV ; - -/* Pick the first cpu we find that is associated with the cache. */ - plr->cpu =cpumask_first (&plr->d->hdr.cpu_mask); - -if (!cpu_online (plr->cpu)) { -rdt_last_cmd_printf ("CPU %u associated with cache not online\n" , - plr->cpu); - ret = -ENODEV ; - goto out_region; - } - - ci =get_cpu_cacheinfo_level (plr->cpu, scope); -if (ci) { - plr->line_size = ci->coherency_line_size; - plr->size =rdtgroup_cbm_to_size (plr->s->res, plr->d, plr->cbm); -return 0 ; - } - - ret =-1 ; -rdt_last_cmd_puts ("Unable to determine cache line size\n" ); -out_region: -pseudo_lock_region_clear (plr); -return ret; -} - -/** -* pseudo_lock_init - Initialize a pseudo-lock region -* @rdtgrp: resource group to which new pseudo-locked region will belong -* -* A pseudo-locked region is associated with a resource group. When this -* association is created the pseudo-locked region is initialized. The -* details of the pseudo-locked region are not known at this time so only -* allocation is done and association established. -* -* Return: 0 on success, <0 on failure -*/ -static int pseudo_lock_init (struct rdtgroup *rdtgrp) -{ -struct pseudo_lock_region *plr; - - plr =kzalloc (sizeof (*plr),GFP_KERNEL ); -if (!plr) -return -ENOMEM ; - -init_waitqueue_head (&plr->lock_thread_wq); -INIT_LIST_HEAD (&plr->pm_reqs); - rdtgrp->plr = plr; -return 0 ; -} - -/** -* pseudo_lock_region_alloc - Allocate kernel memory that will be pseudo-locked -* @plr: pseudo-lock region -* -* Initialize the details required to set up the pseudo-locked region and -* allocate the contiguous memory that will be pseudo-locked to the cache. -* -* Return: 0 on success, <0 on failure. Descriptive error will be written -* to last_cmd_status buffer. -*/ -static int pseudo_lock_region_alloc (struct pseudo_lock_region *plr) -{ -int ret; - - ret =pseudo_lock_region_init (plr); -if (ret <0 ) -return ret; - -/* -* We do not yet support contiguous regions larger than -* KMALLOC_MAX_SIZE. -*/ -if (plr->size >KMALLOC_MAX_SIZE ) { -rdt_last_cmd_puts ("Requested region exceeds maximum size\n" ); - ret = -E2BIG ; - goto out_region; - } - - plr->kmem =kzalloc (plr->size,GFP_KERNEL ); -if (!plr->kmem) { -rdt_last_cmd_puts ("Unable to allocate memory\n" ); - ret = -ENOMEM ; - goto out_region; - } - - ret =0 ; - goto out; -out_region: -pseudo_lock_region_clear (plr); -out: -return ret; -} - -/** -* pseudo_lock_free - Free a pseudo-locked region -* @rdtgrp: resource group to which pseudo-locked region belonged -* -* The pseudo-locked region's resources have already been released, or not -* yet created at this point. Now it can be freed and disassociated from the -* resource group. -* -* Return: void -*/ -static void pseudo_lock_free (struct rdtgroup *rdtgrp) -{ -pseudo_lock_region_clear (rdtgrp->plr); -kfree (rdtgrp->plr); - rdtgrp->plr =NULL ; -} -/** * resctrl_arch_pseudo_lock_fn - Load kernel memory into cache * @_plr: the pseudo-lock region descriptor @@ -542,340 +229,6 @@ int resctrl_arch_pseudo_lock_fn(void *_plr)return 0 ; } -/** -* rdtgroup_monitor_in_progress - Test if monitoring in progress -* @rdtgrp: resource group being queried -* -* Return: 1 if monitor groups have been created for this resource -* group, 0 otherwise. -*/ -static int rdtgroup_monitor_in_progress (struct rdtgroup *rdtgrp) -{ -return !list_empty (&rdtgrp->mon.crdtgrp_list); -} - -/** -* rdtgroup_locksetup_user_restrict - Restrict user access to group -* @rdtgrp: resource group needing access restricted -* -* A resource group used for cache pseudo-locking cannot have cpus or tasks -* assigned to it. This is communicated to the user by restricting access -* to all the files that can be used to make such changes. -* -* Permissions restored with rdtgroup_locksetup_user_restore() -* -* Return: 0 on success, <0 on failure. If a failure occurs during the -* restriction of access an attempt will be made to restore permissions but -* the state of the mode of these files will be uncertain when a failure -* occurs. -*/ -static int rdtgroup_locksetup_user_restrict (struct rdtgroup *rdtgrp) -{ -int ret; - - ret =rdtgroup_kn_mode_restrict (rdtgrp,"tasks" ); -if (ret) -return ret; - - ret =rdtgroup_kn_mode_restrict (rdtgrp,"cpus" ); -if (ret) - goto err_tasks; - - ret =rdtgroup_kn_mode_restrict (rdtgrp,"cpus_list" ); -if (ret) - goto err_cpus; - -if (resctrl_arch_mon_capable ()) { - ret =rdtgroup_kn_mode_restrict (rdtgrp,"mon_groups" ); -if (ret) - goto err_cpus_list; - } - - ret =0 ; - goto out; - -err_cpus_list: -rdtgroup_kn_mode_restore (rdtgrp,"cpus_list" ,0777 ); -err_cpus: -rdtgroup_kn_mode_restore (rdtgrp,"cpus" ,0777 ); -err_tasks: -rdtgroup_kn_mode_restore (rdtgrp,"tasks" ,0777 ); -out: -return ret; -} - -/** -* rdtgroup_locksetup_user_restore - Restore user access to group -* @rdtgrp: resource group needing access restored -* -* Restore all file access previously removed using -* rdtgroup_locksetup_user_restrict() -* -* Return: 0 on success, <0 on failure. If a failure occurs during the -* restoration of access an attempt will be made to restrict permissions -* again but the state of the mode of these files will be uncertain when -* a failure occurs. -*/ -static int rdtgroup_locksetup_user_restore (struct rdtgroup *rdtgrp) -{ -int ret; - - ret =rdtgroup_kn_mode_restore (rdtgrp,"tasks" ,0777 ); -if (ret) -return ret; - - ret =rdtgroup_kn_mode_restore (rdtgrp,"cpus" ,0777 ); -if (ret) - goto err_tasks; - - ret =rdtgroup_kn_mode_restore (rdtgrp,"cpus_list" ,0777 ); -if (ret) - goto err_cpus; - -if (resctrl_arch_mon_capable ()) { - ret =rdtgroup_kn_mode_restore (rdtgrp,"mon_groups" ,0777 ); -if (ret) - goto err_cpus_list; - } - - ret =0 ; - goto out; - -err_cpus_list: -rdtgroup_kn_mode_restrict (rdtgrp,"cpus_list" ); -err_cpus: -rdtgroup_kn_mode_restrict (rdtgrp,"cpus" ); -err_tasks: -rdtgroup_kn_mode_restrict (rdtgrp,"tasks" ); -out: -return ret; -} - -/** -* rdtgroup_locksetup_enter - Resource group enters locksetup mode -* @rdtgrp: resource group requested to enter locksetup mode -* -* A resource group enters locksetup mode to reflect that it would be used -* to represent a pseudo-locked region and is in the process of being set -* up to do so. A resource group used for a pseudo-locked region would -* lose the closid associated with it so we cannot allow it to have any -* tasks or cpus assigned nor permit tasks or cpus to be assigned in the -* future. Monitoring of a pseudo-locked region is not allowed either. -* -* The above and more restrictions on a pseudo-locked region are checked -* for and enforced before the resource group enters the locksetup mode. -* -* Returns: 0 if the resource group successfully entered locksetup mode, <0 -* on failure. On failure the last_cmd_status buffer is updated with text to -* communicate details of failure to the user. -*/ -int rdtgroup_locksetup_enter (struct rdtgroup *rdtgrp) -{ -int ret; - -/* -* The default resource group can neither be removed nor lose the -* default closid associated with it. -*/ -if (rdtgrp == &rdtgroup_default) { -rdt_last_cmd_puts ("Cannot pseudo-lock default group\n" ); -return -EINVAL ; - } - -/* -* Cache Pseudo-locking not supported when CDP is enabled. -* -* Some things to consider if you would like to enable this -* support (using L3 CDP as example): -* - When CDP is enabled two separate resources are exposed, -* L3DATA and L3CODE, but they are actually on the same cache. -* The implication for pseudo-locking is that if a -* pseudo-locked region is created on a domain of one -* resource (eg. L3CODE), then a pseudo-locked region cannot -* be created on that same domain of the other resource -* (eg. L3DATA). This is because the creation of a -* pseudo-locked region involves a call to wbinvd that will -* affect all cache allocations on particular domain. -* - Considering the previous, it may be possible to only -* expose one of the CDP resources to pseudo-locking and -* hide the other. For example, we could consider to only -* expose L3DATA and since the L3 cache is unified it is -* still possible to place instructions there are execute it. -* - If only one region is exposed to pseudo-locking we should -* still keep in mind that availability of a portion of cache -* for pseudo-locking should take into account both resources. -* Similarly, if a pseudo-locked region is created in one -* resource, the portion of cache used by it should be made -* unavailable to all future allocations from both resources. -*/ -if (resctrl_arch_get_cdp_enabled (RDT_RESOURCE_L3 ) || -resctrl_arch_get_cdp_enabled (RDT_RESOURCE_L2 )) { -rdt_last_cmd_puts ("CDP enabled\n" ); -return -EINVAL ; - } - -/* -* Not knowing the bits to disable prefetching implies that this -* platform does not support Cache Pseudo-Locking. -*/ -if (resctrl_arch_get_prefetch_disable_bits () ==0 ) { -rdt_last_cmd_puts ("Pseudo-locking not supported\n" ); -return -EINVAL ; - } - -if (rdtgroup_monitor_in_progress (rdtgrp)) { -rdt_last_cmd_puts ("Monitoring in progress\n" ); -return -EINVAL ; - } - -if (rdtgroup_tasks_assigned (rdtgrp)) { -rdt_last_cmd_puts ("Tasks assigned to resource group\n" ); -return -EINVAL ; - } - -if (!cpumask_empty (&rdtgrp->cpu_mask)) { -rdt_last_cmd_puts ("CPUs assigned to resource group\n" ); -return -EINVAL ; - } - -if (rdtgroup_locksetup_user_restrict (rdtgrp)) { -rdt_last_cmd_puts ("Unable to modify resctrl permissions\n" ); -return -EIO ; - } - - ret =pseudo_lock_init (rdtgrp); -if (ret) { -rdt_last_cmd_puts ("Unable to init pseudo-lock region\n" ); - goto out_release; - } - -/* -* If this system is capable of monitoring a rmid would have been -* allocated when the control group was created. This is not needed -* anymore when this group would be used for pseudo-locking. This -* is safe to call on platforms not capable of monitoring. -*/ -free_rmid (rdtgrp->closid, rdtgrp->mon.rmid); - - ret =0 ; - goto out; - -out_release: -rdtgroup_locksetup_user_restore (rdtgrp); -out: -return ret; -} - -/** -* rdtgroup_locksetup_exit - resource group exist locksetup mode -* @rdtgrp: resource group -* -* When a resource group exits locksetup mode the earlier restrictions are -* lifted. -* -* Return: 0 on success, <0 on failure -*/ -int rdtgroup_locksetup_exit (struct rdtgroup *rdtgrp) -{ -int ret; - -if (resctrl_arch_mon_capable ()) { - ret =alloc_rmid (rdtgrp->closid); -if (ret <0 ) { -rdt_last_cmd_puts ("Out of RMIDs\n" ); -return ret; - } - rdtgrp->mon.rmid = ret; - } - - ret =rdtgroup_locksetup_user_restore (rdtgrp); -if (ret) { -free_rmid (rdtgrp->closid, rdtgrp->mon.rmid); -return ret; - } - -pseudo_lock_free (rdtgrp); -return 0 ; -} - -/** -* rdtgroup_cbm_overlaps_pseudo_locked - Test if CBM or portion is pseudo-locked -* @d: RDT domain -* @cbm: CBM to test -* -* @d represents a cache instance and @cbm a capacity bitmask that is -* considered for it. Determine if @cbm overlaps with any existing -* pseudo-locked region on @d. -* -* @cbm is unsigned long, even if only 32 bits are used, to make the -* bitmap functions work correctly. -* -* Return: true if @cbm overlaps with pseudo-locked region on @d, false -* otherwise. -*/ -bool rdtgroup_cbm_overlaps_pseudo_locked (struct rdt_ctrl_domain *d,unsigned long cbm) -{ -unsigned int cbm_len; -unsigned long cbm_b; - -if (d->plr) { - cbm_len = d->plr->s->res->cache.cbm_len; - cbm_b = d->plr->cbm; -if (bitmap_intersects (&cbm, &cbm_b, cbm_len)) -return true; - } -return false; -} - -/** -* rdtgroup_pseudo_locked_in_hierarchy - Pseudo-locked region in cache hierarchy -* @d: RDT domain under test -* -* The setup of a pseudo-locked region affects all cache instances within -* the hierarchy of the region. It is thus essential to know if any -* pseudo-locked regions exist within a cache hierarchy to prevent any -* attempts to create new pseudo-locked regions in the same hierarchy. -* -* Return: true if a pseudo-locked region exists in the hierarchy of @d or -* if it is not possible to test due to memory allocation issue, -* false otherwise. -*/ -bool rdtgroup_pseudo_locked_in_hierarchy (struct rdt_ctrl_domain *d) -{ -struct rdt_ctrl_domain *d_i; -cpumask_var_t cpu_with_psl; -struct rdt_resource *r; -bool ret = false; - -/* Walking r->domains, ensure it can't race with cpuhp */ -lockdep_assert_cpus_held (); - -if (!zalloc_cpumask_var (&cpu_with_psl,GFP_KERNEL )) -return true; - -/* -* First determine which cpus have pseudo-locked regions -* associated with them. -*/ -for_each_alloc_capable_rdt_resource (r) { -list_for_each_entry (d_i, &r->ctrl_domains, hdr.list) { -if (d_i->plr) -cpumask_or (cpu_with_psl, cpu_with_psl, - &d_i->hdr.cpu_mask); - } - } - -/* -* Next test if new pseudo-locked region would intersect with -* existing region. -*/ -if (cpumask_intersects (&d->hdr.cpu_mask, cpu_with_psl)) - ret = true; - -free_cpumask_var (cpu_with_psl); -return ret; -} -/** * resctrl_arch_measure_cycles_lat_fn - Measure cycle latency to read * pseudo-locked memory @@ -1168,428 +521,3 @@ int resctrl_arch_measure_l3_residency(void *_plr)wake_up_interruptible (&plr->lock_thread_wq);return 0 ; } - -/** -* pseudo_lock_measure_cycles - Trigger latency measure to pseudo-locked region -* @rdtgrp: Resource group to which the pseudo-locked region belongs. -* @sel: Selector of which measurement to perform on a pseudo-locked region. -* -* The measurement of latency to access a pseudo-locked region should be -* done from a cpu that is associated with that pseudo-locked region. -* Determine which cpu is associated with this region and start a thread on -* that cpu to perform the measurement, wait for that thread to complete. -* -* Return: 0 on success, <0 on failure -*/ -static int pseudo_lock_measure_cycles (struct rdtgroup *rdtgrp,int sel) -{ -struct pseudo_lock_region *plr = rdtgrp->plr; -struct task_struct *thread; -unsigned int cpu; -int ret =-1 ; - -cpus_read_lock (); -mutex_lock (&rdtgroup_mutex); - -if (rdtgrp->flags &RDT_DELETED ) { - ret = -ENODEV ; - goto out; - } - -if (!plr->d) { - ret = -ENODEV ; - goto out; - } - - plr->thread_done =0 ; - cpu =cpumask_first (&plr->d->hdr.cpu_mask); -if (!cpu_online (cpu)) { - ret = -ENODEV ; - goto out; - } - - plr->cpu = cpu; - -if (sel ==1 ) - thread =kthread_run_on_cpu (resctrl_arch_measure_cycles_lat_fn, - plr, cpu,"pseudo_lock_measure/%u" ); -else if (sel ==2 ) - thread =kthread_run_on_cpu (resctrl_arch_measure_l2_residency, - plr, cpu,"pseudo_lock_measure/%u" ); -else if (sel ==3 ) - thread =kthread_run_on_cpu (resctrl_arch_measure_l3_residency, - plr, cpu,"pseudo_lock_measure/%u" ); -else - goto out; - -if (IS_ERR (thread)) { - ret =PTR_ERR (thread); - goto out; - } - - ret =wait_event_interruptible (plr->lock_thread_wq, - plr->thread_done ==1 ); -if (ret <0 ) - goto out; - - ret =0 ; - -out: -mutex_unlock (&rdtgroup_mutex); -cpus_read_unlock (); -return ret; -} - -static ssize_t pseudo_lock_measure_trigger (struct file *file, -const char __user *user_buf, -size_t count,loff_t *ppos) -{ -struct rdtgroup *rdtgrp = file->private_data; -size_t buf_size; -char buf[32 ]; -int ret; -int sel; - - buf_size =min (count, (sizeof (buf) -1 )); -if (copy_from_user (buf, user_buf, buf_size)) -return -EFAULT ; - - buf[buf_size] ='\0' ; - ret =kstrtoint (buf,10 , &sel); -if (ret ==0 ) { -if (sel !=1 && sel !=2 && sel !=3 ) -return -EINVAL ; - ret =debugfs_file_get (file->f_path.dentry); -if (ret) -return ret; - ret =pseudo_lock_measure_cycles (rdtgrp, sel); -if (ret ==0 ) - ret = count; -debugfs_file_put (file->f_path.dentry); - } - -return ret; -} - -static const struct file_operations pseudo_measure_fops = { - .write = pseudo_lock_measure_trigger, - .open = simple_open, - .llseek = default_llseek, -}; - -/** -* rdtgroup_pseudo_lock_create - Create a pseudo-locked region -* @rdtgrp: resource group to which pseudo-lock region belongs -* -* Called when a resource group in the pseudo-locksetup mode receives a -* valid schemata that should be pseudo-locked. Since the resource group is -* in pseudo-locksetup mode the &struct pseudo_lock_region has already been -* allocated and initialized with the essential information. If a failure -* occurs the resource group remains in the pseudo-locksetup mode with the -* &struct pseudo_lock_region associated with it, but cleared from all -* information and ready for the user to re-attempt pseudo-locking by -* writing the schemata again. -* -* Return: 0 if the pseudo-locked region was successfully pseudo-locked, <0 -* on failure. Descriptive error will be written to last_cmd_status buffer. -*/ -int rdtgroup_pseudo_lock_create (struct rdtgroup *rdtgrp) -{ -struct pseudo_lock_region *plr = rdtgrp->plr; -struct task_struct *thread; -unsigned int new_minor; -struct device *dev; -int ret; - - ret =pseudo_lock_region_alloc (plr); -if (ret <0 ) -return ret; - - ret =pseudo_lock_cstates_constrain (plr); -if (ret <0 ) { - ret = -EINVAL ; - goto out_region; - } - - plr->thread_done =0 ; - - thread =kthread_run_on_cpu (resctrl_arch_pseudo_lock_fn, plr, - plr->cpu,"pseudo_lock/%u" ); -if (IS_ERR (thread)) { - ret =PTR_ERR (thread); -rdt_last_cmd_printf ("Locking thread returned error %d\n" , ret); - goto out_cstates; - } - - ret =wait_event_interruptible (plr->lock_thread_wq, - plr->thread_done ==1 ); -if (ret <0 ) { -/* -* If the thread does not get on the CPU for whatever -* reason and the process which sets up the region is -* interrupted then this will leave the thread in runnable -* state and once it gets on the CPU it will dereference -* the cleared, but not freed, plr struct resulting in an -* empty pseudo-locking loop. -*/ -rdt_last_cmd_puts ("Locking thread interrupted\n" ); - goto out_cstates; - } - - ret =pseudo_lock_minor_get (&new_minor); -if (ret <0 ) { -rdt_last_cmd_puts ("Unable to obtain a new minor number\n" ); - goto out_cstates; - } - -/* -* Unlock access but do not release the reference. The -* pseudo-locked region will still be here on return. -* -* The mutex has to be released temporarily to avoid a potential -* deadlock with the mm->mmap_lock which is obtained in the -* device_create() and debugfs_create_dir() callpath below as well as -* before the mmap() callback is called. -*/ -mutex_unlock (&rdtgroup_mutex); - -if (!IS_ERR_OR_NULL (debugfs_resctrl)) { - plr->debugfs_dir =debugfs_create_dir (rdtgrp->kn->name, - debugfs_resctrl); -if (!IS_ERR_OR_NULL (plr->debugfs_dir)) -debugfs_create_file ("pseudo_lock_measure" ,0200 , - plr->debugfs_dir, rdtgrp, - &pseudo_measure_fops); - } - - dev =device_create (&pseudo_lock_class,NULL , -MKDEV (pseudo_lock_major, new_minor), - rdtgrp,"%s" , rdtgrp->kn->name); - -mutex_lock (&rdtgroup_mutex); - -if (IS_ERR (dev)) { - ret =PTR_ERR (dev); -rdt_last_cmd_printf ("Failed to create character device: %d\n" , - ret); - goto out_debugfs; - } - -/* We released the mutex - check if group was removed while we did so */ -if (rdtgrp->flags &RDT_DELETED ) { - ret = -ENODEV ; - goto out_device; - } - - plr->minor = new_minor; - - rdtgrp->mode =RDT_MODE_PSEUDO_LOCKED ; -closid_free (rdtgrp->closid); -rdtgroup_kn_mode_restore (rdtgrp,"cpus" ,0444 ); -rdtgroup_kn_mode_restore (rdtgrp,"cpus_list" ,0444 ); - - ret =0 ; - goto out; - -out_device: -device_destroy (&pseudo_lock_class,MKDEV (pseudo_lock_major, new_minor)); -out_debugfs: -debugfs_remove_recursive (plr->debugfs_dir); -pseudo_lock_minor_release (new_minor); -out_cstates: -pseudo_lock_cstates_relax (plr); -out_region: -pseudo_lock_region_clear (plr); -out: -return ret; -} - -/** -* rdtgroup_pseudo_lock_remove - Remove a pseudo-locked region -* @rdtgrp: resource group to which the pseudo-locked region belongs -* -* The removal of a pseudo-locked region can be initiated when the resource -* group is removed from user space via a "rmdir" from userspace or the -* unmount of the resctrl filesystem. On removal the resource group does -* not go back to pseudo-locksetup mode before it is removed, instead it is -* removed directly. There is thus asymmetry with the creation where the -* &struct pseudo_lock_region is removed here while it was not created in -* rdtgroup_pseudo_lock_create(). -* -* Return: void -*/ -void rdtgroup_pseudo_lock_remove (struct rdtgroup *rdtgrp) -{ -struct pseudo_lock_region *plr = rdtgrp->plr; - -if (rdtgrp->mode ==RDT_MODE_PSEUDO_LOCKSETUP ) { -/* -* Default group cannot be a pseudo-locked region so we can -* free closid here. -*/ -closid_free (rdtgrp->closid); - goto free; - } - -pseudo_lock_cstates_relax (plr); -debugfs_remove_recursive (rdtgrp->plr->debugfs_dir); -device_destroy (&pseudo_lock_class,MKDEV (pseudo_lock_major, plr->minor)); -pseudo_lock_minor_release (plr->minor); - -free: -pseudo_lock_free (rdtgrp); -} - -static int pseudo_lock_dev_open (struct inode *inode,struct file *filp) -{ -struct rdtgroup *rdtgrp; - -mutex_lock (&rdtgroup_mutex); - - rdtgrp =region_find_by_minor (iminor (inode)); -if (!rdtgrp) { -mutex_unlock (&rdtgroup_mutex); -return -ENODEV ; - } - - filp->private_data = rdtgrp; -atomic_inc (&rdtgrp->waitcount); -/* Perform a non-seekable open - llseek is not supported */ - filp->f_mode &= ~(FMODE_LSEEK |FMODE_PREAD |FMODE_PWRITE ); -Lines of this file are not shown. View the raw message.
arch/x86/kernel/cpu/resctrl/pseudo_lock_trace.h +2
-0Lines of this file are not shown. View the raw message.
arch/x86/kernel/cpu/resctrl/rdtgroup.c +2
-4292Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Since no trace event is defined in fs/resctrl/pseudo_lock_trace.h, gcc reports fatal error:
CC fs/resctrl/pseudo_lock.o
In file included from fs/resctrl/pseudo_lock_trace.h:17,
from fs/resctrl/pseudo_lock.c:35:./include/trace/define_trace.h:106:42: fatal error: ./pseudo_lock_trace.h: No such file or directory 106 | #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
| ^
compilation terminated.
This only happens when applying the first 45 patches. No error when applying the whole patch set since patch 46 removes this file.
Similar fix as the last email is to merge patch 45 and patch 46 together.
...
Thanks.
-Fenghua
Part of the diff is not shown here. View the raw message.
James Morse
reviewerPATCH v7 46/49 x86,fs/resctrl: Remove duplicated trace header files
In reply to James MorseThe copy-pasting python script harmlessly creates some empty trace point header files. Remove them.
---
Changes since v6:
* This patch is new.
--- arch/x86/kernel/cpu/resctrl/monitor.c | 4 ---- arch/x86/kernel/cpu/resctrl/monitor_trace.h | 17 ----------------- fs/resctrl/pseudo_lock.c | 4 ---- fs/resctrl/pseudo_lock_trace.h | 17 ----------------- 4 files changed, 42 deletions(-) delete mode 100644 arch/x86/kernel/cpu/resctrl/monitor_trace.h delete mode 100644 fs/resctrl/pseudo_lock_trace.h
arch/x86/kernel/cpu/resctrl/monitor.c +0 -4
@@ -27,10 +27,6 @@#include "internal.h" -#define CREATE_TRACE_POINTS - -#include "monitor_trace.h" -/* * Global boolean for rdt_monitor which is true if any * resource monitoring is enabled.
arch/x86/kernel/cpu/resctrl/monitor_trace.h deleted +0 -17
@@ -1,17 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#undef TRACE_SYSTEM -#define TRACE_SYSTEM resctrl - -#if !defined(_FS_RESCTRL_MONITOR_TRACE_H) || defined(TRACE_HEADER_MULTI_READ ) -#define _FS_RESCTRL_MONITOR_TRACE_H - -#include <linux/tracepoint.h> - -#endif /* _FS_RESCTRL_MONITOR_TRACE_H */ - -#undef TRACE_INCLUDE_PATH -#define TRACE_INCLUDE_PATH . - -#define TRACE_INCLUDE_FILE monitor_trace - -#include <trace/define_trace.h>
fs/resctrl/pseudo_lock.c +0 -4
@@ -30,10 +30,6 @@#include "../../events/perf_event.h" /* For X86_CONFIG() */ #include "internal.h" -#define CREATE_TRACE_POINTS - -#include "pseudo_lock_trace.h" -/* * Major number assigned to and shared by all devices exposing * pseudo-locked regions.
fs/resctrl/pseudo_lock_trace.h deleted +0 -17
@@ -1,17 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#undef TRACE_SYSTEM -#define TRACE_SYSTEM resctrl - -#if !defined(_X86_RESCTRL_PSEUDO_LOCK_TRACE_H) || defined(TRACE_HEADER_MULTI_READ ) -#define _X86_RESCTRL_PSEUDO_LOCK_TRACE_H - -#include <linux/tracepoint.h> - -#endif /* _X86_RESCTRL_PSEUDO_LOCK_TRACE_H */ - -#undef TRACE_INCLUDE_PATH -#define TRACE_INCLUDE_PATH . - -#define TRACE_INCLUDE_FILE pseudo_lock_trace - -#include <trace/define_trace.h>
Signature · 1 line
2.39.5
Re: [PATCH v7 46/49] x86,fs/resctrl: Remove duplicated trace header files
Hi, James,
Quoted 82 lines · James Morse
The copy-pasting python script harmlessly creates some empty trace point header files. Remove them.
Signed-off-by James Morse <[email protected]>---
Changes since v6:
* This patch is new.--- arch/x86/kernel/cpu/resctrl/monitor.c | 4 ---- arch/x86/kernel/cpu/resctrl/monitor_trace.h | 17 ----------------- fs/resctrl/pseudo_lock.c | 4 ---- fs/resctrl/pseudo_lock_trace.h | 17 ----------------- 4 files changed, 42 deletions(-)delete mode 100644
arch/x86/kernel/cpu/resctrl/monitor_trace.hdelete mode 100644fs/resctrl/pseudo_lock_trace.harch/x86/kernel/cpu/resctrl/monitor.c +0
-4@@ -27,10 +27,6 @@#include "internal.h" -#define CREATE_TRACE_POINTS - -#include "monitor_trace.h" -/* * Global boolean for rdt_monitor which is true if any * resource monitoring is enabled. arch/x86/kernel/cpu/resctrl/monitor_trace.h deleted +0
-17@@ -1,17 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#undef TRACE_SYSTEM -#define TRACE_SYSTEM resctrl - -#if !defined(_FS_RESCTRL_MONITOR_TRACE_H) || defined(TRACE_HEADER_MULTI_READ ) -#define _FS_RESCTRL_MONITOR_TRACE_H - -#include <linux/tracepoint.h> - -#endif /* _FS_RESCTRL_MONITOR_TRACE_H */ - -#undef TRACE_INCLUDE_PATH -#define TRACE_INCLUDE_PATH . - -#define TRACE_INCLUDE_FILE monitor_trace - -#include <trace/define_trace.h> fs/resctrl/pseudo_lock.c +0
-4@@ -30,10 +30,6 @@#include "../../events/perf_event.h" /* For X86_CONFIG() */ #include "internal.h" -#define CREATE_TRACE_POINTS - -#include "pseudo_lock_trace.h" -/* * Major number assigned to and shared by all devices exposing * pseudo-locked regions. fs/resctrl/pseudo_lock_trace.h deleted +0
-7@@ -1,17 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#undef TRACE_SYSTEM -#define TRACE_SYSTEM resctrl - -#if !defined(_X86_RESCTRL_PSEUDO_LOCK_TRACE_H) || defined(TRACE_HEADER_MULTI_READ ) -#define _X86_RESCTRL_PSEUDO_LOCK_TRACE_H -
fs/resctrl/pseudo_lock_trace.h line 17
Quoted 10 lines
fs/resctrl/pseudo_lock_trace.h deleted +0
-10-#include <linux/tracepoint.h> - -#endif /* _X86_RESCTRL_PSEUDO_LOCK_TRACE_H */ - -#undef TRACE_INCLUDE_PATH -#define TRACE_INCLUDE_PATH . - -#define TRACE_INCLUDE_FILE pseudo_lock_trace - -#include <trace/define_trace.h>
This patch may be merged into patch #45 to fix the compilation errors in patch #45?
Thanks.
-Fenghua
James Morse
reviewerRe: [PATCH v7 46/49] x86,fs/resctrl: Remove duplicated trace header files
Hi Fenghua,
Quoted 21 lines · Fenghua Yu
Quoted 20 lines · James Morse
The copy-pasting python script harmlessly creates some empty trace point header files. Remove them.
fs/resctrl/pseudo_lock_trace.h deleted +0
-11@@ -1,17 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#undef TRACE_SYSTEM -#define TRACE_SYSTEM resctrl - -#if !defined(_X86_RESCTRL_PSEUDO_LOCK_TRACE_H) || defined(TRACE_HEADER_MULTI_READ ) -#define _X86_RESCTRL_PSEUDO_LOCK_TRACE_H - -#include <linux/tracepoint.h> - -#endif /* _X86_RESCTRL_PSEUDO_LOCK_TRACE_H */ -
Quoted 8 lines
fs/resctrl/pseudo_lock_trace.h line 17
Quoted 6 lines
fs/resctrl/pseudo_lock_trace.h deleted +0
-6-#undef TRACE_INCLUDE_PATH -#define TRACE_INCLUDE_PATH . - -#define TRACE_INCLUDE_FILE pseudo_lock_trace - -#include <trace/define_trace.h> This patch may be merged into patch #45 to fix the compilation errors in patch #45?
As a final step before merging it. Otherwise patch 45 is impossible to work with - it can't be reviewed, but it can be regenerated. (and the script that does that inspected to show I have nothing up my sleeve!).
The alternative is a patch that is "mostly generated, but then lightly messed with", which means we would want someone to double check it.
Thanks,
James
James Morse
reviewerPATCH v7 47/49 fs/resctrl: Remove unnecessary includes
In reply to James MorseWhen splitting and moving the resctrl code to live in fs/resctrl and arch/x86, some code was duplicated. This was done to keep the parser in the script that does the moving simple. These extra includes are harmless on x86.
Remove them to allow other architectures to start using fs/resctrl.
---
Changes since v6:
* This patch is new.
--- fs/resctrl/monitor.c | 2 -- fs/resctrl/pseudo_lock.c | 1 - 2 files changed, 3 deletions(-)
fs/resctrl/monitor.c +0 -2
@@ -23,8 +23,6 @@#include <linux/sizes.h> #include <linux/slab.h> -#include <asm/cpu_device_id.h> -#include "internal.h" #define CREATE_TRACE_POINTS
fs/resctrl/pseudo_lock.c +0 -1
@@ -27,7 +27,6 @@#include <asm/cpu_device_id.h> #include <asm/perf_event.h> -#include "../../events/perf_event.h" /* For X86_CONFIG() */ #include "internal.h" /*
Signature · 1 line
2.39.5
Re: [PATCH v7 47/49] fs/resctrl: Remove unnecessary includes
Hi, James,
Quoted 3 lines · James Morse
When splitting and moving the resctrl code to live in fs/resctrl and
arch/x86, some code was duplicated. This was done to keep the parser in the script that does the moving simple. These extra includes are
As for "parser in the script", my concern is people may forget or don't know the context of the python script in the future and get confused when reading this patch.
Is it possible to merge this patch into patch 45 which introduces the macros? It simplify the patch set and avoid future confuse?
Quoted 31 lines
harmless on x86.
Remove them to allow other architectures to start using fs/resctrl.
Signed-off-by James Morse <[email protected]>---
Changes since v6:
* This patch is new.--- fs/resctrl/monitor.c | 2 -- fs/resctrl/pseudo_lock.c | 1 - 2 files changed, 3 deletions(-)fs/resctrl/monitor.c +0
-2@@ -23,8 +23,6 @@#include <linux/sizes.h> #include <linux/slab.h> -#include <asm/cpu_device_id.h> -#include "internal.h" #define CREATE_TRACE_POINTS fs/resctrl/pseudo_lock.c +0
-0
fs/resctrl/pseudo_lock.c line 32
Quoted 7 lines
fs/resctrl/pseudo_lock.c +0
-1@@ -27,7 +27,6 @@#include <asm/cpu_device_id.h> #include <asm/perf_event.h> -#include "../../events/perf_event.h" /* For X86_CONFIG() */ #include "internal.h" /*
Thanks.
-Fenghua
James Morse
reviewerRe: [PATCH v7 47/49] fs/resctrl: Remove unnecessary includes
Hi Fenghua,
Quoted 10 lines · Fenghua Yu
Quoted 3 lines · James Morse
When splitting and moving the resctrl code to live in fs/resctrl and
arch/x86, some code was duplicated. This was done to keep the parser in the script that does the moving simple. These extra includes areAs for "parser in the script", my concern is people may forget or don't know the context of the python script in the future and get confused when reading this patch.
Is it possible to merge this patch into patch 45 which introduces the macros? It simplify the patch set and avoid future confuse?
The plan would be for these patches to get merged together by the person that applies them.
Thanks,
James
Reinette Chatre
maintainerRe: [PATCH v7 47/49] fs/resctrl: Remove unnecessary includes
In reply to James MorseHi James,
Quoted 9 lines · James Morse
When splitting and moving the resctrl code to live in fs/resctrl and
arch/x86, some code was duplicated. This was done to keep the parser in the script that does the moving simple. These extra includes are harmless on x86.Remove them to allow other architectures to start using fs/resctrl.
Signed-off-by James Morse <[email protected]>---
I think it is going to take more digging to find all the unnecessary includes. For example, one that was easy to spot is the include of linux/kthread.h in arch/x86/kernel/cpu/resctrl/pseudo_lock.c
Reinette
James Morse
reviewerPATCH v7 48/49 fs/resctrl: Change internal.h's header guard macros
In reply to James MorseThe code in internal.h was moved by a script. The script didn't know to change the header guard macros. Do that.
---
Changes since v6:
* This patch is new.
--- fs/resctrl/internal.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/resctrl/internal.h +3 -3
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ASM_X86_RESCTRL_INTERNAL_H -#define _ASM_X86_RESCTRL_INTERNAL_H +#ifndef _FS_RESCTRL_INTERNAL_H +#define _FS_RESCTRL_INTERNAL_H#include <linux/resctrl.h> #include <linux/sched.h>
@@ -432,4 +432,4 @@ static inline int rdtgroup_pseudo_lock_create(struct rdtgroup *rdtgrp)static inline void rdtgroup_pseudo_lock_remove (struct rdtgroup *rdtgrp) { }#endif /* CONFIG_RESCTRL_FS_PSEUDO_LOCK */ -#endif /* _ASM_X86_RESCTRL_INTERNAL_H */ +#endif /* _FS_RESCTRL_INTERNAL_H */
Signature · 1 line
2.39.5
Re: [PATCH v7 48/49] fs/resctrl: Change internal.h's header guard macros
Hi, James,
Quoted 2 lines · James Morse
The code in
internal.hwas moved by a script. The script didn't know to change the header guard macros. Do that.
As for "The script ...", people may forget or don't know the context of the script in the future.
Is it better to merge this patch into patch #45 to avoid future confusion?
Quoted 22 lines
Signed-off-by James Morse <[email protected]>---
Changes since v6:
* This patch is new.--- fs/resctrl/internal.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)fs/resctrl/internal.h +2
-2@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ASM_X86_RESCTRL_INTERNAL_H -#define _ASM_X86_RESCTRL_INTERNAL_H +#ifndef _FS_RESCTRL_INTERNAL_H +#define _FS_RESCTRL_INTERNAL_H#include <linux/resctrl.h> #include <linux/sched.h>
fs/resctrl/internal.h static inline int rdtgroup_pseudo_lock_create(struct rdtgroup *rdtgrp) · line 435
Quoted 5 lines
fs/resctrl/internal.h +1
-1@@ -432,4 +432,4 @@ static inline int rdtgroup_pseudo_lock_create(struct rdtgroup *rdtgrp)static inline void rdtgroup_pseudo_lock_remove (struct rdtgroup *rdtgrp) { }#endif /* CONFIG_RESCTRL_FS_PSEUDO_LOCK */ -#endif /* _ASM_X86_RESCTRL_INTERNAL_H */ +#endif /* _FS_RESCTRL_INTERNAL_H */
Thanks.
-Fenghua
James Morse
reviewerPATCH v7 49/49 x86,fs/resctrl: Move resctrl.rst to live under Documentation/filesystems
In reply to James MorseThe filesystem code has moved from arch/x86 to fs. Move the documentation too.
---
Changes since v6:
* This patch is new.
---
Documentation/arch/x86/index.rst | 1 -
Documentation/filesystems/index.rst | 1 +
Documentation/{arch/x86 => filesystems}/resctrl.rst | 0
MAINTAINERS | 2 +-
arch/x86/kernel/cpu/resctrl/monitor.c | 2 +-
fs/resctrl/Kconfig | 2 +-
6 files changed, 4 insertions(+), 4 deletions(-)
rename Documentation/{arch/x86 => filesystems}/resctrl.rst (100%)Documentation/arch/x86/index.rst +0 -1
@@ -31,7 +31,6 @@ x86-specific Documentation pti mds microcode - resctrl tsx_async_abort buslock usb-legacy-support
Documentation/filesystems/index.rst +1 -0
@@ -113,6 +113,7 @@ Documentation for filesystem implementations. qnx6 ramfs-rootfs-initramfs relay + resctrl romfs smb/index spufs/index
Documentation/filesystems/resctrl.rst renamed from Documentation/arch/x86/resctrl.rst +0 -0
MAINTAINERS +1 -1
@@ -19878,7 +19878,7 @@ M: Fenghua Yu <[email protected]> M: Reinette Chatre <[email protected]> L: [email protected] S: Supported -F: Documentation/arch/x86/resctrl* +F: Documentation/filesystems/resctrl.rst F: arch/x86/include/asm/resctrl.h F: arch/x86/kernel/cpu/resctrl/ F: fs/resctrl/
arch/x86/kernel/cpu/resctrl/monitor.c +1 -1
@@ -43,7 +43,7 @@ unsigned int rdt_mon_features;static int snc_nodes_per_l3_cache =1 ;/* -* The correction factor table is documented in Documentation/arch/x86/resctrl.rst. +* The correction factor table is documented in Documentation/filesystems/resctrl.rst. * If rmid > rmid threshold, MBM total and local values should be multiplied * by the correction factor. *
fs/resctrl/Kconfig +1 -1
@@ -21,7 +21,7 @@ config RESCTRL_FS On architectures where this can be disabled independently, it is safe to say N. - See <file:Documentation/arch/x86/resctrl.rst> for more information. + See <file:Documentation/filesystems/resctrl.rst> for more information. config RESCTRL_FS_PSEUDO_LOCK bool
Signature · 1 line
2.39.5
Re: [PATCH v7 49/49] x86,fs/resctrl: Move resctrl.rst to live under Documentation/filesystems
Quoted 4 lines · James Morse
The filesystem code has moved from
arch/x86to fs. Move the documentation too.Signed-off-by James Morse <[email protected]>
Thanks.
-Fenghua
Hi James,
Quoted 146 lines · James Morse
Changes since v6?:
* All the excitement is in patch 37, turns out there are twormdir()paths that don't join up.
The last eight patches are new:
* The python script has been replaced with the patch that it generates, see the bare branch below if you want to regenerate it.
* There have been comments on the followup to the generated patch, those are included here - I suggest they be squashed into the generated patch.
* This version includes some checkpatch linting from Dave.---
This series renames functions and moves code around. With the exception of invalid configurations for the configurable-events, there should be no changes in behaviour caused by this series. It is now possible forthrottle_modeto report 'undefined', but no known platform will do this.The driving pattern is to make things like struct rdtgroup private to resctrl. Features like pseudo-lock aren't going to work on arm64, the ability to disable it at compile time is added.
After this, I can start posting the MPAM driver to make use of resctrl on arm64. (What's MPAM? See the cover letter of the first series. [1])
This series is based on v6.14-rc3 and can be retrieved from:
https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git mpam/move_to_fs/v7 or for those who want to regnerate the patch that moves all the code:
https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git mpam/move_to_fs/v7_bareAs ever - bugs welcome,
Thanks,James
[v6] https://lore.kernel.org/lkml/[email protected]/
[v5] https://lore.kernel.org/r/[email protected]
[v4] https://lore.kernel.org/all/[email protected]/
[v3] https://lore.kernel.org/r/[email protected]
[v2] https://lore.kernel.org/r/[email protected]
[v1] https://lore.kernel.org/r/[email protected]
[1] https://lore.kernel.org/lkml/[email protected]/Amit Singh Tomar (1):
x86/resctrl: Remove the limit on the number of CLOSIDDave Martin (3):
x86/resctrl: Squelch whitespace anomalies in resctrl core code x86/resctrl: Prefer alloc(sizeof(*foo)) idiom inrdt_init_fs_context()x86/resctrl: Relax some asm #includesJames Morse (45):
x86/resctrl: Fix allocation of cleanest CLOSID on platforms with no
monitors
x86/resctrl: Add a helper to avoid reaching into the arch code
resource list
x86/resctrl: Remove fflags from structrdt_resourcex86/resctrl: Use schema type to determine how to parse schema values x86/resctrl: Use schema type to determine the schema format string x86/resctrl: Removedata_widthand the tabular format x86/resctrl: Addmax_bwto structresctrl_membwx86/resctrl: Generatedefault_ctrlinstead of sharing it x86/resctrl: Add helper for setting CPU default properties x86/resctrl: Remove rdtgroup fromupdate_cpu_closid_rmid()x86/resctrl: Expose resctrl fs's init function to the rest of the
kernel
x86/resctrl: Moverdt_find_domain()to be visible to arch and fs code x86/resctrl: Move resctrl types to a separate header x86/resctrl: Add an arch helper to reset one resource x86/resctrl: Move monitor exit work to a resctrl exit call x86/resctrl: Move monitor init work to a resctrl init call x86/resctrl: Rewrite and move the for_each_*_rdt_resource() walkers x86/resctrl: Move the is_mbm_*_enabled() helpers toasm/resctrl.hx86/resctrl: Addresctrl_arch_is_evt_configurable()to abstract BMEC x86/resctrl: Change mon_event_config_{read,write}() to be arch helpers x86/resctrl: Movemba_mbps_default_eventinit to filesystem code x86/resctrl: Movembm_cfg_maskto structrdt_resourcex86/resctrl: Addresctrl_arch_prefix to pseudo lock functions x86/resctrl: Allow an architecture to disable pseudo lock x86/resctrl: Makeprefetch_disable_bitsbelong to the arch code x86/resctrl: Makeresctrl_arch_pseudo_lock_fn()take a plr x86/resctrl: Move RFTYPE flags to be managed by resctrl x86/resctrl: Handlethrottle_modefor SMBA resources x86/resctrl: Moveget_config_index()to a header x86/resctrl: Move get_{mon,ctrl}_domain_from_cpu() to live with their
callers
x86/resctrl: Renameresctrl_sched_in()to begin with "resctrl_arch_" x86/resctrl:resctrl_exit()teardown resctrl but leave the mount point x86/resctrl: Drop __init/__exit on assorted symbols x86/resctrl: Moveis_mba_sc()out ofcore.c
x86/resctrl: Add end-marker to theresctrl_event_idenum x86/resctrl: Expand the width ofdom_idby replacingmon_data_bitsx86/resctrl: Remove a newline to avoid confusing the code move script x86/resctrl: Splittrace.h
fs/resctrl: Add boiler plate for external resctrl code x86/resctrl: Move the filesystem bits to headers visible to fs/resctrl x86,fs/resctrl: Move the resctrl filesystem code to live in
/fs/resctrl
x86,fs/resctrl: Remove duplicated trace header files fs/resctrl: Remove unnecessary includes
fs/resctrl: Change internal.h's header guard macros x86,fs/resctrl: Moveresctrl.rstto live under
Documentation/filesystemsDocumentation/arch/x86/index.rst | 1 - Documentation/filesystems/index.rst | 1 + .../{arch/x86 => filesystems}/resctrl.rst | 0 MAINTAINERS | 4 +- arch/Kconfig | 8 + arch/x86/Kconfig | 6 +- arch/x86/include/asm/resctrl.h | 43 +- arch/x86/kernel/cpu/resctrl/Makefile | 8 +- arch/x86/kernel/cpu/resctrl/core.c | 214 +- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 606 +-- arch/x86/kernel/cpu/resctrl/internal.h | 504 +- arch/x86/kernel/cpu/resctrl/monitor.c | 863 +--- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 1120 +---- .../resctrl/{trace.h => pseudo_lock_trace.h} | 26 +- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4031 +-------------- arch/x86/kernel/process_32.c | 2 +- arch/x86/kernel/process_64.c | 2 +- fs/Kconfig | 1 + fs/Makefile | 1 + fs/resctrl/Kconfig | 39 + fs/resctrl/Makefile | 6 + fs/resctrl/ctrlmondata.c | 660 +++ fs/resctrl/internal.h | 435 ++ fs/resctrl/monitor.c | 933 ++++ fs/resctrl/monitor_trace.h | 33 + fs/resctrl/pseudo_lock.c | 1104 +++++ fs/resctrl/rdtgroup.c | 4329 +++++++++++++++++ include/linux/resctrl.h | 216 +- include/linux/resctrl_types.h | 59 + 29 files changed, 7992 insertions(+), 7263 deletions(-) rename Documentation/{arch/x86 => filesystems}/resctrl.rst (100%) rename arch/x86/kernel/cpu/resctrl/{trace.h => pseudo_lock_trace.h} (56%) create mode 100644 fs/resctrl/Kconfig create mode 100644 fs/resctrl/Makefile create mode 100644 fs/resctrl/ctrlmondata.c create mode 100644 fs/resctrl/internal.h create mode 100644 fs/resctrl/monitor.c create mode 100644 fs/resctrl/monitor_trace.h create mode 100644 fs/resctrl/pseudo_lock.c create mode 100644 fs/resctrl/rdtgroup.c create mode 100644 include/linux/resctrl_types.h
Quoted 3 lines
--
2.39.5
I applied the series successfully and ran through my usual assortment of container management-oriented testcases on the following implementations:
* AMD EPYC 7B12 64-Core Processor
* Intel(R) Xeon(R) Gold 6268CL CPU @ 2.80GHz
Everything looked good.
Thanks!
-Peter
James Morse
reviewerHi Peter,
Quoted 30 lines · Peter Newman
Quoted 21 lines · James Morse
Changes since v6?:
* All the excitement is in patch 37, turns out there are twormdir()paths that don't join up.
The last eight patches are new:
* The python script has been replaced with the patch that it generates, see the bare branch below if you want to regenerate it.
* There have been comments on the followup to the generated patch, those are included here - I suggest they be squashed into the generated patch.
* This version includes some checkpatch linting from Dave.---
This series renames functions and moves code around. With the exception of invalid configurations for the configurable-events, there should be no changes in behaviour caused by this series. It is now possible forthrottle_modeto report 'undefined', but no known platform will do this.The driving pattern is to make things like struct rdtgroup private to resctrl. Features like pseudo-lock aren't going to work on arm64, the ability to disable it at compile time is added.
Quoted 7 lines
After this, I can start posting the MPAM driver to make use of resctrl on arm64. (What's MPAM? See the cover letter of the first series. [1])
This series is based on v6.14-rc3 and can be retrieved from:
https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git mpam/move_to_fs/v7 or for those who want to regnerate the patch that moves all the code:
https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git mpam/move_to_fs/v7_bare
Quoted 5 lines
I applied the series successfully and ran through my usual assortment of container management-oriented testcases on the following implementations:
* AMD EPYC 7B12 64-Core Processor
Great! This is something I've not managed to get my hands on.
Quoted 5 lines
* Intel(R) Xeon(R) Gold 6268CL CPU @ 2.80GHz
Everything looked good.
Tested-by Peter Newman <[email protected]>
Thanks!
James
Luck, Tony
maintainerQuoted 29 lines · James Morse
Changes since v6?:
* All the excitement is in patch 37, turns out there are twormdir()paths that don't join up.
The last eight patches are new:
* The python script has been replaced with the patch that it generates, see the bare branch below if you want to regenerate it.
* There have been comments on the followup to the generated patch, those are included here - I suggest they be squashed into the generated patch.
* This version includes some checkpatch linting from Dave.---
This series renames functions and moves code around. With the exception of invalid configurations for the configurable-events, there should be no changes in behaviour caused by this series. It is now possible forthrottle_modeto report 'undefined', but no known platform will do this.The driving pattern is to make things like struct rdtgroup private to resctrl. Features like pseudo-lock aren't going to work on arm64, the ability to disable it at compile time is added.
After this, I can start posting the MPAM driver to make use of resctrl on arm64. (What's MPAM? See the cover letter of the first series. [1])
This series is based on v6.14-rc3 and can be retrieved from:
https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git mpam/move_to_fs/v7 or for those who want to regnerate the patch that moves all the code:
https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git mpam/move_to_fs/v7_bare
Quoted 4 lines
As ever - bugs welcome,
Thanks,James
Upstream is at -rc5, so it's time to pick what to ask Boris to apply to tip for the upcoming v6.15 merge window.
There are several open issues for Babu's ABMC series. So it isn't ready at this time.
Also several against this MPAM series from James ... but IMHO the first bunch of patches look to be in good shape with a full set of Reviewed-by and Tested-by tags on parts 1-7,9-11,13-17 (things get murkier in the 20's and maybe more likely to have issues due to skipping patches that don't have all their tags).
So I applied those patches on top of v6.14-rc5 (all but one applied automatically, patch 10 had two line "fuzz" due to skipping patch 8).
Resulting kernel builds (with W=1), boots, and passes the tests in tools/tests/selftests/resctrl.
In the interests of making forward progress, should we ask Boris to take this subset of the MPAM series?
-Tony
Reinette Chatre
maintainerQuoted 47 lines · Tony
Quoted 29 lines · James Morse
Changes since v6?:
* All the excitement is in patch 37, turns out there are twormdir()paths that don't join up.
The last eight patches are new:
* The python script has been replaced with the patch that it generates, see the bare branch below if you want to regenerate it.
* There have been comments on the followup to the generated patch, those are included here - I suggest they be squashed into the generated patch.
* This version includes some checkpatch linting from Dave.---
This series renames functions and moves code around. With the exception of invalid configurations for the configurable-events, there should be no changes in behaviour caused by this series. It is now possible forthrottle_modeto report 'undefined', but no known platform will do this.The driving pattern is to make things like struct rdtgroup private to resctrl. Features like pseudo-lock aren't going to work on arm64, the ability to disable it at compile time is added.
After this, I can start posting the MPAM driver to make use of resctrl on arm64. (What's MPAM? See the cover letter of the first series. [1])
This series is based on v6.14-rc3 and can be retrieved from:
https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git mpam/move_to_fs/v7 or for those who want to regnerate the patch that moves all the code:
https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git mpam/move_to_fs/v7_bareQuoted 4 lines
As ever - bugs welcome,
Thanks,James
Upstream is at -rc5, so it's time to pick what to ask Boris to apply to tip for the upcoming v6.15 merge window.
There are several open issues for Babu's ABMC series. So it isn't ready at this time.
Also several against this MPAM series from James ... but IMHO the first bunch of patches look to be in good shape with a full set of Reviewed-by and Tested-by tags on parts 1-7,9-11,13-17 (things get murkier in the 20's and maybe more likely to have issues due to skipping patches that don't have all their tags).
Quoted 9 lines
So I applied those patches on top of v6.14-rc5 (all but one applied automatically, patch 10 had two line "fuzz" due to skipping patch 8).
Resulting kernel builds (with W=1), boots, and passes the tests in
tools/tests/selftests/resctrl.In the interests of making forward progress, should we ask Boris to take this subset of the MPAM series?
Sounds like there may have only been about a five minute window for clarifying questions about v6 before the door was shut on it. Since I missed that window by a couple of hours I'll move to v7 where the MPAM pressure has so promptly shifted.
I'd be happy to work with Boris and other x86 maintainers on any mechanism they prefer.
Reinette
Moger, Babu
reviewerQuoted 36 lines · Reinette Chatre
Quoted 33 lines · Tony
Quoted 32 lines · James Morse
Changes since v6?:
* All the excitement is in patch 37, turns out there are twormdir()paths that don't join up.
The last eight patches are new:
* The python script has been replaced with the patch that it generates, see the bare branch below if you want to regenerate it.
* There have been comments on the followup to the generated patch, those are included here - I suggest they be squashed into the generated patch.
* This version includes some checkpatch linting from Dave.---
This series renames functions and moves code around. With the exception of invalid configurations for the configurable-events, there should be no changes in behaviour caused by this series. It is now possible forthrottle_modeto report 'undefined', but no known platform will do this.The driving pattern is to make things like struct rdtgroup private to resctrl. Features like pseudo-lock aren't going to work on arm64, the ability to disable it at compile time is added.
After this, I can start posting the MPAM driver to make use of resctrl on arm64. (What's MPAM? See the cover letter of the first series. [1])
This series is based on v6.14-rc3 and can be retrieved from:
https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git mpam/move_to_fs/v7 or for those who want to regnerate the patch that moves all the code:
https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git mpam/move_to_fs/v7_bareAs ever - bugs welcome,
Thanks,
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
James
Upstream is at -rc5, so it's time to pick what to ask Boris to apply to tip for the upcoming v6.15 merge window.
There are several open issues for Babu's ABMC series. So it isn't ready at this time.
I agree. ABMC series is not ready yet.
This series should merge first. I have tested on couple of AMD systems and everything looks good. I will respond with Tested-by and reviewed-by.
Quoted 17 lines
Quoted 7 lines
Also several against this MPAM series from James ... but IMHO the first bunch of patches look to be in good shape with a full set of Reviewed-by and Tested-by tags on parts 1-7,9-11,13-17 (things get murkier in the 20's and maybe more likely to have issues due to skipping patches that don't have all their tags).
Quoted 9 lines
So I applied those patches on top of v6.14-rc5 (all but one applied automatically, patch 10 had two line "fuzz" due to skipping patch 8).
Resulting kernel builds (with W=1), boots, and passes the tests in
tools/tests/selftests/resctrl.In the interests of making forward progress, should we ask Boris to take this subset of the MPAM series?
Quoted 8 lines
Sounds like there may have only been about a five minute window for clarifying questions about v6 before the door was shut on it. Since I missed that window by a couple of hours I'll move to v7 where the MPAM pressure has so promptly shifted.
I'd be happy to work with Boris and other x86 maintainers on any mechanism they prefer.
Sure. Please go ahead.
Signature · 2 lines
Thanks Babu Moger
Hello James
I ran tools/tests/selftests/resctrl on Intel(R) Xeon(R) Gold 6338T CPU @ 2.10GHz, there is no problem.
Best regards,
Shaopeng TAN
James Morse
reviewerHello!
Quoted 3 lines · Shaopeng Tan (Fujitsu)
I ran
tools/tests/selftests/resctrlon Intel(R) Xeon(R) Gold 6338T CPU @ 2.10GHz, there is no problem.Tested-by Shaopeng Tan <[email protected]>
Thanks for testing again!
James
v7 cover x86/resctrl: Move the resctrl filesystem code to /fs/resctrl
In reply to James MorseHi James,
Changes since v6?:
Quoted 19 lines
* All the excitement is in patch 37, turns out there are two
rmdir()paths that don't join up.
The last eight patches are new:
* The python script has been replaced with the patch that it generates, see the bare branch below if you want to regenerate it.
* There have been comments on the followup to the generated patch, those are included here - I suggest they be squashed into the generated patch.
* This version includes some checkpatch linting from Dave.---
This series renames functions and moves code around. With the exception of invalid configurations for the configurable-events, there should be no changes in behaviour caused by this series. It is now possible forthrottle_modeto report 'undefined', but no known platform will do this.The driving pattern is to make things like struct rdtgroup private to resctrl. Features like pseudo-lock aren't going to work on arm64, the ability to disable it at compile time is added.
Quoted 6 lines
After this, I can start posting the MPAM driver to make use of resctrl on arm64. (What's MPAM? See the cover letter of the first series. [1])
This series is based on v6.14-rc3 and can be retrieved from:
https://urldefense.proofpoint.com/v2/url?u=https-3A__git.kernel.org_pub_scm_linux_kernel_git_morse_linux.git&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=34Q-cAJD41LWUgU21FvoSkXHOM-uSrOs2a1vEwaxrNE&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__git.kernel.org_pub_scm_linux_kernel_git_morse_linux.git&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=34Q-cAJD41LWUgU21FvoSkXHOM-uSrOs2a1vEwaxrNE&e=> mpam/move_to_fs/v7 or for those who want to regnerate the patch that moves all the code:
After rebasing mpam/snapshot/v6.14-rc1 on top of this series, Tested a few MPAM controls, including Cache Portion Partitioning and Memory Bandwidth Partitioning, on Marvell CN10K ARM64 platform, and It looks good.
For this patch-set:
Quoted 122 lines
https://urldefense.proofpoint.com/v2/url?u=https-3A__git.kernel.org_pub_scm_linux_kernel_git_morse_linux.git&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=34Q-cAJD41LWUgU21FvoSkXHOM-uSrOs2a1vEwaxrNE&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__git.kernel.org_pub_scm_linux_kernel_git_morse_linux.git&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=34Q-cAJD41LWUgU21FvoSkXHOM-uSrOs2a1vEwaxrNE&e=> mpam/move_to_fs/v7_bare
As ever - bugs welcome,
Thanks,James
[v6]https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_lkml_20250207181823.6378-2D1-2Djames.morse-40arm.com_&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=Giw7Cw-bCKcY06OE4h_CYGNmKoeW3Rnf9Ph433fTflg&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_lkml_20250207181823.6378-2D1-2Djames.morse-40arm.com_&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=Giw7Cw-bCKcY06OE4h_CYGNmKoeW3Rnf9Ph433fTflg&e=>
[v5]https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20241004180347.19985-2D1-2Djames.morse-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=NuPo6XsrzJWgoWgnhpf5PxXdFEozS_Zgk_XBTnhAn6k&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20241004180347.19985-2D1-2Djames.morse-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=NuPo6XsrzJWgoWgnhpf5PxXdFEozS_Zgk_XBTnhAn6k&e=>
[v4]https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_all_20240802172853.22529-2D1-2Djames.morse-40arm.com_&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=x0enrBNorLUBSyhg_SOJl9itXA4Ht_65SifVAOpMEO4&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_all_20240802172853.22529-2D1-2Djames.morse-40arm.com_&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=x0enrBNorLUBSyhg_SOJl9itXA4Ht_65SifVAOpMEO4&e=>
[v3]https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20240614150033.10454-2D1-2Djames.morse-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=FPG_ZTHC69sPw7sz4QOvpKZ76X7VQSTuO2yN67LY4VI&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20240614150033.10454-2D1-2Djames.morse-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=FPG_ZTHC69sPw7sz4QOvpKZ76X7VQSTuO2yN67LY4VI&e=>
[v2]https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20240426150537.8094-2D1-2DDave.Martin-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=C--gCozXx-zNwx631Snz1h6SShLrm546dr0_ISKSC9A&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20240426150537.8094-2D1-2DDave.Martin-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=C--gCozXx-zNwx631Snz1h6SShLrm546dr0_ISKSC9A&e=>
[v1]https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20240321165106.31602-2D1-2Djames.morse-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=0PJ7kJsoRhwOqCcYwUYrJwbRM9zTssWuhqkgaqXdPNY&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20240321165106.31602-2D1-2Djames.morse-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=0PJ7kJsoRhwOqCcYwUYrJwbRM9zTssWuhqkgaqXdPNY&e=>
[1]https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_lkml_20201030161120.227225-2D1-2Djames.morse-40arm.com_&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=sYrXz5z6dOOGmy5Xjm0lsmdUCAN25SnhDjyq_hUSYi4&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_lkml_20201030161120.227225-2D1-2Djames.morse-40arm.com_&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=sYrXz5z6dOOGmy5Xjm0lsmdUCAN25SnhDjyq_hUSYi4&e=>Amit Singh Tomar (1):
x86/resctrl: Remove the limit on the number of CLOSIDDave Martin (3):
x86/resctrl: Squelch whitespace anomalies in resctrl core code x86/resctrl: Prefer alloc(sizeof(*foo)) idiom inrdt_init_fs_context()x86/resctrl: Relax some asm #includesJames Morse (45):
x86/resctrl: Fix allocation of cleanest CLOSID on platforms with no
monitors
x86/resctrl: Add a helper to avoid reaching into the arch code
resource list
x86/resctrl: Remove fflags from structrdt_resourcex86/resctrl: Use schema type to determine how to parse schema values x86/resctrl: Use schema type to determine the schema format string x86/resctrl: Removedata_widthand the tabular format x86/resctrl: Addmax_bwto structresctrl_membwx86/resctrl: Generatedefault_ctrlinstead of sharing it x86/resctrl: Add helper for setting CPU default properties x86/resctrl: Remove rdtgroup fromupdate_cpu_closid_rmid()x86/resctrl: Expose resctrl fs's init function to the rest of the
kernel
x86/resctrl: Moverdt_find_domain()to be visible to arch and fs code x86/resctrl: Move resctrl types to a separate header x86/resctrl: Add an arch helper to reset one resource x86/resctrl: Move monitor exit work to a resctrl exit call x86/resctrl: Move monitor init work to a resctrl init call x86/resctrl: Rewrite and move the for_each_*_rdt_resource() walkers x86/resctrl: Move the is_mbm_*_enabled() helpers toasm/resctrl.hx86/resctrl: Addresctrl_arch_is_evt_configurable()to abstract BMEC x86/resctrl: Change mon_event_config_{read,write}() to be arch helpers x86/resctrl: Movemba_mbps_default_eventinit to filesystem code x86/resctrl: Movembm_cfg_maskto structrdt_resourcex86/resctrl: Addresctrl_arch_prefix to pseudo lock functions x86/resctrl: Allow an architecture to disable pseudo lock x86/resctrl: Makeprefetch_disable_bitsbelong to the arch code x86/resctrl: Makeresctrl_arch_pseudo_lock_fn()take a plr x86/resctrl: Move RFTYPE flags to be managed by resctrl x86/resctrl: Handlethrottle_modefor SMBA resources x86/resctrl: Moveget_config_index()to a header x86/resctrl: Move get_{mon,ctrl}_domain_from_cpu() to live with their
callers
x86/resctrl: Renameresctrl_sched_in()to begin with "resctrl_arch_" x86/resctrl:resctrl_exit()teardown resctrl but leave the mount point x86/resctrl: Drop __init/__exit on assorted symbols x86/resctrl: Moveis_mba_sc()out ofcore.c
x86/resctrl: Add end-marker to theresctrl_event_idenum x86/resctrl: Expand the width ofdom_idby replacingmon_data_bitsx86/resctrl: Remove a newline to avoid confusing the code move script x86/resctrl: Splittrace.h
fs/resctrl: Add boiler plate for external resctrl code x86/resctrl: Move the filesystem bits to headers visible to fs/resctrl x86,fs/resctrl: Move the resctrl filesystem code to live in
/fs/resctrl
x86,fs/resctrl: Remove duplicated trace header files fs/resctrl: Remove unnecessary includes
fs/resctrl: Change internal.h's header guard macros x86,fs/resctrl: Moveresctrl.rstto live under
Documentation/filesystemsDocumentation/arch/x86/index.rst | 1 - Documentation/filesystems/index.rst | 1 + .../{arch/x86 => filesystems}/resctrl.rst | 0 MAINTAINERS | 4 +- arch/Kconfig | 8 + arch/x86/Kconfig | 6 +- arch/x86/include/asm/resctrl.h | 43 +- arch/x86/kernel/cpu/resctrl/Makefile | 8 +- arch/x86/kernel/cpu/resctrl/core.c | 214 +- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 606 +-- arch/x86/kernel/cpu/resctrl/internal.h | 504 +- arch/x86/kernel/cpu/resctrl/monitor.c | 863 +--- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 1120 +---- .../resctrl/{trace.h => pseudo_lock_trace.h} | 26 +- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4031 +-------------- arch/x86/kernel/process_32.c | 2 +- arch/x86/kernel/process_64.c | 2 +- fs/Kconfig | 1 + fs/Makefile | 1 + fs/resctrl/Kconfig | 39 + fs/resctrl/Makefile | 6 + fs/resctrl/ctrlmondata.c | 660 +++ fs/resctrl/internal.h | 435 ++ fs/resctrl/monitor.c | 933 ++++ fs/resctrl/monitor_trace.h | 33 + fs/resctrl/pseudo_lock.c | 1104 +++++ fs/resctrl/rdtgroup.c | 4329 +++++++++++++++++ include/linux/resctrl.h | 216 +- include/linux/resctrl_types.h | 59 + 29 files changed, 7992 insertions(+), 7263 deletions(-)rename
Documentation/{arch/x86=>filesystems}/resctrl.rst(100%) renamearch/x86/kernel/cpu/resctrl/{trace.h=>pseudo_lock_trace.h} (56%) create mode 100644fs/resctrl/Kconfig
create mode 100644fs/resctrl/Makefile
create mode 100644fs/resctrl/ctrlmondata.c
create mode 100644fs/resctrl/internal.h
create mode 100644fs/resctrl/monitor.c
create mode 100644fs/resctrl/monitor_trace.h
create mode 100644fs/resctrl/pseudo_lock.c
create mode 100644fs/resctrl/rdtgroup.c
create mode 100644include/linux/resctrl_types.hSignature · 1 line
2.39.5
Quoted 150 lines · James Morse
Changes since v6?: * All the excitement is in patch 37, turns out there are two
rmdir()paths that don't join up. The last eight patches are new: * The python script has been replaced with the patch that it generates, see the bare branch belowChanges since v6?:
* All the excitement is in patch 37, turns out there are twormdir()paths that don't join up.
The last eight patches are new:
* The python script has been replaced with the patch that it generates, see the bare branch below if you want to regenerate it.
* There have been comments on the followup to the generated patch, those are included here - I suggest they be squashed into the generated patch.
* This version includes some checkpatch linting from Dave.---
This series renames functions and moves code around. With the exception of invalid configurations for the configurable-events, there should be no changes in behaviour caused by this series. It is now possible forthrottle_modeto report 'undefined', but no known platform will do this.The driving pattern is to make things like struct rdtgroup private to resctrl. Features like pseudo-lock aren't going to work on arm64, the ability to disable it at compile time is added.
After this, I can start posting the MPAM driver to make use of resctrl on arm64. (What's MPAM? See the cover letter of the first series. [1])
This series is based on v6.14-rc3 and can be retrieved from:
https://urldefense.proofpoint.com/v2/url?u=https-3A__git.kernel.org_pub_scm_linux_kernel_git_morse_linux.git&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=34Q-cAJD41LWUgU21FvoSkXHOM-uSrOs2a1vEwaxrNE&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__git.kernel.org_pub_scm_linux_kernel_git_morse_linux.git&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=34Q-cAJD41LWUgU21FvoSkXHOM-uSrOs2a1vEwaxrNE&e=> mpam/move_to_fs/v7 or for those who want to regnerate the patch that moves all the code:
https://urldefense.proofpoint.com/v2/url?u=https-3A__git.kernel.org_pub_scm_linux_kernel_git_morse_linux.git&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=34Q-cAJD41LWUgU21FvoSkXHOM-uSrOs2a1vEwaxrNE&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__git.kernel.org_pub_scm_linux_kernel_git_morse_linux.git&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=34Q-cAJD41LWUgU21FvoSkXHOM-uSrOs2a1vEwaxrNE&e=> mpam/move_to_fs/v7_bareAs ever - bugs welcome,
Thanks,James
[v6]https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_lkml_20250207181823.6378-2D1-2Djames.morse-40arm.com_&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=Giw7Cw-bCKcY06OE4h_CYGNmKoeW3Rnf9Ph433fTflg&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_lkml_20250207181823.6378-2D1-2Djames.morse-40arm.com_&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=Giw7Cw-bCKcY06OE4h_CYGNmKoeW3Rnf9Ph433fTflg&e=>
[v5]https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20241004180347.19985-2D1-2Djames.morse-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=NuPo6XsrzJWgoWgnhpf5PxXdFEozS_Zgk_XBTnhAn6k&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20241004180347.19985-2D1-2Djames.morse-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=NuPo6XsrzJWgoWgnhpf5PxXdFEozS_Zgk_XBTnhAn6k&e=>
[v4]https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_all_20240802172853.22529-2D1-2Djames.morse-40arm.com_&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=x0enrBNorLUBSyhg_SOJl9itXA4Ht_65SifVAOpMEO4&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_all_20240802172853.22529-2D1-2Djames.morse-40arm.com_&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=x0enrBNorLUBSyhg_SOJl9itXA4Ht_65SifVAOpMEO4&e=>
[v3]https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20240614150033.10454-2D1-2Djames.morse-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=FPG_ZTHC69sPw7sz4QOvpKZ76X7VQSTuO2yN67LY4VI&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20240614150033.10454-2D1-2Djames.morse-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=FPG_ZTHC69sPw7sz4QOvpKZ76X7VQSTuO2yN67LY4VI&e=>
[v2]https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20240426150537.8094-2D1-2DDave.Martin-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=C--gCozXx-zNwx631Snz1h6SShLrm546dr0_ISKSC9A&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20240426150537.8094-2D1-2DDave.Martin-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=C--gCozXx-zNwx631Snz1h6SShLrm546dr0_ISKSC9A&e=>
[v1]https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20240321165106.31602-2D1-2Djames.morse-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=0PJ7kJsoRhwOqCcYwUYrJwbRM9zTssWuhqkgaqXdPNY&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20240321165106.31602-2D1-2Djames.morse-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=0PJ7kJsoRhwOqCcYwUYrJwbRM9zTssWuhqkgaqXdPNY&e=>
[1]https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_lkml_20201030161120.227225-2D1-2Djames.morse-40arm.com_&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=sYrXz5z6dOOGmy5Xjm0lsmdUCAN25SnhDjyq_hUSYi4&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_lkml_20201030161120.227225-2D1-2Djames.morse-40arm.com_&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=sYrXz5z6dOOGmy5Xjm0lsmdUCAN25SnhDjyq_hUSYi4&e=>Amit Singh Tomar (1):
x86/resctrl: Remove the limit on the number of CLOSIDDave Martin (3):
x86/resctrl: Squelch whitespace anomalies in resctrl core code x86/resctrl: Prefer alloc(sizeof(*foo)) idiom inrdt_init_fs_context()x86/resctrl: Relax some asm #includesJames Morse (45):
x86/resctrl: Fix allocation of cleanest CLOSID on platforms with no
monitors
x86/resctrl: Add a helper to avoid reaching into the arch code
resource list
x86/resctrl: Remove fflags from structrdt_resourcex86/resctrl: Use schema type to determine how to parse schema values x86/resctrl: Use schema type to determine the schema format string x86/resctrl: Removedata_widthand the tabular format x86/resctrl: Addmax_bwto structresctrl_membwx86/resctrl: Generatedefault_ctrlinstead of sharing it x86/resctrl: Add helper for setting CPU default properties x86/resctrl: Remove rdtgroup fromupdate_cpu_closid_rmid()x86/resctrl: Expose resctrl fs's init function to the rest of the
kernel
x86/resctrl: Moverdt_find_domain()to be visible to arch and fs code x86/resctrl: Move resctrl types to a separate header x86/resctrl: Add an arch helper to reset one resource x86/resctrl: Move monitor exit work to a resctrl exit call x86/resctrl: Move monitor init work to a resctrl init call x86/resctrl: Rewrite and move the for_each_*_rdt_resource() walkers x86/resctrl: Move the is_mbm_*_enabled() helpers toasm/resctrl.hx86/resctrl: Addresctrl_arch_is_evt_configurable()to abstract BMEC x86/resctrl: Change mon_event_config_{read,write}() to be arch helpers x86/resctrl: Movemba_mbps_default_eventinit to filesystem code x86/resctrl: Movembm_cfg_maskto structrdt_resourcex86/resctrl: Addresctrl_arch_prefix to pseudo lock functions x86/resctrl: Allow an architecture to disable pseudo lock x86/resctrl: Makeprefetch_disable_bitsbelong to the arch code x86/resctrl: Makeresctrl_arch_pseudo_lock_fn()take a plr x86/resctrl: Move RFTYPE flags to be managed by resctrl x86/resctrl: Handlethrottle_modefor SMBA resources x86/resctrl: Moveget_config_index()to a header x86/resctrl: Move get_{mon,ctrl}_domain_from_cpu() to live with their
callers
x86/resctrl: Renameresctrl_sched_in()to begin with "resctrl_arch_" x86/resctrl:resctrl_exit()teardown resctrl but leave the mount point x86/resctrl: Drop __init/__exit on assorted symbols x86/resctrl: Moveis_mba_sc()out ofcore.c
x86/resctrl: Add end-marker to theresctrl_event_idenum x86/resctrl: Expand the width ofdom_idby replacingmon_data_bitsx86/resctrl: Remove a newline to avoid confusing the code move script x86/resctrl: Splittrace.h
fs/resctrl: Add boiler plate for external resctrl code x86/resctrl: Move the filesystem bits to headers visible to fs/resctrl x86,fs/resctrl: Move the resctrl filesystem code to live in
/fs/resctrl
x86,fs/resctrl: Remove duplicated trace header files fs/resctrl: Remove unnecessary includes
fs/resctrl: Change internal.h's header guard macros x86,fs/resctrl: Moveresctrl.rstto live under
Documentation/filesystemsDocumentation/arch/x86/index.rst | 1 - Documentation/filesystems/index.rst | 1 + .../{arch/x86 => filesystems}/resctrl.rst | 0 MAINTAINERS | 4 +- arch/Kconfig | 8 + arch/x86/Kconfig | 6 +- arch/x86/include/asm/resctrl.h | 43 +- arch/x86/kernel/cpu/resctrl/Makefile | 8 +- arch/x86/kernel/cpu/resctrl/core.c | 214 +- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 606 +-- arch/x86/kernel/cpu/resctrl/internal.h | 504 +- arch/x86/kernel/cpu/resctrl/monitor.c | 863 +--- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 1120 +---- .../resctrl/{trace.h => pseudo_lock_trace.h} | 26 +- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4031 +-------------- arch/x86/kernel/process_32.c | 2 +- arch/x86/kernel/process_64.c | 2 +- fs/Kconfig | 1 + fs/Makefile | 1 + fs/resctrl/Kconfig | 39 + fs/resctrl/Makefile | 6 + fs/resctrl/ctrlmondata.c | 660 +++ fs/resctrl/internal.h | 435 ++ fs/resctrl/monitor.c | 933 ++++ fs/resctrl/monitor_trace.h | 33 + fs/resctrl/pseudo_lock.c | 1104 +++++ fs/resctrl/rdtgroup.c | 4329 +++++++++++++++++ include/linux/resctrl.h | 216 +- include/linux/resctrl_types.h | 59 + 29 files changed, 7992 insertions(+), 7263 deletions(-)rename
Documentation/{arch/x86=>filesystems}/resctrl.rst(100%) renamearch/x86/kernel/cpu/resctrl/{trace.h=>pseudo_lock_trace.h} (56%) create mode 100644fs/resctrl/Kconfig
create mode 100644fs/resctrl/Makefile
create mode 100644fs/resctrl/ctrlmondata.c
create mode 100644fs/resctrl/internal.h
create mode 100644fs/resctrl/monitor.c
create mode 100644fs/resctrl/monitor_trace.h
create mode 100644fs/resctrl/pseudo_lock.c
create mode 100644fs/resctrl/rdtgroup.c
create mode 100644include/linux/resctrl_types.hSignature · 1 line
2.39.5
v7 cover x86/resctrl: Move the resctrl filesystem code to /fs/resctrl
Quoted 26 lines · Amit Singh Tomar
Hi James,
Changes since v6?:
Quoted 22 lines
* All the excitement is in patch 37, turns out there are two
rmdir()paths that don't join up.
The last eight patches are new:
* The python script has been replaced with the patch that it generates, see the bare branch below if you want to regenerate it.
* There have been comments on the followup to the generated patch, those are included here - I suggest they be squashed into the generated patch.
* This version includes some checkpatch linting from Dave.---
This series renames functions and moves code around. With the exception of invalid configurations for the configurable-events, there should be no changes in behaviour caused by this series. It is now possible forthrottle_modeto report 'undefined', but no known platform will do this.The driving pattern is to make things like struct rdtgroup private to resctrl. Features like pseudo-lock aren't going to work on arm64, the ability to disable it at compile time is added.
After this, I can start posting the MPAM driver to make use of resctrl on arm64. (What's MPAM? See the cover letter of the first series. [1])
Quoted 8 lines
Quoted 3 lines
This series is based on v6.14-rc3 and can be retrieved from:
https://urldefense.proofpoint.com/v2/url?u=https-3A__git.kernel.org_pub_scm_linux_kernel_git_morse_linux.git&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=34Q-cAJD41LWUgU21FvoSkXHOM-uSrOs2a1vEwaxrNE&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__git.kernel.org_pub_scm_linux_kernel_git_morse_linux.git&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=34Q-cAJD41LWUgU21FvoSkXHOM-uSrOs2a1vEwaxrNE&e=> mpam/move_to_fs/v7 or for those who want to regnerate the patch that moves all the code:After rebasing mpam/snapshot/v6.14-rc1 on top of this series, Tested a few MPAM controls, including Cache Portion Partitioning and Memory Bandwidth Partitioning, on Marvell CN10K ARM64 platform, and It looks good.
For this patch-set:
Tested-by [email protected]
Realized I used an incorrect format for the Tested-by tag, correcting it now
Quoted 289 lines
Quoted 130 lines
https://urldefense.proofpoint.com/v2/url?u=https-3A__git.kernel.org_pub_scm_linux_kernel_git_morse_linux.git&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=34Q-cAJD41LWUgU21FvoSkXHOM-uSrOs2a1vEwaxrNE&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__git.kernel.org_pub_scm_linux_kernel_git_morse_linux.git&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=34Q-cAJD41LWUgU21FvoSkXHOM-uSrOs2a1vEwaxrNE&e=> mpam/move_to_fs/v7_bare
As ever - bugs welcome,
Thanks,James
[v6]https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_lkml_20250207181823.6378-2D1-2Djames.morse-40arm.com_&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=Giw7Cw-bCKcY06OE4h_CYGNmKoeW3Rnf9Ph433fTflg&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_lkml_20250207181823.6378-2D1-2Djames.morse-40arm.com_&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=Giw7Cw-bCKcY06OE4h_CYGNmKoeW3Rnf9Ph433fTflg&e=>
[v5]https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20241004180347.19985-2D1-2Djames.morse-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=NuPo6XsrzJWgoWgnhpf5PxXdFEozS_Zgk_XBTnhAn6k&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20241004180347.19985-2D1-2Djames.morse-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=NuPo6XsrzJWgoWgnhpf5PxXdFEozS_Zgk_XBTnhAn6k&e=>
[v4]https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_all_20240802172853.22529-2D1-2Djames.morse-40arm.com_&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=x0enrBNorLUBSyhg_SOJl9itXA4Ht_65SifVAOpMEO4&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_all_20240802172853.22529-2D1-2Djames.morse-40arm.com_&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=x0enrBNorLUBSyhg_SOJl9itXA4Ht_65SifVAOpMEO4&e=>
[v3]https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20240614150033.10454-2D1-2Djames.morse-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=FPG_ZTHC69sPw7sz4QOvpKZ76X7VQSTuO2yN67LY4VI&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20240614150033.10454-2D1-2Djames.morse-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=FPG_ZTHC69sPw7sz4QOvpKZ76X7VQSTuO2yN67LY4VI&e=>
[v2]https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20240426150537.8094-2D1-2DDave.Martin-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=C--gCozXx-zNwx631Snz1h6SShLrm546dr0_ISKSC9A&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20240426150537.8094-2D1-2DDave.Martin-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=C--gCozXx-zNwx631Snz1h6SShLrm546dr0_ISKSC9A&e=>
[v1]https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20240321165106.31602-2D1-2Djames.morse-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=0PJ7kJsoRhwOqCcYwUYrJwbRM9zTssWuhqkgaqXdPNY&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20240321165106.31602-2D1-2Djames.morse-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=0PJ7kJsoRhwOqCcYwUYrJwbRM9zTssWuhqkgaqXdPNY&e=>
[1]https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_lkml_20201030161120.227225-2D1-2Djames.morse-40arm.com_&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=sYrXz5z6dOOGmy5Xjm0lsmdUCAN25SnhDjyq_hUSYi4&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_lkml_20201030161120.227225-2D1-2Djames.morse-40arm.com_&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=sYrXz5z6dOOGmy5Xjm0lsmdUCAN25SnhDjyq_hUSYi4&e=>
Amit Singh Tomar (1):
x86/resctrl: Remove the limit on the number of CLOSIDDave Martin (3):
x86/resctrl: Squelch whitespace anomalies in resctrl core code x86/resctrl: Prefer alloc(sizeof(*foo)) idiom inrdt_init_fs_context()x86/resctrl: Relax some asm #includesJames Morse (45):
x86/resctrl: Fix allocation of cleanest CLOSID on platforms with no monitors
x86/resctrl: Add a helper to avoid reaching into the arch code resource list
x86/resctrl: Remove fflags from structrdt_resourcex86/resctrl: Use schema type to determine how to parse schema values x86/resctrl: Use schema type to determine the schema format string x86/resctrl: Removedata_widthand the tabular format x86/resctrl: Addmax_bwto structresctrl_membwx86/resctrl: Generatedefault_ctrlinstead of sharing it x86/resctrl: Add helper for setting CPU default properties x86/resctrl: Remove rdtgroup fromupdate_cpu_closid_rmid()x86/resctrl: Expose resctrl fs's init function to the rest of the kernel
x86/resctrl: Moverdt_find_domain()to be visible to arch and fs code x86/resctrl: Move resctrl types to a separate header x86/resctrl: Add an arch helper to reset one resource x86/resctrl: Move monitor exit work to a resctrl exit call x86/resctrl: Move monitor init work to a resctrl init call x86/resctrl: Rewrite and move the for_each_*_rdt_resource() walkers x86/resctrl: Move the is_mbm_*_enabled() helpers toasm/resctrl.hx86/resctrl: Addresctrl_arch_is_evt_configurable()to abstract BMEC x86/resctrl: Change mon_event_config_{read,write}() to be arch helpers x86/resctrl: Movemba_mbps_default_eventinit to filesystem code x86/resctrl: Movembm_cfg_maskto structrdt_resourcex86/resctrl: Addresctrl_arch_prefix to pseudo lock functions x86/resctrl: Allow an architecture to disable pseudo lock x86/resctrl: Makeprefetch_disable_bitsbelong to the arch code x86/resctrl: Makeresctrl_arch_pseudo_lock_fn()take a plr x86/resctrl: Move RFTYPE flags to be managed by resctrl x86/resctrl: Handlethrottle_modefor SMBA resources x86/resctrl: Moveget_config_index()to a header x86/resctrl: Move get_{mon,ctrl}_domain_from_cpu() to live with their callers
x86/resctrl: Renameresctrl_sched_in()to begin with "resctrl_arch_" x86/resctrl:resctrl_exit()teardown resctrl but leave the mount point x86/resctrl: Drop __init/__exit on assorted symbols x86/resctrl: Moveis_mba_sc()out ofcore.c
x86/resctrl: Add end-marker to theresctrl_event_idenum x86/resctrl: Expand the width ofdom_idby replacingmon_data_bitsx86/resctrl: Remove a newline to avoid confusing the code move script x86/resctrl: Splittrace.h
fs/resctrl: Add boiler plate for external resctrl code x86/resctrl: Move the filesystem bits to headers visible to fs/resctrl x86,fs/resctrl: Move the resctrl filesystem code to live in /fs/resctrl
x86,fs/resctrl: Remove duplicated trace header files fs/resctrl: Remove unnecessary includes
fs/resctrl: Change internal.h's header guard macros x86,fs/resctrl: Moveresctrl.rstto live underDocumentation/filesystemsDocumentation/arch/x86/index.rst | 1 - Documentation/filesystems/index.rst | 1 + .../{arch/x86 => filesystems}/resctrl.rst | 0 MAINTAINERS | 4 +- arch/Kconfig | 8 + arch/x86/Kconfig | 6 +- arch/x86/include/asm/resctrl.h | 43 +- arch/x86/kernel/cpu/resctrl/Makefile | 8 +- arch/x86/kernel/cpu/resctrl/core.c | 214 +- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 606 +-- arch/x86/kernel/cpu/resctrl/internal.h | 504 +- arch/x86/kernel/cpu/resctrl/monitor.c | 863 +--- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 1120 +----
.../resctrl/{trace.h=> pseudo_lock_trace.h} | 26 +- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4031 +-------------- arch/x86/kernel/process_32.c | 2 +- arch/x86/kernel/process_64.c | 2 +- fs/Kconfig | 1 + fs/Makefile | 1 + fs/resctrl/Kconfig | 39 + fs/resctrl/Makefile | 6 + fs/resctrl/ctrlmondata.c | 660 +++ fs/resctrl/internal.h | 435 ++ fs/resctrl/monitor.c | 933 ++++ fs/resctrl/monitor_trace.h | 33 + fs/resctrl/pseudo_lock.c | 1104 +++++ fs/resctrl/rdtgroup.c | 4329 +++++++++++++++++ include/linux/resctrl.h | 216 +- include/linux/resctrl_types.h | 59 +29 files changed, 7992 insertions(+), 7263 deletions(-)rename
Documentation/{arch/x86=>filesystems}/resctrl.rst(100%) renamearch/x86/kernel/cpu/resctrl/{trace.h=>pseudo_lock_trace.h} (56%) create mode 100644fs/resctrl/Kconfig
create mode 100644fs/resctrl/Makefile
create mode 100644fs/resctrl/ctrlmondata.c
create mode 100644fs/resctrl/internal.h
create mode 100644fs/resctrl/monitor.c
create mode 100644fs/resctrl/monitor_trace.h
create mode 100644fs/resctrl/pseudo_lock.c
create mode 100644fs/resctrl/rdtgroup.c
create mode 100644include/linux/resctrl_types.hSignature · 1 line
2.39.5Quoted 157 lines · James Morse
Changes since v6?: * All the excitement is in patch 37, turns out there are two
rmdir()paths that don't join up. The last eight patches are new: * The python script has been replaced with the patch that it generates, see the bare branch belowChanges since v6?:
* All the excitement is in patch 37, turns out there are twormdir()paths that don't join up.
The last eight patches are new:
* The python script has been replaced with the patch that it generates, see the bare branch below if you want to regenerate it.
* There have been comments on the followup to the generated patch, those are included here - I suggest they be squashed into the generated patch.
* This version includes some checkpatch linting from Dave.---
This series renames functions and moves code around. With the exception of invalid configurations for the configurable-events, there should be no changes in behaviour caused by this series. It is now possible forthrottle_modeto report 'undefined', but no known platform will do this.The driving pattern is to make things like struct rdtgroup private to resctrl. Features like pseudo-lock aren't going to work on arm64, the ability to disable it at compile time is added.
After this, I can start posting the MPAM driver to make use of resctrl on arm64. (What's MPAM? See the cover letter of the first series. [1])
This series is based on v6.14-rc3 and can be retrieved from:
https://urldefense.proofpoint.com/v2/url?u=https-3A__git.kernel.org_pub_scm_linux_kernel_git_morse_linux.git&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=34Q-cAJD41LWUgU21FvoSkXHOM-uSrOs2a1vEwaxrNE&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__git.kernel.org_pub_scm_linux_kernel_git_morse_linux.git&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=34Q-cAJD41LWUgU21FvoSkXHOM-uSrOs2a1vEwaxrNE&e=> mpam/move_to_fs/v7 or for those who want to regnerate the patch that moves all the code:
https://urldefense.proofpoint.com/v2/url?u=https-3A__git.kernel.org_pub_scm_linux_kernel_git_morse_linux.git&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=34Q-cAJD41LWUgU21FvoSkXHOM-uSrOs2a1vEwaxrNE&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__git.kernel.org_pub_scm_linux_kernel_git_morse_linux.git&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=34Q-cAJD41LWUgU21FvoSkXHOM-uSrOs2a1vEwaxrNE&e=> mpam/move_to_fs/v7_bareAs ever - bugs welcome,
Thanks,James
[v6]https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_lkml_20250207181823.6378-2D1-2Djames.morse-40arm.com_&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=Giw7Cw-bCKcY06OE4h_CYGNmKoeW3Rnf9Ph433fTflg&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_lkml_20250207181823.6378-2D1-2Djames.morse-40arm.com_&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=Giw7Cw-bCKcY06OE4h_CYGNmKoeW3Rnf9Ph433fTflg&e=>
[v5]https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20241004180347.19985-2D1-2Djames.morse-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=NuPo6XsrzJWgoWgnhpf5PxXdFEozS_Zgk_XBTnhAn6k&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20241004180347.19985-2D1-2Djames.morse-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=NuPo6XsrzJWgoWgnhpf5PxXdFEozS_Zgk_XBTnhAn6k&e=>
[v4]https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_all_20240802172853.22529-2D1-2Djames.morse-40arm.com_&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=x0enrBNorLUBSyhg_SOJl9itXA4Ht_65SifVAOpMEO4&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_all_20240802172853.22529-2D1-2Djames.morse-40arm.com_&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=x0enrBNorLUBSyhg_SOJl9itXA4Ht_65SifVAOpMEO4&e=>
[v3]https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20240614150033.10454-2D1-2Djames.morse-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=FPG_ZTHC69sPw7sz4QOvpKZ76X7VQSTuO2yN67LY4VI&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20240614150033.10454-2D1-2Djames.morse-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=FPG_ZTHC69sPw7sz4QOvpKZ76X7VQSTuO2yN67LY4VI&e=>
[v2]https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20240426150537.8094-2D1-2DDave.Martin-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=C--gCozXx-zNwx631Snz1h6SShLrm546dr0_ISKSC9A&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20240426150537.8094-2D1-2DDave.Martin-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=C--gCozXx-zNwx631Snz1h6SShLrm546dr0_ISKSC9A&e=>
[v1]https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20240321165106.31602-2D1-2Djames.morse-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=0PJ7kJsoRhwOqCcYwUYrJwbRM9zTssWuhqkgaqXdPNY&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_r_20240321165106.31602-2D1-2Djames.morse-40arm.com&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=0PJ7kJsoRhwOqCcYwUYrJwbRM9zTssWuhqkgaqXdPNY&e=>
[1]https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_lkml_20201030161120.227225-2D1-2Djames.morse-40arm.com_&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=sYrXz5z6dOOGmy5Xjm0lsmdUCAN25SnhDjyq_hUSYi4&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__lore.kernel.org_lkml_20201030161120.227225-2D1-2Djames.morse-40arm.com_&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=sYrXz5z6dOOGmy5Xjm0lsmdUCAN25SnhDjyq_hUSYi4&e=>
Amit Singh Tomar (1):
x86/resctrl: Remove the limit on the number of CLOSIDDave Martin (3):
x86/resctrl: Squelch whitespace anomalies in resctrl core code x86/resctrl: Prefer alloc(sizeof(*foo)) idiom inrdt_init_fs_context()x86/resctrl: Relax some asm #includesJames Morse (45):
x86/resctrl: Fix allocation of cleanest CLOSID on platforms with no monitors
x86/resctrl: Add a helper to avoid reaching into the arch code resource list
x86/resctrl: Remove fflags from structrdt_resourcex86/resctrl: Use schema type to determine how to parse schema values x86/resctrl: Use schema type to determine the schema format string x86/resctrl: Removedata_widthand the tabular format x86/resctrl: Addmax_bwto structresctrl_membwx86/resctrl: Generatedefault_ctrlinstead of sharing it x86/resctrl: Add helper for setting CPU default properties x86/resctrl: Remove rdtgroup fromupdate_cpu_closid_rmid()x86/resctrl: Expose resctrl fs's init function to the rest of the kernel
x86/resctrl: Moverdt_find_domain()to be visible to arch and fs code x86/resctrl: Move resctrl types to a separate header x86/resctrl: Add an arch helper to reset one resource x86/resctrl: Move monitor exit work to a resctrl exit call x86/resctrl: Move monitor init work to a resctrl init call x86/resctrl: Rewrite and move the for_each_*_rdt_resource() walkers x86/resctrl: Move the is_mbm_*_enabled() helpers toasm/resctrl.hx86/resctrl: Addresctrl_arch_is_evt_configurable()to abstract BMEC x86/resctrl: Change mon_event_config_{read,write}() to be arch helpers x86/resctrl: Movemba_mbps_default_eventinit to filesystem code x86/resctrl: Movembm_cfg_maskto structrdt_resourcex86/resctrl: Addresctrl_arch_prefix to pseudo lock functions x86/resctrl: Allow an architecture to disable pseudo lock x86/resctrl: Makeprefetch_disable_bitsbelong to the arch code x86/resctrl: Makeresctrl_arch_pseudo_lock_fn()take a plr x86/resctrl: Move RFTYPE flags to be managed by resctrl x86/resctrl: Handlethrottle_modefor SMBA resources x86/resctrl: Moveget_config_index()to a header x86/resctrl: Move get_{mon,ctrl}_domain_from_cpu() to live with their callers
x86/resctrl: Renameresctrl_sched_in()to begin with "resctrl_arch_" x86/resctrl:resctrl_exit()teardown resctrl but leave the mount point x86/resctrl: Drop __init/__exit on assorted symbols x86/resctrl: Moveis_mba_sc()out ofcore.c
x86/resctrl: Add end-marker to theresctrl_event_idenum x86/resctrl: Expand the width ofdom_idby replacingmon_data_bitsx86/resctrl: Remove a newline to avoid confusing the code move script x86/resctrl: Splittrace.h
fs/resctrl: Add boiler plate for external resctrl code x86/resctrl: Move the filesystem bits to headers visible to fs/resctrl x86,fs/resctrl: Move the resctrl filesystem code to live in /fs/resctrl
x86,fs/resctrl: Remove duplicated trace header files fs/resctrl: Remove unnecessary includes
fs/resctrl: Change internal.h's header guard macros x86,fs/resctrl: Moveresctrl.rstto live underDocumentation/filesystemsDocumentation/arch/x86/index.rst | 1 - Documentation/filesystems/index.rst | 1 + .../{arch/x86 => filesystems}/resctrl.rst | 0 MAINTAINERS | 4 +- arch/Kconfig | 8 + arch/x86/Kconfig | 6 +- arch/x86/include/asm/resctrl.h | 43 +- arch/x86/kernel/cpu/resctrl/Makefile | 8 +- arch/x86/kernel/cpu/resctrl/core.c | 214 +- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 606 +-- arch/x86/kernel/cpu/resctrl/internal.h | 504 +- arch/x86/kernel/cpu/resctrl/monitor.c | 863 +--- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 1120 +----
.../resctrl/{trace.h=> pseudo_lock_trace.h} | 26 +- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4031 +-------------- arch/x86/kernel/process_32.c | 2 +- arch/x86/kernel/process_64.c | 2 +- fs/Kconfig | 1 + fs/Makefile | 1 + fs/resctrl/Kconfig | 39 + fs/resctrl/Makefile | 6 + fs/resctrl/ctrlmondata.c | 660 +++ fs/resctrl/internal.h | 435 ++ fs/resctrl/monitor.c | 933 ++++ fs/resctrl/monitor_trace.h | 33 + fs/resctrl/pseudo_lock.c | 1104 +++++ fs/resctrl/rdtgroup.c | 4329 +++++++++++++++++ include/linux/resctrl.h | 216 +- include/linux/resctrl_types.h | 59 +29 files changed, 7992 insertions(+), 7263 deletions(-)rename
Documentation/{arch/x86=>filesystems}/resctrl.rst(100%) renamearch/x86/kernel/cpu/resctrl/{trace.h=>pseudo_lock_trace.h} (56%) create mode 100644fs/resctrl/Kconfig
create mode 100644fs/resctrl/Makefile
create mode 100644fs/resctrl/ctrlmondata.c
create mode 100644fs/resctrl/internal.h
create mode 100644fs/resctrl/monitor.c
create mode 100644fs/resctrl/monitor_trace.h
create mode 100644fs/resctrl/pseudo_lock.c
create mode 100644fs/resctrl/rdtgroup.c
create mode 100644include/linux/resctrl_types.hSignature · 1 line
2.39.5
Hi James,
I have tested this patch series w/o MPAM patches on the Grace server platform. Validated both the features CPOR and MBW, results as expected.
-Shanker
Typo, tested with MPAM patches.
Quoted 10 lines · Shanker Donthineni
Hi James,
I have tested this patch series w/ MPAM patches on the Grace server platform. Validated both the features CPOR and MBW, results as expected.
Tested-by Shanker Donthineni <[email protected]>-Shanker
James Morse
reviewerHi Shanker,
Quoted 7 lines · Shanker Donthineni
Quoted 2 lines · Shanker Donthineni
I have tested this patch series w/ MPAM patches on the Grace server platform. Validated both the features CPOR and MBW, results as expected.
Typo, tested with MPAM patches.
Quoted 1 line
Tested-by Shanker Donthineni <[email protected]>
Thanks! (as noted elsewhere - I've added an '# arm64' suffix to this)
James
James Morse
reviewerHi Amit,
Quoted 25 lines · Amit Singh Tomar
Quoted 24 lines · Amit Singh Tomar
Changes since v6?:
Quoted 22 lines
* All the excitement is in patch 37, turns out there are two
rmdir()paths that don't join up.
The last eight patches are new:
* The python script has been replaced with the patch that it generates, see the bare branch below if you want to regenerate it.
* There have been comments on the followup to the generated patch, those are included here - I suggest they be squashed into the generated patch.
* This version includes some checkpatch linting from Dave.---
This series renames functions and moves code around. With the exception of invalid configurations for the configurable-events, there should be no changes in behaviour caused by this series. It is now possible forthrottle_modeto report 'undefined', but no known platform will do this.The driving pattern is to make things like struct rdtgroup private to resctrl. Features like pseudo-lock aren't going to work on arm64, the ability to disable it at compile time is added.
After this, I can start posting the MPAM driver to make use of resctrl on arm64. (What's MPAM? See the cover letter of the first series. [1])
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
This series is based on v6.14-rc3 and can be retrieved from:
https://urldefense.proofpoint.com/v2/url?
u=https-3A__git.kernel.org_pub_scm_linux_kernel_git_morse_linux.git&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=34Q-cAJD41LWUgU21FvoSkXHOM-uSrOs2a1vEwaxrNE&e= <https://urldefense.proofpoint.com/v2/url?u=https-3A__git.kernel.org_pub_scm_linux_kernel_git_morse_linux.git&d=DwIDAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=V_GK7jRuCHDErm6txmgDK1-MbUihtnSQ3gPgB-A-JKU&m=nuwqirfPj-0yJqyDZfy25skE_NJ-fYFcygpI04RUICnSUBYHutdqE6Gakd1Z3I8H&s=34Q-cAJD41LWUgU21FvoSkXHOM-uSrOs2a1vEwaxrNE&e=> mpam/move_to_fs/v7 or for those who want to regnerate the patch that moves all the code:After rebasing mpam/snapshot/v6.14-rc1 on top of this series,
Hmmm - right, because this series doesn't contain the python script that generates patch-45, so git can't know that all the code is the same.
Quoted 3 lines
Quoted 3 lines
Tested a few MPAM
controls, including Cache Portion Partitioning and Memory Bandwidth Partitioning, on Marvell CN10K ARM64 platform, and It looks good.
Thanks!
Quoted 5 lines
Quoted 2 lines
For this patch-set:
Tested-by [email protected]Realized I used an incorrect format for the Tested-by tag, correcting it now
Tested-by Amit Singh Tomar <[email protected]>
I'll add an '# arm64' suffix on that as that's what got tested.
Thanks,
Jaems
Quoted 136 lines · James Morse
Changes since v6?:
* All the excitement is in patch 37, turns out there are twormdir()paths that don't join up.
The last eight patches are new:
* The python script has been replaced with the patch that it generates, see the bare branch below if you want to regenerate it.
* There have been comments on the followup to the generated patch, those are included here - I suggest they be squashed into the generated patch.
* This version includes some checkpatch linting from Dave.---
This series renames functions and moves code around. With the exception of invalid configurations for the configurable-events, there should be no changes in behaviour caused by this series. It is now possible forthrottle_modeto report 'undefined', but no known platform will do this.The driving pattern is to make things like struct rdtgroup private to resctrl. Features like pseudo-lock aren't going to work on arm64, the ability to disable it at compile time is added.
After this, I can start posting the MPAM driver to make use of resctrl on arm64. (What's MPAM? See the cover letter of the first series. [1])
This series is based on v6.14-rc3 and can be retrieved from:
https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git mpam/move_to_fs/v7 or for those who want to regnerate the patch that moves all the code:
https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git mpam/move_to_fs/v7_bareAs ever - bugs welcome,
Thanks,James
[v6] https://lore.kernel.org/lkml/[email protected]/
[v5] https://lore.kernel.org/r/[email protected]
[v4] https://lore.kernel.org/all/[email protected]/
[v3] https://lore.kernel.org/r/[email protected]
[v2] https://lore.kernel.org/r/[email protected]
[v1] https://lore.kernel.org/r/[email protected]
[1] https://lore.kernel.org/lkml/[email protected]/Amit Singh Tomar (1):
x86/resctrl: Remove the limit on the number of CLOSIDDave Martin (3):
x86/resctrl: Squelch whitespace anomalies in resctrl core code x86/resctrl: Prefer alloc(sizeof(*foo)) idiom inrdt_init_fs_context()x86/resctrl: Relax some asm #includesJames Morse (45):
x86/resctrl: Fix allocation of cleanest CLOSID on platforms with no
monitors
x86/resctrl: Add a helper to avoid reaching into the arch code
resource list
x86/resctrl: Remove fflags from structrdt_resourcex86/resctrl: Use schema type to determine how to parse schema values x86/resctrl: Use schema type to determine the schema format string x86/resctrl: Removedata_widthand the tabular format x86/resctrl: Addmax_bwto structresctrl_membwx86/resctrl: Generatedefault_ctrlinstead of sharing it x86/resctrl: Add helper for setting CPU default properties x86/resctrl: Remove rdtgroup fromupdate_cpu_closid_rmid()x86/resctrl: Expose resctrl fs's init function to the rest of the
kernel
x86/resctrl: Moverdt_find_domain()to be visible to arch and fs code x86/resctrl: Move resctrl types to a separate header x86/resctrl: Add an arch helper to reset one resource x86/resctrl: Move monitor exit work to a resctrl exit call x86/resctrl: Move monitor init work to a resctrl init call x86/resctrl: Rewrite and move the for_each_*_rdt_resource() walkers x86/resctrl: Move the is_mbm_*_enabled() helpers toasm/resctrl.hx86/resctrl: Addresctrl_arch_is_evt_configurable()to abstract BMEC x86/resctrl: Change mon_event_config_{read,write}() to be arch helpers x86/resctrl: Movemba_mbps_default_eventinit to filesystem code x86/resctrl: Movembm_cfg_maskto structrdt_resourcex86/resctrl: Addresctrl_arch_prefix to pseudo lock functions x86/resctrl: Allow an architecture to disable pseudo lock x86/resctrl: Makeprefetch_disable_bitsbelong to the arch code x86/resctrl: Makeresctrl_arch_pseudo_lock_fn()take a plr x86/resctrl: Move RFTYPE flags to be managed by resctrl x86/resctrl: Handlethrottle_modefor SMBA resources x86/resctrl: Moveget_config_index()to a header x86/resctrl: Move get_{mon,ctrl}_domain_from_cpu() to live with their
callers
x86/resctrl: Renameresctrl_sched_in()to begin with "resctrl_arch_" x86/resctrl:resctrl_exit()teardown resctrl but leave the mount point x86/resctrl: Drop __init/__exit on assorted symbols x86/resctrl: Moveis_mba_sc()out ofcore.c
x86/resctrl: Add end-marker to theresctrl_event_idenum x86/resctrl: Expand the width ofdom_idby replacingmon_data_bitsx86/resctrl: Remove a newline to avoid confusing the code move script x86/resctrl: Splittrace.h
fs/resctrl: Add boiler plate for external resctrl code x86/resctrl: Move the filesystem bits to headers visible to fs/resctrl x86,fs/resctrl: Move the resctrl filesystem code to live in
/fs/resctrl
x86,fs/resctrl: Remove duplicated trace header files fs/resctrl: Remove unnecessary includes
fs/resctrl: Change internal.h's header guard macros x86,fs/resctrl: Moveresctrl.rstto live under
Documentation/filesystemsDocumentation/arch/x86/index.rst | 1 - Documentation/filesystems/index.rst | 1 + .../{arch/x86 => filesystems}/resctrl.rst | 0 MAINTAINERS | 4 +- arch/Kconfig | 8 + arch/x86/Kconfig | 6 +- arch/x86/include/asm/resctrl.h | 43 +- arch/x86/kernel/cpu/resctrl/Makefile | 8 +- arch/x86/kernel/cpu/resctrl/core.c | 214 +- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 606 +-- arch/x86/kernel/cpu/resctrl/internal.h | 504 +- arch/x86/kernel/cpu/resctrl/monitor.c | 863 +--- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 1120 +---- .../resctrl/{trace.h => pseudo_lock_trace.h} | 26 +- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4031 +-------------- arch/x86/kernel/process_32.c | 2 +- arch/x86/kernel/process_64.c | 2 +- fs/Kconfig | 1 + fs/Makefile | 1 + fs/resctrl/Kconfig | 39 + fs/resctrl/Makefile | 6 + fs/resctrl/ctrlmondata.c | 660 +++ fs/resctrl/internal.h | 435 ++ fs/resctrl/monitor.c | 933 ++++ fs/resctrl/monitor_trace.h | 33 + fs/resctrl/pseudo_lock.c | 1104 +++++ fs/resctrl/rdtgroup.c | 4329 +++++++++++++++++ include/linux/resctrl.h | 216 +- include/linux/resctrl_types.h | 59 + 29 files changed, 7992 insertions(+), 7263 deletions(-) rename Documentation/{arch/x86 => filesystems}/resctrl.rst (100%) rename arch/x86/kernel/cpu/resctrl/{trace.h => pseudo_lock_trace.h} (56%) create mode 100644 fs/resctrl/Kconfig
Quoted 9 lines
create mode 100644 fs/resctrl/Makefile create mode 100644 fs/resctrl/ctrlmondata.c create mode 100644 fs/resctrl/internal.h create mode 100644 fs/resctrl/monitor.c create mode 100644 fs/resctrl/monitor_trace.h create mode 100644 fs/resctrl/pseudo_lock.c create mode 100644 fs/resctrl/rdtgroup.c create mode 100644 include/linux/resctrl_types.h
Ran tests on couple of AMD systems. Everything looks good.
Signature · 2 lines
Thanks Babu Moger
James Morse
reviewerHi Babu,
Quoted 30 lines · Babu
Quoted 20 lines · James Morse
Changes since v6?:
* All the excitement is in patch 37, turns out there are twormdir()paths that don't join up.
The last eight patches are new:
* The python script has been replaced with the patch that it generates, see the bare branch below if you want to regenerate it.
* There have been comments on the followup to the generated patch, those are included here - I suggest they be squashed into the generated patch.
* This version includes some checkpatch linting from Dave.---
This series renames functions and moves code around. With the exception of invalid configurations for the configurable-events, there should be no changes in behaviour caused by this series. It is now possible forthrottle_modeto report 'undefined', but no known platform will do this.The driving pattern is to make things like struct rdtgroup private to resctrl. Features like pseudo-lock aren't going to work on arm64, the ability to disable it at compile time is added.
Quoted 7 lines
After this, I can start posting the MPAM driver to make use of resctrl on arm64. (What's MPAM? See the cover letter of the first series. [1])
This series is based on v6.14-rc3 and can be retrieved from:
https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git mpam/move_to_fs/v7 or for those who want to regnerate the patch that moves all the code:
https://git.kernel.org/pub/scm/linux/kernel/git/morse/linux.git mpam/move_to_fs/v7_bare
Quoted 3 lines
Ran tests on couple of AMD systems. Everything looks good.
Tested-by Babu Moger <[email protected]>
Thanks!
James
Borislav Petkov
maintainerQuoted 9 lines · James Morse
Changes since v6?:
* All the excitement is in patch 37, turns out there are twormdir()paths that don't join up.
The last eight patches are new:
* The python script has been replaced with the patch that it generates, see the bare branch below if you want to regenerate it.
* There have been comments on the followup to the generated patch, those are included here - I suggest they be squashed into the generated patch.
* This version includes some checkpatch linting from Dave.
So, Reinette says that 1-30 should be ready to go. Care to send them ASAP with all the review feedback addressed so that I can try to queue them, we all test the branch this week and thus I can empty a considerable amount out of your bucket of patches...
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteJames Morse
reviewerHi Boris,
Quoted 11 lines · Borislav Petkov
Quoted 9 lines · James Morse
Changes since v6?:
* All the excitement is in patch 37, turns out there are twormdir()paths that don't join up.
The last eight patches are new:
* The python script has been replaced with the patch that it generates, see the bare branch below if you want to regenerate it.
* There have been comments on the followup to the generated patch, those are included here - I suggest they be squashed into the generated patch.
* This version includes some checkpatch linting from Dave.
Quoted 2 lines
So, Reinette says that 1-30 should be ready to go. Care to send them ASAP with all the review feedback addressed so that I can try to queue them,
Thanks - look out for a 'v8:for_boris'.
Quoted 3 lines
we all test
the branch this week and thus I can empty a considerable amount out of your bucket of patches...
Thanks!
James
Borislav Petkov
maintainerQuoted 1 line · James Morse
Thanks - look out for a 'v8:for_boris'.
Got it, working through it slowly.
Thx!
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette