On Fri, 2008-10-10 at 16:58 +0100, Andy Whitcroft wrote:
> +void pool_adjust(char *cmd, unsigned int counter)
> +{
> +     struct hpage_pool pools[MAX_POOLS];
> +     int pos;
> +     int cnt;
> +
> +     char *iter = NULL;
> +     char *page_size_str = NULL;
> +     char *adjust_str = NULL;
> +     long page_size;
> +
> +     unsigned long min;
> +     unsigned long max;
> +
> +     /* Extract the pagesize and adjustment. */
> +     page_size_str = strtok_r(cmd, ":", &iter);
> +     if (page_size_str)
> +             adjust_str = strtok_r(NULL, ":", &iter);
> +
> +     if (!page_size_str || !adjust_str) {
> +             ERROR("%s: invalid resize specificiation\n", cmd);
> +             exit(EXIT_FAILURE);
> +     }
> +     DEBUG("page_size<%s> adjust<%s> counter<%d>\n",
> +                                     page_size_str, adjust_str, counter);
> +
> +     /* Convert and validate the page_size. */
> +     page_size = __lh_parse_page_size(page_size_str);
> +
> +     cnt = __lh_hpool_sizes(pools, MAX_POOLS);
> +     if (cnt < 0) {
> +             ERROR("unable to obtain pools list");
> +             exit(EXIT_FAILURE);
> +     }
> +     for (pos = 0; cnt--; pos++) {
> +             if (pools[pos].pagesize_kb == page_size)
> +                     break;
> +     }
> +     if (cnt < 0) {
> +             ERROR("%s: unknown page size\n", page_size_str);
> +             exit(EXIT_FAILURE);
> +     }
> +
> +     min = pools[pos].minimum;
> +     max = pools[pos].maximum;
> +
> +     if (counter == POOL_MIN) {
> +             min = value_adjust(adjust_str, min);
> +             if (min > max)
> +                     max = min;
> +     } else {
> +             max = value_adjust(adjust_str, max);
> +             if (max < min)
> +                     min = max;
> +     }
> +     
> +     if ((pools[pos].maximum - pools[pos].minimum) < (max - min)) {
> +             DEBUG("setting HUGEPAGES_OC to %ld\n", (max - min));
> +             set_huge_page_counter(page_size, HUGEPAGES_OC, (max - min));
> +     }
> +     if (pools[pos].minimum != min) {
> +             DEBUG("setting HUGEPAGES_TOTAL to %ld\n", min);
> +             set_huge_page_counter(page_size, HUGEPAGES_TOTAL, min);
> +     }
> +     if ((pools[pos].maximum - pools[pos].minimum) > (max - min)) {
> +             DEBUG("setting HUGEPAGES_OC to %ld\n", (max - min));
> +             set_huge_page_counter(page_size, HUGEPAGES_OC, (max - min));
> +     }

Do we want to verify whether these settings took hold and of not, print
a warning message?

-- 
Adam Litke - (agl at us.ibm.com)
IBM Linux Technology Center


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Libhugetlbfs-devel mailing list
Libhugetlbfs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to