Skip to content

Commit

Permalink
try 5.4.284
Browse files Browse the repository at this point in the history
  • Loading branch information
gnurizen committed Feb 3, 2025
1 parent d3ce006 commit fc66810
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 33 deletions.
77 changes: 44 additions & 33 deletions support/ebpf/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,58 @@
#define ROUNDUP_8(x) ((x + 7) & ~7)
static inline __attribute__((__always_inline__))
bool hash_custom_labels(CustomLabelsArray *lbls, int seed, u64 *out) {
// apply murmurhash2 as though this is an array of
// the number of labels (8 bytes), followed by all the key/val lengths,
// followed by all the keys/vals.
const u64 m = 0xc6a4a7935bd1e995LLU;
const int r = 47;
// apply murmurhash2 as though this is an array of
// the number of labels (8 bytes), followed by all the key/val lengths,
// followed by all the keys/vals.
const u64 m = 0xc6a4a7935bd1e995LLU;
const int r = 47;
unsigned num_lbls = lbls->len;

int len = 8;
for (int i = 0; i < MAX_CUSTOM_LABELS; ++i) {
if (i >= lbls->len)
break;
len += 8;
len += ROUNDUP_8(lbls->labels[i].key_len);
len += ROUNDUP_8(lbls->labels[i].val_len);
}
if (num_lbls > MAX_CUSTOM_LABELS) {
num_lbls = MAX_CUSTOM_LABELS;
}

u64 h = seed ^ (len * m);
int len = 8;
for (u32 i = 0; i < MIN(num_lbls, MAX_CUSTOM_LABELS); ++i) {
// Extra check to appease 5.4 kernels.
if (i >= MAX_CUSTOM_LABELS)
break;
len += 8;
len += ROUNDUP_8(lbls->labels[i].key_len);
len += ROUNDUP_8(lbls->labels[i].val_len);
}

// hash the number of labels
{
u64 k = lbls->len;
k *= m;
k ^= k >> r;
k *= m;
u64 h = seed ^ (len * m);

h ^= k;
h *= m;
}
// hash the number of labels
{
u64 k = lbls->len;
k *= m;
k ^= k >> r;
k *= m;

h ^= k;
h *= m;
}

// hash each k/v len
for (int i = 0, n = MIN(MAX_CUSTOM_LABELS,lbls->len); i < n; i++) {
for (u32 i = 0, n = MIN(MAX_CUSTOM_LABELS,num_lbls); i < n; i++) {
// Extra check to appease 5.4 kernels.
if (i >= MAX_CUSTOM_LABELS)
break;
u64 k = (((u64)lbls->labels[i].key_len) << 32) | ((u64)lbls->labels[i].val_len);
k *= m;
k ^= k >> r;
k *= m;

h ^= k;
h *= m;
}
h ^= k;
h *= m;
}

// hash each k/v
for (int i = 0, n = MIN(MAX_CUSTOM_LABELS,lbls->len); i < n; i++) {
for (u32 i = 0, n = MIN(MAX_CUSTOM_LABELS,num_lbls); i < n; i++) {
if (i >= MAX_CUSTOM_LABELS)
break;
CustomLabel *lbl = &lbls->labels[i];
u64 kl = ROUNDUP_8(lbl->key_len);
#pragma unroll
Expand All @@ -71,17 +82,17 @@ bool hash_custom_labels(CustomLabelsArray *lbls, int seed, u64 *out) {
k ^= k >> r;
k *= m;

h ^= k;
h *= m;
}
h ^= k;
h *= m;
}

h ^= h >> r;
h *= m;
h ^= h >> r;
}

*out = h;
return true;
*out = h;
return true;
}

#endif
Binary file modified support/ebpf/tracer.ebpf.debug.amd64
Binary file not shown.
Binary file modified support/ebpf/tracer.ebpf.debug.arm64
Binary file not shown.
Binary file modified support/ebpf/tracer.ebpf.release.amd64
Binary file not shown.
Binary file modified support/ebpf/tracer.ebpf.release.arm64
Binary file not shown.

0 comments on commit fc66810

Please sign in to comment.