Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 463481
Collapse All | Expand All

(-)systemd-199.orig/src/udev/udevd.c (-6 / +29 lines)
Lines 879-884 Link Here
879
        fclose(f);
879
        fclose(f);
880
}
880
}
881
881
882
static int mem_size_mb(void)
883
{
884
        FILE *f;
885
        char buf[4096];
886
        long int memsize = -1;
887
888
        f = fopen("/proc/meminfo", "re");
889
        if (f == NULL)
890
                return -1;
891
892
        while (fgets(buf, sizeof(buf), f) != NULL) {
893
                long int value;
894
895
                if (sscanf(buf, "MemTotal: %ld kB", &value) == 1) {
896
                        memsize = value / 1024;
897
                        break;
898
                }
899
        }
900
901
        fclose(f);
902
        return memsize;
903
}
904
882
static int systemd_fds(struct udev *udev, int *rctrl, int *rnetlink)
905
static int systemd_fds(struct udev *udev, int *rctrl, int *rnetlink)
883
{
906
{
884
        int ctrl = -1, netlink = -1;
907
        int ctrl = -1, netlink = -1;
Lines 1255-1267 Link Here
1255
        }
1278
        }
1256
1279
1257
        if (children_max <= 0) {
1280
        if (children_max <= 0) {
1258
                cpu_set_t cpu_set;
1281
                int memsize = mem_size_mb();
1259
1282
1260
                children_max = 8;
1283
                /* set value depending on the amount of RAM */
1261
1284
                if (memsize > 0)
1262
                if (sched_getaffinity(0, sizeof (cpu_set), &cpu_set) == 0) {
1285
                        children_max = 16 + (memsize / 8);
1263
                        children_max +=  CPU_COUNT(&cpu_set) * 2;
1286
                else
1264
                }
1287
                        children_max = 16;
1265
        }
1288
        }
1266
        log_debug("set children_max to %u\n", children_max);
1289
        log_debug("set children_max to %u\n", children_max);
1267
1290

Return to bug 463481