-
Notifications
You must be signed in to change notification settings - Fork 3
Refactor maps_pass #6
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0d69186
Add is_map in maps_pass
r41k0u 1a1f2cf
create BPFMapType enum
r41k0u 9ae1b6c
Fix usage of map_params to use BPFMapType
r41k0u cbc6b93
restructure maps dir, fix imports
r41k0u 2e005f6
Create MapProcessorRegistry to add more maps
r41k0u ca51b7c
Fix invalid member func for MapProcessorRegistry
r41k0u 9fa362e
Remove global map_sym_tab
r41k0u 744aa3f
Use logger instead of prints in map_pass
r41k0u d943b78
Add __init__ to maps to improve imports
r41k0u 0f3cc43
Fix return for unknown map types
r41k0u 87908e8
Remove backslash for multiline conditions in maps
r41k0u File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
#include <linux/bpf.h> | ||
#include <bpf/bpf_helpers.h> | ||
#include <bpf/bpf_tracing.h> | ||
#include <linux/blkdev.h> | ||
#define __TARGET_ARCH_aarch64 | ||
#define u64 unsigned long long | ||
|
||
struct { | ||
__uint(type, BPF_MAP_TYPE_HASH); | ||
__uint(max_entries, 10240); | ||
__type(key, struct request *); | ||
__type(value, u64); | ||
} start SEC(".maps"); | ||
|
||
SEC("kprobe/blk_start_request") | ||
int BPF_KPROBE(trace_start_req, struct request *req) | ||
{ | ||
u64 ts = bpf_ktime_get_ns(); | ||
bpf_map_update_elem(&start, &req, &ts, BPF_ANY); | ||
return 0; | ||
} | ||
|
||
SEC("kprobe/blk_mq_start_request") | ||
int BPF_KPROBE(trace_start_mq, struct request *req) | ||
{ | ||
u64 ts = bpf_ktime_get_ns(); | ||
bpf_map_update_elem(&start, &req, &ts, BPF_ANY); | ||
return 0; | ||
} | ||
|
||
SEC("kprobe/blk_account_io_completion") | ||
int BPF_KPROBE(trace_completion, struct request *req) | ||
{ | ||
u64 *tsp, delta; | ||
|
||
tsp = bpf_map_lookup_elem(&start, &req); | ||
if (tsp) { | ||
delta = bpf_ktime_get_ns() - *tsp; | ||
bpf_printk("%d %x %d\n", req->__data_len, | ||
req->cmd_flags, delta / 1000); | ||
bpf_map_delete_elem(&start, &req); | ||
} | ||
return 0; | ||
} | ||
|
||
char LICENSE[] SEC("license") = "GPL"; |
This file contains hidden or 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 hidden or 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,2 @@ | ||
from .maps import HashMap, PerfEventArray | ||
from .maps_pass import maps_proc |
File renamed without changes.
This file contains hidden or 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 hidden or 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 @@ | ||
class MapProcessorRegistry: | ||
"""Registry for map processor functions""" | ||
_processors = {} | ||
|
||
@classmethod | ||
def register(cls, map_type_name): | ||
"""Decorator to register a processor function for a map type""" | ||
def decorator(func): | ||
cls._processors[map_type_name] = func | ||
return func | ||
return decorator | ||
|
||
@classmethod | ||
def get_processor(cls, map_type_name): | ||
"""Get the processor function for a map type""" | ||
return cls._processors.get(map_type_name) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.