Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp3600224rwr; Sat, 22 Apr 2023 08:06:14 -0700 (PDT) X-Google-Smtp-Source: AKy350ZfmuuYshjPVYaT95W4IXHnC5sNWqG3gH/1EKiJ8xWtK++GD35zSVKi2MQVl2/zFU8uMV0c X-Received: by 2002:a17:902:e544:b0:1a6:cf4b:4d7d with SMTP id n4-20020a170902e54400b001a6cf4b4d7dmr10335539plf.2.1682175973729; Sat, 22 Apr 2023 08:06:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682175973; cv=none; d=google.com; s=arc-20160816; b=cv9h7LWZxLgyWW52Ticu62P1EwUJ1GSyxSdPZ07fsYgMF1Mp4LZ/sSTPTE0j0Qm9FU po0dgpQC40uqi/jo4lscMphbjJ0274qMk9QcMaUL7XZ/OZZfz7aUefXtJLOnkTCtrSO7 4veKsyVD6PNw3x3G+uA+CmpUuEiyHzARQJmir4unEjsoDins+MwvM0n7w1VNEZCWLfLd NHNIT1LJC9EdebWTy69hRZxNaDfeDqT52NSmnEDtwarO/+2VKYbhZ36afVFmkZ+GseLA +da96aIsXN5qdPKedEGM9VRu6Wkoe4zwgwDNfNc3Lw/Ve7ERkaHHeyUFjGRd4HbBkI3F 9WoQ== 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=Dh78r88+5qqvJ46/gebWeTgNCDzInpaJstd9OEj2z8A=; b=VTG2BUWnspN9/Y87kF9lq2qThdbnVHGezzFaQVC9lVvixxH3I1ses4B5x3Pqh2AkXK pvOGOBW2TRmM/8SOu62HenNCxVbkI4o/vZUoZjp4DRsP2SnfeYjqTK4jmMR7ZEgTf1Gp BRxfBkpo4FdxUUII5L0NBqoGTrx1uiSH7MUraLj6FLGzmrB/iEi9vS+eGiT6Qkjj9FKu EgPJRfow2Kc6tkkVpSKm9sbbrMNQJ6MSWPWlChGqrZTm8a+jYbs/9TaXbwnCvqYJwgmJ Q8NY+whMqaQDxjoPyyxuBuLu+y8Cb9937dokW/jruxEhZpvivebY+09UZJ+qX4b8a47B 44bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lqZcPBL8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mu1-20020a17090b388100b002467d05c498si7597392pjb.69.2023.04.22.08.05.42; Sat, 22 Apr 2023 08:06:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lqZcPBL8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229825AbjDVOss (ORCPT + 99 others); Sat, 22 Apr 2023 10:48:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229451AbjDVOsp (ORCPT ); Sat, 22 Apr 2023 10:48:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 882F21723 for ; Sat, 22 Apr 2023 07:48:44 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 264FF60670 for ; Sat, 22 Apr 2023 14:48:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CF3EC433EF; Sat, 22 Apr 2023 14:48:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682174923; bh=O4rgEkLJmewMNmbBssn0vGFbxV4mGZy57G3IusOA+d4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lqZcPBL8IbGvxblXaJir3U/7j7Th8Z0ZUNwtLiX+mu1NTyR92gnv+oVooKTlWFGXw TE2Ie9ei/NV0ezt2Kz/BR/aTkhEvfK6+wGWqLWQwiZYnct+jfN7YfFnGiRLaA6ivcu i7qsh1uVzVP20SPhtRLzO7N7GBfL1L27eDT73Lbq2fXTtzyYRdL6lgs/ICzOX+SXUL 1+HgW4aMfoHY2jeAxoxRm/OaYXgPml94ODZGqn5OvmPoVoNwyjSTHGG4zz7Gk3amGn 426tUePWmgRH2Xjm5s6nHovp2guapp+rn0N++15/0OwXHuMffKXwLTVfF/AWA6U5BJ 02kyvVnRtWs+A== Date: Sat, 22 Apr 2023 16:48:40 +0200 From: Frederic Weisbecker To: Peter Zijlstra Cc: Huacai Chen , WANG Xuerui , Thomas Gleixner , "Rafael J. Wysocki" , Anna-Maria Behnsen , LKML Subject: Re: Loongson (and other $ARCHs?) idle VS timer enqueue Message-ID: References: <20230421142446.GA1185829@hirez.programming.kicks-ass.net> <20230422080814.GA1214746@hirez.programming.kicks-ass.net> <20230422113811.GB1215777@hirez.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: <20230422113811.GB1215777@hirez.programming.kicks-ass.net> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org eeLe Sat, Apr 22, 2023 at 01:38:11PM +0200, Peter Zijlstra a ?crit : > On Sat, Apr 22, 2023 at 10:08:14AM +0200, Peter Zijlstra wrote: > > On Fri, Apr 21, 2023 at 06:47:29PM +0200, Frederic Weisbecker wrote: > > > > > > *HOWEVER* > > > > > > > > intel_idle_irq() is affected -- except that we only (normally) use that > > > > for very shallow idle states and it won't interact with NOHZ (because we > > > > only disable the tick for deep idle states). > > > > > > Well I don't know, that doesn't look comfortable... :) > > > > > > Also why does it need to enable IRQs if ecx=1 ? > > > > Supposedly this is some interrupt latency hack. See commit: > > > > c227233ad64c ("intel_idle: enable interrupts before C1 on Xeons") > > Something like so perhaps... > > diff --git a/arch/x86/include/asm/mwait.h b/arch/x86/include/asm/mwait.h > index 778df05f8539..07a4072c43de 100644 > --- a/arch/x86/include/asm/mwait.h > +++ b/arch/x86/include/asm/mwait.h > @@ -115,8 +115,14 @@ static __always_inline void mwait_idle_with_hints(unsigned long eax, unsigned lo > } > > __monitor((void *)¤t_thread_info()->flags, 0, 0); > - if (!need_resched()) > - __mwait(eax, ecx); > + if (!need_resched()) { > + if (ecx & 1) { > + __mwait(eax, ecx); > + } else { > + __sti_mwait(eax, ecx); > + raw_local_irq_disable(); > + } > + } Yep that looks good! Thanks!