Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kvm_watcher:优化对map数据排序的代码,更新说明文档 #796

Merged
merged 39 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
07b2488
add kvmexit watcher
Monkey857 Feb 2, 2024
c7e7088
Update kvmexit.py
Monkey857 Feb 2, 2024
df01307
Merge branch 'linuxkerneltravel:develop' into develop
Monkey857 Feb 19, 2024
dbc493c
Merge branch 'linuxkerneltravel:develop' into develop
Monkey857 Feb 26, 2024
dbb0fc6
VMexit
Monkey857 Mar 1, 2024
9190fa1
修改action
Monkey857 Mar 1, 2024
47a3077
修改action
Monkey857 Mar 1, 2024
389a192
修改makefile
Monkey857 Mar 1, 2024
8d18306
update makefile
Monkey857 Mar 1, 2024
f4f9ce2
update yml
Monkey857 Mar 1, 2024
2248966
调整代码格式
Monkey857 Mar 1, 2024
781523b
merge
Monkey857 Mar 5, 2024
1e4a880
vm exit
Monkey857 Mar 8, 2024
1548430
优化代码
Monkey857 Mar 8, 2024
8b3d9a9
.c
Monkey857 Mar 19, 2024
0654095
Merge branch 'develop' of github.com:Monkey857/lmp into develop
Monkey857 Mar 19, 2024
fa67984
Merge branch 'linuxkerneltravel:develop' into develop
Monkey857 Mar 21, 2024
6eac5e6
Merge branch 'linuxkerneltravel:develop' into develop
Monkey857 Mar 22, 2024
a1ca34d
modify sort_bug
Monkey857 Mar 22, 2024
0c02211
modify sort_bug
Monkey857 Mar 22, 2024
013e146
add fun
Monkey857 Mar 22, 2024
0353dc5
Merge branch 'linuxkerneltravel:develop' into develop
Monkey857 Mar 25, 2024
d70269d
Merge branch 'linuxkerneltravel:develop' into develop
Monkey857 Apr 1, 2024
26537d1
vcpu_load
Monkey857 Apr 2, 2024
2d96bc6
resolve conflict
Monkey857 Apr 2, 2024
bd1c242
Merge branch 'linuxkerneltravel:develop' into develop
Monkey857 Apr 7, 2024
063fc19
Merge branch 'linuxkerneltravel:develop' into develop
Monkey857 Apr 8, 2024
7a2d292
Merge branch 'linuxkerneltravel:develop' into develop
Monkey857 Apr 14, 2024
cd20a57
Merge branch 'linuxkerneltravel:develop' into develop
Monkey857 Apr 25, 2024
fa3b350
optimize code
Monkey857 Apr 25, 2024
8b213c6
Merge branch 'linuxkerneltravel:develop' into develop
Monkey857 May 10, 2024
3bb0058
modify sortFun
Monkey857 May 10, 2024
7725b23
Revert "modify sortFun"
Monkey857 May 10, 2024
ba56e3f
fix bug
Monkey857 May 10, 2024
e040b62
Merge branch 'linuxkerneltravel:develop' into develop
Monkey857 May 16, 2024
d31944b
improve code
Monkey857 May 16, 2024
d856b1e
Revert "improve code"
Monkey857 May 16, 2024
27b9f8d
Revert "Revert "improve code""
Monkey857 May 16, 2024
657cb42
Merge branch 'develop' of github.com:Monkey857/lmp into develop
Monkey857 May 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eBPF_Supermarket/kvm_watcher/docs/kvm_exit.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
## 示例输出

4391为主机上的虚拟机进程,4508、4509、4510...分别是虚拟机中的vcpu子进程,每隔两秒输出虚拟机中产生的exit事件及其处理延时等信息。

结果会以进程号(VM的唯一标识)以及线程号(VM中每个VCPU的唯一标识)的优先级依次从小到大的顺序输出。
```
ubuntu@rd350x:~/nans/lmp/eBPF_Supermarket/kvm_watcher$ sudo ./kvm_watcher -e

Expand Down
25 changes: 6 additions & 19 deletions eBPF_Supermarket/kvm_watcher/src/kvm_watcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -870,40 +870,27 @@ int sort_by_key(int fd, struct exit_key *keys, struct exit_value *values) {
struct exit_key lookup_key = {};
struct exit_key next_key = {};
struct exit_value exit_value;
int first = 1;
int i = 0, j;
int count = 0;
int i = 0, j = 0, count = 0;
while (!bpf_map_get_next_key(fd, &lookup_key, &next_key)) {
count++;
if (first) {
first = 0;
bpf_map_lookup_elem(fd, &next_key, &exit_value);
keys[0] = next_key;
values[0] = exit_value;
i++;
lookup_key = next_key;
continue;
}
j = i - 1;
Monkey857 marked this conversation as resolved.
Show resolved Hide resolved
struct exit_key temp_key = next_key;
err = bpf_map_lookup_elem(fd, &next_key, &exit_value);
if (err < 0) {
fprintf(stderr, "failed to lookup exit_value: %d\n", err);
return -1;
}
// insert sort
j = i - 1;
struct exit_key temp_key = next_key;
struct exit_value temp_value = exit_value;
while (j >= 0 &&
Monkey857 marked this conversation as resolved.
Show resolved Hide resolved
(keys[j].pid > temp_key.pid || (keys[j].tid > temp_key.tid))) {
keys[j + 1] = keys[j];
values[j + 1] = values[j];
j--;
}
i++;
keys[j + 1] = next_key;
keys[j + 1] = temp_key;
values[j + 1] = temp_value;
// Move to the next key
lookup_key = next_key;
count++;
i++;
}
return count;
}
Expand Down
Loading