From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A240C072A2 for ; Wed, 15 Nov 2023 15:57:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231810AbjKOP5v (ORCPT ); Wed, 15 Nov 2023 10:57:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231511AbjKOP5t (ORCPT ); Wed, 15 Nov 2023 10:57:49 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D0C3A2 for ; Wed, 15 Nov 2023 07:57:46 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96A48C433C7; Wed, 15 Nov 2023 15:57:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700063865; bh=bs8jJhi9NjZvhbt3lOoxsn0RaQ6GU0zuz33zw7GNIFI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Kk4dOkdituq8WX4i20BJeGMebva2citeKL0dKBRnThQr9wftZjliVqB+L3wCbY2iw e+KdUNVrIwDxX8UnxcmKon4k8xWWqbHFCeIOUN0eLKq0azgnNh9NSvYwk5kHVIHUsv QpRcxPYMC0TnFeHQngIU6teVp3/1AG7+PNHAqlnN+roRUWmU9ZTaAk2dElGKDIVBbX LMKCyjE5hvO/lXn328rEA7XM5DmSPJdmH/KEu1o/XBzBND/eJKH27Zxqlwj6t0EgqN hjyqxQ9iqGrYJ29OdIa+E/hycxOlt3Siei1kvi6rt7r6jWr42TaJlNxrGx7j5PRxep nc0dZrubLr1vg== Date: Wed, 15 Nov 2023 10:57:44 -0500 From: Frederic Weisbecker To: Peter Zijlstra Cc: LKML , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "Rafael J . Wysocki" Subject: Re: [PATCH 2/4] x86: Fix CPUIDLE_FLAG_IRQ_ENABLE leaking timer reprogram Message-ID: References: <20231115151325.6262-1-frederic@kernel.org> <20231115151325.6262-3-frederic@kernel.org> <20231115155232.GD8262@noisy.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231115155232.GD8262@noisy.programming.kicks-ass.net> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le Wed, Nov 15, 2023 at 04:52:32PM +0100, Peter Zijlstra a écrit : > On Wed, Nov 15, 2023 at 10:13:23AM -0500, Frederic Weisbecker wrote: > > From: Peter Zijlstra > > > > intel_idle_irq() re-enables IRQs very early. As a result, an interrupt > > may fire before mwait() is eventually called. If such an interrupt queues > > a timer, it may go unnoticed until mwait returns and the idle loop > > handles the tick re-evaluation. And monitoring TIF_NEED_RESCHED doesn't > > help because a local timer enqueue doesn't set that flag. > > > > The issue is mitigated by the fact that this idle handler is only invoked > > for shallow C-states when, presumably, the next tick is supposed to be > > close enough. There may still be rare cases though when the next tick > > is far away and the selected C-state is shallow, resulting in a timer > > getting ignored for a while. > > > > Fix this with using sti_mwait() whose IRQ-reenablement only triggers > > upon calling mwait(), dealing with the race while keeping the interrupt > > latency within acceptable bounds. > > > > Fixes: c227233ad64c (intel_idle: enable interrupts before C1 on Xeons) > > Not-yet-signed-off-by: Peter Zijlstra > > Feel free to change to normal SOB, I'm assuming it actually compiles and > works by now :-) Not sure, I might have tested it at some point ;-) Thanks!