Re: [PATCH 08/10] psi: pressure stall information for CPU, memory, and IO

From: Peter Zijlstra
Date: Wed Jul 18 2018 - 08:22:23 EST


On Wed, Jul 18, 2018 at 02:03:18PM +0200, Peter Zijlstra wrote:
> On Thu, Jul 12, 2018 at 01:29:40PM -0400, Johannes Weiner wrote:
> > + for (to = 0; (bo = ffs(set)); to += bo, set >>= bo)
> > + tasks[to + (bo - 1)]++;
>
> You want to benchmark this, but since it's only 3 consecutive bits, it
> might actually be faster to not use ffs() and simply test all 3 bits:
>
> for (to = set, bo = 0; to; to &= ~(1 << bo), bo++)

if (to & (1 << bo))

> tasks[bo]++;