forked from iovisor/bcc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
memleak: Add workaround to alleviate misjudgments when free is missing
Profiling in memory part is hard to be accurate because of BPF infrastructure. memleak keeps misjudging memory leak on the complicated environment which has the action of free in hard/soft irq. For example, in my misjudged case: 640 bytes in 10 allocations from stack -- __kmalloc+0x178 [kernel] __kmalloc+0x178 [kernel] xhci_urb_enqueue+0x140 [kernel] usb_hcd_submit_urb+0x5e0 [kernel] This result looks like kernel doesn't free urb_priv. However, it's not true. The reason for this leak is because xhci hw irq interrupts during the BPF program. BPF program is not finished on that CPU, and xhci_irq() will call xhci_urb_free_priv() before the end. But the kernel doesn't permit this isr to go into BPF program again. Because BPF infrastructure(trace_call_bpf) denied this action. So we miss this free action and cause memory leak misjudgment. Side-effect: - Increase overhead for each memory allocation. - A higher chance to be interrupted at the allocation part causes ignore more allocations. This workaround doesn't solve all misjudgments, the improvement in BPF infrastructure is the only solution.
- Loading branch information
1 parent
95c9229
commit cd81f13
Showing
3 changed files
with
48 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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 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 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