Re: [PATCH 4/5] xfs: speed up directory bestfree block scanning

Christoph Hellwig
2019-08-29T09:33:06Z

On Thu, Aug 29, 2019 at 07:31:17PM +1000, Dave Chinner wrote:
> On Thu, Aug 29, 2019 at 01:25:01AM -0700, Christoph Hellwig wrote:
> > Actually, another comment:
> >
> > > + /* Scan the free entry array for a large enough free space. */
> > > + do {
> > > + if (be16_to_cpu(bests[findex]) != NULLDATAOFF &&
> >
> > This could be changed to:
> >
> > if (bests[findex] != cpu_to_be16(NULLDATAOFF) &&
> >
> > which might lead to slightly better code generation.
>
> I don't think it will make any difference because the very next
> comparison in the if() statement needs the cpu order bests[findex]
> value because its a >= check. Hence we have to calculate it anyway,
> and the compiler should be smart enough to only evaluate it once...

Yeah, makes sense.