From 4b3aac3d4efaec9785a1fc8dc2605a8b59a4f9c4 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Wed, 11 Sep 2002 20:46:50 +0000 Subject: [PATCH] Change namei and syscall ktrace events to malloc work buffers before obtaining a ktr_request structure from the free pool so we can avoid starving other threads of ktr_request structures. --- sys/kern/kern_ktrace.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index 71bdd2454177..3cf3db9bb578 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -330,18 +330,22 @@ ktrsyscall(code, narg, args) struct ktr_request *req; struct ktr_syscall *ktp; size_t buflen; + char *buf = NULL; + buflen = sizeof(register_t) * narg; + if (buflen > 0) { + buf = malloc(buflen, M_KTRACE, M_WAITOK); + bcopy(args, buf, buflen); + } req = ktr_getrequest(KTR_SYSCALL); if (req == NULL) return; ktp = &req->ktr_data.ktr_syscall; ktp->ktr_code = code; ktp->ktr_narg = narg; - buflen = sizeof(register_t) * narg; if (buflen > 0) { - req->ktr_header.ktr_buffer = malloc(buflen, M_KTRACE, M_WAITOK); - bcopy(args, req->ktr_header.ktr_buffer, buflen); req->ktr_header.ktr_len = buflen; + req->ktr_header.ktr_buffer = buf; } ktr_submitrequest(req); } @@ -373,16 +377,19 @@ ktrnamei(path) { struct ktr_request *req; int namelen; + char *buf = NULL; + namelen = strlen(path); + if (namelen > 0) { + buf = malloc(namelen, M_KTRACE, M_WAITOK); + bcopy(path, buf, namelen); + } req = ktr_getrequest(KTR_NAMEI); if (req == NULL) return; - namelen = strlen(path); if (namelen > 0) { req->ktr_header.ktr_len = namelen; - req->ktr_header.ktr_buffer = malloc(namelen, M_KTRACE, - M_WAITOK); - bcopy(path, req->ktr_header.ktr_buffer, namelen); + req->ktr_header.ktr_buffer = buf; } ktr_submitrequest(req); }