tools/testing/selftests/arm64/fp/vec-syscfg.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/arm64/fp/vec-syscfg.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/arm64/fp/vec-syscfg.c- Extension
.c- Size
- 18636 bytes
- Lines
- 797
- 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
assert.herrno.hfcntl.hstdbool.hstddef.hstdio.hstdlib.hstring.hunistd.hsys/auxv.hsys/prctl.hsys/types.hsys/wait.hasm/sigcontext.hasm/hwcap.hkselftest.hrdvl.h
Detected Declarations
struct vec_datafunction vec_type_supportedfunction stdio_read_integerfunction get_child_rdvlfunction file_read_integerfunction file_write_integerfunction proc_read_defaultfunction proc_write_minfunction proc_write_maxfunction prctl_getfunction prctl_set_samefunction prctl_setfunction prctl_set_no_childfunction prctl_set_for_childfunction prctl_set_onexecfunction prctl_set_all_vqsfunction smstartfunction smstart_smfunction smstopfunction change_sve_with_zafunction main
Annotated Snippet
struct vec_data {
const char *name;
unsigned long hwcap_type;
unsigned long hwcap;
const char *rdvl_binary;
int (*rdvl)(void);
int prctl_get;
int prctl_set;
const char *default_vl_file;
int default_vl;
int min_vl;
int max_vl;
};
#define VEC_SVE 0
#define VEC_SME 1
static struct vec_data vec_data[] = {
[VEC_SVE] = {
.name = "SVE",
.hwcap_type = AT_HWCAP,
.hwcap = HWCAP_SVE,
.rdvl = rdvl_sve,
.rdvl_binary = "./rdvl-sve",
.prctl_get = PR_SVE_GET_VL,
.prctl_set = PR_SVE_SET_VL,
.default_vl_file = "/proc/sys/abi/sve_default_vector_length",
},
[VEC_SME] = {
.name = "SME",
.hwcap_type = AT_HWCAP2,
.hwcap = HWCAP2_SME,
.rdvl = rdvl_sme,
.rdvl_binary = "./rdvl-sme",
.prctl_get = PR_SME_GET_VL,
.prctl_set = PR_SME_SET_VL,
.default_vl_file = "/proc/sys/abi/sme_default_vector_length",
},
};
static bool vec_type_supported(struct vec_data *data)
{
return getauxval(data->hwcap_type) & data->hwcap;
}
static int stdio_read_integer(FILE *f, const char *what, int *val)
{
int n = 0;
int ret;
ret = fscanf(f, "%d%*1[\n]%n", val, &n);
if (ret < 1 || n < 1) {
ksft_print_msg("failed to parse integer from %s\n", what);
return -1;
}
return 0;
}
/* Start a new process and return the vector length it sees */
static int get_child_rdvl(struct vec_data *data)
{
FILE *out;
int pipefd[2];
pid_t pid, child;
int read_vl, ret;
ret = pipe(pipefd);
if (ret == -1) {
ksft_print_msg("pipe() failed: %d (%s)\n",
errno, strerror(errno));
return -1;
}
fflush(stdout);
child = fork();
if (child == -1) {
ksft_print_msg("fork() failed: %d (%s)\n",
errno, strerror(errno));
close(pipefd[0]);
close(pipefd[1]);
return -1;
}
/* Child: put vector length on the pipe */
if (child == 0) {
/*
Annotation
- Immediate include surface: `assert.h`, `errno.h`, `fcntl.h`, `stdbool.h`, `stddef.h`, `stdio.h`, `stdlib.h`, `string.h`.
- Detected declarations: `struct vec_data`, `function vec_type_supported`, `function stdio_read_integer`, `function get_child_rdvl`, `function file_read_integer`, `function file_write_integer`, `function proc_read_default`, `function proc_write_min`, `function proc_write_max`, `function prctl_get`.
- 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.