Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp3662662ybh; Mon, 5 Aug 2019 23:10:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqw3k8OReqe5y51jAN9XYJYu65ri3bd6IgMtNTz4cHjk62LH6/WKXies+vKDVlT8w99xQEgh X-Received: by 2002:aa7:9aaf:: with SMTP id x15mr1993277pfi.214.1565071808043; Mon, 05 Aug 2019 23:10:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565071808; cv=none; d=google.com; s=arc-20160816; b=pr+umE7J9bDetm/fVRPZbIXiJ9bZ4JJmpBoKYOhgrY9Q1Aya1tyI2qgdjpY9bO6bca ZZlA5J+VUJryLcr7d9oZd9lAmp2rS+rOouFbrBjtMi2Jh4fC0ub9iqWP3jV9953ocSyM K7qCjFME4tbkWJpshSYpMk1kOqhHutdHk9K4U+TXjJrvPKJL34WG4OlwCffCW5+7hFaD uTRoloHM9ZPwYiSnMxhg/YF1+jbv2e3o/og6eqlw6AcG3QSeZ69hHr13fSUCe03p8OSM gIxoP3nBsl9jV+WKoqiPjYNxBBW+/zcoznGu1Q5l6JDEwpDEwe6JMTk1Gvc6MtwpRNwA bWKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=1QuA9Oi9RdGP1TV0Lis+5FhUlJQztixRhMmqBJD7dnI=; b=kOh+HdsC69FMjbFtAyVXLvJtCIaATkhfWQRokIzr8Mxz/eHAEdVy00YnpHVnwPIE20 KBVSx0xxKAJazHpZaTMIwF1uGu1UFMiXQjcFwl/upetwmRWSRdmeqMWVFIn1UkvC6zDB baVoPUvKmNKWWH1cI9KK+QNEq9I8qlplb9PU7mE+QYkmnGS1sE57thKV3bsQUR5ABfqZ q19VfFoarEFHtmD39LCFdlWUxERLqso03GnalkIrM30Tswj/vOSJUELWImZhHZupmPyY SHxxR2EgGv9Zvmln8HzWtF6klYdssXhE1kYzWHVpIvfNUpbrUy9Dm/GNlNOSpWLhHL1M +BIA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a17si47359800pfa.45.2019.08.05.23.09.51; Mon, 05 Aug 2019 23:10:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731731AbfHFGIJ (ORCPT + 99 others); Tue, 6 Aug 2019 02:08:09 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:4179 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731540AbfHFGII (ORCPT ); Tue, 6 Aug 2019 02:08:08 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id B983E3713BE58045AB45; Tue, 6 Aug 2019 14:08:02 +0800 (CST) Received: from [127.0.0.1] (10.133.217.137) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.439.0; Tue, 6 Aug 2019 14:07:55 +0800 Subject: Re: [RFC PATCH] rtc: add a schedule point in 'rtc_timer_do_work' To: Xiongfeng Wang , , CC: , , , , Andy Shevchenko , wangkefeng wang References: <1564054230-32742-1-git-send-email-wangxiongfeng2@huawei.com> From: Kefeng Wang Message-ID: <6232158b-fed4-4e6a-84af-1aa6deb65608@huawei.com> Date: Tue, 6 Aug 2019 14:07:54 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <1564054230-32742-1-git-send-email-wangxiongfeng2@huawei.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.133.217.137] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Kindly ping... On 2019/7/25 19:30, Xiongfeng Wang wrote: > When I ran the syzkaller testsuite, it prints out the following calltrace. > > [ 138.350029] rcu: INFO: rcu_sched self-detected stall on CPU > [ 138.354703] rcu: 2-....: (104998 ticks this GP) idle=ece/1/0x4000000000000002 softirq=2825/2825 fqs=26250 > [ 138.357771] (t=105005 jiffies g=8033 q=1) > [ 138.358952] NMI backtrace for cpu 2 > [ 138.359954] CPU: 2 PID: 170 Comm: kworker/2:1 Not tainted 5.2.0-514.55.6.9.x86_64 #64 > [ 138.362212] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.10.2-0-g5f4c7b1-prebuilt.qemu-project.org 04/01/2014 > [ 138.365818] Workqueue: events rtc_timer_do_work > [ 138.367122] Call Trace: > [ 138.367815] > [ 138.368420] dump_stack+0xa7/0xf9 > [ 138.369372] nmi_cpu_backtrace+0xc2/0xd0 > [ 138.370516] ? lapic_can_unplug_cpu+0xa0/0xa0 > [ 138.371747] nmi_trigger_cpumask_backtrace+0x14e/0x190 > [ 138.373201] rcu_dump_cpu_stacks+0x97/0xc5 > [ 138.374376] rcu_sched_clock_irq+0x819/0x8d0 > [ 138.375571] ? tick_sched_do_timer+0xb0/0xb0 > [ 138.376787] ? tick_sched_do_timer+0xb0/0xb0 > [ 138.377991] update_process_times+0x2d/0x60 > [ 138.379176] tick_sched_handle+0x2f/0x70 > [ 138.381088] tick_sched_timer+0x41/0x90 > [ 138.382170] __hrtimer_run_queues+0x11b/0x580 > [ 138.383386] hrtimer_interrupt+0x11b/0x280 > [ 138.384585] smp_apic_timer_interrupt+0x7a/0x230 > [ 138.385909] apic_timer_interrupt+0xf/0x20 > [ 138.387066] > [ 138.387668] RIP: 0010:debug_lockdep_rcu_enabled+0x6/0x30 > [ 138.389149] Code: 1f 44 00 00 0f 1f 44 00 00 f0 ff 05 94 08 32 01 c3 0f 1f 00 0f 1f 44 00 00 f0 ff 0d 84 08 32 01 c3 0f 1f 00 8b 0d 2e 59 54 01 <31> c0 85 c9 74 21 8b 15 c2 b8 54 01 85 d2 74 17 65 48 8b 04 25 c0 > [ 138.394395] RSP: 0018:ffffc9000080fd30 EFLAGS: 00000203 ORIG_RAX: ffffffffffffff13 > [ 138.397117] RAX: 0000000000000000 RBX: ffff88813b77de10 RCX: 0000000000000002 > [ 138.399104] RDX: 0000000000000000 RSI: ffffffff81886439 RDI: ffff88813b77de10 > [ 138.401128] RBP: ffffc9000080fe38 R08: 0000000000000000 R09: 0000000000000000 > [ 138.403149] R10: 0000000000000001 R11: 0000000000000013 R12: ffff88813b77de98 > [ 138.405147] R13: ffff88813bab0c00 R14: 1a15e2eb5cd98000 R15: 000000003b9aca00 > [ 138.407118] ? rtc_timer_do_work+0x349/0x710 > [ 138.408344] rtc_timer_do_work+0x35c/0x710 > [ 138.409516] ? graph_unlock+0x41/0x80 > [ 138.410591] ? process_one_work+0x1d4/0x710 > [ 138.412062] process_one_work+0x272/0x710 > [ 138.413193] ? process_one_work+0x1d4/0x710 > [ 138.414376] worker_thread+0x58/0x520 > [ 138.415405] kthread+0x120/0x160 > [ 138.416337] ? process_one_work+0x710/0x710 > [ 138.417486] ? kthread_bind+0x20/0x20 > [ 138.418526] ret_from_fork+0x24/0x30 > > After looking into the syzkaller log, I found out it is caused by the > following procedure. Firstly, enable the update interrupt through ioctl > 'RTC_UIE_ON'. Secondly, set the rtc time to be a far further time > through ioctl 'RTC_SET_TIME'. This will cause we stuck in > 'rtc_timer_do_work()' because the expiring time of 'UIE' is far less > than the current rtc time. This patch add a schedule point to avoid the > RCU calltrace. > > Signed-off-by: Xiongfeng Wang > --- > drivers/rtc/interface.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c > index 72b7ddc4..0c8339d 100644 > --- a/drivers/rtc/interface.c > +++ b/drivers/rtc/interface.c > @@ -911,6 +911,8 @@ void rtc_timer_do_work(struct work_struct *work) > timerqueue_add(&rtc->timerqueue, &timer->node); > trace_rtc_timer_enqueue(timer); > } > + > + cond_resched(); > } > > /* Set next alarm */ >