[Bug 253877] [libgeom] O(n^2) behavior in geom_stats_resync

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Fri Feb 26 17:33:31 UTC 2021


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=253877

            Bug ID: 253877
           Summary: [libgeom] O(n^2) behavior in geom_stats_resync
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: bin
          Assignee: bugs at FreeBSD.org
          Reporter: asomers at FreeBSD.org

geom_stats_resync tries to mmap all of /dev/devstat.  But without knowing that
device's size, it simply tries to mmap successively larger amounts of memory
until it fails.  That means that the entire operation has O(n^2) syscalls,
where n is related to the number of geom providers.  On a system with a few
thousand providers, running "mdconfig -l" can take several minutes.

void
geom_stats_resync(void)
{
        void *p;

        if (statsfd == -1)
                return;
        for (;;) {
                p = mmap(statp, (npages + 1) * pagesize,
                    PROT_READ, MAP_SHARED, statsfd, 0);
                if (p == MAP_FAILED)
                        break;
                else
                        statp = p;
                npages++;
        }
}

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list