[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200302150819.GA259142@krava>
Date: Mon, 2 Mar 2020 16:08:19 +0100
From: Jiri Olsa <jolsa@...hat.com>
To: Kajol Jain <kjain@...ux.ibm.com>
Cc: acme@...nel.org, linuxppc-dev@...ts.ozlabs.org, mpe@...erman.id.au,
sukadev@...ux.vnet.ibm.com, linux-kernel@...r.kernel.org,
linux-perf-users@...r.kernel.org, anju@...ux.vnet.ibm.com,
maddy@...ux.vnet.ibm.com, ravi.bangoria@...ux.ibm.com,
peterz@...radead.org, yao.jin@...ux.intel.com, ak@...ux.intel.com,
jolsa@...nel.org, kan.liang@...ux.intel.com, jmario@...hat.com,
alexander.shishkin@...ux.intel.com, mingo@...nel.org,
paulus@...abs.org, namhyung@...nel.org, mpetlan@...hat.com,
gregkh@...uxfoundation.org, benh@...nel.crashing.org,
mamatha4@...ux.vnet.ibm.com, mark.rutland@....com,
tglx@...utronix.de
Subject: Re: [PATCH v3 6/8] perf/tools: Enhance JSON/metric infrastructure to
handle "?"
On Sat, Feb 29, 2020 at 03:11:57PM +0530, Kajol Jain wrote:
SNIP
> #define PVR_VER(pvr) (((pvr) >> 16) & 0xFFFF) /* Version field */
> #define PVR_REV(pvr) (((pvr) >> 0) & 0xFFFF) /* Revison field */
>
> +#define SOCKETS_INFO_FILE_PATH "/devices/hv_24x7/interface/"
> +
> int
> get_cpuid(char *buffer, size_t sz)
> {
> @@ -44,3 +51,43 @@ get_cpuid_str(struct perf_pmu *pmu __maybe_unused)
>
> return bufp;
> }
> +
> +int arch_get_runtimeparam(void)
> +{
> + int count = 0;
> + DIR *dir;
> + char path[PATH_MAX];
> + const char *sysfs = sysfs__mountpoint();
> + char filename[] = "sockets";
> + FILE *file;
> + char buf[16], *num;
> + int data;
> +
> + if (!sysfs)
> + goto out;
> +
> + snprintf(path, PATH_MAX,
> + "%s" SOCKETS_INFO_FILE_PATH, sysfs);
> + dir = opendir(path);
> +
> + if (!dir)
> + goto out;
> +
> + strcat(path, filename);
> + file = fopen(path, "r");
> +
> + if (!file)
> + goto out;
> +
> + data = fread(buf, 1, sizeof(buf), file);
> +
> + if (data == 0)
> + goto out;
> +
> + count = strtol(buf, &num, 10);
> +out:
> + if (!count)
> + count = 1;
> +
> + return count;
we have sysfs__read_ull for this
jirka
Powered by blists - more mailing lists