diff mbox series

[4/4] Check if parent is alive once per loadfile processed

Message ID 20220209221849.434616-5-mcgrof@kernel.org (mailing list archive)
State New, archived
Headers show
Series dbench: few enhancements from mmtests | expand

Commit Message

Luis Chamberlain Feb. 9, 2022, 10:18 p.m. UTC
From: Mel Gorman <mgorman@techsingularity.net>

strace reports that a high percentage of time is spent calling kill()
with 12,000,000 calls in 3 minutes. Check if the parent is alive once per
load file processed. With later versions of apparmor, kill() is permission
checked which is very expensive in itself and unnecessary.  Instead use
the ligher getppid() call and check against the cached value.

Signed-off-by: Mel Gorman <mgorman@techsingularity.net>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 child.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/child.c b/child.c
index 828295d..7abb238 100644
--- a/child.c
+++ b/child.c
@@ -371,6 +371,10 @@  again:
 		nb_time_reset(child);
 	}
 
+	if (getppid() != parent) {
+		exit(1);
+	}
+
 	gettimeofday(&start, NULL);
 
 	while (gzgets(gzf, line, sizeof(line)-1)) {
@@ -384,10 +388,6 @@  again:
 
 		params = sparams;
 
-		if (kill(parent, 0) == -1) {
-			exit(1);
-		}
-
 loop_again:
 		/* if this is a "LOOP <xxx>" line, 
 		 * remember the current file position and move to the next line