182 lines
6.4 KiB
Diff
182 lines
6.4 KiB
Diff
From 4beed871afcdd1d9f1a50f89bba960d91181f3b5 Mon Sep 17 00:00:00 2001
|
|
From: Longfang Liu <liulongfang@huawei.com>
|
|
Date: Tue, 23 Jul 2024 19:48:13 +0800
|
|
Subject: [PATCH 09/16] uadk_tools: add segfault locating function
|
|
|
|
When a segfault occurs within a test thread, it is generally
|
|
difficult to locate the problem. In order to improve the efficiency
|
|
of problem location, a segmentation fault capture entry is added
|
|
to each business thread entry.
|
|
And register a segfault callback handler function. As long as a
|
|
segfault occurs within the thread, the callback is triggered and
|
|
the segfault error message is output.
|
|
|
|
Signed-off-by: Longfang Liu <liulongfang@huawei.com>
|
|
Signed-off-by: Qi Tao <taoqi10@huawei.com>
|
|
---
|
|
uadk_tool/benchmark/hpre_uadk_benchmark.c | 1 +
|
|
uadk_tool/benchmark/hpre_wd_benchmark.c | 1 +
|
|
uadk_tool/benchmark/sec_soft_benchmark.c | 1 +
|
|
uadk_tool/benchmark/sec_uadk_benchmark.c | 1 +
|
|
uadk_tool/benchmark/sec_wd_benchmark.c | 1 +
|
|
uadk_tool/benchmark/trng_wd_benchmark.c | 1 +
|
|
uadk_tool/benchmark/uadk_benchmark.c | 15 +++++++++++++++
|
|
uadk_tool/benchmark/uadk_benchmark.h | 3 +++
|
|
uadk_tool/benchmark/zip_uadk_benchmark.c | 1 +
|
|
uadk_tool/benchmark/zip_wd_benchmark.c | 1 +
|
|
10 files changed, 26 insertions(+)
|
|
|
|
diff --git a/uadk_tool/benchmark/hpre_uadk_benchmark.c b/uadk_tool/benchmark/hpre_uadk_benchmark.c
|
|
index 0148e56..5dd6a39 100644
|
|
--- a/uadk_tool/benchmark/hpre_uadk_benchmark.c
|
|
+++ b/uadk_tool/benchmark/hpre_uadk_benchmark.c
|
|
@@ -2706,6 +2706,7 @@ int hpre_uadk_benchmark(struct acc_option *options)
|
|
u32 ptime;
|
|
int ret;
|
|
|
|
+ signal(SIGSEGV, segmentfault_handler);
|
|
g_thread_num = options->threads;
|
|
g_ctxnum = options->ctxnums;
|
|
|
|
diff --git a/uadk_tool/benchmark/hpre_wd_benchmark.c b/uadk_tool/benchmark/hpre_wd_benchmark.c
|
|
index 5545ad8..0196e62 100644
|
|
--- a/uadk_tool/benchmark/hpre_wd_benchmark.c
|
|
+++ b/uadk_tool/benchmark/hpre_wd_benchmark.c
|
|
@@ -2564,6 +2564,7 @@ int hpre_wd_benchmark(struct acc_option *options)
|
|
u32 ptime;
|
|
int ret;
|
|
|
|
+ signal(SIGSEGV, segmentfault_handler);
|
|
g_thread_num = options->threads;
|
|
|
|
if (options->optype >= (WCRYPTO_EC_OP_MAX - WCRYPTO_ECDSA_VERIFY)) {
|
|
diff --git a/uadk_tool/benchmark/sec_soft_benchmark.c b/uadk_tool/benchmark/sec_soft_benchmark.c
|
|
index 84dab63..8fa523c 100644
|
|
--- a/uadk_tool/benchmark/sec_soft_benchmark.c
|
|
+++ b/uadk_tool/benchmark/sec_soft_benchmark.c
|
|
@@ -1277,6 +1277,7 @@ int sec_soft_benchmark(struct acc_option *options)
|
|
u32 ptime;
|
|
int ret;
|
|
|
|
+ signal(SIGSEGV, segmentfault_handler);
|
|
g_thread_num = options->threads;
|
|
g_pktlen = options->pktlen;
|
|
g_jobsnum = options->ctxnums;
|
|
diff --git a/uadk_tool/benchmark/sec_uadk_benchmark.c b/uadk_tool/benchmark/sec_uadk_benchmark.c
|
|
index 56f4fa6..41b7416 100644
|
|
--- a/uadk_tool/benchmark/sec_uadk_benchmark.c
|
|
+++ b/uadk_tool/benchmark/sec_uadk_benchmark.c
|
|
@@ -1777,6 +1777,7 @@ int sec_uadk_benchmark(struct acc_option *options)
|
|
u32 ptime;
|
|
int ret;
|
|
|
|
+ signal(SIGSEGV, segmentfault_handler);
|
|
g_thread_num = options->threads;
|
|
g_pktlen = options->pktlen;
|
|
g_ctxnum = options->ctxnums;
|
|
diff --git a/uadk_tool/benchmark/sec_wd_benchmark.c b/uadk_tool/benchmark/sec_wd_benchmark.c
|
|
index bb47d61..e022dcb 100644
|
|
--- a/uadk_tool/benchmark/sec_wd_benchmark.c
|
|
+++ b/uadk_tool/benchmark/sec_wd_benchmark.c
|
|
@@ -1630,6 +1630,7 @@ int sec_wd_benchmark(struct acc_option *options)
|
|
u32 ptime;
|
|
int ret;
|
|
|
|
+ signal(SIGSEGV, segmentfault_handler);
|
|
g_alg = options->subtype;
|
|
g_algtype = options->algtype;
|
|
g_optype = options->optype;
|
|
diff --git a/uadk_tool/benchmark/trng_wd_benchmark.c b/uadk_tool/benchmark/trng_wd_benchmark.c
|
|
index 3ce329a..2f058d4 100644
|
|
--- a/uadk_tool/benchmark/trng_wd_benchmark.c
|
|
+++ b/uadk_tool/benchmark/trng_wd_benchmark.c
|
|
@@ -312,6 +312,7 @@ int trng_wd_benchmark(struct acc_option *options)
|
|
u32 ptime;
|
|
int ret;
|
|
|
|
+ signal(SIGSEGV, segmentfault_handler);
|
|
g_thread_num = options->threads;
|
|
|
|
ret = init_trng_wd_queue(options);
|
|
diff --git a/uadk_tool/benchmark/uadk_benchmark.c b/uadk_tool/benchmark/uadk_benchmark.c
|
|
index 1bf9fee..0f01fdf 100644
|
|
--- a/uadk_tool/benchmark/uadk_benchmark.c
|
|
+++ b/uadk_tool/benchmark/uadk_benchmark.c
|
|
@@ -331,6 +331,21 @@ void cal_avg_latency(u32 count)
|
|
ACC_TST_PRT("thread<%lu> avg latency: %.1fus\n", gettid(), latency);
|
|
}
|
|
|
|
+void segmentfault_handler(int sig)
|
|
+{
|
|
+#define BUF_SZ 64
|
|
+ void *array[BUF_SZ];
|
|
+ size_t size;
|
|
+
|
|
+ /* Get void*'s for all entries on the stack */
|
|
+ size = backtrace(array, BUF_SZ);
|
|
+
|
|
+ /* Print out all the frames to stderr */
|
|
+ fprintf(stderr, "Error: signal %d:\n", sig);
|
|
+ backtrace_symbols_fd(array, size, STDERR_FILENO);
|
|
+ exit(1);
|
|
+}
|
|
+
|
|
/*-------------------------------------main code------------------------------------------------------*/
|
|
static void parse_alg_param(struct acc_option *option)
|
|
{
|
|
diff --git a/uadk_tool/benchmark/uadk_benchmark.h b/uadk_tool/benchmark/uadk_benchmark.h
|
|
index c493ac3..0def4b9 100644
|
|
--- a/uadk_tool/benchmark/uadk_benchmark.h
|
|
+++ b/uadk_tool/benchmark/uadk_benchmark.h
|
|
@@ -4,6 +4,7 @@
|
|
|
|
#include <ctype.h>
|
|
#include <errno.h>
|
|
+#include <execinfo.h>
|
|
#include <fcntl.h>
|
|
#include <getopt.h>
|
|
#include <linux/random.h>
|
|
@@ -15,6 +16,7 @@
|
|
#include <signal.h>
|
|
#include <sys/syscall.h>
|
|
#include <sys/time.h>
|
|
+#include <signal.h>
|
|
#include <unistd.h>
|
|
|
|
#define ACC_TST_PRT printf
|
|
@@ -217,6 +219,7 @@ extern void add_send_complete(void);
|
|
extern u32 get_recv_time(void);
|
|
extern void cal_avg_latency(u32 count);
|
|
extern int get_alg_name(int alg, char *alg_name);
|
|
+extern void segmentfault_handler(int sig);
|
|
|
|
int acc_cmd_parse(int argc, char *argv[], struct acc_option *option);
|
|
int acc_default_case(struct acc_option *option);
|
|
diff --git a/uadk_tool/benchmark/zip_uadk_benchmark.c b/uadk_tool/benchmark/zip_uadk_benchmark.c
|
|
index ecb688f..22aa916 100644
|
|
--- a/uadk_tool/benchmark/zip_uadk_benchmark.c
|
|
+++ b/uadk_tool/benchmark/zip_uadk_benchmark.c
|
|
@@ -1331,6 +1331,7 @@ int zip_uadk_benchmark(struct acc_option *options)
|
|
u32 ptime;
|
|
int ret;
|
|
|
|
+ signal(SIGSEGV, segmentfault_handler);
|
|
g_thread_num = options->threads;
|
|
g_pktlen = options->pktlen;
|
|
g_ctxnum = options->ctxnums;
|
|
diff --git a/uadk_tool/benchmark/zip_wd_benchmark.c b/uadk_tool/benchmark/zip_wd_benchmark.c
|
|
index cbe07fc..8ad3e96 100644
|
|
--- a/uadk_tool/benchmark/zip_wd_benchmark.c
|
|
+++ b/uadk_tool/benchmark/zip_wd_benchmark.c
|
|
@@ -1162,6 +1162,7 @@ int zip_wd_benchmark(struct acc_option *options)
|
|
u32 ptime;
|
|
int ret;
|
|
|
|
+ signal(SIGSEGV, segmentfault_handler);
|
|
g_thread_num = options->threads;
|
|
g_pktlen = options->pktlen;
|
|
|
|
--
|
|
2.25.1
|
|
|