Lines Matching +full:cpu +full:- +full:capacity
1 // SPDX-License-Identifier: GPL-2.0-only
20 #include <asm/cpu.h>
22 #include <asm/intel-family.h>
24 #include "cpu.h"
58 * Since the frequency freq_curr on x86 is controlled by micro-controller and
59 * our P-state setting is little more than a request/hint, we need to observe
65 * where freq_base is the max non-turbo P-state.
178 fratio -= delta_fratio;
234 /* The CPU may have less than 4 cores */
274 pr_debug("Couldn't determine cpu base or turbo frequency, necessary for scale-invariant accounting.\n");
280 pr_debug("Non-zero turbo and base frequencies led to a 0 ratio.\n");
334 int cpu;
342 for_each_possible_cpu(cpu)
343 per_cpu(arch_freq_scale, cpu) = SCHED_CAPACITY_SCALE;
355 unsigned long capacity;
362 * arch_enable_hybrid_capacity_scale() - Enable hybrid CPU capacity scaling
364 * Allocate memory for per-CPU data used by hybrid CPU capacity scaling,
371 int cpu;
374 WARN_ONCE(1, "Hybrid CPU capacity scaling already enabled");
382 for_each_possible_cpu(cpu) {
383 per_cpu_ptr(arch_cpu_scale, cpu)->capacity = SCHED_CAPACITY_SCALE;
384 per_cpu_ptr(arch_cpu_scale, cpu)->freq_ratio = arch_max_freq_ratio;
389 pr_info("Hybrid CPU capacity scaling enabled\n");
395 * arch_set_cpu_capacity() - Set scale-invariance parameters for a CPU
396 * @cpu: Target CPU.
397 * @cap: Capacity of @cpu at its maximum frequency, relative to @max_cap.
398 * @max_cap: System-wide maximum CPU capacity.
399 * @cap_freq: Frequency of @cpu corresponding to @cap.
400 * @base_freq: Frequency of @cpu at which MPERF counts.
407 * to let the scheduler know that capacity-aware scheduling can be used going
410 void arch_set_cpu_capacity(int cpu, unsigned long cap, unsigned long max_cap,
414 WRITE_ONCE(per_cpu_ptr(arch_cpu_scale, cpu)->capacity,
416 WRITE_ONCE(per_cpu_ptr(arch_cpu_scale, cpu)->freq_ratio,
419 WARN_ONCE(1, "Hybrid CPU capacity scaling not enabled");
423 unsigned long arch_scale_cpu_capacity(int cpu)
426 return READ_ONCE(per_cpu_ptr(arch_cpu_scale, cpu)->capacity);
443 freq_ratio = READ_ONCE(this_cpu_ptr(arch_cpu_scale)->freq_ratio);
479 acnt = aperf - s->aperf;
480 mcnt = mperf - s->mperf;
482 s->aperf = aperf;
483 s->mperf = mperf;
485 raw_write_seqcount_begin(&s->seq);
486 s->last_update = jiffies;
487 s->acnt = acnt;
488 s->mcnt = mcnt;
489 raw_write_seqcount_end(&s->seq);
497 * not running then the CPU is either idle or isolated.
501 int arch_freq_get_on_cpu(int cpu)
503 struct aperfmperf *s = per_cpu_ptr(&cpu_samples, cpu);
512 seq = raw_read_seqcount_begin(&s->seq);
513 last = s->last_update;
514 acnt = s->acnt;
515 mcnt = s->mcnt;
516 } while (read_seqcount_retry(&s->seq, seq));
522 if (!mcnt || (jiffies - last) > MAX_SAMPLE_AGE)
528 freq = cpufreq_quick_get(cpu);