Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp2689435rdb; Wed, 15 Nov 2023 07:58:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IFNBsufKA3yhEtAwvsEv1tj+sxKMZ/QOYE0SF3ZD3rHaWfB1gCq+9omKdQqZQYmguf8ce9/ X-Received: by 2002:a17:902:da8a:b0:1cc:686a:4120 with SMTP id j10-20020a170902da8a00b001cc686a4120mr6646855plx.55.1700063885597; Wed, 15 Nov 2023 07:58:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700063885; cv=none; d=google.com; s=arc-20160816; b=FakgSa+z0ghSk1HDRgkORlEq6zWa24vH2ZHTjVNmVkig8J9HVn/ORTXqiTEsF3lt3J H8pS0VEbF6y/dotgJIaCXfpX4v/IvuKZUHU7YWG/RuDQtCQV7seL7vbGgCk/0ObRMDTU RQW0hhX/buaGbtfFUatX2nSWpugHDOkVx+gC9NzJLgLyhFsiGS1wjh6EsVt8hV98x4U4 UR0tzNJ7CyieREMeRVKzs/0lCwddcpYO09mgPljA1USU7j5AmzHiAhRbQ1aTlN2Xz7w6 JTJs+hQvyLnXN1Sa+p1TOjIaX3OtFgCnjBWthxXjvOWNw7k5j2p0liXOYN1VJZfRC7oO IejA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=UnivPfx9QWaMzLcJ+QUyJeO2kApXl9HyWKaS1fxgSkk=; fh=hOrYZMVHpjYX4qdSvyslvtocqyeiZbjRsqNckK9HsoE=; b=DTur8mX3pqWJjXQLng2LIC35ON9FydUxjvr/KDrVWDTC1Uz73K5IWrK4IeXa4CPk6o 9h7LAhsiqq5SW2PRR3Vwaqu+7//bPxZGKglDzMZ22cfETu4tgwOFMXXG7EroClydyJPM ideEeAgIUxYgaNViIIbp+SzJD7V9YwtfNt8H8FQsffebsdF08ln5VZ7OaQl2PRiX9173 xK1wJEOnL95aFcVBBCXAnNRboVygRz/1H/3TmbhUJZFmSZes22hi3VL5A4bL4T5JCxks IKGpkQVmoP3Ypj7MzGo5CPkND0SUUdey/pgV0uV/tnKw7te4uTsv/OKE7qc4bGE6cWmq gn8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Kk4dOkdi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id x21-20020a170902821500b001c755810f80si9819130pln.28.2023.11.15.07.58.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 07:58:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Kk4dOkdi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 10B0C80CFD09; Wed, 15 Nov 2023 07:58:03 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231668AbjKOP5u (ORCPT + 99 others); Wed, 15 Nov 2023 10:57:50 -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> X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 15 Nov 2023 07:58:03 -0800 (PST) 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!