public inbox for linux-rtc@vger.kernel.org
 help / color / mirror / Atom feed
From: Jinjie Ruan <ruanjinjie@huawei.com>
To: <alexandre.belloni@bootlin.com>, <linux-rtc@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] rtc: interface: Fix softlockup in rtc_timer_do_work()
Date: Tue, 6 Jan 2026 14:24:46 +0800	[thread overview]
Message-ID: <10e7c2e6-ef7d-7de1-5f02-ea6cb56bfa1a@huawei.com> (raw)
In-Reply-To: <20251231092321.3787542-1-ruanjinjie@huawei.com>



On 2025/12/31 17:23, Jinjie Ruan wrote:
> On kvm qemu with cmos rtc and mc146818 chip, when the read time jump to
> a future time after set the uie timer expire with a current RTC time,
> rtc_timer_do_work() will loop for a while util softlockup because
> the expiration of the uie timer was way before the current
> RTC time and a new timer will be enqueued until the current rtc time
> is reached, as below:
> 
> Fix it by voluntarily yield the CPU in the loop in rtc_timer_do_work().
> 
> RTC_UIE_ON:
> 	read now: 2019:04:08:12:32:27, add timer0 (expire: 2019:04:08:12:32:28)
> 		 ^^^^^^^^^^^^^^^^^^^^
> ...
> rtc_timer_do_work() iterate the list in a loop:
> 	read now: 2033:12:02:07:27:15

Please ignore, this seems to be a bug in QEMU.

> 		  ^^^^^^^^^^^^^^^^^^^
> 	handle timer0, add timer1 to the list (expire: 2019:04:08:12:32:29)
> 	handle timer1, add timer2 to the list (expire: 2019:04:08:12:32:30)
> 	handle timer2, add timer3: 2019:04:08:12:32:31
> 	...
> 	-> softlockup
> 
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> ---
>  drivers/rtc/interface.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
> index b8b298efd9a9..9ded10e82f4b 100644
> --- a/drivers/rtc/interface.c
> +++ b/drivers/rtc/interface.c
> @@ -964,6 +964,7 @@ void rtc_timer_do_work(struct work_struct *work)
>  			timer->enabled = 1;
>  			timerqueue_add(&rtc->timerqueue, &timer->node);
>  			trace_rtc_timer_enqueue(timer);
> +			cond_resched();
>  		}
>  	}
>  

      reply	other threads:[~2026-01-06  6:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-31  9:23 [PATCH] rtc: interface: Fix softlockup in rtc_timer_do_work() Jinjie Ruan
2026-01-06  6:24 ` Jinjie Ruan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=10e7c2e6-ef7d-7de1-5f02-ea6cb56bfa1a@huawei.com \
    --to=ruanjinjie@huawei.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox