395 Star 1.4K Fork 1.3K

GVPopenEuler / kernel

 / 详情

【OLK-5.10】workqueue: fix sanity check warning when invoke destroy_workqueue()

已完成
任务
创建于  
2023-07-17 17:52

【标题描述】能够简要描述问题:说明什么场景下,做了什么操作,出现什么问题(尽量使用正向表达方式)
创建workqueue工作队列,在工作队列仍在工作状态下,发起销毁工作队列,有概率发生warning

【环境信息】
硬件信息:
1) 裸机场景提供出问题的硬件信息;
2) 虚机场景提供虚机XML文件或者配置信息
软件信息:
1) OS版本及分支
2) 内核信息
3) 发现问题的组件版本信息
如果有特殊组网,请提供网络拓扑图

【问题复现步骤】
具体操作步骤
出现概率(是否必现,概率性错误)
概率性错误

【预期结果】
描述预期结果,可以通过对比新老版本获取
消除 warning

【实际结果】
描述出问题的结果
该问题会导致 struct pool_workqueue 内存泄漏

【附件信息】
比如系统message日志/组件日志、dump信息、图片等

[  115.195073] 99 done
[  115.317571] ------------[ cut here ]------------
[  115.327449] WARNING: CPU: 3 PID: 130 at kernel/workqueue.c:4453 destroy_workqueue+0xf8/0x2d0
[  115.328262] Modules linked in: wq_issue(O-)
[  115.330528] CPU: 3 PID: 130 Comm: rmmod Tainted: G           O      5.10.0-03441-g527301dba422-dirty #131
[  115.331028] Hardware name: linux,dummy-virt (DT)
[  115.331875] pstate: 20000085 (nzCv daIf -PAN -UAO -TCO BTYPE=--)
[  115.332274] pc : destroy_workqueue+0xf8/0x2d0
[  115.332507] lr : destroy_workqueue+0xac/0x2d0
[  115.332735] sp : ffff8000135dbda0
[  115.332963] x29: ffff8000135dbda0 x28: ffff0000c085eac0
[  115.333348] x27: 0000000000000000 x26: 0000000000000000
[  115.333627] x25: 0000000000000000 x24: 0000000000000000
[  115.333903] x23: ffff0000c0027620 x22: ffff800011b81068
[  115.334180] x21: ffff0000c0027600 x20: ffff00027ebdd900
[  115.334459] x19: ffff00027ebdd924 x18: 0000000000000000
[  115.334777] x17: 0000000000000000 x16: 0000000000000000
[  115.335195] x15: 0000000000000173 x14: 0000000000000251
[  115.335638] x13: 0000000000000001 x12: 0000000000000000
[  115.335912] x11: 0000000000000001 x10: 000000000000033e
[  115.336208] x9 : 00000000000f1000 x8 : 0000000000000003
[  115.336483] x7 : 00000000ffffffff x6 : ffff00027ebd9118
[  115.336858] x5 : 0000000000000003 x4 : 0000000000000000
[  115.337361] x3 : ffff00027ebd8000 x2 : ffff00027ebdd958
[  115.337649] x1 : 0000000000000001 x0 : 0000000000000000
[  115.338143] Call trace:
[  115.338498]  destroy_workqueue+0xf8/0x2d0
[  115.339541]  wq_test_exit+0x10/0x24 [wq_issue]
[  115.339779]  __arm64_sys_delete_module+0x184/0x250
[  115.340020]  do_el0_svc+0x84/0x1d0
[  115.340201]  el0_svc+0x10/0x1c
[  115.340356]  el0_sync_handler+0xa8/0xf0
[  115.340549]  el0_sync+0x158/0x180
[  115.340870] ---[ end trace ad43b955b80573a2 ]---
[  115.341484] destroy_workqueue: my_workqueue has the following busy pwq
[  115.341840]   pwq 6: cpus=3 node=0 flags=0x0 nice=0 active=1/1 refcnt=2
[  115.342862]     pending: my_work_function
[  115.346575] Sanity checks
[  115.348693] Showing busy workqueues and worker pools:
[  115.349232] workqueue events_power_efficient: flags=0x82
[  115.350752]   pwq 8: cpus=0-3 flags=0x4 nice=0 active=1/256 refcnt=3
[  115.351409]     pending: neigh_periodic_work
[  115.352947] wq_test_exit

复现测试用例:

+#include <linux/module.h>
+#include <linux/delay.h>
+
+#define NR_WORK 100
+
+struct workqueue_struct *my_workqueue;
+
+struct my_work_struct {
+	struct work_struct work;
+	int index;
+};
+struct my_work_struct my_work[NR_WORK];
+
+void my_work_function(struct work_struct *work)
+{
+	msleep(100);
+}
+
+static int wq_test_init(void)
+{
+	int i;
+
+	pr_info("wq_test_init\n");
+
+	my_workqueue = create_workqueue("my_workqueue");
+
+	for (i = 0; i < NR_WORK; i++) {
+		INIT_WORK((struct work_struct *)(my_work + i), my_work_function);
+		my_work[i].index = i;
+		// queue_work(ret_my_workqueue(), (struct work_struct *)(my_work + i));
+		queue_work(my_workqueue, (struct work_struct *)(my_work + i));
+	}
+
+	pr_info("wq_test_init done\n");
+	return 0;
+}
+
+static void wq_test_exit(void)
+{
+	flush_work((struct work_struct *)(my_work + (NR_WORK - 1)));
+	destroy_workqueue(my_workqueue);
+
+	pr_info("wq_test_exit done\n");
+	return;
+}
+
+module_init(wq_test_init);
+module_exit(wq_test_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("workqueue issue");

评论 (1)

henryZeng 创建了缺陷

Hi henryze, welcome to the openEuler Community.
I'm the Bot here serving you. You can find the instructions on how to interact with me at Here.
If you have any questions, please contact the SIG: Kernel, and any of the maintainers.

openeuler-ci-bot 添加了
 
sig/Kernel
标签
henryZeng 修改了标题
henryZeng 修改了描述
zhangjialin 任务类型缺陷 修改为任务
henryZeng 上传了附件0001-workqueue-sanity-check-warning-reproduce.patch
henryZeng 修改了描述
henryZeng 通过openeuler/kernel Pull Request !1441任务状态待办的 修改为已完成

登录 后才可以发表评论

状态
负责人
项目
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
预计工期 (小时)
参与者(2)
5329419 openeuler ci bot 1632792936
C
1
https://gitee.com/openeuler/kernel.git
git@gitee.com:openeuler/kernel.git
openeuler
kernel
kernel

搜索帮助