libhugetlbfs attempts to restrict its statfs calls to only hugetlbfs filesystems. Unfortunately, the sscanf pattern isn't quite correct, and libhugetlbfs ends up calling statfs on all mounted filesystems. This can be quite costly when many network filesystems are mounted.
Correct the sscanf pattern. Signed-off-by: Andrew Hastings <[email protected]> on behalf of Cray Inc. --- -Andrew Hastings Cray Inc. diff -ruNp libhugetlbfs-2.10/hugeutils.c libhugetlbfs-2.10-patch/hugeutils.c --- libhugetlbfs-2.10/hugeutils.c 2010-10-08 15:27:00.000000000 -0500 +++ libhugetlbfs-2.10-patch/hugeutils.c 2010-11-10 14:52:34.128289000 -0600 @@ -508,7 +508,7 @@ static void find_mounts(void) char path[PATH_MAX+1]; char line[LINE_MAXLEN + 1]; char *eol; - int bytes, err; + int bytes, err, dummy; off_t offset; fd = open("/proc/mounts", O_RDONLY); @@ -537,9 +537,16 @@ static void find_mounts(void) offset = bytes - (eol + 1 - line); lseek(fd, -offset, SEEK_CUR); - err = sscanf(line, "%*s %" stringify(PATH_MAX) "s hugetlbfs ", - path); - if ((err == 1) && (hugetlbfs_test_path(path) == 1)) + /* + * Match only hugetlbfs filesystems. + * Subtle: sscanf returns the number of input items matched + * and assigned. To force sscanf to match the literal + * "hugetlbfs" string we include a 'dummy' input item + * following that string. + */ + err = sscanf(line, "%*s %" stringify(PATH_MAX) "s hugetlbfs " + "%*s %d", path, &dummy); + if ((err == 2) && (hugetlbfs_test_path(path) == 1)) add_hugetlbfs_mount(path, 0); } close(fd); ------------------------------------------------------------------------------ Centralized Desktop Delivery: Dell and VMware Reference Architecture Simplifying enterprise desktop deployment and management using Dell EqualLogic storage and VMware View: A highly scalable, end-to-end client virtualization framework. Read more! http://p.sf.net/sfu/dell-eql-dev2dev _______________________________________________ Libhugetlbfs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel
