lkml.org 
[lkml]   [2014]   [Mar]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 04/19] perf: Allow ability to map cpus to nodes easily
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


\
 
 \ /
  Last update: 2014-03-19 16:21    [W:0.275 / U:0.456 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site