|
|
0978ec |
From 8aacb573cd2c4a2f8160d99ff100ad0aa5e7859d Mon Sep 17 00:00:00 2001
|
|
|
0978ec |
From: Carl Love <cel@us.ibm.com>
|
|
|
0978ec |
Date: Thu, 25 Jul 2019 10:24:16 -0400
|
|
|
0978ec |
Subject: [PATCH] Only start the application if the perf events setup was
|
|
|
0978ec |
successful
|
|
|
0978ec |
|
|
|
0978ec |
Changes the order of starting the application and performance events.
|
|
|
0978ec |
|
|
|
0978ec |
Given this change we have a new issue. The issue is the routine
|
|
|
0978ec |
start_counting() calls fork, creating app_PID process.
|
|
|
0978ec |
|
|
|
0978ec |
The parent then tries to setup the performance events, then if the
|
|
|
0978ec |
performance events were setup correctly, app_PID is then told to start
|
|
|
0978ec |
before exiting. If the performance counter setup fails, the app_PID is
|
|
|
0978ec |
left running. The app_PID is never told to start the workload, which is
|
|
|
0978ec |
correct but we don't record the fact that app_PID is running. The
|
|
|
0978ec |
error path then fails to kill app_PID in routine main(), in file
|
|
|
0978ec |
oprofile-git/pe_counting, at about lie 909 because the if statement
|
|
|
0978ec |
|
|
|
0978ec |
if (startApp && app_started && (run_result != APP_ABNORMAL_END)) {
|
|
|
0978ec |
|
|
|
0978ec |
is false because app_started is False.
|
|
|
0978ec |
|
|
|
0978ec |
The fix, I believe, is to set app_started to True in the parent code if
|
|
|
0978ec |
the fork was successful. With this fix, there is no orphan processes
|
|
|
0978ec |
left after ocount exits.
|
|
|
0978ec |
---
|
|
|
0978ec |
pe_counting/ocount.cpp | 5 ++++-
|
|
|
0978ec |
1 file changed, 4 insertions(+), 1 deletion(-)
|
|
|
0978ec |
|
|
|
0978ec |
diff --git a/pe_counting/ocount.cpp b/pe_counting/ocount.cpp
|
|
|
0978ec |
index 77177176..2470745d 100644
|
|
|
0978ec |
--- a/pe_counting/ocount.cpp
|
|
|
0978ec |
+++ b/pe_counting/ocount.cpp
|
|
|
0978ec |
@@ -242,6 +242,10 @@ bool start_counting(void)
|
|
|
0978ec |
|
|
|
0978ec |
// parent
|
|
|
0978ec |
int startup;
|
|
|
0978ec |
+ if ( app_PID != -1)
|
|
|
0978ec |
+ // app_PID child process created successfully
|
|
|
0978ec |
+ app_started = true;
|
|
|
0978ec |
+
|
|
|
0978ec |
if (startApp) {
|
|
|
0978ec |
if (read(app_ready_pipe[0], &startup, sizeof(startup)) == -1) {
|
|
|
0978ec |
perror("Internal error on app_ready_pipe");
|
|
|
0978ec |
@@ -297,7 +301,6 @@ bool start_counting(void)
|
|
|
0978ec |
perror("Internal error on start_app_pipe");
|
|
|
0978ec |
return false;
|
|
|
0978ec |
}
|
|
|
0978ec |
- app_started = true;
|
|
|
0978ec |
}
|
|
|
0978ec |
|
|
|
0978ec |
return ret;
|
|
|
0978ec |
--
|
|
|
0978ec |
2.21.0
|
|
|
0978ec |
|