tools/perf/util/s390-cpumsf.c
Source file repositories/reference/linux-study-clean/tools/perf/util/s390-cpumsf.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/util/s390-cpumsf.c- Extension
.c- Size
- 34776 bytes
- Lines
- 1175
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
endian.herrno.hbyteswap.hinttypes.hlinux/kernel.hlinux/types.hlinux/bitops.hlinux/log2.hlinux/zalloc.hsys/stat.hsys/types.hcolor.hevsel.hevlist.hmachine.hsession.htool.hdebug.hauxtrace.hs390-cpumsf.hs390-cpumsf-kernel.hs390-cpumcf-kernel.hconfig.hutil/sample.h
Detected Declarations
struct s390_cpumsfstruct s390_cpumsf_queuefunction s390_cpumcf_dumpctrfunction s390_cpumsf_basic_showfunction s390_cpumsf_diag_showfunction trailer_timestampfunction s390_cpumsf_trailer_showfunction s390_cpumsf_validatefunction s390_cpumsf_reached_trailerfunction s390_cpumsf_dumpfunction s390_cpumsf_dump_eventfunction s390_cpumsf_make_eventfunction get_trailer_timefunction s390_cpumsf_samplesfunction s390_cpumsf_run_decoderfunction donefunction s390_cpumsf_alloc_queuefunction s390_cpumsf_setup_queuefunction s390_cpumsf_setup_queuesfunction s390_cpumsf_update_queuesfunction s390_cpumsf_process_queuesfunction s390_cpumsf_synth_errorfunction s390_cpumsf_lostfunction s390_cpumsf_process_eventfunction s390_cpumsf_process_auxtrace_eventfunction s390_cpumsf_free_eventsfunction s390_cpumsf_free_queuesfunction s390_cpumsf_freefunction s390_cpumsf_evsel_is_auxtracefunction s390_cpumsf_get_typefunction s390function s390_cpumsf__configfunction s390_cpumsf_process_auxtrace_info
Annotated Snippet
struct s390_cpumsf {
struct auxtrace auxtrace;
struct auxtrace_queues queues;
struct auxtrace_heap heap;
struct perf_session *session;
struct machine *machine;
u32 auxtrace_type;
u32 pmu_type;
u16 machine_type;
bool data_queued;
bool use_logfile;
char *logdir;
};
struct s390_cpumsf_queue {
struct s390_cpumsf *sf;
unsigned int queue_nr;
struct auxtrace_buffer *buffer;
int cpu;
FILE *logfile;
FILE *logfile_ctr;
};
/* Check if the raw data should be dumped to file. If this is the case and
* the file to dump to has not been opened for writing, do so.
*
* Return 0 on success and greater zero on error so processing continues.
*/
static int s390_cpumcf_dumpctr(struct s390_cpumsf *sf,
struct perf_sample *sample)
{
struct s390_cpumsf_queue *sfq;
struct auxtrace_queue *q;
int rc = 0;
if (!sf->use_logfile || sf->queues.nr_queues <= sample->cpu)
return rc;
q = &sf->queues.queue_array[sample->cpu];
sfq = q->priv;
if (!sfq) /* Queue not yet allocated */
return rc;
if (!sfq->logfile_ctr) {
char *name;
rc = (sf->logdir)
? asprintf(&name, "%s/aux.ctr.%02x",
sf->logdir, sample->cpu)
: asprintf(&name, "aux.ctr.%02x", sample->cpu);
if (rc > 0)
sfq->logfile_ctr = fopen(name, "w");
if (sfq->logfile_ctr == NULL) {
pr_err("Failed to open counter set log file %s, "
"continue...\n", name);
rc = 1;
}
free(name);
}
if (sfq->logfile_ctr) {
/* See comment above for -4 */
size_t n = fwrite(sample->raw_data, sample->raw_size - 4, 1,
sfq->logfile_ctr);
if (n != 1) {
pr_err("Failed to write counter set data\n");
rc = 1;
}
}
return rc;
}
/* Display s390 CPU measurement facility basic-sampling data entry
* Data written on s390 in big endian byte order and contains bit
* fields across byte boundaries.
*/
static bool s390_cpumsf_basic_show(const char *color, size_t pos,
struct hws_basic_entry *basicp)
{
struct hws_basic_entry *basic = basicp;
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
struct hws_basic_entry local;
unsigned long long word = be64toh(*(unsigned long long *)basicp);
memset(&local, 0, sizeof(local));
local.def = be16toh(basicp->def);
local.prim_asn = word & 0xffff;
local.CL = word >> 30 & 0x3;
local.I = word >> 32 & 0x1;
local.AS = word >> 33 & 0x3;
Annotation
- Immediate include surface: `endian.h`, `errno.h`, `byteswap.h`, `inttypes.h`, `linux/kernel.h`, `linux/types.h`, `linux/bitops.h`, `linux/log2.h`.
- Detected declarations: `struct s390_cpumsf`, `struct s390_cpumsf_queue`, `function s390_cpumcf_dumpctr`, `function s390_cpumsf_basic_show`, `function s390_cpumsf_diag_show`, `function trailer_timestamp`, `function s390_cpumsf_trailer_show`, `function s390_cpumsf_validate`, `function s390_cpumsf_reached_trailer`, `function s390_cpumsf_dump`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
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.