intel_rdt_monitor.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. /*
  2. * Resource Director Technology(RDT)
  3. * - Monitoring code
  4. *
  5. * Copyright (C) 2017 Intel Corporation
  6. *
  7. * Author:
  8. * Vikas Shivappa <vikas.shivappa@intel.com>
  9. *
  10. * This replaces the cqm.c based on perf but we reuse a lot of
  11. * code and datastructures originally from Peter Zijlstra and Matt Fleming.
  12. *
  13. * This program is free software; you can redistribute it and/or modify it
  14. * under the terms and conditions of the GNU General Public License,
  15. * version 2, as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope it will be useful, but WITHOUT
  18. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  19. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  20. * more details.
  21. *
  22. * More information about RDT be found in the Intel (R) x86 Architecture
  23. * Software Developer Manual June 2016, volume 3, section 17.17.
  24. */
  25. #include <linux/module.h>
  26. #include <linux/slab.h>
  27. #include <asm/cpu_device_id.h>
  28. #include "intel_rdt.h"
  29. #define MSR_IA32_QM_CTR 0x0c8e
  30. #define MSR_IA32_QM_EVTSEL 0x0c8d
  31. struct rmid_entry {
  32. u32 rmid;
  33. int busy;
  34. struct list_head list;
  35. };
  36. /**
  37. * @rmid_free_lru A least recently used list of free RMIDs
  38. * These RMIDs are guaranteed to have an occupancy less than the
  39. * threshold occupancy
  40. */
  41. static LIST_HEAD(rmid_free_lru);
  42. /**
  43. * @rmid_limbo_count count of currently unused but (potentially)
  44. * dirty RMIDs.
  45. * This counts RMIDs that no one is currently using but that
  46. * may have a occupancy value > intel_cqm_threshold. User can change
  47. * the threshold occupancy value.
  48. */
  49. static unsigned int rmid_limbo_count;
  50. /**
  51. * @rmid_entry - The entry in the limbo and free lists.
  52. */
  53. static struct rmid_entry *rmid_ptrs;
  54. /*
  55. * Global boolean for rdt_monitor which is true if any
  56. * resource monitoring is enabled.
  57. */
  58. bool rdt_mon_capable;
  59. /*
  60. * Global to indicate which monitoring events are enabled.
  61. */
  62. unsigned int rdt_mon_features;
  63. /*
  64. * This is the threshold cache occupancy at which we will consider an
  65. * RMID available for re-allocation.
  66. */
  67. unsigned int intel_cqm_threshold;
  68. static inline struct rmid_entry *__rmid_entry(u32 rmid)
  69. {
  70. struct rmid_entry *entry;
  71. entry = &rmid_ptrs[rmid];
  72. WARN_ON(entry->rmid != rmid);
  73. return entry;
  74. }
  75. static u64 __rmid_read(u32 rmid, u32 eventid)
  76. {
  77. u64 val;
  78. /*
  79. * As per the SDM, when IA32_QM_EVTSEL.EvtID (bits 7:0) is configured
  80. * with a valid event code for supported resource type and the bits
  81. * IA32_QM_EVTSEL.RMID (bits 41:32) are configured with valid RMID,
  82. * IA32_QM_CTR.data (bits 61:0) reports the monitored data.
  83. * IA32_QM_CTR.Error (bit 63) and IA32_QM_CTR.Unavailable (bit 62)
  84. * are error bits.
  85. */
  86. wrmsr(MSR_IA32_QM_EVTSEL, eventid, rmid);
  87. rdmsrl(MSR_IA32_QM_CTR, val);
  88. return val;
  89. }
  90. static bool rmid_dirty(struct rmid_entry *entry)
  91. {
  92. u64 val = __rmid_read(entry->rmid, QOS_L3_OCCUP_EVENT_ID);
  93. return val >= intel_cqm_threshold;
  94. }
  95. /*
  96. * Check the RMIDs that are marked as busy for this domain. If the
  97. * reported LLC occupancy is below the threshold clear the busy bit and
  98. * decrement the count. If the busy count gets to zero on an RMID, we
  99. * free the RMID
  100. */
  101. void __check_limbo(struct rdt_domain *d, bool force_free)
  102. {
  103. struct rmid_entry *entry;
  104. struct rdt_resource *r;
  105. u32 crmid = 1, nrmid;
  106. r = &rdt_resources_all[RDT_RESOURCE_L3];
  107. /*
  108. * Skip RMID 0 and start from RMID 1 and check all the RMIDs that
  109. * are marked as busy for occupancy < threshold. If the occupancy
  110. * is less than the threshold decrement the busy counter of the
  111. * RMID and move it to the free list when the counter reaches 0.
  112. */
  113. for (;;) {
  114. nrmid = find_next_bit(d->rmid_busy_llc, r->num_rmid, crmid);
  115. if (nrmid >= r->num_rmid)
  116. break;
  117. entry = __rmid_entry(nrmid);
  118. if (force_free || !rmid_dirty(entry)) {
  119. clear_bit(entry->rmid, d->rmid_busy_llc);
  120. if (!--entry->busy) {
  121. rmid_limbo_count--;
  122. list_add_tail(&entry->list, &rmid_free_lru);
  123. }
  124. }
  125. crmid = nrmid + 1;
  126. }
  127. }
  128. bool has_busy_rmid(struct rdt_resource *r, struct rdt_domain *d)
  129. {
  130. return find_first_bit(d->rmid_busy_llc, r->num_rmid) != r->num_rmid;
  131. }
  132. /*
  133. * As of now the RMIDs allocation is global.
  134. * However we keep track of which packages the RMIDs
  135. * are used to optimize the limbo list management.
  136. */
  137. int alloc_rmid(void)
  138. {
  139. struct rmid_entry *entry;
  140. lockdep_assert_held(&rdtgroup_mutex);
  141. if (list_empty(&rmid_free_lru))
  142. return rmid_limbo_count ? -EBUSY : -ENOSPC;
  143. entry = list_first_entry(&rmid_free_lru,
  144. struct rmid_entry, list);
  145. list_del(&entry->list);
  146. return entry->rmid;
  147. }
  148. static void add_rmid_to_limbo(struct rmid_entry *entry)
  149. {
  150. struct rdt_resource *r;
  151. struct rdt_domain *d;
  152. int cpu;
  153. u64 val;
  154. r = &rdt_resources_all[RDT_RESOURCE_L3];
  155. entry->busy = 0;
  156. cpu = get_cpu();
  157. list_for_each_entry(d, &r->domains, list) {
  158. if (cpumask_test_cpu(cpu, &d->cpu_mask)) {
  159. val = __rmid_read(entry->rmid, QOS_L3_OCCUP_EVENT_ID);
  160. if (val <= intel_cqm_threshold)
  161. continue;
  162. }
  163. /*
  164. * For the first limbo RMID in the domain,
  165. * setup up the limbo worker.
  166. */
  167. if (!has_busy_rmid(r, d))
  168. cqm_setup_limbo_handler(d, CQM_LIMBOCHECK_INTERVAL);
  169. set_bit(entry->rmid, d->rmid_busy_llc);
  170. entry->busy++;
  171. }
  172. put_cpu();
  173. if (entry->busy)
  174. rmid_limbo_count++;
  175. else
  176. list_add_tail(&entry->list, &rmid_free_lru);
  177. }
  178. void free_rmid(u32 rmid)
  179. {
  180. struct rmid_entry *entry;
  181. if (!rmid)
  182. return;
  183. lockdep_assert_held(&rdtgroup_mutex);
  184. entry = __rmid_entry(rmid);
  185. if (is_llc_occupancy_enabled())
  186. add_rmid_to_limbo(entry);
  187. else
  188. list_add_tail(&entry->list, &rmid_free_lru);
  189. }
  190. static u64 mbm_overflow_count(u64 prev_msr, u64 cur_msr)
  191. {
  192. u64 shift = 64 - MBM_CNTR_WIDTH, chunks;
  193. chunks = (cur_msr << shift) - (prev_msr << shift);
  194. return chunks >>= shift;
  195. }
  196. static int __mon_event_count(u32 rmid, struct rmid_read *rr)
  197. {
  198. struct mbm_state *m;
  199. u64 chunks, tval;
  200. tval = __rmid_read(rmid, rr->evtid);
  201. if (tval & (RMID_VAL_ERROR | RMID_VAL_UNAVAIL)) {
  202. rr->val = tval;
  203. return -EINVAL;
  204. }
  205. switch (rr->evtid) {
  206. case QOS_L3_OCCUP_EVENT_ID:
  207. rr->val += tval;
  208. return 0;
  209. case QOS_L3_MBM_TOTAL_EVENT_ID:
  210. m = &rr->d->mbm_total[rmid];
  211. break;
  212. case QOS_L3_MBM_LOCAL_EVENT_ID:
  213. m = &rr->d->mbm_local[rmid];
  214. break;
  215. default:
  216. /*
  217. * Code would never reach here because
  218. * an invalid event id would fail the __rmid_read.
  219. */
  220. return -EINVAL;
  221. }
  222. if (rr->first) {
  223. memset(m, 0, sizeof(struct mbm_state));
  224. m->prev_bw_msr = m->prev_msr = tval;
  225. return 0;
  226. }
  227. chunks = mbm_overflow_count(m->prev_msr, tval);
  228. m->chunks += chunks;
  229. m->prev_msr = tval;
  230. rr->val += m->chunks;
  231. return 0;
  232. }
  233. /*
  234. * Supporting function to calculate the memory bandwidth
  235. * and delta bandwidth in MBps.
  236. */
  237. static void mbm_bw_count(u32 rmid, struct rmid_read *rr)
  238. {
  239. struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3];
  240. struct mbm_state *m = &rr->d->mbm_local[rmid];
  241. u64 tval, cur_bw, chunks;
  242. tval = __rmid_read(rmid, rr->evtid);
  243. if (tval & (RMID_VAL_ERROR | RMID_VAL_UNAVAIL))
  244. return;
  245. chunks = mbm_overflow_count(m->prev_bw_msr, tval);
  246. cur_bw = (chunks * r->mon_scale) >> 20;
  247. if (m->delta_comp)
  248. m->delta_bw = abs(cur_bw - m->prev_bw);
  249. m->delta_comp = false;
  250. m->prev_bw = cur_bw;
  251. m->prev_bw_msr = tval;
  252. }
  253. /*
  254. * This is called via IPI to read the CQM/MBM counters
  255. * on a domain.
  256. */
  257. void mon_event_count(void *info)
  258. {
  259. struct rdtgroup *rdtgrp, *entry;
  260. struct rmid_read *rr = info;
  261. struct list_head *head;
  262. rdtgrp = rr->rgrp;
  263. if (__mon_event_count(rdtgrp->mon.rmid, rr))
  264. return;
  265. /*
  266. * For Ctrl groups read data from child monitor groups.
  267. */
  268. head = &rdtgrp->mon.crdtgrp_list;
  269. if (rdtgrp->type == RDTCTRL_GROUP) {
  270. list_for_each_entry(entry, head, mon.crdtgrp_list) {
  271. if (__mon_event_count(entry->mon.rmid, rr))
  272. return;
  273. }
  274. }
  275. }
  276. /*
  277. * Feedback loop for MBA software controller (mba_sc)
  278. *
  279. * mba_sc is a feedback loop where we periodically read MBM counters and
  280. * adjust the bandwidth percentage values via the IA32_MBA_THRTL_MSRs so
  281. * that:
  282. *
  283. * current bandwdith(cur_bw) < user specified bandwidth(user_bw)
  284. *
  285. * This uses the MBM counters to measure the bandwidth and MBA throttle
  286. * MSRs to control the bandwidth for a particular rdtgrp. It builds on the
  287. * fact that resctrl rdtgroups have both monitoring and control.
  288. *
  289. * The frequency of the checks is 1s and we just tag along the MBM overflow
  290. * timer. Having 1s interval makes the calculation of bandwidth simpler.
  291. *
  292. * Although MBA's goal is to restrict the bandwidth to a maximum, there may
  293. * be a need to increase the bandwidth to avoid uncecessarily restricting
  294. * the L2 <-> L3 traffic.
  295. *
  296. * Since MBA controls the L2 external bandwidth where as MBM measures the
  297. * L3 external bandwidth the following sequence could lead to such a
  298. * situation.
  299. *
  300. * Consider an rdtgroup which had high L3 <-> memory traffic in initial
  301. * phases -> mba_sc kicks in and reduced bandwidth percentage values -> but
  302. * after some time rdtgroup has mostly L2 <-> L3 traffic.
  303. *
  304. * In this case we may restrict the rdtgroup's L2 <-> L3 traffic as its
  305. * throttle MSRs already have low percentage values. To avoid
  306. * unnecessarily restricting such rdtgroups, we also increase the bandwidth.
  307. */
  308. static void update_mba_bw(struct rdtgroup *rgrp, struct rdt_domain *dom_mbm)
  309. {
  310. u32 closid, rmid, cur_msr, cur_msr_val, new_msr_val;
  311. struct mbm_state *pmbm_data, *cmbm_data;
  312. u32 cur_bw, delta_bw, user_bw;
  313. struct rdt_resource *r_mba;
  314. struct rdt_domain *dom_mba;
  315. struct list_head *head;
  316. struct rdtgroup *entry;
  317. if (!is_mbm_local_enabled())
  318. return;
  319. r_mba = &rdt_resources_all[RDT_RESOURCE_MBA];
  320. closid = rgrp->closid;
  321. rmid = rgrp->mon.rmid;
  322. pmbm_data = &dom_mbm->mbm_local[rmid];
  323. dom_mba = get_domain_from_cpu(smp_processor_id(), r_mba);
  324. if (!dom_mba) {
  325. pr_warn_once("Failure to get domain for MBA update\n");
  326. return;
  327. }
  328. cur_bw = pmbm_data->prev_bw;
  329. user_bw = dom_mba->mbps_val[closid];
  330. delta_bw = pmbm_data->delta_bw;
  331. cur_msr_val = dom_mba->ctrl_val[closid];
  332. /*
  333. * For Ctrl groups read data from child monitor groups.
  334. */
  335. head = &rgrp->mon.crdtgrp_list;
  336. list_for_each_entry(entry, head, mon.crdtgrp_list) {
  337. cmbm_data = &dom_mbm->mbm_local[entry->mon.rmid];
  338. cur_bw += cmbm_data->prev_bw;
  339. delta_bw += cmbm_data->delta_bw;
  340. }
  341. /*
  342. * Scale up/down the bandwidth linearly for the ctrl group. The
  343. * bandwidth step is the bandwidth granularity specified by the
  344. * hardware.
  345. *
  346. * The delta_bw is used when increasing the bandwidth so that we
  347. * dont alternately increase and decrease the control values
  348. * continuously.
  349. *
  350. * For ex: consider cur_bw = 90MBps, user_bw = 100MBps and if
  351. * bandwidth step is 20MBps(> user_bw - cur_bw), we would keep
  352. * switching between 90 and 110 continuously if we only check
  353. * cur_bw < user_bw.
  354. */
  355. if (cur_msr_val > r_mba->membw.min_bw && user_bw < cur_bw) {
  356. new_msr_val = cur_msr_val - r_mba->membw.bw_gran;
  357. } else if (cur_msr_val < MAX_MBA_BW &&
  358. (user_bw > (cur_bw + delta_bw))) {
  359. new_msr_val = cur_msr_val + r_mba->membw.bw_gran;
  360. } else {
  361. return;
  362. }
  363. cur_msr = r_mba->msr_base + closid;
  364. wrmsrl(cur_msr, delay_bw_map(new_msr_val, r_mba));
  365. dom_mba->ctrl_val[closid] = new_msr_val;
  366. /*
  367. * Delta values are updated dynamically package wise for each
  368. * rdtgrp everytime the throttle MSR changes value.
  369. *
  370. * This is because (1)the increase in bandwidth is not perfectly
  371. * linear and only "approximately" linear even when the hardware
  372. * says it is linear.(2)Also since MBA is a core specific
  373. * mechanism, the delta values vary based on number of cores used
  374. * by the rdtgrp.
  375. */
  376. pmbm_data->delta_comp = true;
  377. list_for_each_entry(entry, head, mon.crdtgrp_list) {
  378. cmbm_data = &dom_mbm->mbm_local[entry->mon.rmid];
  379. cmbm_data->delta_comp = true;
  380. }
  381. }
  382. static void mbm_update(struct rdt_domain *d, int rmid)
  383. {
  384. struct rmid_read rr;
  385. rr.first = false;
  386. rr.d = d;
  387. /*
  388. * This is protected from concurrent reads from user
  389. * as both the user and we hold the global mutex.
  390. */
  391. if (is_mbm_total_enabled()) {
  392. rr.evtid = QOS_L3_MBM_TOTAL_EVENT_ID;
  393. __mon_event_count(rmid, &rr);
  394. }
  395. if (is_mbm_local_enabled()) {
  396. rr.evtid = QOS_L3_MBM_LOCAL_EVENT_ID;
  397. __mon_event_count(rmid, &rr);
  398. /*
  399. * Call the MBA software controller only for the
  400. * control groups and when user has enabled
  401. * the software controller explicitly.
  402. */
  403. if (is_mba_sc(NULL))
  404. mbm_bw_count(rmid, &rr);
  405. }
  406. }
  407. /*
  408. * Handler to scan the limbo list and move the RMIDs
  409. * to free list whose occupancy < threshold_occupancy.
  410. */
  411. void cqm_handle_limbo(struct work_struct *work)
  412. {
  413. unsigned long delay = msecs_to_jiffies(CQM_LIMBOCHECK_INTERVAL);
  414. int cpu = smp_processor_id();
  415. struct rdt_resource *r;
  416. struct rdt_domain *d;
  417. mutex_lock(&rdtgroup_mutex);
  418. r = &rdt_resources_all[RDT_RESOURCE_L3];
  419. d = get_domain_from_cpu(cpu, r);
  420. if (!d) {
  421. pr_warn_once("Failure to get domain for limbo worker\n");
  422. goto out_unlock;
  423. }
  424. __check_limbo(d, false);
  425. if (has_busy_rmid(r, d))
  426. schedule_delayed_work_on(cpu, &d->cqm_limbo, delay);
  427. out_unlock:
  428. mutex_unlock(&rdtgroup_mutex);
  429. }
  430. void cqm_setup_limbo_handler(struct rdt_domain *dom, unsigned long delay_ms)
  431. {
  432. unsigned long delay = msecs_to_jiffies(delay_ms);
  433. struct rdt_resource *r;
  434. int cpu;
  435. r = &rdt_resources_all[RDT_RESOURCE_L3];
  436. cpu = cpumask_any(&dom->cpu_mask);
  437. dom->cqm_work_cpu = cpu;
  438. schedule_delayed_work_on(cpu, &dom->cqm_limbo, delay);
  439. }
  440. void mbm_handle_overflow(struct work_struct *work)
  441. {
  442. unsigned long delay = msecs_to_jiffies(MBM_OVERFLOW_INTERVAL);
  443. struct rdtgroup *prgrp, *crgrp;
  444. int cpu = smp_processor_id();
  445. struct list_head *head;
  446. struct rdt_domain *d;
  447. mutex_lock(&rdtgroup_mutex);
  448. if (!static_branch_likely(&rdt_enable_key))
  449. goto out_unlock;
  450. d = get_domain_from_cpu(cpu, &rdt_resources_all[RDT_RESOURCE_L3]);
  451. if (!d)
  452. goto out_unlock;
  453. list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) {
  454. mbm_update(d, prgrp->mon.rmid);
  455. head = &prgrp->mon.crdtgrp_list;
  456. list_for_each_entry(crgrp, head, mon.crdtgrp_list)
  457. mbm_update(d, crgrp->mon.rmid);
  458. if (is_mba_sc(NULL))
  459. update_mba_bw(prgrp, d);
  460. }
  461. schedule_delayed_work_on(cpu, &d->mbm_over, delay);
  462. out_unlock:
  463. mutex_unlock(&rdtgroup_mutex);
  464. }
  465. void mbm_setup_overflow_handler(struct rdt_domain *dom, unsigned long delay_ms)
  466. {
  467. unsigned long delay = msecs_to_jiffies(delay_ms);
  468. int cpu;
  469. if (!static_branch_likely(&rdt_enable_key))
  470. return;
  471. cpu = cpumask_any(&dom->cpu_mask);
  472. dom->mbm_work_cpu = cpu;
  473. schedule_delayed_work_on(cpu, &dom->mbm_over, delay);
  474. }
  475. static int dom_data_init(struct rdt_resource *r)
  476. {
  477. struct rmid_entry *entry = NULL;
  478. int i, nr_rmids;
  479. nr_rmids = r->num_rmid;
  480. rmid_ptrs = kcalloc(nr_rmids, sizeof(struct rmid_entry), GFP_KERNEL);
  481. if (!rmid_ptrs)
  482. return -ENOMEM;
  483. for (i = 0; i < nr_rmids; i++) {
  484. entry = &rmid_ptrs[i];
  485. INIT_LIST_HEAD(&entry->list);
  486. entry->rmid = i;
  487. list_add_tail(&entry->list, &rmid_free_lru);
  488. }
  489. /*
  490. * RMID 0 is special and is always allocated. It's used for all
  491. * tasks that are not monitored.
  492. */
  493. entry = __rmid_entry(0);
  494. list_del(&entry->list);
  495. return 0;
  496. }
  497. static struct mon_evt llc_occupancy_event = {
  498. .name = "llc_occupancy",
  499. .evtid = QOS_L3_OCCUP_EVENT_ID,
  500. };
  501. static struct mon_evt mbm_total_event = {
  502. .name = "mbm_total_bytes",
  503. .evtid = QOS_L3_MBM_TOTAL_EVENT_ID,
  504. };
  505. static struct mon_evt mbm_local_event = {
  506. .name = "mbm_local_bytes",
  507. .evtid = QOS_L3_MBM_LOCAL_EVENT_ID,
  508. };
  509. /*
  510. * Initialize the event list for the resource.
  511. *
  512. * Note that MBM events are also part of RDT_RESOURCE_L3 resource
  513. * because as per the SDM the total and local memory bandwidth
  514. * are enumerated as part of L3 monitoring.
  515. */
  516. static void l3_mon_evt_init(struct rdt_resource *r)
  517. {
  518. INIT_LIST_HEAD(&r->evt_list);
  519. if (is_llc_occupancy_enabled())
  520. list_add_tail(&llc_occupancy_event.list, &r->evt_list);
  521. if (is_mbm_total_enabled())
  522. list_add_tail(&mbm_total_event.list, &r->evt_list);
  523. if (is_mbm_local_enabled())
  524. list_add_tail(&mbm_local_event.list, &r->evt_list);
  525. }
  526. int rdt_get_mon_l3_config(struct rdt_resource *r)
  527. {
  528. int ret;
  529. r->mon_scale = boot_cpu_data.x86_cache_occ_scale;
  530. r->num_rmid = boot_cpu_data.x86_cache_max_rmid + 1;
  531. /*
  532. * A reasonable upper limit on the max threshold is the number
  533. * of lines tagged per RMID if all RMIDs have the same number of
  534. * lines tagged in the LLC.
  535. *
  536. * For a 35MB LLC and 56 RMIDs, this is ~1.8% of the LLC.
  537. */
  538. intel_cqm_threshold = boot_cpu_data.x86_cache_size * 1024 / r->num_rmid;
  539. /* h/w works in units of "boot_cpu_data.x86_cache_occ_scale" */
  540. intel_cqm_threshold /= r->mon_scale;
  541. ret = dom_data_init(r);
  542. if (ret)
  543. return ret;
  544. l3_mon_evt_init(r);
  545. r->mon_capable = true;
  546. r->mon_enabled = true;
  547. return 0;
  548. }