-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When BPFPRofiling is set to Enabled, bpf programs execution will collect duration of ebpf processing per device, per direction and per new/established connection metrics. 'calico-bpf prifiling e2e' can dump the stats. It zeroes the stats after dump. ----------------+-------------+-----+-------------+-------+-------------+-------+-------------+-------+ | IFACE | INGRESS NEW | # | INGRESS EST | # | EGRESS NEW | # | EGRESS ETS | # | +----------------+-------------+-----+-------------+-------+-------------+-------+-------------+-------+ | lo | --- | --- | --- | --- | 142.263 ns | 10272 | --- | --- | | eth0 | 2492.344 ns | 32 | 1535.443 ns | 16114 | 6296.421 ns | 749 | 1503.339 ns | 10982 | | eni76136be4c77 | 5031.436 ns | 149 | 1194.923 ns | 1421 | 4950.196 ns | 138 | 1437.015 ns | 1432 | | eni80d5c04bc95 | 7773.459 ns | 74 | 1508.973 ns | 641 | 4907.333 ns | 69 | 1715.848 ns | 646 | | eth1 | 136.250 ns | 24 | --- | --- | 75.320 ns | 25 | --- | --- | | eni5f8ab1cfc29 | 107.250 ns | 36 | 1068.596 ns | 1514 | 189.528 ns | 36 | 1104.335 ns | 1658 | | bpfout.cali | 440.000 ns | 1 | --- | --- | 206.000 ns | 1 | --- | --- | +----------------+-------------+-----+-------------+-------+-------------+-------+-------------+-------+
- Loading branch information
1 parent
8a901cc
commit ebaea11
Showing
36 changed files
with
1,529 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Project Calico BPF dataplane programs. | ||
// Copyright (c) 2024 Tigera, Inc. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later | ||
|
||
#ifndef __CALI_BPF_PROFILING_H__ | ||
#define __CALI_BPF_PROFILING_H__ | ||
|
||
struct prof_key { | ||
__u32 ifindex; | ||
__u32 kind; | ||
}; | ||
|
||
struct prof_val { | ||
__u64 time; | ||
__u64 samples; | ||
}; | ||
|
||
CALI_MAP(cali_profiling, 2, | ||
BPF_MAP_TYPE_PERCPU_HASH, | ||
struct prof_key, struct prof_val, | ||
20000, 0) | ||
|
||
static CALI_BPF_INLINE void prof_record_sample(__u32 ifindex, __u32 kind, __u64 start, __u64 end) | ||
{ | ||
struct prof_key key = { | ||
.ifindex = ifindex, | ||
.kind = kind, | ||
}; | ||
|
||
__u64 diff = end - start; | ||
|
||
struct prof_val *val = cali_profiling_lookup_elem(&key); | ||
|
||
if (val) { | ||
val->time += diff; | ||
val->samples++; | ||
} else { | ||
struct prof_val val = { | ||
.time = diff, | ||
.samples = 1, | ||
}; | ||
|
||
cali_profiling_update_elem(&key, &val, 0); | ||
} | ||
} | ||
|
||
#endif /* __CALI_BPF_PROFILING_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright (c) 2024 Tigera, Inc. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package profiling | ||
|
||
import ( | ||
"encoding/binary" | ||
|
||
"github.com/projectcalico/calico/felix/bpf/maps" | ||
) | ||
|
||
const ( | ||
KeySize = 8 // 2 x uint32 | ||
ValueSize = 16 // 2 x uint64 | ||
) | ||
|
||
var MapParameters = maps.MapParameters{ | ||
Type: "percpu_hash", | ||
KeySize: KeySize, | ||
ValueSize: ValueSize, | ||
MaxEntries: 20000, | ||
Name: "cali_profiling", | ||
Version: 2, | ||
} | ||
|
||
func Map() maps.Map { | ||
return maps.NewPinnedMap(MapParameters) | ||
} | ||
|
||
type Key struct { | ||
Ifindex int | ||
Kind int | ||
} | ||
|
||
func KeyFromBytes(b []byte) Key { | ||
return Key{ | ||
Ifindex: int(binary.LittleEndian.Uint32(b[0:4])), | ||
Kind: int(binary.LittleEndian.Uint32(b[4:8])), | ||
} | ||
} | ||
|
||
type Value struct { | ||
Time int | ||
Samples int | ||
} | ||
|
||
func ValueFromBytes(b []byte) Value { | ||
return Value{ | ||
Time: int(binary.LittleEndian.Uint64(b[0:8])), | ||
Samples: int(binary.LittleEndian.Uint64(b[8:16])), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.