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: 12513203 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=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 61DE2C433F5 for ; Thu, 23 Sep 2021 16:05:20 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 D9A646115A for ; Thu, 23 Sep 2021 16:05:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D9A646115A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linutronix.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id ACA9C828; Thu, 23 Sep 2021 18:04:26 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz ACA9C828 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1632413116; bh=HKJ62ec0H3rRqwouVaEOlCdmeDwscUCB9fggww1qtqs=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=TyF19K1ARhvlbey7sl98Ut+qIEwG+Y54qRwqupaNg14lRPcEfumaxpi/L3wrnUzo2 yy5BbI6YTSYmn8qj/dEKIWL7kkIVJoMpQGLb6N6kWEZ6V98d6hjPBhkuyuF6I3l2kM /oTBb+GeAkhRWZfepviBUzuGpzqjGl0RVO5bB+vg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3AB53F8025F; Thu, 23 Sep 2021 18:04:26 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B3078F80268; Thu, 23 Sep 2021 18:04:24 +0200 (CEST) Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 039C8F8013F for ; Thu, 23 Sep 2021 18:04:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 039C8F8013F Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="S9Sw4KaT"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="qLgcomT0" 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 Subject: [patch 00/11] hrtimers: Cleanup hrtimer_forward() [ab]use MIME-Version: 1.0 Date: Thu, 23 Sep 2021 18:04:18 +0200 (CEST) Cc: alsa-devel@alsa-project.org, Sergey Ryazanov , Peter Zijlstra , Joonas Lahtinen , dri-devel@lists.freedesktop.org, Intel Corporation , David Airlie , Jakub Kicinski , Johannes Berg , linux-pm@vger.kernel.org, intel-gfx@lists.freedesktop.org, Jani Nikula , linux-can@vger.kernel.org, Marc Kleine-Budde , Sebastian Reichel , Rodrigo Vivi , Dmitry Vyukov , Loic Poulain , netdev@vger.kernel.org, Takashi Iwai , "Eric W. Biederman" , Daniel Vetter , Oliver Hartkopp , M Chetan Kumar , Johannes Berg , "David S. Miller" X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-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(-)