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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4F288C433F5 for ; Tue, 30 Nov 2021 14:18:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=EU3sUW7YaT3f0KzlLhyjO7J4yIZKWrlLQB0dgylJ6ow=; b=UV6YtxpJTlYM0k wEPO4npmFuEtER+fxBue9xN80cHpzT2CzZlN/Y4bnrvdEP31uB7N1iIgHadUdPFTly8bI68aB2HLL KtgxZvKlzOYmf907YGbX90Jk4odI4Vv1/mc99n2p+Wt87fEpbePUC1JC6ffv7q5nrHep9errIRLJj Iwk8IsGT2ie24yd0NK20sflOGee5yXlGuY7bNjbAK+ceGZyGZ/Wgt9g4qbtxEXUPPH2ScGe5rC9HP edNE+DpgqA2vcG9op6CJxwb547IUh9NB2AGtvNnGqvQVSuLzK3dXkkS282CqypPcrdQqsuLoa6RgG eK5vEdnAZtKlAbQj0R/g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ms3vv-005YC2-3m; Tue, 30 Nov 2021 14:16:35 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ms3tT-005XEr-HG for linux-arm-kernel@lists.infradead.org; Tue, 30 Nov 2021 14:14:05 +0000 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 sin.source.kernel.org (Postfix) with ESMTPS id 2ED49CE1A21; Tue, 30 Nov 2021 14:14:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67DC7C53FC1; Tue, 30 Nov 2021 14:13:58 +0000 (UTC) Date: Tue, 30 Nov 2021 09:13:56 -0500 From: Steven Rostedt To: Thomas Gleixner Cc: Nicolas Saenz Julienne , linux-kernel , linux-arm-kernel , rcu@vger.kernel.org, Peter Zijlstra , Mark Rutland , paulmck@kernel.org, mtosatti , frederic Subject: Re: Question WRT early IRQ/NMI entry code Message-ID: <20211130091356.7336e277@gandalf.local.home> In-Reply-To: <875ys9dacq.ffs@tglx> References: <8719ad46cc29a2c5d7baac3c35770e5460ab8d5c.camel@redhat.com> <875ys9dacq.ffs@tglx> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211130_061403_825106_FDCC8CA5 X-CRM114-Status: GOOD ( 20.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 30 Nov 2021 14:47:01 +0100 Thomas Gleixner wrote: > The reason is symmetry vs. returning from interupt / exception: > > irqentry_enter() > exit_rcu = false; > > if (user_mode(regs)) { > irqentry_enter_from_user_mode(regs) > __enter_from_user_mode(regs) > user_exit_irqoff(); <- RCU handling for NOHZ full > > } else if (is_idle_task_current()) { > rcu_irq_enter() > exit_rcu = true; > } > > irq_enter_rcu() > __irq_enter_raw() > preempt_count_add(HARDIRQ_OFFSET); > > irq_handler() > > irq_exit_rcu() > preempt_count_sub(HARDIRQ_OFFSET); > if (!in_interrupt() && local_softirq_pending()) > invoke_softirq(); > > irqentry_exit(regs, exit_rcu) > > if (user_mode(regs)) { > irqentry_exit_to_usermode(regs) > user_enter_irqoff(); <- RCU handling for NOHZ full > } else if (irqs_enabled(regs)) { > if (exit_rcu) { <- Idle task special case > rcu_irq_exit(); > } else { > irqentry_exit_cond_resched(); > } > > } else if (exit_rcu) { > rcu_irq_exit(); > } > > On return from interrupt HARDIRQ_OFFSET has to be removed _before_ > handling soft interrupts. It's also required that the preempt count has > the original state _before_ reaching irqentry_exit() which > might schedule if the interrupt/exception hit user space or kernel space > with interrupts enabled. > > So doing it symmetric makes sense. > > For NMIs the above conditionals do not apply at all and we just do > > __nmi_enter() > preempt_count_add(NMI_COUNT + HARDIRQ_COUNT); > rcu_nmi_enter(); > > handle_nmi(); > > rcu_nmi_exit(); > __nmi_exit() > preempt_count_sub(NMI_COUNT + HARDIRQ_COUNT); > > The reason why preempt count is incremented before invoking > rcu_nmi_enter() is simply that RCU has to know about being in NMI > context, i.e. in_nmi() has to return the correct answer. Seems like there should be a comment in the code somewhere that explains this. -- Steve _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel