powerpc64 head -r344018 stuck sleeping problems: th->th_scale * tc_delta(th) overflows unsigned 64 bits sometimes [patched failed]

Mark Millard marklmi at yahoo.com
Fri Mar 1 21:19:12 UTC 2019



On 2019-Mar-1, at 11:42, Konstantin Belousov <kib at freebsd.org> wrote:

> . . .
> +#ifdef _LP64
> +	scale_bits = ffsl(scale);
> +#else
> +	scale_bits = ffsll(scale);
> +#endif. . .
> +		if (__predict_false(scale_bits + fls(delta) > 63)) {


The patch from yesterday uniformly used:

int
fls(int mask)
{
        int bit;

        if (mask == 0)
                return (0);
        for (bit = 1; mask != 1; bit++)
                mask = (unsigned int)mask >> 1;
        return (bit);
}

that looks for the most significant 1 bit.

The new patch uses in some places:

int
ffsl(long mask)
{
        int bit;

        if (mask == 0)
                return (0);
        for (bit = 1; !(mask & 1); bit++)
                mask = (unsigned long)mask >> 1;
        return (bit);
}

that looks for the least significant 1 bit. Similarly
for:

int
ffsll(long long mask)
{
        int bit;

        if (mask == 0)
                return (0);
        for (bit = 1; !(mask & 1); bit++)
                mask = (unsigned long long)mask >> 1;
        return (bit);
}

Was that deliberate?



===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)



More information about the freebsd-hackers mailing list