svn commit: r334545 - in head/sys: contrib/zstd/lib/freebsd kern netinet/libalias sys

Gleb Smirnoff glebius at FreeBSD.org
Fri Jun 8 23:58:59 UTC 2018


On Wed, Jun 06, 2018 at 12:56:47AM +0200, Mateusz Guzik wrote:
M> > M> Thank you for the kind words. It is positive feedback like this which
M> > M> keeps me going!
M> >
M> > Btw, what was the point of checking flags || result? Most places in kernel
M> > ignore flags and just test result regerdless of M_WAITOK/M_NOWAIT.
M> >
M> > The result is already in a register, why do you think checking for absense
M> > of M_WAITOK is faster that checking for !NULL _malloc_item?
M> >
M> 
M> This part is only reachable if flags are known at compilation time. If they
M> contain
M> M_WAITOK, the flag check will get elided along (we know for a fact it
M> passes)
M> and subsequently the NULL check will be short circuited, iow for known
M> M_WAITOK|M_ZERO flags this is:
M> 
M> _malloc_item = malloc(_size, type, flags & ~ M_ZERO);
M> bzero(_malloc_item, _size);

Thanks a lot for explanation!

-- 
Gleb Smirnoff


More information about the svn-src-head mailing list