tools/testing/selftests/powerpc/tm/tm-signal-context-force-tm.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/powerpc/tm/tm-signal-context-force-tm.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/powerpc/tm/tm-signal-context-force-tm.c- Extension
.c- Size
- 4472 bytes
- Lines
- 181
- 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.hstdlib.hsignal.hstring.hucontext.hunistd.hsys/mman.htm.hutils.hreg.h
Detected Declarations
function usr_signal_handlerfunction forkfunction seg_signal_handlerfunction tm_trap_testfunction tm_signal_context_force_tmfunction main
Annotated Snippet
if (ss.ss_sp == (void *)-1) {
perror("mmap error\n");
exit(-1);
}
/* Force the allocation through a page fault */
if (madvise(ss.ss_sp, SIGSTKSZ, MADV_DONTNEED)) {
perror("madvise\n");
exit(-1);
}
/*
* Setting an alternative stack to generate a page fault when
* the signal is raised.
*/
if (sigaltstack(&ss, NULL)) {
perror("sigaltstack\n");
exit(-1);
}
/* The signal handler will enable MSR_TS */
sigaction(SIGUSR1, &usr_sa, NULL);
/* If it does not crash, it might segfault, avoid it to retest */
sigaction(SIGSEGV, &seg_sa, NULL);
raise(SIGUSR1);
count++;
}
}
int tm_signal_context_force_tm(void)
{
SKIP_IF(!have_htm());
/*
* Skipping if not running on 64 bits system, since I think it is
* not possible to set mcontext's [MSR] with TS, due to it being 32
* bits.
*/
SKIP_IF(!is_ppc64le());
tm_trap_test();
return EXIT_SUCCESS;
}
int main(int argc, char **argv)
{
return test_harness(tm_signal_context_force_tm, "tm_signal_context_force_tm");
}
Annotation
- Immediate include surface: `stdio.h`, `stdlib.h`, `signal.h`, `string.h`, `ucontext.h`, `unistd.h`, `sys/mman.h`, `tm.h`.
- Detected declarations: `function usr_signal_handler`, `function fork`, `function seg_signal_handler`, `function tm_trap_test`, `function tm_signal_context_force_tm`, `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.