Lines Matching +full:software +full:- +full:locked
1 // SPDX-License-Identifier: GPL-2.0-only
4 * - Cache Allocation code.
13 * Software Developer Manual June 2016, volume 3, section 17.17.
40 if (!r->membw.delay_linear && r->membw.arch_needs_linear) { in bw_validate()
41 rdt_last_cmd_puts("No support for non-linear MB domains\n"); in bw_validate()
51 /* Nothing else to do if software controller is enabled. */ in bw_validate()
57 if (bw < r->membw.min_bw || bw > r->default_ctrl) { in bw_validate()
59 bw, r->membw.min_bw, r->default_ctrl); in bw_validate()
63 *data = roundup(bw, (unsigned long)r->membw.bw_gran); in bw_validate()
71 u32 closid = data->rdtgrp->closid; in parse_bw()
72 struct rdt_resource *r = s->res; in parse_bw()
75 cfg = &d->staged_config[s->conf_type]; in parse_bw()
76 if (cfg->have_new_ctrl) { in parse_bw()
77 rdt_last_cmd_printf("Duplicate domain %d\n", d->hdr.id); in parse_bw()
78 return -EINVAL; in parse_bw()
81 if (!bw_validate(data->buf, &bw_val, r)) in parse_bw()
82 return -EINVAL; in parse_bw()
85 d->mbps_val[closid] = bw_val; in parse_bw()
89 cfg->new_ctrl = bw_val; in parse_bw()
90 cfg->have_new_ctrl = true; in parse_bw()
97 * On Intel CPUs, non-contiguous 1s value support is indicated by CPUID:
98 * - CPUID.0x10.1:ECX[3]: L3 non-contiguous 1s value supported if 1
99 * - CPUID.0x10.2:ECX[3]: L2 non-contiguous 1s value supported if 1
101 * Haswell does not support a non-contiguous 1s value and additionally
103 * AMD allows non-contiguous bitmasks.
108 unsigned int cbm_len = r->cache.cbm_len; in cbm_validate()
113 rdt_last_cmd_printf("Non-hex character in the mask %s\n", buf); in cbm_validate()
117 if ((r->cache.min_cbm_bits > 0 && val == 0) || val > r->default_ctrl) { in cbm_validate()
125 /* Are non-contiguous bitmasks allowed? */ in cbm_validate()
126 if (!r->cache.arch_has_sparse_bitmasks && in cbm_validate()
128 rdt_last_cmd_printf("The mask %lx has non-consecutive 1-bits\n", val); in cbm_validate()
132 if ((zero_bit - first_bit) < r->cache.min_cbm_bits) { in cbm_validate()
134 r->cache.min_cbm_bits); in cbm_validate()
149 struct rdtgroup *rdtgrp = data->rdtgrp; in parse_cbm()
151 struct rdt_resource *r = s->res; in parse_cbm()
154 cfg = &d->staged_config[s->conf_type]; in parse_cbm()
155 if (cfg->have_new_ctrl) { in parse_cbm()
156 rdt_last_cmd_printf("Duplicate domain %d\n", d->hdr.id); in parse_cbm()
157 return -EINVAL; in parse_cbm()
161 * Cannot set up more than one pseudo-locked region in a cache in parse_cbm()
164 if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP && in parse_cbm()
166 rdt_last_cmd_puts("Pseudo-locked region in hierarchy\n"); in parse_cbm()
167 return -EINVAL; in parse_cbm()
170 if (!cbm_validate(data->buf, &cbm_val, r)) in parse_cbm()
171 return -EINVAL; in parse_cbm()
173 if ((rdtgrp->mode == RDT_MODE_EXCLUSIVE || in parse_cbm()
174 rdtgrp->mode == RDT_MODE_SHAREABLE) && in parse_cbm()
176 rdt_last_cmd_puts("CBM overlaps with pseudo-locked region\n"); in parse_cbm()
177 return -EINVAL; in parse_cbm()
184 if (rdtgroup_cbm_overlaps(s, d, cbm_val, rdtgrp->closid, true)) { in parse_cbm()
186 return -EINVAL; in parse_cbm()
189 if (rdtgroup_cbm_overlaps(s, d, cbm_val, rdtgrp->closid, false)) { in parse_cbm()
190 if (rdtgrp->mode == RDT_MODE_EXCLUSIVE || in parse_cbm()
191 rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) { in parse_cbm()
193 return -EINVAL; in parse_cbm()
197 cfg->new_ctrl = cbm_val; in parse_cbm()
198 cfg->have_new_ctrl = true; in parse_cbm()
212 enum resctrl_conf_type t = s->conf_type; in parse_line()
214 struct rdt_resource *r = s->res; in parse_line()
220 /* Walking r->domains, ensure it can't race with cpuhp */ in parse_line()
223 if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP && in parse_line()
224 (r->rid == RDT_RESOURCE_MBA || r->rid == RDT_RESOURCE_SMBA)) { in parse_line()
225 rdt_last_cmd_puts("Cannot pseudo-lock MBA resource\n"); in parse_line()
226 return -EINVAL; in parse_line()
235 rdt_last_cmd_puts("Missing '=' or non-numeric domain\n"); in parse_line()
236 return -EINVAL; in parse_line()
239 list_for_each_entry(d, &r->ctrl_domains, hdr.list) { in parse_line()
240 if (d->hdr.id == dom_id) { in parse_line()
243 if (r->parse_ctrlval(&data, s, d)) in parse_line()
244 return -EINVAL; in parse_line()
245 if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) { in parse_line()
246 cfg = &d->staged_config[t]; in parse_line()
248 * In pseudo-locking setup mode and just in parse_line()
250 * pseudo-locked. Only one locked region per in parse_line()
255 rdtgrp->plr->s = s; in parse_line()
256 rdtgrp->plr->d = d; in parse_line()
257 rdtgrp->plr->cbm = cfg->new_ctrl; in parse_line()
258 d->plr = rdtgrp->plr; in parse_line()
264 return -EINVAL; in parse_line()
288 if (!cpumask_test_cpu(smp_processor_id(), &d->hdr.cpu_mask)) in resctrl_arch_update_one()
289 return -EINVAL; in resctrl_arch_update_one()
291 hw_dom->ctrl_val[idx] = cfg_val; in resctrl_arch_update_one()
297 hw_res->msr_update(&msr_param); in resctrl_arch_update_one()
311 /* Walking r->domains, ensure it can't race with cpuhp */ in resctrl_arch_update_domains()
314 list_for_each_entry(d, &r->ctrl_domains, hdr.list) { in resctrl_arch_update_domains()
318 cfg = &hw_dom->d_resctrl.staged_config[t]; in resctrl_arch_update_domains()
319 if (!cfg->have_new_ctrl) in resctrl_arch_update_domains()
323 if (cfg->new_ctrl == hw_dom->ctrl_val[idx]) in resctrl_arch_update_domains()
325 hw_dom->ctrl_val[idx] = cfg->new_ctrl; in resctrl_arch_update_domains()
338 smp_call_function_any(&d->hdr.cpu_mask, rdt_ctrl_update, &msr_param, 1); in resctrl_arch_update_domains()
350 if (!strcmp(resname, s->name) && rdtgrp->closid < s->num_closid) in rdtgroup_parse_resource()
354 return -EINVAL; in rdtgroup_parse_resource()
367 if (nbytes == 0 || buf[nbytes - 1] != '\n') in rdtgroup_schemata_write()
368 return -EINVAL; in rdtgroup_schemata_write()
369 buf[nbytes - 1] = '\0'; in rdtgroup_schemata_write()
371 rdtgrp = rdtgroup_kn_lock_live(of->kn); in rdtgroup_schemata_write()
373 rdtgroup_kn_unlock(of->kn); in rdtgroup_schemata_write()
374 return -ENOENT; in rdtgroup_schemata_write()
379 * No changes to pseudo-locked region allowed. It has to be removed in rdtgroup_schemata_write()
380 * and re-created instead. in rdtgroup_schemata_write()
382 if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKED) { in rdtgroup_schemata_write()
383 ret = -EINVAL; in rdtgroup_schemata_write()
384 rdt_last_cmd_puts("Resource group is pseudo-locked\n"); in rdtgroup_schemata_write()
394 ret = -EINVAL; in rdtgroup_schemata_write()
399 ret = -EINVAL; in rdtgroup_schemata_write()
408 r = s->res; in rdtgroup_schemata_write()
411 * Writes to mba_sc resources update the software controller, in rdtgroup_schemata_write()
417 ret = resctrl_arch_update_domains(r, rdtgrp->closid); in rdtgroup_schemata_write()
422 if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) { in rdtgroup_schemata_write()
424 * If pseudo-locking fails we keep the resource group in in rdtgroup_schemata_write()
426 * active and updated for just the domain the pseudo-locked in rdtgroup_schemata_write()
434 rdtgroup_kn_unlock(of->kn); in rdtgroup_schemata_write()
444 return hw_dom->ctrl_val[idx]; in resctrl_arch_get_config()
449 struct rdt_resource *r = schema->res; in show_doms()
454 /* Walking r->domains, ensure it can't race with cpuhp */ in show_doms()
457 seq_printf(s, "%*s:", max_name_width, schema->name); in show_doms()
458 list_for_each_entry(dom, &r->ctrl_domains, hdr.list) { in show_doms()
463 ctrl_val = dom->mbps_val[closid]; in show_doms()
466 schema->conf_type); in show_doms()
468 seq_printf(s, r->format_str, dom->hdr.id, max_data_width, in show_doms()
483 rdtgrp = rdtgroup_kn_lock_live(of->kn); in rdtgroup_schemata_show()
485 if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKSETUP) { in rdtgroup_schemata_show()
487 seq_printf(s, "%s:uninitialized\n", schema->name); in rdtgroup_schemata_show()
489 } else if (rdtgrp->mode == RDT_MODE_PSEUDO_LOCKED) { in rdtgroup_schemata_show()
490 if (!rdtgrp->plr->d) { in rdtgroup_schemata_show()
493 ret = -ENODEV; in rdtgroup_schemata_show()
496 rdtgrp->plr->s->res->name, in rdtgroup_schemata_show()
497 rdtgrp->plr->d->hdr.id, in rdtgroup_schemata_show()
498 rdtgrp->plr->cbm); in rdtgroup_schemata_show()
501 closid = rdtgrp->closid; in rdtgroup_schemata_show()
503 if (closid < schema->num_closid) in rdtgroup_schemata_show()
508 ret = -ENOENT; in rdtgroup_schemata_show()
510 rdtgroup_kn_unlock(of->kn); in rdtgroup_schemata_show()
533 rr->rgrp = rdtgrp; in mon_event_read()
534 rr->evtid = evtid; in mon_event_read()
535 rr->r = r; in mon_event_read()
536 rr->d = d; in mon_event_read()
537 rr->first = first; in mon_event_read()
538 rr->arch_mon_ctx = resctrl_arch_mon_ctx_alloc(r, evtid); in mon_event_read()
539 if (IS_ERR(rr->arch_mon_ctx)) { in mon_event_read()
540 rr->err = -EINVAL; in mon_event_read()
557 resctrl_arch_mon_ctx_free(r, evtid, rr->arch_mon_ctx); in mon_event_read()
562 struct kernfs_open_file *of = m->private; in rdtgroup_mondata_show()
572 rdtgrp = rdtgroup_kn_lock_live(of->kn); in rdtgroup_mondata_show()
574 ret = -ENOENT; in rdtgroup_mondata_show()
578 md.priv = of->kn->priv; in rdtgroup_mondata_show()
591 list_for_each_entry(d, &r->mon_domains, hdr.list) { in rdtgroup_mondata_show()
592 if (d->ci->id == domid) { in rdtgroup_mondata_show()
593 rr.ci = d->ci; in rdtgroup_mondata_show()
595 &d->ci->shared_cpu_map, evtid, false); in rdtgroup_mondata_show()
599 ret = -ENOENT; in rdtgroup_mondata_show()
606 hdr = rdt_find_domain(&r->mon_domains, domid, NULL); in rdtgroup_mondata_show()
607 if (!hdr || WARN_ON_ONCE(hdr->type != RESCTRL_MON_DOMAIN)) { in rdtgroup_mondata_show()
608 ret = -ENOENT; in rdtgroup_mondata_show()
612 mon_event_read(&rr, r, d, rdtgrp, &d->hdr.cpu_mask, evtid, false); in rdtgroup_mondata_show()
617 if (rr.err == -EIO) in rdtgroup_mondata_show()
619 else if (rr.err == -EINVAL) in rdtgroup_mondata_show()
625 rdtgroup_kn_unlock(of->kn); in rdtgroup_mondata_show()