Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp3610614rwr; Sat, 22 Apr 2023 08:14:55 -0700 (PDT) X-Google-Smtp-Source: AKy350Y4SqHV1VDQFQ3j1HFvtqGekqQ+CBSt7kV+mqrC3Botv8HvBm6y6YVV/6+IKMEV/9R/aTG5 X-Received: by 2002:a05:6a20:3d20:b0:f2:15f7:a7f8 with SMTP id y32-20020a056a203d2000b000f215f7a7f8mr10305922pzi.2.1682176494627; Sat, 22 Apr 2023 08:14:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682176494; cv=none; d=google.com; s=arc-20160816; b=0CJ+KN8gmvB22q+FN2MFiz1ajak/Jom96Njnn+U/qOVe8WEjAN32CcHMzQySrc1pkJ 3x2GfEojRUJ1iGbm164YbF4+qj6ueIuwdxCSdq9m4Mb+iy7TAOm74lMgko8NFd6mZOoU p3j2x/fFW68LJzd1FlRVfnMf2pPQpV4eIvbhd/aNLdYs6Lyh/jKz1eoUkvnDywSpWP0O DuB5V3Nyq+P8cd9E51Yfueb7DMt62o1yVEED1DNttTABvT9twBolAbe2Mfjx1YvGhh4F 6EaU0NCJz7z3hgmad7zY+WJwcHiM1lfX4E71KebmsMV8ninOlDN1k1YrA3IBEgJ7PtBk RNEw== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=e7NZCjbPVKi0/f20JwNEha0Xa8ShkuoZ6+XGb+MgtoI=; b=MGN2KJgMcMbx52eCuyAW9CRdzL5mYJD8DZFmhVBNhQlQfkIHJTyynA57Me/2+KjUwE FQHEs44BWNQFBGFKtcMmajY8xrksasESL8yjTzPdNI8AhpPDkaJDOYncOFNnKcSzQIng zlqI7yVjwbmpdUiKI6tHr9+RpagsRnzK6mqJ6gCq+UB+5z2eUxnoPbMe3QM15cTZq9Cm AWEfk05+uNzBsFH9v6rXAiqtI7I+zrNSxEqfYaVm6f2lG83sos2iKAFfsPF6cZAP0KaO ZKdUbML7Z/+8lnL5URsF6+6VYwYQTjin60cZFLv1Esbkfnh3iedXJmHeJimSd4i7AxXc V+ZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=hfPkSrfb; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b3-20020a63e703000000b0050c164c8e99si6962790pgi.436.2023.04.22.08.14.28; Sat, 22 Apr 2023 08:14:54 -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=@infradead.org header.s=casper.20170209 header.b=hfPkSrfb; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229867AbjDVPEd (ORCPT + 99 others); Sat, 22 Apr 2023 11:04:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229556AbjDVPEc (ORCPT ); Sat, 22 Apr 2023 11:04:32 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 939311BC2 for ; Sat, 22 Apr 2023 08:04:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=e7NZCjbPVKi0/f20JwNEha0Xa8ShkuoZ6+XGb+MgtoI=; b=hfPkSrfbXtZ2uC4kHA+nkugca/ sh4tGYA456nSjGuJ4hMGGLa2EKC1QBBva2IwZExCMT99mK9xFgd0O1ixx9cywOzZ83HtxR1g5U0OH +alJdjLcdyXvXwXuyEFyJnezjrFASvix52r2zMiKJ+Aq1X2FgG0hhP9XV/Mfh9zjFXPk55EmiCo9f QXXQBb6ZibK/TjM0oRRCsy4ckM8R9ec0Wb6eNwQcw8CVuVsU0XGqDeNuOgJ3evB/d8Kyv3TMv9a9/ cPr7HZ4FVCzpzubn6paxtLSmw5ec+UJDNOAjvdLoNpMO5vbpyx6uF3PqwWV97xk7djGKxOWE8xW05 2AyAtdkw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pqEmZ-00GJLV-Vv; Sat, 22 Apr 2023 15:04:12 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id A41F13000DC; Sat, 22 Apr 2023 17:04:09 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 495C720979C18; Sat, 22 Apr 2023 17:04:09 +0200 (CEST) Date: Sat, 22 Apr 2023 17:04:09 +0200 From: Peter Zijlstra To: Frederic Weisbecker Cc: Thomas Gleixner , Huacai Chen , WANG Xuerui , "Rafael J. Wysocki" , Anna-Maria Behnsen , LKML Subject: Re: Loongson (and other $ARCHs?) idle VS timer enqueue Message-ID: <20230422150409.GL1214746@hirez.programming.kicks-ass.net> References: <87leil2r7v.ffs@tglx> <20230422081700.GB1214746@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 On Sat, Apr 22, 2023 at 04:21:45PM +0200, Frederic Weisbecker wrote: > On Sat, Apr 22, 2023 at 10:17:00AM +0200, Peter Zijlstra wrote: > > diff --git a/arch/loongarch/kernel/genex.S b/arch/loongarch/kernel/genex.S > > index 44ff1ff64260..5a102ff80de0 100644 > > --- a/arch/loongarch/kernel/genex.S > > +++ b/arch/loongarch/kernel/genex.S > > @@ -40,6 +40,7 @@ SYM_FUNC_START(handle_vint) > > ori t0, t0, 0x1f > > xori t0, t0, 0x1f > > bne t0, t1, 1f > > + addi.d t0, t0, 0x20 > > LONG_S t0, sp, PT_ERA > > 1: move a0, sp > > move a1, sp > > But the interrupts are enabled in C from arch_cpu_idle(), which > only then calls the ASM __arch_cpu_idle(). So if the interrupt happens > somewhere in between the call, the rollback (or fast-forward now) > doesn't apply. > > I guess interrupts need to be re-enabled from ASM in the beginning > of __arch_cpu_idle() so that it's part of the fast-forward region. Right; something like so I suppose, but at this point I'm really just guessing... Loongarch person will have to do. diff --git a/arch/loongarch/kernel/genex.S b/arch/loongarch/kernel/genex.S index 44ff1ff64260..4814ac5334ef 100644 --- a/arch/loongarch/kernel/genex.S +++ b/arch/loongarch/kernel/genex.S @@ -19,13 +19,13 @@ .align 5 SYM_FUNC_START(__arch_cpu_idle) /* start of rollback region */ + move t0, CSR_CRMD_IE + csrxchg t0, t0, LOONGARCH_CSR_CRMD LONG_L t0, tp, TI_FLAGS nop andi t0, t0, _TIF_NEED_RESCHED bnez t0, 1f nop - nop - nop idle 0 /* end of rollback region */ 1: jr ra @@ -40,6 +40,7 @@ SYM_FUNC_START(handle_vint) ori t0, t0, 0x1f xori t0, t0, 0x1f bne t0, t1, 1f + addi.d t0, t0, 0x20 LONG_S t0, sp, PT_ERA 1: move a0, sp move a1, sp diff --git a/arch/loongarch/kernel/idle.c b/arch/loongarch/kernel/idle.c index 0b5dd2faeb90..5ba72d229920 100644 --- a/arch/loongarch/kernel/idle.c +++ b/arch/loongarch/kernel/idle.c @@ -11,7 +11,6 @@ void __cpuidle arch_cpu_idle(void) { - raw_local_irq_enable(); __arch_cpu_idle(); /* idle instruction needs irq enabled */ raw_local_irq_disable(); }