From patchwork Thu Sep 23 16:04:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12513225 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1A01C433F5 for ; Thu, 23 Sep 2021 16:15:28 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 49693610D1 for ; Thu, 23 Sep 2021 16:15:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 49693610D1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DD0EF6ED93; Thu, 23 Sep 2021 16:15:25 +0000 (UTC) Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4AEA36ED92; Thu, 23 Sep 2021 16:15:24 +0000 (UTC) Message-ID: <20210923153311.225307347@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1632413059; 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: content-transfer-encoding:content-transfer-encoding; bh=HKJ62ec0H3rRqwouVaEOlCdmeDwscUCB9fggww1qtqs=; b=S9Sw4KaTyb9s7Z3KdYbFaJAvUzjpHUVpUTxvyQ3jFIhlWRMGgqgxLk8/cDw3/6XKvUpZZp dhPkgsAfepaag4dai3tsQG8H1SEb6OcdSZOt4ZOJ+L5fXItf38KOz+VqvC3n7RURS0RvCQ AOymsMXCjVfXsiR5+QYlShryPPOPagMf/WTMdP3bCxY4nDARQHkLdyUfBjfybnlnp7aDF4 +1FziWh42JVQop5OoCpYLsWFXx4DjgT4Pae3ReQR206O4iu4W5dBMixmm0/zU/iKuBBxQg Lzba969dREamrSViMjsujMdwDyfjxU3YaUi5eaDsZEB1EpwUfhtSN4rB5GULJA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1632413059; 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: content-transfer-encoding:content-transfer-encoding; bh=HKJ62ec0H3rRqwouVaEOlCdmeDwscUCB9fggww1qtqs=; b=qLgcomT0elm/TlKSiEwnkZ3rD3NJKvPZV3pfy2RnYzqCkiviMbALY7urqFmSkwiw4ven3n 7eMZvc1fRymbs4Dw== From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Dmitry Vyukov , Johannes Berg , Loic Poulain , netdev@vger.kernel.org, Sergey Ryazanov , Jakub Kicinski , M Chetan Kumar , Johannes Berg , "David S. Miller" , Intel Corporation , alsa-devel@alsa-project.org, Takashi Iwai , Jaroslav Kysela , Oliver Hartkopp , linux-can@vger.kernel.org, Marc Kleine-Budde , Sebastian Reichel , linux-pm@vger.kernel.org, David Airlie , intel-gfx@lists.freedesktop.org, Joonas Lahtinen , Jani Nikula , dri-devel@lists.freedesktop.org, Daniel Vetter , Rodrigo Vivi , "Eric W. Biederman" Subject: [patch 00/11] hrtimers: Cleanup hrtimer_forward() [ab]use MIME-Version: 1.0 Date: Thu, 23 Sep 2021 18:04:18 +0200 (CEST) X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" A recent syzbot report unearthed abuse of hrtimer_forward() which can cause runaway timers hogging the CPU in timer expiry context by rearming the timer in the past over and over. This happens when the caller uses timer->expiry for the 'now' argument of hrtimer_forward(). That works as long as the timer expiry is on time, but can cause a long period of rearm/fire loops which hog the CPU. Expiring late can have various causes, but obviously virtualization is prone to that due to VCPU scheduling. The correct usage of hrtimer_forward() is to hand the current time to the 'now' argument which ensures that the next event on the periodic time line is past now. This is what hrtimer_forward_now() provides. The following series addresses this: 1) Add a debug mechanism to the hrtimer expiry loop 2) Convert all hrtimer_forward() usage outside of kernel/time/ to use hrtimer_forward_now(). 3) Confine hrtimer_forward() to kernel/time/ core code. The mac80211_hwsim patch has already been picked up by the wireless maintainer and all other patches which affect usage outside the core code can be picked up by the relevant subsystems. If a maintainer wants me to pick a particular patch up, please let me know. The last patch which confines hrtimer_forward() will be postponed until all other patches have been merged into Linus tree. The series is also available from git: git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git hrtimer Thanks, tglx --- drivers/gpu/drm/i915/i915_pmu.c | 2 - drivers/net/wireless/mac80211_hwsim.c | 4 +- drivers/net/wwan/iosm/iosm_ipc_imem.c | 4 +- drivers/power/reset/ltc2952-poweroff.c | 4 -- include/linux/hrtimer.h | 26 ----------------- include/linux/posix-timers.h | 3 ++ kernel/signal.c | 14 +-------- kernel/time/hrtimer.c | 48 ++++++++++++++++++++++++++++++++- kernel/time/itimer.c | 13 ++++++++ kernel/time/posix-timers.c | 42 +++++++++++----------------- kernel/time/tick-internal.h | 1 net/can/bcm.c | 2 - sound/drivers/pcsp/pcsp_lib.c | 2 - 13 files changed, 92 insertions(+), 73 deletions(-)