Index: sys/conf/NOTES =================================================================== --- sys/conf/NOTES +++ sys/conf/NOTES @@ -2984,6 +2984,7 @@ # If neither is present, then the Fortuna algorithm is used. options RANDOM_YARROW # Yarrow CSPRNG (old default) #options RANDOM_DUMMY # Dummy CSPRNG that always blocks +options RANDOM_ENABLE_UMA # slab allocator # For developers. options RANDOM_DEBUG # Extra debugging messages Index: sys/conf/options =================================================================== --- sys/conf/options +++ sys/conf/options @@ -950,6 +950,9 @@ # These are mutually exclusive. With neither, Fortuna is selected. RANDOM_DUMMY opt_global.h RANDOM_YARROW opt_random.h +# This turns on high-rate and potentially expensive harvesting in +# the uma slab allocator. +RANDOM_ENABLE_UMA opt_global.h # Intel em(4) driver EM_MULTIQUEUE opt_em.h Index: sys/sys/random.h =================================================================== --- sys/sys/random.h +++ sys/sys/random.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2000-2013 Mark R. V. Murray + * Copyright (c) 2000-2015 Mark R. V. Murray * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -86,6 +86,12 @@ void random_harvest_direct(const void *, u_int, u_int, enum random_entropy_source); #endif /* defined(RANDOM_DUMMY) */ +#if defined(RANDOM_ENABLE_UMA) +#define random_harvest_fast_uma(a, b, c, d) random_harvest_fast(a, b, c, d) +#else /* !defined(RANDOM_ENABLE_UMA) */ +#define random_harvest_fast_uma(a, b, c, d) do {} while (0) +#endif /* defined(RANDOM_ENABLE_UMA) */ + #endif /* _KERNEL */ #endif /* _SYS_RANDOM_H_ */ Index: sys/vm/uma_core.c =================================================================== --- sys/vm/uma_core.c +++ sys/vm/uma_core.c @@ -2135,8 +2135,11 @@ int lockfail; int cpu; - /* XXX: FIX? The entropy here is desirable, but the harvesting may be expensive */ - random_harvest_fast(&zone, sizeof(zone), 1, RANDOM_FAST); + /* + * This is only enabled by kernel option. + * If not enabled, it is a null macro. + */ + random_harvest_fast_uma(&zone, sizeof(zone), 1, RANDOM_FAST); /* This is the fast path allocation */ #ifdef UMA_DEBUG_ALLOC_1 @@ -2677,8 +2680,11 @@ int lockfail; int cpu; - /* XXX: FIX? The entropy here is desirable, but the harvesting may be expensive */ - random_harvest_fast(&zone, sizeof(zone), 1, RANDOM_FAST); + /* + * This is only enabled by kernel option. + * If not enabled, it is a null macro. + */ + random_harvest_fast_uma(&zone, sizeof(zone), 1, RANDOM_FAST); #ifdef UMA_DEBUG_ALLOC_1 printf("Freeing item %p to %s(%p)\n", item, zone->uz_name, zone);