Skip to content

Commit 637d4c1

Browse files
committed
sampling: Recursively initialize watchdir
This is necessary to fix the per-cgroup benchmark
1 parent f94fe92 commit 637d4c1

2 files changed

Lines changed: 18 additions & 13 deletions

File tree

bench/bench_per_cgroup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ def __init__(self, benchresults_cls=BenchResults, cli_args=None):
208208

209209
# Only initialize cache_ext policies if not using default mode
210210
if not self.args.default:
211+
# TODO: set the watch dirs more precisely to avoid needing recursive
212+
# watch dir initialization.
211213
self.cache_ext_policy = CacheExtPolicy(
212214
DEFAULT_CACHE_EXT_CGROUP, self.args.policy_loader, self.args.search_path
213215
)

policies/cache_ext_sampling.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -111,25 +111,28 @@ int main(int argc, char **argv)
111111
}
112112

113113
// Initialize inode_watchlist map
114-
ret = initialize_watch_dir_map(args.watch_dir,
115-
bpf_map__fd(skel->maps.inode_watchlist), false);
114+
ret = initialize_watch_dir_map(
115+
args.watch_dir, bpf_map__fd(skel->maps.inode_watchlist), true);
116+
if (ret) {
117+
perror("Failed to initialize inode watchlist map");
118+
goto cleanup;
119+
}
116120

117-
// Attach cache_ext_ops to the specific cgroup
118-
link =
119-
bpf_map__attach_cache_ext_ops(skel->maps.sampling_ops, cgroup_fd);
120-
if (link == NULL) {
121+
// Attach cache_ext_ops to the specific cgroup
122+
link = bpf_map__attach_cache_ext_ops(skel->maps.sampling_ops, cgroup_fd);
123+
if (link == NULL) {
121124
perror("Failed to attach BPF cache_ext_ops to cgroup");
122-
goto cleanup;
123-
}
125+
goto cleanup;
126+
}
124127

125-
// Attach probes
126-
ret = cache_ext_sampling_bpf__attach(skel);
128+
// Attach probes
129+
ret = cache_ext_sampling_bpf__attach(skel);
127130
if (ret) {
128131
perror("Failed to attach BPF programs");
129-
goto cleanup;
130-
}
132+
goto cleanup;
133+
}
131134

132-
// Wait for keyboard input
135+
// Wait for keyboard input
133136
printf("Press any key to exit...\n");
134137
getchar();
135138

0 commit comments

Comments
 (0)