Re: [PATCH 1/3] perf header: Add die information in CPU topology

From: Jiri Olsa
Date: Tue May 28 2019 - 05:03:29 EST


On Thu, May 23, 2019 at 01:41:19PM -0700, kan.liang@xxxxxxxxxxxxxxx wrote:

SNIP

> if (sret <= 0)
> - goto try_threads;
> + goto try_dies;
>
> p = strchr(buf, '\n');
> if (p)
> @@ -57,6 +78,35 @@ static int build_cpu_topology(struct cpu_topology *tp, int cpu)
> }
> ret = 0;
>
> +try_dies:
> + if (has_die) {

less depth..

if (!has_die())
goto try_threads;


scnprintf(filename, MAXPATHLEN, DIE_SIB_FMT,
sysfs__mountpoint(), cpu);
...

> + scnprintf(filename, MAXPATHLEN, DIE_SIB_FMT,
> + sysfs__mountpoint(), cpu);
> + fp = fopen(filename, "r");
> + if (!fp)
> + goto try_threads;
> +
> + sret = getline(&buf, &len, fp);
> + fclose(fp);
> + if (sret <= 0)
> + goto try_threads;
> +
> + p = strchr(buf, '\n');
> + if (p)
> + *p = '\0';
> +
> + for (i = 0; i < tp->die_sib; i++) {
> + if (!strcmp(buf, tp->die_siblings[i]))
> + break;
> + }
> + if (i == tp->die_sib) {
> + tp->die_siblings[i] = buf;
> + tp->die_sib++;
> + buf = NULL;
> + len = 0;
> + }
> + ret = 0;
> + }
> try_threads:
> scnprintf(filename, MAXPATHLEN, THRD_SIB_FMT,

SNIP