tools/testing/selftests/powerpc/pmu/event_code_tests/invalid_event_code_test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/powerpc/pmu/event_code_tests/invalid_event_code_test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/powerpc/pmu/event_code_tests/invalid_event_code_test.c- Extension
.c- Size
- 1793 bytes
- Lines
- 68
- 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
stdio.hsys/prctl.hlimits.h../event.h../sampling_tests/misc.h
Detected Declarations
function invalid_event_codefunction power10function main
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright 2022, Athira Rajeev, IBM Corp.
*/
#include <stdio.h>
#include <sys/prctl.h>
#include <limits.h>
#include "../event.h"
#include "../sampling_tests/misc.h"
/* The data cache was reloaded from local core's L3 due to a demand load */
#define EventCode_1 0x1340000001c040
/* PM_DATA_RADIX_PROCESS_L2_PTE_FROM_L2 */
#define EventCode_2 0x14242
/* Event code with IFM, EBB, BHRB bits set in event code */
#define EventCode_3 0xf00000000000001e
/*
* Some of the bits in the event code is
* reserved for specific platforms.
* Event code bits 52-59 are reserved in power9,
* whereas in ISA v3.1, these are used for programming
* Monitor Mode Control Register 3 (MMCR3).
* Bit 9 in event code is reserved in power9,
* whereas it is used for programming "radix_scope_qual"
* bit 18 in Monitor Mode Control Register 1 (MMCR1).
*
* Testcase to ensure that using reserved bits in
* event code should cause event_open to fail.
*/
static int invalid_event_code(void)
{
struct event event;
/* Check for platform support for the test */
SKIP_IF(platform_check_for_tests());
/*
* Events using MMCR3 bits and radix scope qual bits
* should fail in power9 and should succeed in power10 ( ISA v3.1 )
* Init the events and check for pass/fail in event open.
*/
if (have_hwcap2(PPC_FEATURE2_ARCH_3_1)) {
event_init(&event, EventCode_1);
FAIL_IF(event_open(&event));
event_close(&event);
event_init(&event, EventCode_2);
FAIL_IF(event_open(&event));
event_close(&event);
} else {
event_init(&event, EventCode_1);
FAIL_IF(!event_open(&event));
event_init(&event, EventCode_2);
FAIL_IF(!event_open(&event));
}
return 0;
}
int main(void)
{
return test_harness(invalid_event_code, "invalid_event_code");
}
Annotation
- Immediate include surface: `stdio.h`, `sys/prctl.h`, `limits.h`, `../event.h`, `../sampling_tests/misc.h`.
- Detected declarations: `function invalid_event_code`, `function power10`, `function main`.
- 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.