• Ingo Molnar's avatar
    kconfig: improve seed in randconfig · b0fe5510
    Ingo Molnar authored
    'make randconfig' uses glibc's rand function, and the seed of
    that PRNG is set via:
    
    			srand(time(NULL));
    
    But 'time()' only increases once every second - freezing the
    randconfig result within a single second.
    
    My Nehalem testbox does randconfig much faster than 1 second
     and i have a few scripts that do 'randconfig until condition X'
    loops.
    
    Those scripts currently waste a lot of CPU time due to randconfig
    changing its seed only once per second currently.
    
    Change the seed to be micrseconds based. (I checked the statistical
    spread of the seed - the now.tv_sec*now.tv_usec multiplication
    there further improves it.)
    Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
    Cc: Roman Zippel <zippel@linux-m68k.org>
    [sam: fix for systems where usec is zero - noticed by Geert Uytterhoeven]
    Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
    b0fe5510
conf.c 11.7 KB