Messages in this thread | | | Date | Wed, 19 Mar 2014 14:22:59 +0100 | From | Jiri Olsa <> | Subject | Re: [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
| |