Re: [PATCH 5.15 00/78] 5.15.55-rc1 review

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 14, 2022 at 7:46 AM Boris Petkov <bp@xxxxxxxxx> wrote:
>
> On July 14, 2022 1:46:53 PM UTC, Paolo Bonzini <pbonzini@xxxxxxxxxx> wrote:
> >Please leave that one out as Peter suggested a better fix and I have that queued for Linus.
>
> Already zapped.

I like Peter's more obvious use of FASTYOP_LENGTH, but this is just disgusting:

    #define FASTOP_SIZE (8 << ((FASTOP_LENGTH > 8) & 1) <<
((FASTOP_LENGTH > 16) & 1))

I mean, I understand what it's doing, but just two lines above it the
code has a "ilog2()" use that already depends on the fact that you can
use ilog2() as a constant compile-time expression.

And guess what? The code could just use roundup_pow_of_two(), which is
designed exactly like ilog2() to be used for compile-time constant
values.

So the code should just use

    #define FASTOP_SIZE roundup_pow_of_two(FASTOP_LENGTH)

and be a lot more legible, wouldn't it?

Because I don't think there is anything magical about the length
"8/16/32". It's purely "aligned and big enough to contain
FASTOP_LENGTH".

And then the point of that

    static_assert(FASTOP_LENGTH <= FASTOP_SIZE);

just goes away, because there are no subtle math issues there any more.

In fact, the remaining question is just "where did the 7 come from" in

    #define FASTOP_LENGTH (7 + ENDBR_INSN_SIZE + RET_LENGTH)

because other than that it all looks fairly straightforward.

              Linus



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux