Blob Blame Raw
commit 34e62f15da5adf06361ac66489936d0ffa1cc430
Author: Frank Ch. Eigler <fche@redhat.com>
Date:   Tue Nov 10 22:13:53 2020 -0500

    RHBZ1892179: handle exhausted stp_task_work structs
    
    In utrace_report_syscall_entry and _exit, there is a possibility of
    dereferencing a NULL pointer, in case __stp_utrace_alloc_task_work
    exhausts UTRACE_TASK_WORK_POOL_SIZE live elements.  While OOM is
    still a possibility, this patch handles it more gracefully.

diff --git a/runtime/stp_utrace.c b/runtime/stp_utrace.c
index 47355de..e2880f1 100644
--- a/runtime/stp_utrace.c
+++ b/runtime/stp_utrace.c
@@ -2337,11 +2337,11 @@ static void utrace_report_syscall_entry(void *cb_data __attribute__ ((unused)),
 
 	/* Defer the report_syscall_entry work so it doesn't happen in atomic context: */
 	work = __stp_utrace_alloc_task_work(utrace, NULL);
-	__stp_utrace_save_regs(work, regs);
 	if (work == NULL) {
 		_stp_error("Unable to allocate space for task_work");
 		return;
 	}
+	__stp_utrace_save_regs(work, regs);
 	stp_init_task_work(work, &utrace_syscall_entry_work);
 	rc = stp_task_work_add(task, work);
 	// stp_task_work_add() returns -ESRCH if the task has already
@@ -2444,11 +2444,11 @@ static void utrace_report_syscall_exit(void *cb_data __attribute__ ((unused)),
 
 	/* Defer the report_syscall_exit work so it doesn't happen in atomic context: */
 	work = __stp_utrace_alloc_task_work(utrace, NULL);
-	__stp_utrace_save_regs(work, regs);
 	if (work == NULL) {
 		_stp_error("Unable to allocate space for task_work");
 		return;
 	}
+	__stp_utrace_save_regs(work, regs);
 	stp_init_task_work(work, &utrace_syscall_exit_work);
 	rc = stp_task_work_add(task, work);
 	// stp_task_work_add() returns -ESRCH if the task has already

commit 83cb271b390a1b36abd4c3aa69f89c466e99e253
Author: Frank Ch. Eigler <fche@redhat.com>
Date:   Fri Nov 13 12:36:07 2020 -0500

    RHBZ1892179: double default UTRACE_TASK_WORKPOOL
    
    Some workloads were observed to exhaust the previous limit of 288.

diff --git a/runtime/stp_utrace.c b/runtime/stp_utrace.c
index 46ba489..6022267 100644
--- a/runtime/stp_utrace.c
+++ b/runtime/stp_utrace.c
@@ -141,7 +141,7 @@ struct __stp_utrace_task_work { /* NB: about 216 bytes, 18 per page: */
    TODO: UTRACE_TASK_WORK_POOL_SIZE can be specified on the Systemtap
    command line. Experiment to find the best default value. */
 #ifndef UTRACE_TASK_WORK_POOL_SIZE
-#define UTRACE_TASK_WORK_POOL_SIZE 288
+#define UTRACE_TASK_WORK_POOL_SIZE 576
 #endif
 static DECLARE_BITMAP(__stp_utrace_task_work_pool_bitmap, UTRACE_TASK_WORK_POOL_SIZE);
 static struct __stp_utrace_task_work __stp_utrace_task_work_pool[UTRACE_TASK_WORK_POOL_SIZE];