[DTrace-devel] [PATCH 4/7] libproc: detect dead process faster when updating maps
Nick Alcock
nick.alcock at oracle.com
Wed Mar 20 14:15:34 UTC 2024
Scanning maps and lmids is really quite slow: it involves parsing text files
out of /proc and digging around in the dynamic linker and even doing
searches of victim process memory to detect changes in internal dynamic
linker data structures. So, in Pupdate_syms(), after we do that, check if
the process has died before we run off and update all the per-file mappings,
which will all fail noisily if the process has died.
(Just a cosmetic improvement, but it can reduce the amount of debugging
output by hundreds of megabytes sometimes.)
Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
---
libproc/Psymtab.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/libproc/Psymtab.c b/libproc/Psymtab.c
index 9191a7ab82c20..4054351115452 100644
--- a/libproc/Psymtab.c
+++ b/libproc/Psymtab.c
@@ -833,7 +833,15 @@ Pupdate_syms(struct ps_prochandle *P)
Pupdate_maps(P);
Pupdate_lmids(P);
- for (i = 0, fptr = dt_list_next(&P->file_list);
+ /*
+ * The process might have died while updating maps or lmids, both of
+ * which can be quite time-consuming.
+ */
+
+ if (P->state == PS_DEAD)
+ return;
+
+ for (i = 0, fptr = dt_list_next(&P->file_list);
i < P->num_files; i++, fptr = dt_list_next(fptr))
Pbuild_file_symtab(P, fptr);
}
--
2.44.0.273.ge0bd14271f
More information about the DTrace-devel
mailing list