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 F0233C7618E for ; Sat, 22 Apr 2023 15:04:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229884AbjDVPEe (ORCPT ); Sat, 22 Apr 2023 11:04:34 -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: 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(); }