Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp215204pxb; Thu, 12 Aug 2021 14:44:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxTcK5tce89HPBE5pYUC0dUDSBmAS7nH42Slw3e9wwkaNFToUpgpjI7HzQrHUIqKGoEqA1 X-Received: by 2002:a05:6402:b56:: with SMTP id bx22mr8105256edb.285.1628804663334; Thu, 12 Aug 2021 14:44:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628804663; cv=none; d=google.com; s=arc-20160816; b=PwQV2nIkks4RJZIUp0sfZffj75rIhSR7N0WjU9/rVUTwpFB1kmW8M04oalSgVr1bFx 2pwJZWXs7HGTuflBSM9zTokJbejdtGou+zojWQY9xlQziJzO5tyTCv+yrwGWiIx5E9bV QNRQxsXKN4RAZ0tBG88N5EbNuTOVUk8QtVFiHb9O8hlGQ/fV7vG9eBjOdiiijxvvqgV9 JqCd1jNWq32xbEWdo0oLaOtGrAZa4YDrq8RwZhB29W+G4j/pw+j/0LREabR5sb8Hc8IF lhd8UXkfVUFqbUONaiK3tK9gwfXRioz4d6oaKJSC8L54JRRyde6WNPQYglDoMIWVcFq2 ohCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=P0g6kaj3w3l8s66z1iLQpOYDO2iUHwY9sG7pabFyb34=; b=XdcjZDQXVBL0fxcbMxMWBIHd6GKY+s5fFkoMo1RgqCguYBnPaWzRjwncSNC/qD6OMr y9LRkVAtTS1lwWBSQqWjhU7TngohMugEvXo4kZuV50ovmJVOQqDq72bF8sa7sU3bFLs3 cgjOv/8CPjE57KVQpxtnly8vB88nubiZb81LeuSRmQVdGuL2SVj6E2qrI0cvkrtOQEa5 znLnMxH/TAHohgAKkzvokLfeI9c10s2lK76FvMktPZ2DGX/hlK9ua1ig1iU5Q+9PRsus ZGHqjGK9FhY12cj1ARHnoLAZiqtWepbm2bH4rnwH5V/IxcyRzDinw3kBkNfpiBJdYfuK 3Khg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=DYKdHnUv; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m21si3877373edc.147.2021.08.12.14.44.00; Thu, 12 Aug 2021 14:44:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=DYKdHnUv; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237033AbhHLUc6 (ORCPT + 99 others); Thu, 12 Aug 2021 16:32:58 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:60834 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229677AbhHLUc5 (ORCPT ); Thu, 12 Aug 2021 16:32:57 -0400 From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1628800351; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=P0g6kaj3w3l8s66z1iLQpOYDO2iUHwY9sG7pabFyb34=; b=DYKdHnUvdxnuxcXHyOctQBNAzVUGe/MdAiljNir0XmAdfJkJswzL1jCWknLQ8S9IKq7jiW /mJgyYqZBmPnoAebGmfP2YbSDzSfsp2R+ve1YpkNqQAFhfq0YrikoyZwUF9q3qJbdMxywY 9RNl08VOqk1cHNFmCl7k8sCFBJAgYE+wH7nYp/spmdtdqzB4w1ZZ8XrT5+nbIO7IIgR3jY 6/j5cWEhrfCGlu2w9GWZc4nTYvc+D3jdDhEKJ2KAJ21mhDjdByXmzGiHhCh9ysGgvcSglW jP73Kf0aiSpjLPfRqkdJOU6STCzb3kjQw5bf10NIqAXNugGDHJhCOqwfjjEImg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1628800351; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=P0g6kaj3w3l8s66z1iLQpOYDO2iUHwY9sG7pabFyb34=; b=lZ3p8zpAaDTY0wOmAI3HB0PocayVusZIVK1yN+a/OCs3DPncIdjTJ71/v9xZhrwyBlx91L ucH9SccbnJnRdmBg== To: Mike Galbraith , linux-kernel@vger.kernel.org, linux-tip-commits@vger.kernel.org Cc: Peter Zijlstra , x86@kernel.org Subject: [PATCH] hrtimer: Unbreak hrtimer_force_reprogram() In-Reply-To: <877dgqivhy.ffs@tglx> References: <20210713135158.054424875@linutronix.de> <162861133759.395.7795246170325882103.tip-bot2@tip-bot2> <7dfb3b15af67400227e7fa9e1916c8add0374ba9.camel@gmx.de> <87a6lmiwi0.ffs@tglx> <877dgqivhy.ffs@tglx> Date: Thu, 12 Aug 2021 22:32:30 +0200 Message-ID: <8735recskh.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since the recent consoliation of reprogramming functions, hrtimer_force_reprogram() is affected by a check whether the new expiry time is past the current expiry time. This breaks the NOHZ logic as that relies on the fact that the tick hrtimer is moved into the future. That means cpu_base->expires_next becomes stale and subsequent reprogramming attempts fail as well until the situation is cleaned up by an hrtimer interrupts. For some yet unknown reason this leads to a complete stall, so for now partially revert the offending commit to a known working state. The root cause for the stall is still investigated and will be fixed in a subsequent commit. Fixes: b14bca97c9f5 ("hrtimer: Consolidate reprogramming code") Reported-by: Mike Galbraith Reported-by: Marek Szyprowski Signed-off-by: Thomas Gleixner Tested-by: Mike Galbraith --- kernel/time/hrtimer.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -652,24 +652,10 @@ static inline int hrtimer_hres_active(vo return __hrtimer_hres_active(this_cpu_ptr(&hrtimer_bases)); } -static void -__hrtimer_reprogram(struct hrtimer_cpu_base *cpu_base, int skip_equal, - struct hrtimer *next_timer, ktime_t expires_next) +static void __hrtimer_reprogram(struct hrtimer_cpu_base *cpu_base, + struct hrtimer *next_timer, + ktime_t expires_next) { - /* - * If the hrtimer interrupt is running, then it will reevaluate the - * clock bases and reprogram the clock event device. - */ - if (cpu_base->in_hrtirq) - return; - - if (expires_next > cpu_base->expires_next) - return; - - if (skip_equal && expires_next == cpu_base->expires_next) - return; - - cpu_base->next_timer = next_timer; cpu_base->expires_next = expires_next; /* @@ -707,8 +693,10 @@ hrtimer_force_reprogram(struct hrtimer_c expires_next = hrtimer_update_next_event(cpu_base); - __hrtimer_reprogram(cpu_base, skip_equal, cpu_base->next_timer, - expires_next); + if (skip_equal && expires_next == cpu_base->expires_next) + return; + + __hrtimer_reprogram(cpu_base, cpu_base->next_timer, expires_next); } /* High resolution timer related functions */ @@ -863,7 +851,19 @@ static void hrtimer_reprogram(struct hrt if (base->cpu_base != cpu_base) return; - __hrtimer_reprogram(cpu_base, true, timer, expires); + if (expires >= cpu_base->expires_next) + return; + + /* + * If the hrtimer interrupt is running, then it will reevaluate the + * clock bases and reprogram the clock event device. + */ + if (cpu_base->in_hrtirq) + return; + + cpu_base->next_timer = timer; + + __hrtimer_reprogram(cpu_base, timer, expires); } static bool update_needs_ipi(struct hrtimer_cpu_base *cpu_base,