Projectname
large_stringclasses
15 values
Filepath
large_stringlengths
4
106
⌀
Function
large_stringlengths
11
3.45k
Label
list
Linux Kernel
tools/power/x86/intel-speed-select/isst-config.c
static int get_physical_package_id(int cpu) { int ret; if (cpu < 0) return -1; if (cpu_map && cpu_map[cpu].initialized) return cpu_map[cpu].pkg_id; ret = parse_int_file( 0, "/sys/devices/system/cpu/cpu%d/topology/physical_package_id", cpu); if (ret < 0) { int core_id, pkg_id, die_id; ...
[ 0, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-config.c
static int get_physical_die_id(int cpu) { int ret; if (cpu < 0) return -1; if (cpu_map && cpu_map[cpu].initialized) return cpu_map[cpu].die_id; ret = parse_int_file(0, "/sys/devices/system/cpu/cpu%d/topology/die_id", cpu); if (ret < 0) { int core_id, pkg_id, die_id; ret = get_stored_topol...
[ 0, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-config.c
int get_cpufreq_base_freq(int cpu) { return parse_int_file( 0, "/sys/devices/system/cpu/cpu%d/cpufreq/base_frequency", cpu); }
[ 0, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-config.c
int get_topo_max_cpus(void) { return topo_max_cpus; }
[ 0, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-config.c
void for_each_online_package_in_set(void (*callback)(struct isst_id *, void *, void *, void *, void *), void *arg1, void *arg2, void *arg3, void *arg4) { int max_packages[MAX_PACKAGE_COUNT * MA...
[ 1, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-config.c
void free_cpu_set(cpu_set_t *cpu_set) { CPU_FREE(cpu_set); }
[ 0, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-config.c
int get_max_punit_core_id(struct isst_id *id) { int max_id = 0; int i; for (i = 0; i < topo_max_cpus; ++i) { if (!CPU_ISSET_S(i, present_cpumask_size, present_cpumask)) continue; if (is_cpu_in_power_domain(i, id) && cpu_map[i].punit_cpu_core > max_id) max_id = cpu_map[i].punit_cpu_core; }...
[ 0, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-config.c
int get_cpu_count(struct isst_id *id) { if (id->pkg < 0 || id->die < 0) return 0; return cpu_cnt[id->pkg][id->die]; }
[ 0, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-config.c
int find_phy_core_num(int logical_cpu) { if (logical_cpu < topo_max_cpus) return cpu_map[logical_cpu].punit_cpu_core; return -EINVAL; }
[ 0, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-config.c
static int isst_fill_platform_info(void) { const char *pathname = "/dev/isst_interface"; int fd; fd = open(pathname, O_RDWR); if (fd < 0) err(-1, "%s open failed", pathname); if (ioctl(fd, ISST_IF_GET_PLATFORM_INFO, &isst_platform_info) == -1) { perror("ISST_IF_GET_PLATFORM_INFO"); close(fd); ...
[ 0, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-config.c
static void set_tdp_level(int arg) { if (cmd_help) { fprintf(stderr, "Set Config TDP level\n"); fprintf(stderr, "\t Arguments: -l|--level : Specify tdp level\n"); fprintf(stderr, "\t Optional Arguments: -o | online : online/offline for " "the tdp level\n"); fprintf(stderr, "\t on...
[ 1, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-config.c
static void set_scaling_min_to_cpuinfo_max(struct isst_id *id) { int i; for (i = 0; i < get_topo_max_cpus(); ++i) { if (!is_cpu_in_power_domain(i, id)) continue; adjust_scaling_max_from_base_freq(i); set_cpufreq_scaling_min_max_from_cpuinfo(i, 1, 0); adjust_scaling_min_from_base_freq(i); ...
[ 0, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-config.c
static void set_clos_enable(int arg) { int enable = arg; if (cmd_help) { if (enable) { fprintf(stderr, "Enable core-power for a package/die\n"); if (!is_skx_based_platform()) { fprintf(stderr, "\tClos Enable: Specify priority type with [--priority|-p]\n"); fprintf(s...
[ 1, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-config.c
static void dump_clos_info(int arg) { if (cmd_help) { fprintf(stderr, "Print Intel Speed Select Technology core power information\n"); fprintf(stderr, "\t Optionally specify targeted cpu id with [--cpu|-c]\n"); exit(0); } isst_ctdp_display_information_start(outf); if (max_target_cpus) ...
[ 1, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-config.c
static void set_clos_assoc_for_cpu(struct isst_id *id, void *arg1, void *arg2, void *arg3, void *arg4) { int ret; ret = isst_clos_associate(id, current_clos); if (ret) debug_printf("isst_clos_associate failed"); else isst_display_result(id, outf, "core-power", "assoc...
[ 0, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-config.c
static void set_clos_assoc(int arg) { if (cmd_help) { fprintf(stderr, "Associate a clos id to a CPU\n"); fprintf(stderr, "\tSpecify targeted clos id with [--clos|-c]\n"); fprintf(stderr, "\tFor example to associate clos 1 to CPU 0: issue\n"); fprintf(stderr, "\tintel-speed-select --cpu 0 core-power a...
[ 1, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-config.c
static void set_turbo_mode(int arg) { int i, enable = arg; struct isst_id id; if (cmd_help) { if (enable) fprintf(stderr, "Set turbo mode enable\n"); else fprintf(stderr, "Set turbo mode disable\n"); exit(0); } isst_ctdp_display_information_start(outf); for (i = 0; i < topo_max_cp...
[ 0, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-core.c
int isst_write_pm_config(struct isst_id *id, int cp_state) { unsigned int req, resp; int ret; if (cp_state) req = BIT(16); else req = 0; ret = isst_send_mbox_command(id->cpu, WRITE_PM_CONFIG, PM_FEATURE, 0, req, &resp); if (ret) return ret; debug_printf("cpu:...
[ 0, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-core.c
int isst_get_ctdp_control(struct isst_id *id, int config_index, struct isst_pkg_ctdp_level_info *ctdp_level) { int cp_state, cp_cap; unsigned int resp; int ret; ret = isst_send_mbox_command(id->cpu, CONFIG_TDP, CONFIG_TDP_GET_TDP_CONTROL, 0, config_inde...
[ 1, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-core.c
void isst_get_uncore_mem_freq(struct isst_id *id, int config_index, struct isst_pkg_ctdp_level_info *ctdp_level) { unsigned int resp; int ret; ret = isst_send_mbox_command(id->cpu, CONFIG_TDP, CONFIG_TDP_GET_MEM_FREQ, 0, config_index, &resp); if (re...
[ 0, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-core.c
int isst_get_tjmax_info(struct isst_id *id, int config_index, struct isst_pkg_ctdp_level_info *ctdp_level) { unsigned int resp; int ret; ret = isst_send_mbox_command(id->cpu, CONFIG_TDP, CONFIG_TDP_GET_TJMAX_INFO, 0, config_index, &resp); if (ret) ret...
[ 0, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-core.c
int isst_get_get_trl(struct isst_id *id, int level, int avx_level, int *trl) { unsigned int req, resp; int ret; req = level | (avx_level << 16); ret = isst_send_mbox_command( id->cpu, CONFIG_TDP, CONFIG_TDP_GET_TURBO_LIMIT_RATIOS, 0, req, &resp); if (ret) return ret; debug_printf("cpu:%d CONFIG...
[ 0, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-core.c
int isst_get_trl_bucket_info(struct isst_id *id, unsigned long long *buckets_info) { int ret; debug_printf("cpu:%d bucket info via MSR\n", id->cpu); *buckets_info = 0; ret = isst_send_msr_command(id->cpu, 0x1ae, 0, buckets_info); if (ret) return ret; debug_printf("cpu:%...
[ 0, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-core.c
void isst_get_pbf_info_complete(struct isst_pbf_info *pbf_info) { free_cpu_set(pbf_info->core_cpumask); }
[ 0, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-core.c
int isst_get_trl(struct isst_id *id, unsigned long long *trl) { int ret; ret = isst_send_msr_command(id->cpu, 0x1AD, 0, trl); if (ret) return ret; return 0; }
[ 0, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-core.c
int isst_set_trl(struct isst_id *id, unsigned long long trl) { int ret; if (!trl) trl = 0xFFFFFFFFFFFFFFFFULL; ret = isst_send_msr_command(id->cpu, 0x1AD, 1, &trl); if (ret) return ret; return 0; }
[ 1, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-core.c
int isst_clos_get_clos_information(struct isst_id *id, int *enable, int *type) { unsigned int resp; int ret; ret = isst_send_mbox_command(id->cpu, CONFIG_CLOS, CLOS_PM_QOS_CONFIG, 0, 0, &resp); if (ret) return ret; debug_printf("cpu:%d CLOS_PM_QOS_CONFIG resp:%x\n", id->c...
[ 0, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-core.c
int isst_clos_associate(struct isst_id *id, int clos_id) { unsigned int req, resp; unsigned int param; int core_id, ret; req = (clos_id & 0x03) << 16; core_id = find_phy_core_num(id->cpu); param = BIT(MBOX_CMD_WRITE_BIT) | core_id; ret = isst_send_mbox_command(id->cpu, CONFIG_CLOS, CLOS_PQR_ASSOC, para...
[ 0, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-display.c
static void format_and_print(FILE *outf, int level, char *header, char *value) { char *spaces = " "; static char delimiters[256]; int i; if (!out_format_is_json()) { format_and_print_txt(outf, level, header, value); return; } if (level == 0) { if (header) fprintf(outf, "{"); else ...
[ 1, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-display.c
void isst_ctdp_display_information_end(FILE *outf) { format_and_print(outf, 0, NULL, NULL); start = 0; }
[ 0, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-display.c
void isst_clos_display_clos_information(struct isst_id *id, FILE *outf, int clos_enable, int type, int state, int cap) { char header[256]; char value[256]; int level; level = print_package_info(id, outf); snprintf(header, sizeo...
[ 1, 0 ]
Linux Kernel
tools/power/x86/intel-speed-select/isst-display.c
void isst_clos_display_assoc_information(struct isst_id *id, FILE *outf, int clos) { char header[256]; char value[256]; int level; level = print_package_info(id, outf); snprintf(header, sizeof(header), "get-assoc"); format_and_print(outf, level + 1, header, NULL);...
[ 1, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
int idx_valid(int idx) { switch (idx) { case IDX_PKG_ENERGY: return do_rapl & (RAPL_PKG | RAPL_AMD_F17H); case IDX_DRAM_ENERGY: return do_rapl & RAPL_DRAM; case IDX_PP0_ENERGY: return do_rapl & RAPL_CORES_ENERGY_STATUS; case IDX_PP1_ENERGY: return do_rapl & RAPL_GFX; case IDX_PKG_PERF: ...
[ 0, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
int cpu_is_not_present(int cpu) { return !CPU_ISSET_S(cpu, cpu_present_setsize, cpu_present_set); }
[ 0, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
int cpu_migrate(int cpu) { CPU_ZERO_S(cpu_affinity_setsize, cpu_affinity_set); CPU_SET_S(cpu, cpu_affinity_setsize, cpu_affinity_set); if (sched_setaffinity(0, cpu_affinity_setsize, cpu_affinity_set) == -1) return -1; else return 0; }
[ 0, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
static int perf_instr_count_open(int cpu_num) { struct perf_event_attr pea; int fd; memset(&pea, 0, sizeof(struct perf_event_attr)); pea.type = PERF_TYPE_HARDWARE; pea.size = sizeof(struct perf_event_attr); pea.config = PERF_COUNT_HW_INSTRUCTIONS; fd = perf_event_open(&pea, -1, cpu_num, -1, 0); if (fd...
[ 1, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
int get_instr_count_fd(int cpu) { if (fd_instr_count_percpu[cpu]) return fd_instr_count_percpu[cpu]; fd_instr_count_percpu[cpu] = perf_instr_count_open(cpu); return fd_instr_count_percpu[cpu]; }
[ 0, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
FILE *fopen_or_die(const char *path, const char *mode) { FILE *filep = fopen(path, mode); if (!filep) err(1, "%s: open failed", path); return filep; }
[ 0, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
unsigned long long get_uncore_mhz(int package, int die) { char path[128]; sprintf(path, "/sys/devices/system/cpu/intel_uncore_frequency/package_0%d_die_0%d/" "current_freq_khz", package, die); return (snapshot_sysfs_counter(path) / 1000); }
[ 1, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
int get_epb(int cpu) { char path[128 + PATH_BYTES]; unsigned long long msr; int ret, epb = -1; FILE *fp; sprintf(path, "/sys/devices/system/cpu/cpu%d/power/energy_perf_bias", cpu); fp = fopen(path, "r"); if (!fp) goto msr_fallback; ret = fscanf(fp, "%d", &epb); if (ret != 1) err(1, "%s(%s)...
[ 1, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
void get_apic_id(struct thread_data *t) { unsigned int eax, ebx, ecx, edx; if (DO_BIC(BIC_APIC)) { eax = ebx = ecx = edx = 0; __cpuid(1, eax, ebx, ecx, edx); t->apic_id = (ebx >> 24) & 0xff; } if (!DO_BIC(BIC_X2APIC)) return; if (authentic_amd || hygon_genuine) { unsigned int topology...
[ 1, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
static void calculate_tsc_tweak() { tsc_tweak = base_hz / tsc_hz; }
[ 0, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
void free_fd_percpu(void) { int i; for (i = 0; i < topo.max_cpu_num + 1; ++i) { if (fd_percpu[i] != 0) close(fd_percpu[i]); } free(fd_percpu); }
[ 1, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
int parse_int_file(const char *fmt, ...) { va_list args; char path[PATH_MAX]; FILE *filep; int value; va_start(args, fmt); vsnprintf(path, sizeof(path), fmt, args); va_end(args); filep = fopen(path, "r"); if (!filep) return 0; if (fscanf(filep, "%d", &value) != 1) err(1, "%s: failed to pars...
[ 1, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
int get_die_id(int cpu) { return parse_int_file("/sys/devices/system/cpu/cpu%d/topology/die_id", cpu); }
[ 0, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
int mark_cpu_present(int cpu) { CPU_SET_S(cpu, cpu_present_setsize, cpu_present_set); return 0; }
[ 0, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
int init_thread_id(int cpu) { cpus[cpu].thread_id = -1; return 0; }
[ 0, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
int snapshot_gfx_rc6_ms(void) { FILE *fp; int retval; fp = fopen_or_die("/sys/class/drm/card0/power/rc6_residency_ms", "r"); retval = fscanf(fp, "%lld", &gfx_cur_rc6_ms); if (retval != 1) err(1, "GFX rc6"); fclose(fp); return 0; }
[ 1, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
int snapshot_gfx_act_mhz(void) { static FILE *fp; int retval; if (fp == NULL) fp = fopen_or_die( "/sys/class/graphics/fb0/device/drm/card0/gt_act_freq_mhz", "r"); else { rewind(fp); fflush(fp); } retval = fscanf(fp, "%d", &gfx_act_mhz); if (retval != 1) err(1, "GFX ACT MHz"); ...
[ 0, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
int snapshot_proc_sysfs_files(void) { if (DO_BIC(BIC_IRQ)) if (snapshot_proc_interrupts()) return 1; if (DO_BIC(BIC_GFX_rc6)) snapshot_gfx_rc6_ms(); if (DO_BIC(BIC_GFXMHz)) snapshot_gfx_mhz(); if (DO_BIC(BIC_GFXACTMHz)) snapshot_gfx_act_mhz(); if (DO_BIC(BIC_CPU_LPI)) snapshot_cp...
[ 0, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
static void signal_handler(int signal) { switch (signal) { case SIGINT: exit_requested = 1; if (debug) fprintf(stderr, " SIGINT\n"); break; case SIGUSR1: if (debug > 1) fprintf(stderr, "SIGUSR1\n"); break; } }
[ 1, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
void setup_signal_handler(void) { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_handler = &signal_handler; if (sigaction(SIGINT, &sa, NULL) < 0) err(1, "sigaction SIGINT"); if (sigaction(SIGUSR1, &sa, NULL) < 0) err(1, "sigaction SIGUSR1"); }
[ 1, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
void msr_sum_record(void) { struct itimerspec its; struct sigevent sev; per_cpu_msr_sum = calloc(topo.max_cpu_num + 1, sizeof(struct msr_sum_array)); if (!per_cpu_msr_sum) { fprintf(outf, "Can not allocate memory for long time MSR.\n"); return; } memset(&sev, 0, sizeof(struct sigevent)); sev.sig...
[ 1, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
int set_my_sched_priority(int priority) { int retval; int original_priority; errno = 0; original_priority = getpriority(PRIO_PROCESS, 0); if (errno && (original_priority == -1)) err(errno, "getpriority"); retval = setpriority(PRIO_PROCESS, 0, priority); if (retval) err(retval, "setpriority(%d)",...
[ 1, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
void check_dev_msr() { struct stat sb; char pathname[32]; sprintf(pathname, "/dev/cpu/%d/msr", base_cpu); if (stat(pathname, &sb)) if (system("/sbin/modprobe msr > /dev/null 2>&1")) err(-5, "no /dev/cpu/0/msr, Try \"# modprobe msr\" "); }
[ 1, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
void check_permissions(void) { int do_exit = 0; char pathname[32]; do_exit += check_for_cap_sys_rawio(); /* test file permissions */ sprintf(pathname, "/dev/cpu/%d/msr", base_cpu); if (euidaccess(pathname, R_OK)) { do_exit++; warn("/dev/cpu/0/msr open failed, try chown or chmod +r /dev/cpu/*/msr")...
[ 1, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
int has_slv_msrs(unsigned int family, unsigned int model) { if (!genuine_intel) return 0; if (family != 6) return 0; switch (model) { case INTEL_FAM6_ATOM_SILVERMONT: case INTEL_FAM6_ATOM_SILVERMONT_MID: case INTEL_FAM6_ATOM_AIRMONT_MID: return 1; } return 0; }
[ 1, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
int has_hsw_turbo_ratio_limit(unsigned int family, unsigned int model) { if (!genuine_intel) return 0; if (family != 6) return 0; switch (model) { case INTEL_FAM6_HASWELL_X: return 1; default: return 0; } }
[ 0, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
static void dump_cstate_pstate_config_info(unsigned int family, unsigned int model) { if (!do_nhm_platform_info) return; dump_nhm_platform_info(); dump_turbo_ratio_info(family, model); dump_nhm_cst_cfg(); }
[ 0, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
double get_tdp_intel(unsigned int model) { unsigned long long msr; if (do_rapl & RAPL_PKG_POWER_INFO) if (!get_msr(base_cpu, MSR_PKG_POWER_INFO, &msr)) return ((msr >> 0) & RAPL_POWER_GRANULARITY) * rapl_power_units; switch (model) { case INTEL_FAM6_ATOM_SILVERMONT: case INTEL_FAM6_ATOM_SILVERMON...
[ 0, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
double get_tdp_amd(unsigned int family) { UNUSED(family); return 280.0; }
[ 0, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
int has_snb_msrs(unsigned int family, unsigned int model) { if (!genuine_intel) return 0; if (family != 6) return 0; switch (model) { case INTEL_FAM6_SANDYBRIDGE: case INTEL_FAM6_SANDYBRIDGE_X: case INTEL_FAM6_IVYBRIDGE: case INTEL_FAM6_IVYBRIDGE_X: /* IVB Xeon */ case INTEL_FAM6_HASWELL:...
[ 1, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
int is_slm(unsigned int family, unsigned int model) { if (!genuine_intel) return 0; if (family != 6) return 0; switch (model) { case INTEL_FAM6_ATOM_SILVERMONT: case INTEL_FAM6_ATOM_SILVERMONT_D: /* AVN */ return 1; } return 0; }
[ 1, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
int is_knl(unsigned int family, unsigned int model) { if (!genuine_intel) return 0; if (family != 6) return 0; switch (model) { case INTEL_FAM6_XEON_PHI_KNL: return 1; } return 0; }
[ 1, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
void decode_misc_enable_msr(void) { unsigned long long msr; if (!genuine_intel) return; if (!get_msr(base_cpu, MSR_IA32_MISC_ENABLE, &msr)) fprintf(outf, "cpu%d: MSR_IA32_MISC_ENABLE: 0x%08llx (%sTCC %sEIST %sMWAIT " "%sPREFETCH %sTURBO)\n", base_cpu, msr, msr & MSR_...
[ 0, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
void decode_misc_feature_control(void) { unsigned long long msr; if (!has_misc_feature_control) return; if (!get_msr(base_cpu, MSR_MISC_FEATURE_CONTROL, &msr)) fprintf(outf, "cpu%d: MSR_MISC_FEATURE_CONTROL: 0x%08llx (%sL2-Prefetch " "%sL2-Prefetch-pair %sL1-Prefetch %sL1-IP-Pre...
[ 1, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
int dir_filter(const struct dirent *dirp) { if (isdigit(dirp->d_name[0])) return 1; else return 0; }
[ 0, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
void allocate_output_buffer() { output_buffer = calloc(1, (1 + topo.num_cpus) * 2048); outp = output_buffer; if (outp == NULL) err(-1, "calloc output buffer"); }
[ 1, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
void setup_all_buffers(void) { topology_probe(); allocate_irq_buffers(); allocate_fd_percpu(); allocate_counters(&thread_even, &core_even, &package_even); allocate_counters(&thread_odd, &core_odd, &package_odd); allocate_output_buffer(); for_all_proc_cpus(initialize_counters); }
[ 0, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
int fork_it(char **argv) { pid_t child_pid; int status; snapshot_proc_sysfs_files(); status = for_all_cpus(get_counters, EVEN_COUNTERS); first_counter_read = 0; if (status) exit(status); sched_setaffinity(0, cpu_present_setsize, cpu_present_set); gettimeofday(&tv_even, (struct timezone *)NULL); ...
[ 1, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
int get_and_dump_counters(void) { int status; snapshot_proc_sysfs_files(); status = for_all_cpus(get_counters, ODD_COUNTERS); if (status) return status; status = for_all_cpus(dump_counters, ODD_COUNTERS); if (status) return status; flush_output_stdout(); return status; }
[ 0, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
void print_bootcmd(void) { char bootcmd[COMMAND_LINE_SIZE]; FILE *fp; int ret; memset(bootcmd, 0, COMMAND_LINE_SIZE); fp = fopen("/proc/cmdline", "r"); if (!fp) return; ret = fread(bootcmd, sizeof(char), COMMAND_LINE_SIZE - 1, fp); if (ret) { bootcmd[ret] = '\0'; fprintf(outf, "Kernel com...
[ 1, 0 ]
Linux Kernel
tools/power/x86/turbostat/turbostat.c
int is_deferred_add(char *name) { int i; for (i = 0; i < deferred_add_index; ++i) if (!strcmp(name, deferred_add_names[i])) return 1; return 0; }
[ 0, 0 ]
Linux Kernel
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c
int parse_cmdline_hwp_max(int i) { update_hwp_max = 1; switch (i) { case OPTARG_POWER: return HWP_CAP_LOWEST; case OPTARG_NORMAL: case OPTARG_BALANCE_POWER: case OPTARG_BALANCE_PERFORMANCE: case OPTARG_PERFORMANCE: return HWP_CAP_HIGHEST; } return i; }
[ 1, 0 ]
Linux Kernel
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c
int parse_cmdline_hwp_window(int i) { unsigned int exponent; update_hwp_window = 1; switch (i) { case OPTARG_POWER: case OPTARG_BALANCE_POWER: case OPTARG_NORMAL: case OPTARG_BALANCE_PERFORMANCE: case OPTARG_PERFORMANCE: return 0; } if (i < 0 || i > 1270000000) { fprintf( stderr, ...
[ 1, 0 ]
Linux Kernel
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c
int parse_cmdline_turbo(int i) { update_turbo = 1; switch (i) { case OPTARG_POWER: return 0; case OPTARG_NORMAL: case OPTARG_BALANCE_POWER: case OPTARG_BALANCE_PERFORMANCE: case OPTARG_PERFORMANCE: return 1; } if (i < 0 || i > 1) { fprintf(stderr, "--turbo-enable: 1 to enable, 0 to disabl...
[ 1, 0 ]
Linux Kernel
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c
void validate_cpu_selected_set(void) { int cpu; if (CPU_COUNT_S(cpu_setsize, cpu_selected_set) == 0) errx(0, "no CPUs requested"); for (cpu = 0; cpu <= max_cpu_num; ++cpu) { if (CPU_ISSET_S(cpu, cpu_setsize, cpu_selected_set)) if (!CPU_ISSET_S(cpu, cpu_setsize, cpu_present_set)) errx(1, "...
[ 0, 0 ]
Linux Kernel
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c
FILE *fopen_or_die(const char *path, const char *mode) { FILE *filep = fopen(path, "r"); if (!filep) err(1, "%s: open failed", path); return filep; }
[ 0, 0 ]
Linux Kernel
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c
void err_on_hypervisor(void) { FILE *cpuinfo; char *flags, *hypervisor; char *buffer; cpuinfo = fopen_or_die("/proc/cpuinfo", "ro"); buffer = malloc(4096); if (!buffer) { fclose(cpuinfo); err(-ENOMEM, "buffer malloc fail"); } if (!fread(buffer, 1024, 1, cpuinfo)) { fclose(cpuinfo); fr...
[ 1, 0 ]
Linux Kernel
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c
static unsigned int write_sysfs(const char *path, char *buf, size_t buflen) { ssize_t numwritten; int fd; fd = open(path, O_WRONLY); if (fd == -1) return 0; numwritten = write(fd, buf, buflen - 1); if (numwritten < 1) { perror("write failed\n"); close(fd); return -1; } close(fd); ...
[ 0, 0 ]
Linux Kernel
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c
void print_hwp_request_pkg(int pkg, struct msr_hwp_request *h, char *str) { printf("pkg%d: ", pkg); if (str) printf("%s", str); printf("HWP_REQ_PKG: min %d max %d des %d epp %d window 0x%x (%d*10^%dus)\n", h->hwp_min, h->hwp_max, h->hwp_desired, h->hwp_epp, h->hwp_window, h->hwp_window & 0...
[ 1, 0 ]
Linux Kernel
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c
int enable_hwp_on_cpu(int cpu) { unsigned long long msr; get_msr(cpu, MSR_PM_ENABLE, &msr); put_msr(cpu, MSR_PM_ENABLE, 1); if (verbose) printf("cpu%d: MSR_PM_ENABLE old: %d new: %d\n", cpu, (unsigned int)msr, 1); return 0; }
[ 0, 0 ]
Linux Kernel
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c
int set_max_cpu_pkg_num(int cpu) { unsigned int pkg; if (max_cpu_num < cpu) max_cpu_num = cpu; pkg = get_pkg_num(cpu); if (pkg >= MAX_PACKAGES) errx(1, "cpu%d: %d >= MAX_PACKAGES (%d)", cpu, pkg, MAX_PACKAGES); if (pkg > max_pkg_num) max_pkg_num = pkg; if ((pkg_present_set & (1ULL << pkg))...
[ 1, 0 ]
Linux Kernel
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c
void verify_hwp_is_enabled(void) { unsigned long long msr; if (!has_hwp) return; /* MSR_PM_ENABLE[1] == 1 if HWP is enabled and MSRs visible */ get_msr(base_cpu, MSR_PM_ENABLE, &msr); if ((msr & 1) == 0) { fprintf(stderr, "HWP can be enabled using '--hwp-enable'\n"); has_hwp = 0; return; }...
[ 0, 0 ]
Linux Kernel
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c
void set_base_cpu(void) { base_cpu = sched_getcpu(); if (base_cpu < 0) err(-ENODEV, "No valid cpus found"); }
[ 0, 0 ]
Linux Kernel
tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c
void probe_dev_msr(void) { struct stat sb; char pathname[32]; sprintf(pathname, "/dev/cpu/%d/msr", base_cpu); if (stat(pathname, &sb)) if (system("/sbin/modprobe msr > /dev/null 2>&1")) err(-5, "no /dev/cpu/0/msr, Try \"# modprobe msr\" "); }
[ 1, 0 ]
Linux Kernel
tools/spi/spidev_fdx.c
static void do_msg(int fd, int len) { struct spi_ioc_transfer xfer[2]; unsigned char buf[32], *bp; int status; memset(xfer, 0, sizeof xfer); memset(buf, 0, sizeof buf); if (len > sizeof buf) len = sizeof buf; buf[0] = 0xaa; xfer[0].tx_buf = (unsigned long)buf; xfer[0].len = 1; xfer[1].rx_bu...
[ 1, 0 ]
Linux Kernel
tools/spi/spidev_fdx.c
static void dumpstat(const char *name, int fd) { __u8 lsb, bits; __u32 mode, speed; if (ioctl(fd, SPI_IOC_RD_MODE32, &mode) < 0) { perror("SPI rd_mode"); return; } if (ioctl(fd, SPI_IOC_RD_LSB_FIRST, &lsb) < 0) { perror("SPI rd_lsb_fist"); return; } if (ioctl(fd, SPI_IOC_RD_BITS_PER_WORD...
[ 0, 0 ]
Linux Kernel
tools/spi/spidev_fdx.c
int main(int argc, char **argv) { int c; int readcount = 0; int msglen = 0; int fd; const char *name; while ((c = getopt(argc, argv, "hm:r:v")) != EOF) { switch (c) { case 'm': msglen = atoi(optarg); if (msglen < 0) goto usage; continue; case 'r': readcount = at...
[ 1, 0 ]
Linux Kernel
tools/spi/spidev_test.c
static void print_usage(const char *prog) { printf("Usage: %s [-DsbdlHOLC3vpNR24SI]\n", prog); puts(" -D --device device to use (default /dev/spidev1.1)\n" " -s --speed max speed (Hz)\n" " -d --delay delay (usec)\n" " -b --bpw bits per word\n" " -i --input input dat...
[ 1, 0 ]
Linux Kernel
tools/spi/spidev_test.c
static void transfer_file(int fd, char *filename) { ssize_t bytes; struct stat sb; int tx_fd; uint8_t *tx; uint8_t *rx; if (stat(filename, &sb) == -1) pabort("can't stat input file"); tx_fd = open(filename, O_RDONLY); if (tx_fd < 0) pabort("can't open input file"); tx = malloc(sb.st_size);...
[ 1, 0 ]
Linux Kernel
tools/testing/cxl/mock_acpi.c
struct acpi_device *to_cxl_host_bridge(struct device *host, struct device *dev) { int index; struct acpi_device *adev, *found = NULL; struct cxl_mock_ops *ops = get_cxl_mock_ops(&index); if (ops && ops->is_mock_bridge(dev)) { found = ACPI_COMPANION(dev); goto out...
[ 1, 0 ]
Linux Kernel
tools/testing/cxl/test/cxl.c
static void depopulate_all_mock_resources(void) { struct cxl_mock_res *res, *_res; mutex_lock(&mock_res_lock); list_for_each_entry_safe(res, _res, &mock_res, list) { gen_pool_free(cxl_mock_pool, res->range.start, range_len(&res->range)); list_del(&res->list); kfree(res); } mutex_unlock(&mock_res...
[ 0, 0 ]
Linux Kernel
tools/testing/cxl/test/cxl.c
static struct cxl_mock_res *alloc_mock_res(resource_size_t size, int align) { struct cxl_mock_res *res = kzalloc(sizeof(*res), GFP_KERNEL); struct genpool_data_align data = { .align = align, }; unsigned long phys; INIT_LIST_HEAD(&res->list); phys = gen_pool_alloc_algo(cxl_mock_pool, size, gen_...
[ 0, 0 ]
Linux Kernel
tools/testing/cxl/test/cxl.c
static bool is_mock_bridge(struct device *dev) { int i; for (i = 0; i < ARRAY_SIZE(cxl_host_bridge); i++) if (dev == &cxl_host_bridge[i]->dev) return true; for (i = 0; i < ARRAY_SIZE(cxl_hb_single); i++) if (dev == &cxl_hb_single[i]->dev) return true; for (i = 0; i < ARRAY_SIZE(cxl_rch); i...
[ 0, 0 ]
Linux Kernel
tools/testing/cxl/test/cxl.c
static int host_bridge_index(struct acpi_device *adev) { return adev - host_bridge; }
[ 0, 0 ]
Linux Kernel
tools/testing/cxl/test/cxl.c
static struct acpi_pci_root *mock_acpi_pci_find_root(acpi_handle handle) { struct acpi_device *adev = find_host_bridge(handle); if (!adev) return acpi_pci_find_root(handle); return &mock_pci_root[host_bridge_index(adev)]; }
[ 0, 0 ]
Linux Kernel
tools/testing/cxl/test/cxl.c
static int mock_decoder_commit(struct cxl_decoder *cxld) { struct cxl_port *port = to_cxl_port(cxld->dev.parent); int id = cxld->id; if (cxld->flags & CXL_DECODER_F_ENABLE) return 0; dev_dbg(&port->dev, "%s commit\n", dev_name(&cxld->dev)); if (port->commit_end + 1 != id) { dev_dbg(&port->dev, "%s:...
[ 1, 0 ]
Linux Kernel
tools/testing/cxl/test/cxl.c
static void cxl_rch_exit(void) { int i; for (i = ARRAY_SIZE(cxl_rcd) - 1; i >= 0; i--) platform_device_unregister(cxl_rcd[i]); for (i = ARRAY_SIZE(cxl_rch) - 1; i >= 0; i--) { struct platform_device *pdev = cxl_rch[i]; if (!pdev) continue; sysfs_remove_link(&pdev->dev.kobj, "firmware_node...
[ 1, 0 ]
Linux Kernel
tools/testing/cxl/test/cxl.c
static void cxl_single_exit(void) { int i; for (i = ARRAY_SIZE(cxl_mem_single) - 1; i >= 0; i--) platform_device_unregister(cxl_mem_single[i]); for (i = ARRAY_SIZE(cxl_swd_single) - 1; i >= 0; i--) platform_device_unregister(cxl_swd_single[i]); for (i = ARRAY_SIZE(cxl_swu_single) - 1; i >= 0; i--) ...
[ 1, 0 ]