-
Notifications
You must be signed in to change notification settings - Fork 9
feat: add CARDWIRE_FORCE_DGPU to cardwire #116
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
Changes from 1 commit
738ce56
2f25f58
d20d098
34bdad1
d8fefb2
e2ca057
8c2f6f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -149,8 +149,16 @@ int cardwire_sys_enter_getdents64(struct trace_event_raw_sys_enter *ctx) | |
| // if we in smart mode and the pid is allowed, skip | ||
| if (is_smart()) { | ||
| if (is_pid_allowed(pid, ppid)) { | ||
| // if allowed, skip | ||
| return 0; | ||
| __u8 *allow_val = | ||
| bpf_map_lookup_elem(&cw_allowed_pid, &pid); | ||
| if (!allow_val) { | ||
| allow_val = bpf_map_lookup_elem(&cw_allowed_pid, | ||
| &ppid); | ||
| } | ||
| // If force_dgpu is NOT enabled, we can safely skip patching | ||
| if (allow_val && *allow_val != 0) { | ||
| return 0; | ||
| } | ||
|
Comment on lines
+152
to
+161
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win Casting the same lookup spell twice, in two scrolls. Both getdents64 hooks repeat: ♻️ Suggested shared helperstatic __always_inline int should_skip_getdents_patch(__u32 pid, __u32 ppid)
{
if (!is_pid_allowed(pid, ppid))
return 0;
__u8 *allow_val = bpf_map_lookup_elem(&cw_allowed_pid, &pid);
if (!allow_val)
allow_val = bpf_map_lookup_elem(&cw_allowed_pid, &ppid);
// If force_dgpu is NOT enabled, we can safely skip patching
return allow_val && *allow_val != 0;
}Then both call sites collapse to: if (is_smart() && should_skip_getdents_patch(pid, ppid)) {
return 0;
}Also applies to: 196-205 🤖 Prompt for AI Agents |
||
| } | ||
| } | ||
|
|
||
|
|
@@ -185,8 +193,16 @@ int cardwire_sys_exit_getdents64(struct trace_event_raw_sys_exit *ctx) | |
| // if we in smart mode and the pid is allowed, skip | ||
| if (is_smart()) { | ||
| if (is_pid_allowed(pid, ppid)) { | ||
| // if allowed, skip | ||
| return 0; | ||
| __u8 *allow_val = | ||
| bpf_map_lookup_elem(&cw_allowed_pid, &pid); | ||
| if (!allow_val) { | ||
| allow_val = bpf_map_lookup_elem(&cw_allowed_pid, | ||
| &ppid); | ||
| } | ||
| // If force_dgpu is NOT enabled, we can safely skip patching | ||
| if (allow_val && *allow_val != 0) { | ||
| return 0; | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.