mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-28 11:18:45 +07:00
e5e7a8f2d8
Add 3 basic tests that stress verifier scalability. test_verif_scale1.c calls non-inlined jhash() function 90 times on different position in the packet. This test simulates network packet parsing. jhash function is ~140 instructions and main program is ~1200 insns. test_verif_scale2.c force inlines jhash() function 90 times. This program is ~15k instructions long. test_verif_scale3.c calls non-inlined jhash() function 90 times on But this time jhash has to process 32-bytes from the packet instead of 14-bytes in tests 1 and 2. jhash function is ~230 insns and main program is ~1200 insns. $ test_progs -s can be used to see verifier stats. Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
71 lines
1.6 KiB
C
71 lines
1.6 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
// Copyright (c) 2019 Facebook
|
|
|
|
typedef unsigned int u32;
|
|
|
|
static __attribute__((always_inline)) u32 rol32(u32 word, unsigned int shift)
|
|
{
|
|
return (word << shift) | (word >> ((-shift) & 31));
|
|
}
|
|
|
|
#define __jhash_mix(a, b, c) \
|
|
{ \
|
|
a -= c; a ^= rol32(c, 4); c += b; \
|
|
b -= a; b ^= rol32(a, 6); a += c; \
|
|
c -= b; c ^= rol32(b, 8); b += a; \
|
|
a -= c; a ^= rol32(c, 16); c += b; \
|
|
b -= a; b ^= rol32(a, 19); a += c; \
|
|
c -= b; c ^= rol32(b, 4); b += a; \
|
|
}
|
|
|
|
#define __jhash_final(a, b, c) \
|
|
{ \
|
|
c ^= b; c -= rol32(b, 14); \
|
|
a ^= c; a -= rol32(c, 11); \
|
|
b ^= a; b -= rol32(a, 25); \
|
|
c ^= b; c -= rol32(b, 16); \
|
|
a ^= c; a -= rol32(c, 4); \
|
|
b ^= a; b -= rol32(a, 14); \
|
|
c ^= b; c -= rol32(b, 24); \
|
|
}
|
|
|
|
#define JHASH_INITVAL 0xdeadbeef
|
|
|
|
static ATTR
|
|
u32 jhash(const void *key, u32 length, u32 initval)
|
|
{
|
|
u32 a, b, c;
|
|
const unsigned char *k = key;
|
|
|
|
a = b = c = JHASH_INITVAL + length + initval;
|
|
|
|
while (length > 12) {
|
|
a += *(volatile u32 *)(k);
|
|
b += *(volatile u32 *)(k + 4);
|
|
c += *(volatile u32 *)(k + 8);
|
|
__jhash_mix(a, b, c);
|
|
length -= 12;
|
|
k += 12;
|
|
}
|
|
switch (length) {
|
|
case 12: c += (u32)k[11]<<24;
|
|
case 11: c += (u32)k[10]<<16;
|
|
case 10: c += (u32)k[9]<<8;
|
|
case 9: c += k[8];
|
|
case 8: b += (u32)k[7]<<24;
|
|
case 7: b += (u32)k[6]<<16;
|
|
case 6: b += (u32)k[5]<<8;
|
|
case 5: b += k[4];
|
|
case 4: a += (u32)k[3]<<24;
|
|
case 3: a += (u32)k[2]<<16;
|
|
case 2: a += (u32)k[1]<<8;
|
|
case 1: a += k[0];
|
|
c ^= a;
|
|
__jhash_final(a, b, c);
|
|
case 0: /* Nothing left to add */
|
|
break;
|
|
}
|
|
|
|
return c;
|
|
}
|