char *flags;
char *mtid; /* maximum thread id (s390) */
char *addrsz; /* address sizes */
- int dispatching; /* none, horizontal or vertical */
+ int dispatching; /* -1 if not evailable, DIST_* */
int freqboost; /* -1 if not evailable */
- int *polarization; /* cpu polarization */
int *addresses; /* physical cpu addresses */
int *configured; /* cpu configured */
int physsockets; /* Physical sockets (modules) */
cpu_set_t **drawermaps;
};
+/* dispatching modes */
+enum {
+ DISP_HORIZONTAL = 0,
+ DISP_VERTICAL = 1
+};
+
+/* cpu polarization */
+enum {
+ POLAR_UNKNOWN = 0,
+ POLAR_VLOW,
+ POLAR_VMEDIUM,
+ POLAR_VHIGH,
+ POLAR_HORIZONTAL
+};
+
struct lscpu_cpu {
int refcount;
struct lscpu_cputype *type;
int socketid;
int bookid;
int drawerid;
+
+ int polarization; /* POLAR_* */
+
};
struct lscpu_arch {
int lscpu_read_topology(struct lscpu_cxt *cxt);
int lscpu_read_topology_ids(struct lscpu_cxt *cxt);
+int lscpu_read_topology_polarization(struct lscpu_cxt *cxt);
void lscpu_cputype_free_topology(struct lscpu_cputype *ct);
struct lscpu_arch *lscpu_read_architecture(struct lscpu_cxt *cxt);
buf[v - p] = '\0';
v++;
+ fprintf(stderr, "key='%s', value='%s'\n", buf, v);
+
rtrim_whitespace((unsigned char *)buf);
/* search in cpu-types patterns */
struct lscpu_cputype *type = NULL;
struct lscpu_cpu *cpu = NULL;
FILE *fp;
+ size_t ncpus = 0;
char buf[BUFSIZ];
DBG(GATHER, ul_debugobj(cxt, "reading cpuinfo"));
if (fgets(buf, sizeof(buf), fp) != NULL)
p = skip_space(buf);
- if (p == NULL || (*buf && !*p)) {
- if (cpu)
+ if (p == NULL || (*buf && !*p)) { /* empty line */
+ if (cpu) {
lscpu_add_cpu(cxt, cpu, type);
- else if (type) {
+ ncpus++;
+ } else if (type) {
/* Generic non-cpu data. For some architectures
* cpuinfo contains description block (at the
* beginning of the file (IBM s390) or at the
lscpu_unref_cpu(cpu);
lscpu_unref_cputype(type);
fclose(fp);
+
+ DBG(GATHER, ul_debug("cpuinfo done: CPUs: %zu, types: %zu",
+ ncpus, cxt->ncputypes));
return 0;
}
lscpu_read_numas(cxt);
lscpu_read_topology(cxt);
lscpu_read_topology_ids(cxt);
+ lscpu_read_topology_polarization(cxt);
lscpu_decode_arm(cxt);
struct path_cxt *sys = cxt->syscpu;
size_t i;
-
for (i = 0; i < cxt->ncpus; i++) {
struct lscpu_cpu *cpu = cxt->cpus[i];
int num = cpu->logical_id;
return 0;
}
+
+int lscpu_read_topology_polarization(struct lscpu_cxt *cxt)
+{
+ struct path_cxt *sys = cxt->syscpu;
+ size_t i;
+
+ for (i = 0; i < cxt->ncpus; i++) {
+ struct lscpu_cpu *cpu = cxt->cpus[i];
+ int num = cpu->logical_id;
+ char mode[64];
+
+ if (!cpu->type || cpu->type->dispatching < 0)
+ continue;
+ if (ul_path_accessf(sys, F_OK, "cpu%d/polarization", num) != 0)
+ continue;
+
+ ul_path_readf_buffer(sys, mode, sizeof(mode), "cpu%d/polarization", num);
+
+ DBG(CPU, ul_debugobj(cpu, "#%d polar=%s", num, mode));
+
+ if (strncmp(mode, "vertical:low", sizeof(mode)) == 0)
+ cpu->polarization = POLAR_VLOW;
+ else if (strncmp(mode, "vertical:medium", sizeof(mode)) == 0)
+ cpu->polarization = POLAR_VMEDIUM;
+ else if (strncmp(mode, "vertical:high", sizeof(mode)) == 0)
+ cpu->polarization = POLAR_VHIGH;
+ else if (strncmp(mode, "horizontal", sizeof(mode)) == 0)
+ cpu->polarization = POLAR_HORIZONTAL;
+ else
+ cpu->polarization = POLAR_UNKNOWN;
+ }
+ return 0;
+}