428 Star 1.6K Fork 1.6K

GVPopenEuler/kernel

 / 详情

【OLK-5.10】BUG: soft lockup in rtc_timer_do_work

已完成
任务
创建于  
2022-11-15 19:30

【严重程度】 一般
【特性】

watchdog: BUG: soft lockup - CPU#3 stuck for 23s! [kworker/3:0:16352]
Modules linked in:
CPU: 3 PID: 16352 Comm: kworker/3:0 Not tainted 5.10.0+ #2
Hardware name: linux,dummy-virt (DT)
Workqueue: events rtc_timer_do_work
pstate: 80000005 (Nzcv daif -PAN -UAO -TCO BTYPE=--)
pc : __sanitizer_cov_trace_pc+0x90/0xac kernel/kcov.c:207
lr : arch_static_branch arch/arm64/include/asm/jump_label.h:21 [inline]
lr : static_key_false include/linux/jump_label.h:200 [inline]
lr : trace_rtc_timer_fired include/trace/events/rtc.h:196 [inline]
lr : rtc_timer_do_work+0x18c/0x5d4 drivers/rtc/interface.c:926
sp : ffffff8014237ac0
x29: ffffff8014237ac0 x28: ffffff80ca742500 
x27: ffffffd012218000 x26: ffffff80d6567210 
x25: ffffff80ca742580 x24: ffffff80ca7424f8 
x23: ffffff80ca742560 x22: ffffffd012bdfb48 
x21: ffffff80ca7425f0 x20: ffffffd01126f640 
x19: ffffff80ca742548 x18: 0000000000000000 
x17: 0000000000000000 x16: 0000000000000000 
x15: 0000007fe23904c8 x14: 0000000000000000 
x13: 0000000000000000 x12: ffffffc0194e849b 
x11: 1ffffff0194e849a x10: ffffffc0194e849a 
x9 : ffffffd01126f56c x8 : ffffff80ca7424d0 
x7 : 0000000000000001 x6 : ffffffc0194e849a 
x5 : ffffff80ca7424d0 x4 : dfffffd000000000 
x3 : ffffffd010000000 x2 : ffffffd011780000 
x1 : ffffff801371dc80 x0 : 0000000000000000 
Call trace:
 __sanitizer_cov_trace_pc+0x90/0xac kernel/kcov.c:205
 arch_static_branch arch/arm64/include/asm/jump_label.h:21 [inline]
 static_key_false include/linux/jump_label.h:200 [inline]
 trace_rtc_timer_fired include/trace/events/rtc.h:196 [inline]
 rtc_timer_do_work+0x18c/0x5d4 drivers/rtc/interface.c:926
 process_one_work+0x3ec/0x930 kernel/workqueue.c:2270
 worker_thread+0x108/0x7dc kernel/workqueue.c:2416
 kthread+0x1a0/0x1ec kernel/kthread.c:313
 ret_from_fork+0x10/0x18 arch/arm64/kernel/entry.S:914

【重现类型】 必现
【* 定位分析】

社区补丁7e7c005b4b1f ("rtc: disable uie before setting time and enable after") 修改rtc问题引入,该补丁修复调用uie on后设置rtc时间为一个未来遥远时间,uie timer一直重复处于到期,导致softlockup问题。未将uie_rtctimer.enabled读取,disable uie,enable uie放在rtc->ops_lock锁保护范围内。导致uie on和set time并发出现数据竞争问题,使得7e7c005b4b1f 修改不生效,出现softlockup。
使用复现程序验证,问题不复现
【复现程序】

#include <asm/ioctl.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
#include <pthread.h>

struct linux_rtc_time {
	int tm_sec;
	int tm_min;
	int tm_hour;
	int tm_mday;
	int tm_mon;
	int tm_year;
	int tm_wday;
	int tm_yday;
	int tm_isdst;
};

# define RTC_RD_TIME	_IOR('p', 0x09, struct linux_rtc_time)
# define RTC_SET_TIME	_IOW('p', 0x0a, struct linux_rtc_time)
# define RTC_UIE_ON	_IO('p', 0x03)
# define RTC_UIE_OFF	_IO('p', 0x04)

void *test_thread(void *arg)
{
	int rtc_fd = arg;
	struct tm rdtime;
	int rc;

	while (1) {
		rc = ioctl(rtc_fd, RTC_RD_TIME, &rdtime);
		if (rc == -1) {
			printf("ioctl(RTC_RD_TIME) to read the time failed\n");
			return NULL;
		}

		/* Turn on update interrupts (one per second) */
		rc = ioctl(rtc_fd, RTC_UIE_ON, 0);
		if (rc == -1) {
			printf("ioctl(RTC_UIE_ON) to turn on update interrupts failed\n");
		}

		/* Set rtc to a time far from now */
		rdtime.tm_mon += 1;

		rc = ioctl(rtc_fd, RTC_SET_TIME, &rdtime);
		if (rc == -1) {
			printf("ioctl(RTC_SET_TIME) to set the time failed\n");
		}

		/* Turn on update interrupts (one per second) */
		rc = ioctl(rtc_fd, RTC_UIE_OFF, 0);
		if (rc == -1) {
			printf("ioctl(RTC_UIE_ON) to turn on update interrupts failed\n");
		}

		/* Set rtc to a time far from now */
		rdtime.tm_mon -= 1;

		rc = ioctl(rtc_fd, RTC_SET_TIME, &rdtime);
		if (rc == -1) {
			printf("ioctl(RTC_SET_TIME) to set the time failed\n");
		}
	}
	return NULL;
}

#define TEST_SIZE 100

int main() {
	int rtc_fd;
	int ret = 1;
	pthread_t thread[TEST_SIZE];
	int i;

	rtc_fd = open("/dev/rtc0", O_RDONLY);
	if (rtc_fd == -1) {
		printf("cannot open rtc device\n");
		return ret;
	}

	for (i = 0; i < TEST_SIZE; i++) {
		pthread_create(&thread[i], NULL, test_thread, (void *)rtc_fd);
	}

	for (i = 0; i < TEST_SIZE; i++) {
		pthread_join(thread[i], NULL);
	}

	close(rtc_fd);
	return 0;
}

【* 影响评估及测试建议】无影响


【* 对外影响描述】否

评论 (1)

hulk-robot 创建了任务 2年前
openeuler-ci-bot 添加了
 
sig/Kernel
标签
2年前
liaoyu 修改了描述 2年前
liaoyu 修改了描述 2年前
liaoyu 修改了描述 2年前
liaoyu 修改了描述 2年前
liaoyu 修改了描述 2年前
zhengzengkai 通过合并 Pull Request !814: release 5.10.0-128.0.0任务状态待办的 修改为已完成 2年前

登录 后才可以发表评论

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

搜索帮助