-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Example: NUMA node information: $ numactl --hardware available: 2 nodes (0-1) node 0 cpus: 0 1 2 3 4 5 6 7 ... [...] node 1 cpus: 20 21 22 23 24 25 ... [...] node distances: node 0 1 0: 10 21 1: 21 10 bpftrace script code net_action.bt: kprobe:net_tx_action, kprobe:net_rx_action { @[numaid, comm] = count(); } Example1: ------------------------------------------------------------ iperf3 server: $ taskset -c 1 iperf3 -s [...] [ 5] 0.00-1.00 sec 6.04 GBytes 51.9 Gbits/sec [...] iperf3 client: $ taskset -c 2 iperf3 -c 0 [...] [ 5] 0.00-1.00 sec 6.04 GBytes 51.9 Gbits/sec 0 1.19 MBytes [...] net_action.bt output: @[0, iperf3]: 2430857 Because both cpu1 and cpu2 are on the numa node 0. Example2: ------------------------------------------------------------ iperf3 server: $ taskset -c 1 iperf3 -s [...] [ 5] 0.00-1.00 sec 2.79 GBytes 24.0 Gbits/sec [...] iperf3 client: $ taskset -c 21 iperf3 -c 0 [...] [ 5] 0.00-1.00 sec 2.79 GBytes 24.0 Gbits/sec 0 1023 KBytes [...] net_action.bt output: @[0, iperf3]: 456193 @[1, iperf3]: 684853 Because cpu1 on numa node0, cpu21 on numa node1, Processes that need to communicate running on different nodes cause poor performance, It is very easy to get numa with `numaid`.
- Loading branch information
Showing
13 changed files
with
91 additions
and
2 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
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
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,16 @@ | ||
#include "common.h" | ||
|
||
namespace bpftrace { | ||
namespace test { | ||
namespace codegen { | ||
|
||
TEST(codegen, builtin_numaid) | ||
{ | ||
test("kprobe:f { @x = numaid }", | ||
|
||
NAME); | ||
} | ||
|
||
} // namespace codegen | ||
} // namespace test | ||
} // namespace bpftrace |
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,37 @@ | ||
; ModuleID = 'bpftrace' | ||
source_filename = "bpftrace" | ||
target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128" | ||
target triple = "bpf-pc-linux" | ||
|
||
; Function Attrs: nounwind | ||
declare i64 @llvm.bpf.pseudo(i64 %0, i64 %1) #0 | ||
|
||
define i64 @"kprobe:f"(i8* %0) section "s_kprobe:f_1" { | ||
entry: | ||
%"@x_val" = alloca i64, align 8 | ||
%"@x_key" = alloca i64, align 8 | ||
%get_numa_id = call i32 inttoptr (i64 42 to i32 ()*)() | ||
%1 = zext i32 %get_numa_id to i64 | ||
%2 = bitcast i64* %"@x_key" to i8* | ||
call void @llvm.lifetime.start.p0i8(i64 -1, i8* %2) | ||
store i64 0, i64* %"@x_key", align 8 | ||
%3 = bitcast i64* %"@x_val" to i8* | ||
call void @llvm.lifetime.start.p0i8(i64 -1, i8* %3) | ||
store i64 %1, i64* %"@x_val", align 8 | ||
%pseudo = call i64 @llvm.bpf.pseudo(i64 1, i64 0) | ||
%update_elem = call i64 inttoptr (i64 2 to i64 (i64, i64*, i64*, i64)*)(i64 %pseudo, i64* %"@x_key", i64* %"@x_val", i64 0) | ||
%4 = bitcast i64* %"@x_val" to i8* | ||
call void @llvm.lifetime.end.p0i8(i64 -1, i8* %4) | ||
%5 = bitcast i64* %"@x_key" to i8* | ||
call void @llvm.lifetime.end.p0i8(i64 -1, i8* %5) | ||
ret i64 0 | ||
} | ||
|
||
; Function Attrs: argmemonly nofree nosync nounwind willreturn | ||
declare void @llvm.lifetime.start.p0i8(i64 immarg %0, i8* nocapture %1) #1 | ||
|
||
; Function Attrs: argmemonly nofree nosync nounwind willreturn | ||
declare void @llvm.lifetime.end.p0i8(i64 immarg %0, i8* nocapture %1) #1 | ||
|
||
attributes #0 = { nounwind } | ||
attributes #1 = { argmemonly nofree nosync nounwind willreturn } |
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