Re: [PATCH 04/19] perf: Allow ability to map cpus to nodes easily
From: Jiri Olsa
Date: Wed Mar 19 2014 - 09:23:20 EST
On Fri, Feb 28, 2014 at 12:42:53PM -0500, Don Zickus wrote:
SNIP
> +
> +/* Determine highest possible node in the system for sparse allocation */
> +static void set_max_node_num(void)
> +{
> + FILE *fp;
> + char buf[256];
> + int num;
> +
> + /* set up default */
> + max_node_num = 8;
> +
> + /* get the highest possible cpu number for a sparse allocation */
> + fp = fopen("/sys/devices/system/node/possible", "r");
> + if (!fp)
> + goto out;
> +
> + num = fread(&buf, 1, sizeof(buf), fp);
> + if (!num)
> + goto out_close;
> + buf[num] = '\0';
> +
> + /* start on the right, to find highest node num */
> + while (--num) {
> + if ((buf[num] == ',') || (buf[num] == '-')) {
> + num++;
> + break;
> + }
> + }
> + if (sscanf(&buf[num], "%d", &max_node_num) < 1)
> + goto out_close;
> +
> + max_node_num++;
> +
> + fclose(fp);
> + return;
these ^^^ inners should go into single function and be used in
both set_max_cpu_num and set_max_node_num functions
jirka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/