]> Git Repo - J-linux.git/commitdiff
Merge tag 'x86_cache_for_v5.15' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <[email protected]>
Mon, 30 Aug 2021 20:31:36 +0000 (13:31 -0700)
committerLinus Torvalds <[email protected]>
Mon, 30 Aug 2021 20:31:36 +0000 (13:31 -0700)
Pull x86 resource control updates from Borislav Petkov:
 "A first round of changes towards splitting the arch-specific bits from
  the filesystem bits of resctrl, the ultimate goal being to support
  ARM's equivalent technology MPAM, with the same fs interface (James
  Morse)"

* tag 'x86_cache_for_v5.15' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (25 commits)
  x86/resctrl: Make resctrl_arch_get_config() return its value
  x86/resctrl: Merge the CDP resources
  x86/resctrl: Expand resctrl_arch_update_domains()'s msr_param range
  x86/resctrl: Remove rdt_cdp_peer_get()
  x86/resctrl: Merge the ctrl_val arrays
  x86/resctrl: Calculate the index from the configuration type
  x86/resctrl: Apply offset correction when config is staged
  x86/resctrl: Make ctrlval arrays the same size
  x86/resctrl: Pass configuration type to resctrl_arch_get_config()
  x86/resctrl: Add a helper to read a closid's configuration
  x86/resctrl: Rename update_domains() to resctrl_arch_update_domains()
  x86/resctrl: Allow different CODE/DATA configurations to be staged
  x86/resctrl: Group staged configuration into a separate struct
  x86/resctrl: Move the schemata names into struct resctrl_schema
  x86/resctrl: Add a helper to read/set the CDP configuration
  x86/resctrl: Swizzle rdt_resource and resctrl_schema in pseudo_lock_region
  x86/resctrl: Pass the schema to resctrl filesystem functions
  x86/resctrl: Add resctrl_arch_get_num_closid()
  x86/resctrl: Store the effective num_closid in the schema
  x86/resctrl: Walk the resctrl schema list instead of an arch list
  ...

1  2 
arch/x86/kernel/cpu/resctrl/monitor.c

index 8caf871b796f27d334089d5fc25f74adbe937db0,b0741bee79fc4b17b1fd74e37557899d4c1fcdda..c9f0f3d63f75fffdc54e6c39259f39e3b88c5b1d
@@@ -174,7 -174,7 +174,7 @@@ void __check_limbo(struct rdt_domain *d
        struct rdt_resource *r;
        u32 crmid = 1, nrmid;
  
-       r = &rdt_resources_all[RDT_RESOURCE_L3];
+       r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
  
        /*
         * Skip RMID 0 and start from RMID 1 and check all the RMIDs that
@@@ -232,7 -232,7 +232,7 @@@ static void add_rmid_to_limbo(struct rm
        int cpu;
        u64 val;
  
-       r = &rdt_resources_all[RDT_RESOURCE_L3];
+       r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
  
        entry->busy = 0;
        cpu = get_cpu();
@@@ -285,14 -285,16 +285,15 @@@ static u64 mbm_overflow_count(u64 prev_
        return chunks >>= shift;
  }
  
 -static int __mon_event_count(u32 rmid, struct rmid_read *rr)
 +static u64 __mon_event_count(u32 rmid, struct rmid_read *rr)
  {
+       struct rdt_hw_resource *hw_res = resctrl_to_arch_res(rr->r);
        struct mbm_state *m;
        u64 chunks, tval;
  
        tval = __rmid_read(rmid, rr->evtid);
        if (tval & (RMID_VAL_ERROR | RMID_VAL_UNAVAIL)) {
 -              rr->val = tval;
 -              return -EINVAL;
 +              return tval;
        }
        switch (rr->evtid) {
        case QOS_L3_OCCUP_EVENT_ID:
                break;
        default:
                /*
 -               * Code would never reach here because
 -               * an invalid event id would fail the __rmid_read.
 +               * Code would never reach here because an invalid
 +               * event id would fail the __rmid_read.
                 */
 -              return -EINVAL;
 +              return RMID_VAL_ERROR;
        }
  
        if (rr->first) {
                return 0;
        }
  
-       chunks = mbm_overflow_count(m->prev_msr, tval, rr->r->mbm_width);
+       chunks = mbm_overflow_count(m->prev_msr, tval, hw_res->mbm_width);
        m->chunks += chunks;
        m->prev_msr = tval;
  
   */
  static void mbm_bw_count(u32 rmid, struct rmid_read *rr)
  {
-       struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3];
+       struct rdt_hw_resource *hw_res = resctrl_to_arch_res(rr->r);
        struct mbm_state *m = &rr->d->mbm_local[rmid];
        u64 tval, cur_bw, chunks;
  
        if (tval & (RMID_VAL_ERROR | RMID_VAL_UNAVAIL))
                return;
  
-       chunks = mbm_overflow_count(m->prev_bw_msr, tval, rr->r->mbm_width);
-       cur_bw = (get_corrected_mbm_count(rmid, chunks) * r->mon_scale) >> 20;
+       chunks = mbm_overflow_count(m->prev_bw_msr, tval, hw_res->mbm_width);
+       cur_bw = (get_corrected_mbm_count(rmid, chunks) * hw_res->mon_scale) >> 20;
  
        if (m->delta_comp)
                m->delta_bw = abs(cur_bw - m->prev_bw);
@@@ -360,29 -362,23 +361,29 @@@ void mon_event_count(void *info
        struct rdtgroup *rdtgrp, *entry;
        struct rmid_read *rr = info;
        struct list_head *head;
 +      u64 ret_val;
  
        rdtgrp = rr->rgrp;
  
 -      if (__mon_event_count(rdtgrp->mon.rmid, rr))
 -              return;
 +      ret_val = __mon_event_count(rdtgrp->mon.rmid, rr);
  
        /*
 -       * For Ctrl groups read data from child monitor groups.
 +       * 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->mon.rmid, rr))
 -                              return;
 +                      if (__mon_event_count(entry->mon.rmid, rr) == 0)
 +                              ret_val = 0;
                }
        }
 +
 +      /* Report error if none of rmid_reads are successful */
 +      if (ret_val)
 +              rr->val = ret_val;
  }
  
  /*
@@@ -421,6 -417,8 +422,8 @@@ static void update_mba_bw(struct rdtgro
  {
        u32 closid, rmid, cur_msr, cur_msr_val, new_msr_val;
        struct mbm_state *pmbm_data, *cmbm_data;
+       struct rdt_hw_resource *hw_r_mba;
+       struct rdt_hw_domain *hw_dom_mba;
        u32 cur_bw, delta_bw, user_bw;
        struct rdt_resource *r_mba;
        struct rdt_domain *dom_mba;
        if (!is_mbm_local_enabled())
                return;
  
-       r_mba = &rdt_resources_all[RDT_RESOURCE_MBA];
+       hw_r_mba = &rdt_resources_all[RDT_RESOURCE_MBA];
+       r_mba = &hw_r_mba->r_resctrl;
        closid = rgrp->closid;
        rmid = rgrp->mon.rmid;
        pmbm_data = &dom_mbm->mbm_local[rmid];
                pr_warn_once("Failure to get domain for MBA update\n");
                return;
        }
+       hw_dom_mba = resctrl_to_arch_dom(dom_mba);
  
        cur_bw = pmbm_data->prev_bw;
-       user_bw = dom_mba->mbps_val[closid];
+       user_bw = resctrl_arch_get_config(r_mba, dom_mba, closid, CDP_NONE);
        delta_bw = pmbm_data->delta_bw;
-       cur_msr_val = dom_mba->ctrl_val[closid];
+       /*
+        * resctrl_arch_get_config() chooses the mbps/ctrl value to return
+        * based on is_mba_sc(). For now, reach into the hw_dom.
+        */
+       cur_msr_val = hw_dom_mba->ctrl_val[closid];
  
        /*
         * For Ctrl groups read data from child monitor groups.
                return;
        }
  
-       cur_msr = r_mba->msr_base + closid;
+       cur_msr = hw_r_mba->msr_base + closid;
        wrmsrl(cur_msr, delay_bw_map(new_msr_val, r_mba));
-       dom_mba->ctrl_val[closid] = new_msr_val;
+       hw_dom_mba->ctrl_val[closid] = new_msr_val;
  
        /*
         * Delta values are updated dynamically package wise for each
@@@ -543,7 -547,7 +552,7 @@@ void cqm_handle_limbo(struct work_struc
  
        mutex_lock(&rdtgroup_mutex);
  
-       r = &rdt_resources_all[RDT_RESOURCE_L3];
+       r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
        d = container_of(work, struct rdt_domain, cqm_limbo.work);
  
        __check_limbo(d, false);
@@@ -579,7 -583,7 +588,7 @@@ void mbm_handle_overflow(struct work_st
        if (!static_branch_likely(&rdt_mon_enable_key))
                goto out_unlock;
  
-       r = &rdt_resources_all[RDT_RESOURCE_L3];
+       r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl;
        d = container_of(work, struct rdt_domain, mbm_over.work);
  
        list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) {
@@@ -676,15 -680,16 +685,16 @@@ static void l3_mon_evt_init(struct rdt_
  int rdt_get_mon_l3_config(struct rdt_resource *r)
  {
        unsigned int mbm_offset = boot_cpu_data.x86_cache_mbm_width_offset;
+       struct rdt_hw_resource *hw_res = resctrl_to_arch_res(r);
        unsigned int cl_size = boot_cpu_data.x86_cache_size;
        int ret;
  
-       r->mon_scale = boot_cpu_data.x86_cache_occ_scale;
+       hw_res->mon_scale = boot_cpu_data.x86_cache_occ_scale;
        r->num_rmid = boot_cpu_data.x86_cache_max_rmid + 1;
-       r->mbm_width = MBM_CNTR_WIDTH_BASE;
+       hw_res->mbm_width = MBM_CNTR_WIDTH_BASE;
  
        if (mbm_offset > 0 && mbm_offset <= MBM_CNTR_WIDTH_OFFSET_MAX)
-               r->mbm_width += mbm_offset;
+               hw_res->mbm_width += mbm_offset;
        else if (mbm_offset > MBM_CNTR_WIDTH_OFFSET_MAX)
                pr_warn("Ignoring impossible MBM counter offset\n");
  
        resctrl_cqm_threshold = cl_size * 1024 / r->num_rmid;
  
        /* h/w works in units of "boot_cpu_data.x86_cache_occ_scale" */
-       resctrl_cqm_threshold /= r->mon_scale;
+       resctrl_cqm_threshold /= hw_res->mon_scale;
  
        ret = dom_data_init(r);
        if (ret)
This page took 0.069751 seconds and 4 git commands to generate.