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

Add BPFStackTable::free_symcache() to free the symbol cache for an PID #3371

Merged
merged 2 commits into from
Apr 28, 2021
Merged

Add BPFStackTable::free_symcache() to free the symbol cache for an PID #3371

merged 2 commits into from
Apr 28, 2021

Conversation

yzhao1012
Copy link
Contributor

This is useful when BPFStackTable is used by a long running program to
limit the memory usage, by removing the cached symbols of an exited
process.

This is useful when BPFStackTable is used by a long running program to
limit the memory usage, by removing the cached symbols of an exited
process.
@yonghong-song
Copy link
Collaborator

[buildbot, test this please]

@yonghong-song
Copy link
Collaborator

@yzhao1012 The change makes sense for long running processes. Once a process exited, you may want to remove it from the symbol cache for reducing memory or avoid reusing the stale pid in the future.

The patch missed a declaration so it has compilation errors.

--- a/src/cc/api/BPFTable.h
+++ b/src/cc/api/BPFTable.h
@@ -381,6 +381,7 @@ class BPFStackTable : public BPFTableBase<int, stacktrace_t> {
   void clear_table_non_atomic();
   std::vector<uintptr_t> get_stack_addr(int stack_id);
   std::vector<std::string> get_stack_symbol(int stack_id, int pid);
+  void free_symcache(int pid);
 
  private:

Please fix and resubmit.

@yzhao1012
Copy link
Contributor Author

@yzhao1012 The change makes sense for long running processes. Once a process exited, you may want to remove it from the symbol cache for reducing memory or avoid reusing the stale pid in the future.

The patch missed a declaration so it has compilation errors.

--- a/src/cc/api/BPFTable.h
+++ b/src/cc/api/BPFTable.h
@@ -381,6 +381,7 @@ class BPFStackTable : public BPFTableBase<int, stacktrace_t> {
   void clear_table_non_atomic();
   std::vector<uintptr_t> get_stack_addr(int stack_id);
   std::vector<std::string> get_stack_symbol(int stack_id, int pid);
+  void free_symcache(int pid);
 
  private:

Please fix and resubmit.

Moved the declaration to BPFStackTable. I mistakenly put it into another class.

@yonghong-song
Copy link
Collaborator

[buildbot, test this please]

@yonghong-song yonghong-song merged commit 23447d2 into iovisor:master Apr 28, 2021
CrackerCat pushed a commit to CrackerCat/bcc that referenced this pull request Jul 31, 2024
iovisor#3371)

This is useful when BPFStackTable is used by a long running program to
limit the memory usage, by removing the cached symbols of an exited
process.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants