Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp13896619pxu; Mon, 4 Jan 2021 07:23:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJw699L/txqIYIaKQAak5EniZHmZEptbKOKPZXNwITxoZzWhA44Bs/0W9X+hmPWTZXlWEbYR X-Received: by 2002:a05:6402:1ac4:: with SMTP id ba4mr17260903edb.383.1609773824566; Mon, 04 Jan 2021 07:23:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609773824; cv=none; d=google.com; s=arc-20160816; b=hmPB7XzV160bQQY7Z2FrS8EoiYLOlt1k3xJ0qIY2JuZ6bW4UFY12sniFivPNBPvzKb D3OBqYohXDOEaZCnG9fuw5i3mPzSQYgqbTwpnLVcaDSZje/qHxyDHaqV04IXayjrbl4Z Jude5+hIpQr5B9algrPPkSSRpkEy7LEnmwKPWEodVFrqMnBjFpTJ7Tk05yauVZRWv7yD gqaB7u3WpD6li6XFBDjXHnqU5Y8iVsRDcIOKtBxh5TT8Ez9oWKzvGOFxrsqhRUhUy9lb MyikZnoMk8LeuXXcredkb6WtWI6QqKbr3qEtc99dweF/nW9J2J/V3cPzsee9UUirRYQz ZV1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Rfdw0pUXFNCgcwvISWz3+f9hm9HfJod6QDJOO8ZxCYw=; b=d56ADDuj/yIKEfiVfGxHcOXb5uwU2ahnX3opUPIth30BU3tME6q8J45O2+8VtRDeBJ swCOSB3WK976Yij+9PUTpqn4TwyTnoARzUf2UwXDYE/D+BMyAFywHGqfr6fKx1WeYQ3d FWMNQ1Nqj4i8NUpUA7r2pTa3DHj20+I/6PZOBzmcDYN5yClX+BkY7PdHp76sK7y2ZVdY CCPSss5f/1QjkkRKDeIT7X+h3afet9AUKD7usNdgRvT/1FxU3Fp1idM00ynXi9oPW819 pPRJwTqzyPRc56sC5Ss6EfjrlFWz5smJKCGNhxBGgQLxxCV0Kd1PuZ8GSFme1YR3zYwn pO1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bls+adfd; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o22si31640653edq.400.2021.01.04.07.23.19; Mon, 04 Jan 2021 07:23:44 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=bls+adfd; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727463AbhADPWA (ORCPT + 99 others); Mon, 4 Jan 2021 10:22:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:54976 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727403AbhADPV7 (ORCPT ); Mon, 4 Jan 2021 10:21:59 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 12A9722286; Mon, 4 Jan 2021 15:21:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1609773679; bh=KnCcCfl5Ujo0xeLkI0m9dHw2QY6hrFRxzWMXtqAvrxY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bls+adfd/7XPttxskOXdd0DZvtCeb+LUIOhIrUhnEaaQmJZthY+QbmtdxKkRyJb+I fyHgXJHGiLnaZUPKkncqdC+DMIKr/jmP8HGkD3HF2wIXB/mo5GODrv2rQYXNe5uV8U BWsoQIyWNpF+zAhdDTz/OGLrSTmEwEG0azq+cNxd8aR4nQ1bhnobwYe51Z+6dIe9bm CZsE1zUXnV7YNIq6PlYZuvRKJfHTUUtKACb8XzOh1bcOi8kIo+ldGmCAd42fEscmhq PPrlWy/RTstaGbPRHfRLI3oIp+JL2GvrEneCuzUsFGmnYzF+QpkU5KPoXydmXTHKdR KzBWkGcjahvsw== From: Frederic Weisbecker To: Peter Zijlstra Cc: LKML , Frederic Weisbecker , "Rafael J . Wysocki" , Ingo Molnar , Fabio Estevam , stable@vger.kernel.org, Thomas Gleixner , "Paul E . McKenney" , Len Brown , Pengutronix Kernel Team , NXP Linux Team , Daniel Lezcano , Shawn Guo , Sascha Hauer Subject: [PATCH 4/4] ACPI: processor: Fix missing need_resched() check after rcu_idle_enter() Date: Mon, 4 Jan 2021 16:20:58 +0100 Message-Id: <20210104152058.36642-5-frederic@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210104152058.36642-1-frederic@kernel.org> References: <20210104152058.36642-1-frederic@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Entering RCU idle mode may cause a deferred wake up of an RCU NOCB_GP kthread (rcuog) to be serviced. Usually a wake up happening while running the idle task is spotted in one of the need_resched() checks carefully placed within the idle loop that can break to the scheduler. Unfortunately within acpi_idle_enter_bm() the call to rcu_idle_enter() is already beyond the last generic need_resched() check. The cpu idle implementation happens to be ok because it ends up calling mwait_idle_with_hints() or acpi_safe_halt() which both perform their own need_resched() checks. But the suspend to idle implementation doesn't so it may suspend the CPU with a resched request unhandled, leaving the task hanging. Fix this with performing a last minute need_resched() check after calling rcu_idle_enter(). Reported-by: Paul E. McKenney Reviewed-by: Rafael J. Wysocki Fixes: 1fecfdbb7acc (ACPI: processor: Take over RCU-idle for C3-BM idle) Cc: stable@vger.kernel.org Cc: Len Brown Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Ingo Molnar Signed-off-by: Frederic Weisbecker --- drivers/acpi/processor_idle.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index d93e400940a3..c4939c49d972 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c @@ -604,8 +604,14 @@ static int acpi_idle_enter_bm(struct cpuidle_driver *drv, } rcu_idle_enter(); - - acpi_idle_do_entry(cx); + /* + * Last need_resched() check must come after rcu_idle_enter() + * which may wake up RCU internal tasks. mwait_idle_with_hints() + * and acpi_safe_halt() have their own checks but s2idle + * implementation doesn't. + */ + if (!need_resched()) + acpi_idle_do_entry(cx); rcu_idle_exit(); -- 2.25.1