Integrate kmemleak scans in igt_runner
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v8 Latest3 patches 11 repliesIn review
- v73 patches 11 repliesSuperseded
- v62 patches 0 repliesSuperseded
Earlier versions · 6
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v5 | 2 patches | 2 replies | Superseded | |
| v4 | 2 patches | 22 replies | Superseded | |
| v3 | 1 of 2 patches | 3 replies | Superseded | |
| v2 posting 2/2 | 2 patches | 0 replies | Superseded | |
| v2 posting 1/2 | 2 patches | 1 reply | Superseded | |
| v1 | 2 patches | 10 replies | Superseded |
Changes in v8 from the cover letter
- Update commit messages
- Fix new line and documentation issues
- Use fd instead of fp
- Use open() and close() instead of fopen() and fclose()
- Update error checking from (!fd) to (fd < 0)
- Add error check for lseek()
- Rename to KMEMLEAK_RESFILENAME
- Increase buf size to 16KB to speedup copy
- Rename the ifndef guard to RUNNER_KMEMLEAK_H
Patches in v8 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | runner/kmemleak: library to interact with kmemleakrunner/ runner/ runner/ +1 more | +569 | 1 reply | |
| 2/3 | runner/executor: Integrate igt_kmemleak scansrunner/ runner/ runner/ +1 more | +68 | 0 replies | |
| 3/3 | scripts/run-tests.sh: Add support to kmemleak and igt_factsscripts/ | +8 | 6 replies |
Reviews trailers per patch
All 3 patches have a Reviewed-by or Acked-by.
| Patch | Zbigniew Kempczyński | Jonathan Cavitt | Vitaly Prosyak | Kamil Konieczny |
|---|---|---|---|---|
| 1/3 | R-b | R-b | R-b | R-b |
| 2/3 | R-b | R-b | R-b | |
| 3/3 | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.
Cover letter [PATCH v8 i-g-t 0/3] Integrate kmemleak scans in igt_runner
This patch series introduces a library to interact with the Linux kernel's kmemleak feature and integrates it into igt_runner. If kmemleaks are detected, they will be saved in the igt_runner results directory in a file named kmemleak.txt.
During testing, the size of the kmemleak.txt file varied significantly. Larger files, up to 2 MB, were observed when running i915-BAT on a Tiger Lake DUT. Conversely, smaller files, typically under 100 KB, were generated when running Xe BAT on the same DUT.
Large files often contain numerous false positives, with the e1000 driver being a frequent source of noise. The time required for the Linux kernel to complete a kmemleak scan ranges from 5 to 60 seconds. This variability can cause igt_runner to slow down by a factor of 4 when using the -keach option.
Transient leaks are a common phenomenon but are mostly undetected by the current version of this library. A typical transient leak occurs when pointers are reused, such as in linked lists. For example, if 10 calls to kmalloc are made, storing the address in the same variable and freeing only the final allocation, the previous 9 allocations become transient leaks. These leaks will go undetected unless the kernel thread performs continuous scanning.
To enable continuous scanning:
# echo scan=1 > /sys/kernel/debug/kmemleak
This configures the kmemleak kernel thread to scan the memory continuously with 1 second pauses. While this may increase the likelihood of detecting transient leaks, it can significantly impact system performance. In most cases, the igt_runner slowdown remains in the 4x range, but the kernel thread will consume 100% of a CPU core, as observed with tools like top.
When using scan=1, transient leaks that exist during an active scan will be detected. However, detection remains non-deterministic due to timing. It is recommended to reset the scan interval to the default value of 600 seconds after completing your tests.
v8:
- Update commit messages
- Fix new line and documentation issues
- Use fd instead of fp
- Use open() and close() instead of fopen() and fclose()
- Update error checking from (!fd) to (fd < 0)
- Add error check for lseek()
- Rename to KMEMLEAK_RESFILENAME
- Increase buf size to 16KB to speedup copy
- Rename the ifndef guard to RUNNER_KMEMLEAK_H
v7:
- Update scripts/run-tests.sh to support:
- igt_facts
- kmemleak integration
v6:
- Update copyright year to 2025
- Remove double newline from runner/executor.c
- Fix indentation issues caused by renaming igt_kmemleak* to runner_kmemleak*
v5:
- move the code from lib/ to runner/
- rename igt_* to runner_*
- replace calls to igt_info() with calls to fprintf(stderr, ...)
- #includes on kmemleak.c:
- remove #include "igt_core.h"
- sort includes aplhabetically
- refacor the if statement for handling the optional argument to -k
- changed where 'k::' is located inside the string for getopt_long()
- fix one ident error
- use two separate assignments instead of making two at the same time
- replaced two calls to errf() by a single call with a multiline string
- commit message: explain the changes to runner unit testing
v4:
- Cleaned-up CC list
- Fixed typo in patch numbering
- Fixed Reviewed-by tag
- Reintroduced ',' after "results-path". It was removed by accident
- Changed unit testing for calling igt_kmemleak() with and without sync.
v3:
- Removed '>' from the end of one of the email addresses in the cc list
- Removed email addresses that no longer exist
v2:
- Pass igt_kmemleak_sync as a function variable to igt_kmemleak instead of keeping it stored as a global variable
- igt_kmemleak_found_leaks(): Remove call to fseek() after close()
- igt_kmemleak_write(): Increase retry counter when writing 0 bytes
- igt_kmemleak_write(): change type to bool
- Unit Testing: Move the call to igt_kmemleak_init() to a fixture.
- igt_kmemleak_append_to(): Add brackets to the if statement for improved readability
Peter Senna Tschudin (3):
runner/kmemleak: library to interact with kmemleak runner/executor: Integrate igt_kmemleak scans scripts/run-tests.sh: Add support to kmemleak reports and igt_facts
runner/executor.c | 26 +++- runner/kmemleak.c | 277 ++++++++++++++++++++++++++++++++++ runner/kmemleak.h | 16 ++ runner/meson.build | 9 ++ runner/runner_kmemleak_test.c | 267 ++++++++++++++++++++++++++++++++ runner/runner_tests.c | 13 +- runner/settings.c | 31 +++- runner/settings.h | 2 + scripts/run-tests.sh | 10 +- 9 files changed, 645 insertions(+), 6 deletions(-) create mode 100644 runner/kmemleak.c create mode 100644 runner/kmemleak.h create mode 100644 runner/runner_kmemleak_test.c
Signature · 1 line
2.34.1