arch/s390/kernel/perf_cpum_cf.c
Source file repositories/reference/linux-study-clean/arch/s390/kernel/perf_cpum_cf.c
File Facts
- System
- Linux kernel
- Corpus path
arch/s390/kernel/perf_cpum_cf.c- Extension
.c- Size
- 56354 bytes
- Lines
- 1948
- Domain
- Architecture Layer
- Bucket
- arch/s390
- Inferred role
- Architecture Layer: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/kernel_stat.hlinux/percpu.hlinux/notifier.hlinux/init.hlinux/miscdevice.hlinux/perf_event.hasm/cpu_mf.hasm/hwctrset.hasm/debug.h
Detected Declarations
struct cpu_cf_eventsstruct cpu_cf_ptrstruct cf_ctrset_entrystruct cf_trailer_entrystruct cfset_call_on_cpu_parmstruct cfset_requestenum cpumf_ctr_setfunction ctr_set_enablefunction ctr_set_disablefunction ctr_set_startfunction ctr_set_stopfunction ctr_stcctmfunction get_cpu_cfhwfunction cpum_cf_reset_cpufunction cpum_cf_free_rootfunction cpum_cf_alloc_rootfunction cpum_cf_free_cpufunction cpum_cf_alloc_cpufunction perf_event_openfunction for_each_online_cpufunction cpum_cf_freefunction cfdiag_trailerfunction cpum_cf_make_setsizefunction sizefunction cpumf_pmu_startfunction cfdiag_getctrfunction cfdiag_diffctrsetfunction cfdiag_diffctrfunction get_counter_setfunction validate_ctr_versionfunction cpumf_pmu_enablefunction enablefunction hw_perf_event_destroyfunction is_userspace_eventfunction __hw_perf_event_initfunction cpumf_pmu_event_typefunction cpumf_pmu_event_initfunction hw_perf_event_resetfunction hw_perf_event_updatefunction cpumf_pmu_readfunction cpumf_pmu_startfunction cfdiag_push_samplefunction cpumf_pmu_stopfunction cpumf_pmu_addfunction cpumf_pmu_delfunction cpum_cf_online_cpufunction cpum_cf_offline_cpufunction stccm_avail
Annotated Snippet
static const struct file_operations cfset_fops = {
.owner = THIS_MODULE,
.open = cfset_open,
.release = cfset_release,
.unlocked_ioctl = cfset_ioctl,
};
static struct miscdevice cfset_dev = {
.name = S390_HWCTR_DEVICE,
.minor = MISC_DYNAMIC_MINOR,
.fops = &cfset_fops,
.mode = 0666,
};
/* Hotplug add of a CPU. Scan through all active processes and add
* that CPU to the list of CPUs supplied with ioctl(..., START, ...).
*/
static int cfset_online_cpu(unsigned int cpu)
{
struct cfset_call_on_cpu_parm p;
struct cfset_request *rp;
if (!list_empty(&cfset_session.head)) {
list_for_each_entry(rp, &cfset_session.head, node) {
p.sets = rp->ctrset;
cfset_ioctl_on(&p);
cpumask_set_cpu(cpu, &rp->mask);
}
}
return 0;
}
/* Hotplug remove of a CPU. Scan through all active processes and clear
* that CPU from the list of CPUs supplied with ioctl(..., START, ...).
* Adjust reference counts.
*/
static int cfset_offline_cpu(unsigned int cpu)
{
struct cfset_call_on_cpu_parm p;
struct cfset_request *rp;
if (!list_empty(&cfset_session.head)) {
list_for_each_entry(rp, &cfset_session.head, node) {
p.sets = rp->ctrset;
cfset_ioctl_off(&p);
cpumask_clear_cpu(cpu, &rp->mask);
}
}
return 0;
}
static void cfdiag_read(struct perf_event *event)
{
}
static int get_authctrsets(void)
{
unsigned long auth = 0;
enum cpumf_ctr_set i;
for (i = CPUMF_CTR_SET_BASIC; i < CPUMF_CTR_SET_MAX; ++i) {
if (cpumf_ctr_info.auth_ctl & cpumf_ctr_ctl[i])
auth |= cpumf_ctr_ctl[i];
}
return auth;
}
/* Setup the event. Test for authorized counter sets and only include counter
* sets which are authorized at the time of the setup. Including unauthorized
* counter sets result in specification exception (and panic).
*/
static int cfdiag_event_init2(struct perf_event *event)
{
struct perf_event_attr *attr = &event->attr;
int err = 0;
/* Set sample_period to indicate sampling */
event->hw.config = attr->config;
event->hw.sample_period = attr->sample_period;
local64_set(&event->hw.period_left, event->hw.sample_period);
local64_set(&event->count, 0);
event->hw.last_period = event->hw.sample_period;
/* Add all authorized counter sets to config_base. The
* the hardware init function is either called per-cpu or just once
* for all CPUS (event->cpu == -1). This depends on the whether
* counting is started for all CPUs or on a per workload base where
* the perf event moves from one CPU to another CPU.
* Checking the authorization on any CPU is fine as the hardware
* applies the same authorization settings to all CPUs.
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/kernel_stat.h`, `linux/percpu.h`, `linux/notifier.h`, `linux/init.h`, `linux/miscdevice.h`, `linux/perf_event.h`, `asm/cpu_mf.h`.
- Detected declarations: `struct cpu_cf_events`, `struct cpu_cf_ptr`, `struct cf_ctrset_entry`, `struct cf_trailer_entry`, `struct cfset_call_on_cpu_parm`, `struct cfset_request`, `enum cpumf_ctr_set`, `function ctr_set_enable`, `function ctr_set_disable`, `function ctr_set_start`.
- Atlas domain: Architecture Layer / arch/s390.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.