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: 12513199 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=ham 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 12914C433EF for ; Thu, 23 Sep 2021 16:04:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E791360E9C for ; Thu, 23 Sep 2021 16:04:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242387AbhIWQFy (ORCPT ); Thu, 23 Sep 2021 12:05:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242363AbhIWQFy (ORCPT ); Thu, 23 Sep 2021 12:05:54 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EAF7C061574; Thu, 23 Sep 2021 09:04:22 -0700 (PDT) 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) Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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(-)