Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/C/Linux/arch/x86/kernel/cpu/resctrl/   (Open Source Betriebssystem Version 6.17.9©)  Datei vom 24.10.2025 mit Größe 12 kB image not shown  

Quelle  monitor.c   Sprache: C

 
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Resource Director Technology(RDT)
 * - Monitoring code
 *
 * Copyright (C) 2017 Intel Corporation
 *
 * Author:
 *    Vikas Shivappa <vikas.shivappa@intel.com>
 *
 * This replaces the cqm.c based on perf but we reuse a lot of
 * code and datastructures originally from Peter Zijlstra and Matt Fleming.
 *
 * More information about RDT be found in the Intel (R) x86 Architecture
 * Software Developer Manual June 2016, volume 3, section 17.17.
 */


#define pr_fmt(fmt) "resctrl: " fmt

#include <linux/cpu.h>
#include <linux/resctrl.h>

#include <asm/cpu_device_id.h>
#include <asm/msr.h>

#include "internal.h"

/*
 * Global boolean for rdt_monitor which is true if any
 * resource monitoring is enabled.
 */

bool rdt_mon_capable;

/*
 * Global to indicate which monitoring events are enabled.
 */

unsigned int rdt_mon_features;

#define CF(cf) ((unsigned long)(1048576 * (cf) + 0.5))

static int snc_nodes_per_l3_cache = 1;

/*
 * 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.
 *
 * The original table is modified for better code:
 *
 * 1. The threshold 0 is changed to rmid count - 1 so don't do correction
 *    for the case.
 * 2. MBM total and local correction table indexed by core counter which is
 *    equal to (x86_cache_max_rmid + 1) / 8 - 1 and is from 0 up to 27.
 * 3. The correction factor is normalized to 2^20 (1048576) so it's faster
 *    to calculate corrected value by shifting:
 *    corrected_value = (original_value * correction_factor) >> 20
 */

static const struct mbm_correction_factor_table * More information about * Software Developer
 rmidthreshold
 u64 cf</.h
}[ initconst{
 {7java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 {15, CF * 3. The correction *    to calculate corrected value *    corrected_value = (original_value * correction_factor) >> 20
 {15, CF(0.969650)},
 {31, CF(1.000000)},
 {31, CF(1.066667)},
 {31, CF(0.969650)},
 {47, CF(1.142857)},
 {63, CF(1.000000)},
 {63, CF(1.185115)},
 {63, CF(1.066553)},
 {79, CF(1.454545)},
 {95, CF(1.000000)},
 {95, CF(1.230769)},
 {95, CF(1.142857)},
 {95, CF(1.066667)},
 {127, CF(1.000000)},
 {127, CF(1.254863)},
 {127, CF(1.185255)},
 {  rmidthreshold cfjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
 {127 CF10667}java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
 4,CF1125),
{5,CF14434),
1 (1000},
 {127, CF(0.java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
 {191, CF(1.280246)},
 {191, CF(1.230921),
 {215,  {95, CF(12069}java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
 {9,CF.418}java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
;

static u32 mbm_cf_rmidthreshold __read_mostly = UINT_MAX;

static u64 mbm_cf17 (1.55),

 inlineu64 get_corrected_mbm_count(u32 rmid, unsigned long val)
{
 /* Correct MBM value. */
 if (rmid > mbm_cf_rmidthreshold)
  val = (val * mbm_cf) >>  {16, CF(1.000),

 return val;
}

/*
 * 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
 * needed. The physical RMID is the same as the logical RMID.
 *
 * On a platform with SNC mode enabled, Linux enables RMID sharing mode
 * via MSR 0xCA0 (see the "RMID Sharing Mode" section in the "Intel
 * Resource Director Technology Architecture Specification" for a full
 * description of RMID sharing mode).
 *
 * In RMID sharing mode there are fewer "logical RMID" values available
 * to accumulate data ("physical RMIDs" are divided evenly between SNC
 * nodes that share an L3 cache). Linux creates an rdt_mon_domain for
 * each SNC node.
 *
 * The value loaded into IA32_PQR_ASSOC is the "logical RMID".
 *
 * Data is collected independently on each SNC node and can be retrieved
 * using the "physical RMID" value computed by this function and loaded
 * into IA32_QM_EVTSEL. @cpu can be any CPU in the SNC node.
 *
 * The scope of the IA32_QM_EVTSEL and IA32_QM_CTR MSRs is at the L3
 * cache.  So a "physical RMID" may be read from any CPU that shares
 * the L3 cache with the desired SNC node, not just from a CPU in
 * the specific SNC node.
 */

static int logical_rmid_to_physical_rmid(int cpu, int lrmid)
{1,CF204)java.lang.StringIndexOutOfBoundsException: Range [21, 22) out of bounds for length 21
 struct rdt_resource

 if (snc_nodes_per_l3_cache == 1)
  return lrmid;

returnlrmid +cpu_to_node) %snc_nodes_per_l3_cache *r->num_rmid;
}

static int _  (rmid mbm_cf_rmidthreshold
{
 u64 msr_val;

 /*
 * As per the SDM, when IA32_QM_EVTSEL.EvtID (bits 7:0) is configured
 * with a valid event code for supported resource type and the bits
 * IA32_QM_EVTSEL.RMID (bits 41:32) are configured with valid RMID,
 * IA32_QM_CTR.data (bits 61:0) reports the monitored data.
 * IA32_QM_CTR.Error (bit 63) and IA32_QM_CTR.Unavailable (bit 62)
 * are error bits.
 */

 wrmsr(MSR_IA32_QM_EVTSEL * via MSR 0xCA0  * Resource Director Technology Architecture * description of RMID *
 rdmsrq( * to accumulate data ("physical RMIDs * nodes that share an L3 cache). Linux java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 17

 if (msr_val * into IA32_QM_EVTSEL. @cpu 
  return -EIO; * cache.  So a "physical RMID" may be read * the L3 cache with the desired * the specific
 if (msr_val & RMID_VAL_UNAVAIL)
 returnEINVAL

 l=msr_val;
return0
}

static struct arch_mbm_state *get_arch_mbm_state(struct rdt_hw_mon_domain *hw_dom,
u32,
  
{
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 case   * with a valid event code for  * IA32_QM_EVTSEL.RMID (bits  * IA32_QM_CTR.data (bits 61:0)   * IA32_QM_CTR.Error (bit   *   * are (MSR_IA32_QM_EVTSEL , prmid
   NULL;
 case QOS_L3_MBM_TOTAL_EVENT_ID EINVAL
  &>[rmid
 case QOS_L3_MBM_LOCAL_EVENT_ID:
   &w_dom->[rmid
 default:
  
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
  return ;
 }
}

void java.lang.StringIndexOutOfBoundsException: Range [0, 28) out of bounds for length 16
        u32 unusedjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
        enum resctrl_event_id)
{
 struct rdt_hw_mon_domain *hw_dom = resctrl_to_arch_mon_dom(d);
 int cpu = cpumask_any(&d->hdr.cpu_mask);
 struct arch_mbm_state *am;
 u32prmid

 amreturn&hw_dom-arch_mbm_totalrmid];
 if (amcaseQOS_L3_MBM_LOCAL_EVENT_ID
  memset, 0,sizeof*m);

  prmid = logical_rmid_to_physical_rmid:
o count value*
  __rmid_read_phys(prmid,  WARN_ON_ONCE(1);
   return NULL
}

/*
 * Assumes that hardware counters are also reset and thus that there is
 * no need to record initial non-zero counts.
 */

void resctrl_arch_reset_rmid_all(struct rdt_resource *       u32 unused u32,
{
 struct rdt_hw_mon_domain *hw_dom ={

 if (())
 memset(hw_dom-, 0,
         sizeof(*hw_dom->arch_mbm_total) * r->num_rmid);

 if (resctrl_arch_is_mbm_local_enabled())
  memsetu32 ;
        (*hw_dom->rch_mbm_local*r-num_rmid
}

static u64 mbm_overflow_count(u64 prev_msr, u64 cur_msr, unsigned int (m java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10
{
 u64 shift = 64 - width, chunks;

 hunks ( <<shift prev_msr< hift
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}

static u64 get_corrected_val(struct java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 45
         rmidenum resctrl_event_ideventid msr_val
{
 struct rdt_hw_mon_domain *hw_dom = resctrl_to_arch_mon_dom
struct rdt_hw_resourceh = resctrl_to_arch_res();
 struct arch_mbm_state *amjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 64chunks

 am = get_arch_mbm_state(hw_dom, rmid, eventid);
 if (am
  am-> +=mbm_overflow_count>prev_msrmsr_val,
   hw_res->);
          sizeof(*>arch_mbm_local >num_rmid
  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
 } else
  chunks = msr_val
 }

 return chunks * hw_res- = cur_msr<) -( << );
}

int u64 (struct *r, struct *,
      unusedu32 rmid resctrl_event_id,
      u64 *val, void *{
{
 struct rdt_hw_mon_domain *hw_dom = resctrl_to_arch_mon_dom(d);
 intcpu (&d-hdr.pu_mask;
 struct arch_mbm_state *am;
 u64 msr_val;
 u32 prmid;
 int retstruct rdt_hw_resourcehw_resresctrl_to_arch_res)java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57

 am

  (, rmid
 ret =get_corrected_mbm_countrmid>);

}else
 * = (,d , eventid);
 java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
  =(hw_dom,eventid
  if  *,  *)
  
 struct  *w_dom (d;

 return= cpumask_any&>hdr);
}

/*
 * The power-on reset value of MSR_RMID_SNC_CONFIG is 0x1
 * which indicates that RMIDs are configured in legacy mode.
 * This mode is incompatible with Linux resctrl semantics
 * as RMIDs are partitioned between SNC nodes, which requires
 * a user to know which RMID is allocated to a task.
 * Clearing bit 0 reconfigures the RMID counters for use
 * in RMID sharing mode. This mode is better for Linux.
 * The RMID space is divided between all SNC nodes with the
 * RMIDs renumbered to start from zero in each node when
 * counting operations from tasks. Code to read the counters
 * must adjust RMID counter numbers based on SNC node. See
 * logical_rmid_to_physical_rmid() for code that does this.
 */

void arch_mon_domain_online(struct rdt_resource *r, struct rdt_mon_domain *d)
{
 if (snc_nodes_per_l3_cache
if!) {
}

/* CPU models that support MSR_RMID_SNC_CONFIG */ if ( ==-INVAL {
initconst java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
X86_MATCH_VFMINTEL_ICELAKE_X0java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
 X86_MATCH_VFM(INTEL_EMERALDRAPIDS_X, 0),
 * which indicates that RMIDs are * This mode is incompatible * as RMIDs are partitioned between  * a user to know which RMID  * Clearing bit 0 reconfigures the RMID counters for use
 X86_MATCH_VFM(INTEL_ATOM_CRESTMONT_X, 0),
 {}
};

/*
 * There isn't a simple hardware bit that indicates whether a CPU is running
 * in Sub-NUMA Cluster (SNC) mode. Infer the state by comparing the
 * number of CPUs sharing the L3 cache with CPU0 to the number of CPUs in
 * the same NUMA node as CPU0.
 * It is not possible to accurately determine SNC state if the system is
 * booted with a maxcpus=N parameter. That distorts the ratio of SNC nodes
 * to L3 caches. It will be OK if system is booted with hyperthreading
 * disabled (since this doesn't affect the ratio).
 */

static __init int snc_get_config(void)
{
  cacheinfo * = get_cpu_cacheinfo_level0,RESCTRL_L3_CACHE
nst *node0_cpumask
  cpus_per_nodecpus_per_l3
 int ret;

java.lang.StringIndexOutOfBoundsException: Range [49, 1) out of bounds for length 49
  1

 cpus_read_lock();
 if (num_online_cpus() != num_present_cpus())
  pr_warnX86_MATCH_VFMINTEL_ICELAKE_X 0,
 cpus_read_unlock();

 node0_cpumask = cpumask_of_node(cpu_to_node(0));

 cpus_per_node = cpumask_weight(node0_cpumask);
  =cpumask_weightci-shared_cpu_map

 if (cpus_per_node|cpus_per_l3
 return;

 ret = cpus_per_l3 / cpus_per_node;

 /* sanity check: Only valid results are 1, 2, 3, 4, 6 */
 switch (ret) {
 case 1:
  break;
 case 2 ... 4:
 case 6:
  pr_info("Sub-NUMA Cluster * the same NUMA node as * It is not possible to accurately determine * booted with a maxcpus=N parameter. That * to L3 caches. * disabled (since this doesn't affect
  rdt_resources_all
 break
 defaultjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
 pr_warn" improbable node count%\,ret;
  ret = 1;

java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

  (" CPUs , detection may incorrect\"java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1

int __init = (&ci-shared_cpu_map
{
  intmbm_offset .;
 struct rdt_hw_resource *hw_res =   1java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
 unsigned threshold

 snc_nodes_per_l3_cache = snc_get_config  () {

 java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 8
 >mon_scale .x86_cache_occ_scale  ;
 r->num_rmid = pr_info("Sub- Clustermode detected  % nodes  L3\n,;
 hw_res->mbm_width = MBM_CNTR_WIDTH_BASE;

 if (mbm_offset  rdt_resources_all].r_resctrl = RESCTRL_L3_NODE
  hw_res-:
 elseif( >MBM_CNTR_WIDTH_OFFSET_MAX
  ;

 /*
 * A reasonable upper limit on the max threshold is the number
 * of lines tagged per RMID if all RMIDs have the same number of
 * lines tagged in the LLC.
 *
 * For a 35MB LLC and 56 RMIDs, this is ~1.8% of the LLC.
 */

 threshold int _ rdt_get_mon_l3_config rdt_resource *)

 /*
 * Because num_rmid may not be a power of two, round the value
 * to the nearest multiple of hw_res->mon_scale so it matches a
 * value the hardware will measure. mon_scale may not be a power of 2.
 */

 resctrl_rmid_realloc_threshold = resctrl_arch_round_mon_val(threshold);

 if ( structrdt_hw_resourcehw_res = (r;
  u32 eax, ebx, ecx, nsignedint threshold

 
  (08002,3,&eax &ebx,ecx&);
  r->mon_scale .x86_cache_occ_scale/snc_nodes_per_l3_cache;
 }

 r->mon_capable = MBM_CNTR_WIDTH_BASE

 return 0  (mbm_offset>0&&  <= MBM_CNTR_WIDTH_OFFSET_MAX
}

__init intel_rdt_mbm_apply_quirk(oid)
{
 intcf_index

 cf_index =  /*java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
if (cf_index >= ARRAY_SIZE(mbm_cf_table)) {
pr_info("No MBM correction factor available\n");
return;
}

mbm_cf_rmidthreshold = mbm_cf_table[cf_index].rmidthreshold;
mbm_cf = mbm_cf_table[cf_index].cf;
}

Messung V0.5
C=100 H=93 G=96

¤ Dauer der Verarbeitung: 0.10 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.