QNX stress-ng工具编译

stress-ng 下载

stress-ng 官网:https://github.com/ColinIanKing/stress-ng

复制代码
git clone https://github.com/ColinIanKing/stress-ng.git

stress-ng 编译

source env

bash 复制代码
source ~/qnx700/qnxsdp-env.sh

build command

To perform a cross-compilation for QNX 7.0, for example, an aarch64 QNX cross build:

bash 复制代码
make clean
CC=aarch64-unknown-nto-qnx7.0.0-gcc CXX=aarch64-unknown-nto-qnx7.0.0-g++ STATIC=1 make

To perform a cross-compilation for QNX 7.1, for example, an aarch64 QNX cross build:

bash 复制代码
make clean
CC=aarch64-unknown-nto-qnx7.1.0-gcc CXX=aarch64-unknown-nto-qnx7.1.0-g++ STATIC=1 make

To perform a cross-compilation for QNX 8, for example, an aarch64 QNX cross build:

bash 复制代码
make clean
CC=aarch64-unknown-nto-qnx8.0.0-gcc CXX=aarch64-unknown-nto-qnx8.0.0-g++ make

QNX 7.0 patch

c 复制代码
diff --git a/Makefile b/Makefile
index 587f89648..7d900d33d 100644
--- a/Makefile
+++ b/Makefile
@@ -60,7 +60,7 @@ endif
 # Static flags, only to be used when using GCC
 #
 ifeq ($(STATIC),1)
-LDFLAGS += -static -z muldefs
+LDFLAGS += -static -z muldefs -lsocket
 CFLAGS += -DBUILD_STATIC
 endif
 
diff --git a/core-helper.c b/core-helper.c
index ba74294ec..93836d0fc 100644
--- a/core-helper.c
+++ b/core-helper.c
@@ -1467,7 +1467,12 @@ int stress_sighandler(
 	(void)memset(&new_action, 0, sizeof new_action);
 	new_action.sa_handler = handler;
 	(void)sigemptyset(&new_action.sa_mask);
+
+#ifdef __QNXNTO__
+	new_action.sa_flags = 0;
+#else
 	new_action.sa_flags = SA_ONSTACK;
+#endif
 
 	if (sigaction(signum, &new_action, orig_action) < 0) {
 		pr_fail("%s: sigaction %s: errno=%d (%s)\n",
diff --git a/stress-dev.c b/stress-dev.c
index cb78c0b48..b0d1353d9 100644
--- a/stress-dev.c
+++ b/stress-dev.c
@@ -3043,10 +3043,69 @@ static void stress_dev_dir(
 		}
 
 		(void)stress_mk_filename(tmp, sizeof(tmp), path, d->d_name);
-		switch (d->d_type) {
-		case DT_DIR:
+#ifdef __QNXNTO__
+		struct stat st;
+		char path[PATH_MAX];
+
+		snprintf( path, sizeof(path), "%s/%s", dirname, d->d_name); 
+		if (stat(path, &st) < 0)
+			continue;
+
+		if (S_ISDIR(st.st_mode)) {
 			if (!recurse)
+					continue;
+			if (stress_hash_get(dev_open_fail, tmp))
+				continue;
+			ret = stat(tmp, &buf);
+			if (ret < 0) {
+				stress_hash_add(dev_open_fail, tmp);
+				continue;
+			}
+			if ((buf.st_mode & flags) == 0) {
+				stress_hash_add(dev_open_fail, tmp);
 				continue;
+			}
+			inc_counter(args);
+			stress_dev_dir(args, tmp, recurse, depth + 1, euid);
+		} else if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)) {
+			if (stress_hash_get(dev_open_fail, tmp))
+				continue;
+			if (strstr(tmp, "watchdog")) {
+				stress_hash_add(dev_open_fail, tmp);
+				continue;
+			}
+
+			/* If it was opened OK before, no need for try_open check */
+			if (!stress_hash_get(dev_open_ok, tmp)) {
+				/* Limit the number of locked up try failures */
+				if (try_failed > STRESS_DEV_OPEN_TRIES_MAX)
+					continue;
+				stress_dev_procname(tmp);
+				ret = stress_try_open(args, tmp, O_RDONLY | O_NONBLOCK | O_NDELAY, 1500000000);
+				if (ret == STRESS_TRY_OPEN_FAIL) {
+					stress_hash_add(dev_open_fail, tmp);
+					try_failed++;
+					continue;
+				}
+				if (ret == STRESS_TRY_AGAIN)
+					continue;
+			}
+			ret = shim_pthread_spin_lock(&lock);
+			if (!ret) {
+				(void)shim_strlcpy(filename, tmp, sizeof(filename));
+				dev_path = filename;
+				(void)shim_pthread_spin_unlock(&lock);
+				stress_dev_procname(filename);
+				stress_dev_rw(args, loops);
+				inc_counter(args);
+			}
+			stress_hash_add(dev_open_ok, tmp);
+		}
+#else
+		switch (d->d_type) {
+			case DT_DIR:
+				if (!recurse)
+					continue;
 			if (stress_hash_get(dev_open_fail, tmp))
 				continue;
 			ret = stat(tmp, &buf);
@@ -3099,6 +3158,7 @@ static void stress_dev_dir(
 		default:
 			break;
 		}
+#endif
 	}
 done:
 	stress_dirent_list_free(dlist, n);
diff --git a/stress-ng.h b/stress-ng.h
index d2a4c5e1b..e4606b3b2 100644
--- a/stress-ng.h
+++ b/stress-ng.h
@@ -4362,6 +4362,15 @@ static inline void *shim_unconstify_ptr(const void *ptr)
 #define shim_unconstify_ptr(ptr)        (ptr)
 #endif
 
+#ifdef __QNXNTO__
+#ifndef SA_ONSTACK
+#define SA_ONSTACK 0
+#endif
+#ifndef SA_RESTORER
+#define SA_RESTORER 0
+#endif
+#endif
+
 extern int shim_arch_prctl(int code, unsigned long addr);
 extern int shim_brk(void *addr);
 extern int shim_cacheflush(char *addr, int nbytes, int cache);
diff --git a/stress-sysinfo.c b/stress-sysinfo.c
index 6fdb5969c..7ba4ec4d0 100644
--- a/stress-sysinfo.c
+++ b/stress-sysinfo.c
@@ -181,7 +181,7 @@ static int stress_sysinfo(const stress_args_t *args)
 			 * Exercise invalid ustat, assuming that major ~0 is
 			 * invalid
 			 */
-			sbuf.st_dev = makedev(~0, stress_mwc32());
+			sbuf.st_dev = makedev(~0, stress_mwc32(), 0);
 			ret = shim_ustat(sbuf.st_dev, &ubuf);
 			(void)ret;
 #endif
diff --git a/stress-tsearch.c b/stress-tsearch.c
index 0aea99a2e..d145bdfef 100644
--- a/stress-tsearch.c
+++ b/stress-tsearch.c
@@ -45,6 +45,12 @@ static int stress_set_tsearch_size(const char *opt)
 	return stress_set_setting("tsearch-size", TYPE_ID_UINT64, &tsearch_size);
 }
 
+static const stress_opt_set_func_t opt_set_funcs[] = {
+	{ OPT_tsearch_size,	stress_set_tsearch_size },
+	{ 0,			NULL }
+};
+
+#ifndef __QNXNTO__
 /*
  *  cmp()
  *	sort on int32 values
@@ -142,14 +148,33 @@ abort:
 	return EXIT_SUCCESS;
 }
 
-static const stress_opt_set_func_t opt_set_funcs[] = {
-	{ OPT_tsearch_size,	stress_set_tsearch_size },
-	{ 0,			NULL }
+stressor_info_t stress_tsearch_info = {
+	.stressor = stress_tsearch,
+	.class = CLASS_CPU_CACHE | CLASS_CPU | CLASS_MEMORY,
+	.opt_set_funcs = opt_set_funcs,
+	.help = help
 };
 
+#else
+
+/*
+ *  The QNX libc does not provide tsearch(3)/tfind(3)/tdelete(3),
+ *  so skip this stressor on QNX rather than emitting an undefined
+ *  reference at link time.
+ */
+static int stress_tsearch_supported(const char *name)
+{
+	pr_inf("%s stressor will be skipped, "
+		"tsearch(3) is not supported on this platform\n", name);
+	return -1;
+}
+
 stressor_info_t stress_tsearch_info = {
-	.stressor = stress_tsearch,
+	.stressor = stress_not_implemented,
+	.supported = stress_tsearch_supported,
 	.class = CLASS_CPU_CACHE | CLASS_CPU | CLASS_MEMORY,
 	.opt_set_funcs = opt_set_funcs,
 	.help = help
 };
+
+#endif
diff --git a/stress-wait.c b/stress-wait.c
index 49a0f76be..8ab78f7ed 100644
--- a/stress-wait.c
+++ b/stress-wait.c
@@ -49,7 +49,7 @@ static void MLOCKED_TEXT stress_usr1_handler(int signum)
  *  spawn()
  *	spawn a process
  */
-static pid_t spawn(
+static pid_t spawn_ng(
 	const stress_args_t *args,
 	void (*func)(const stress_args_t *args, const pid_t pid),
 	pid_t pid_arg)
@@ -196,14 +196,14 @@ static int stress_wait(const stress_args_t *args)
 
 	stress_set_proc_state(args->name, STRESS_STATE_RUN);
 
-	pid_r = spawn(args, runner, 0);
+	pid_r = spawn_ng(args, runner, 0);
 	if (pid_r < 0) {
 		pr_fail("%s: fork failed, errno=%d (%s)\n",
 			args->name, errno, strerror(errno));
 		return EXIT_FAILURE;
 	}
 
-	pid_k = spawn(args, killer, pid_r);
+	pid_k = spawn_ng(args, killer, pid_r);
 	if (pid_k < 0) {
 		pr_fail("%s: fork failed, errno=%d (%s)\n",
 			args->name, errno, strerror(errno));
相关推荐
manageengine14 小时前
服务器 CPU 100% 怎么排查:8 条命令从现象定位到根因
运维·服务器·cpu
我不会起名字32212 天前
Redis 从 0 到 1(二十九):CPU 突然 100%——commandstats 定位法与 6 步排查链路
redis·cpu·慢查询·排查·commandstats
XLYcmy16 天前
实验报告分析评价文档——《第四次阶段汇报:模型产物的仓库瘦身、云端部署与评测链路打通》评析
git·llm·cpu·gpu·反编译·反汇编·safetensors
Logic1011 个月前
如何分辨Intel CPU的好坏?
cpu·intel·电脑配置·i5·i7·i9·i3
UWA1 个月前
UGUI性能排查实战:隐藏血条后耗时下降,减少顶点为何没改善
ui·性能优化·cpu·游戏开发
Felven1 个月前
stress-ng 与 fio 性能测试工具使用指南
linux·测试工具·fio·stress-ng
utmhikari2 个月前
【DIY小记】解决散热问题提升超频性能的经验
性能测试·cpu·硬件·bios·超频·主板·风道
Felven2 个月前
Intel Core Ultra X9 388H全面性能对比分析报告
cpu·gpu·intel·性能对比·amd