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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D9B3C433EF for ; Sat, 9 Oct 2021 04:16:57 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id B261F60FD7 for ; Sat, 9 Oct 2021 04:16:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B261F60FD7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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:In-Reply-To:MIME-Version:References: 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=Svk6hrE9oE7wi2FrTpntbVxgHwk9czmt3p+3M2uSLxw=; b=RuNVUCzclKYn9q yHvIV3Q8RaTc4tqBbfFQB4A4s+9EnK/H4VZbowb7KA3k7AG5cy1qHqArgUC148e7hMxl+tSGaTjd/ HGY/o/hbCDwzJqtFAcNPIyHf6oqwGu2YLPPbfyXFJRhrBp1nDPO6baaLyO93YuaI6NAkA9jR9r8du Sugo/S8jdZySjY5b6/hnh/xWA/Pzw69EDuFeiKkDuOrGnUwG6HTyg9NRwDMiQP7ywfkGMBtrlXONv pBVjO+C2rUy8QiZr7eZ+wY/wu7kzHXLHq3bV5Ya6l2GvaL2btsm1dlRRNDWXdbaqyvGdmuMIZrs7L n9biKiPp2oP0w8yl7Pbw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mZ3lJ-0056Mr-Bk; Sat, 09 Oct 2021 04:15:05 +0000 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mZ3lG-0056M9-0i for linux-arm-kernel@lists.infradead.org; Sat, 09 Oct 2021 04:15:03 +0000 Received: by mail-pg1-x52d.google.com with SMTP id m21so4976395pgu.13 for ; Fri, 08 Oct 2021 21:15:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Io2K8Gs5Uy4lV1ustz6eBAsYaKVHMWynGJ6LMeJkvvY=; b=IHlRPDPpGTYdsWbiRJXxD+IxZUcuwj+pvS7dKcfkiRsFOQl8VutpHqvWEHLw4KE/zR 8QsUEbBbybuj0tGLq930M+QzuaBJaTeUyfo12ZqWWf1yRezDlwYCJuJ2lHZ4vkE2Bgqo yQx3BNgxk9YnBTOHv5gpj2L18cUCS1ZyVwqXh2vIvgODtYzP4n64yB3sGTcS9HyBmBlc XiHptpI2NOjjljCG+RSeCwLHt6+7HMdH81Xp7/R+Cu5FVLxDSIIkv0UDVuvwmz22y+8b j82d119YSaWwWOqdjreO/UzC5bP6PaIrxXXzaJanZFnoV0WW4HAxU0gPZVw6O9clGPZp Gggg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Io2K8Gs5Uy4lV1ustz6eBAsYaKVHMWynGJ6LMeJkvvY=; b=wZb5ASPIjuzfutlyKI37J+DfxTJNEGYEV0kIPG5KgNcI80Wm0ddiVd2tR7n3ogPmAF ddHA8buGBUbWCDqZ+i2zu4Q/0U/xtrZd7HMx5c8aaoJS0IbGyB7cDzZ1hVj6gCghJhcR PiGfHEt2jXiZ4TQAHhfUc9Wl+HT7mhAghCWtWc3iuefwbQoQNqbUEB/DMPKRlBsy9Ev9 ikQmC2cNLIWK97gxhnkzn7TsuLb+5xtENBc23ehosLtg2lrLBo7NAJg6YjsdpNPW0WM5 ZSZ63HSmig52qx5Uvx84stLFMeHFeLWJc3n3+7Qe9gN9kLfnUObwLyrSLiU/9deFqx/2 rmyw== X-Gm-Message-State: AOAM532svYqWLSrYMGxlzuu0IE3GqPG+UijSJ2Ykxtew0TlkttG9gD5a uXXv2kLiNsfYj/akX0pK/Q== X-Google-Smtp-Source: ABdhPJwPoU06MU8dcjlX4qmTI9/9eo81W8ghWdb0go400KHtc5KlpLZVwJhxWSWxNfzg1gGq4ckRLw== X-Received: by 2002:a63:b917:: with SMTP id z23mr7811076pge.284.1633752900459; Fri, 08 Oct 2021 21:15:00 -0700 (PDT) Received: from piliu.users.ipa.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id y3sm623228pjg.7.2021.10.08.21.14.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Oct 2021 21:15:00 -0700 (PDT) Date: Sat, 9 Oct 2021 12:14:52 +0800 From: Pingfan Liu To: "Paul E. McKenney" Cc: Mark Rutland , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon , Marc Zyngier , Joey Gouly , Sami Tolvanen , Julien Thierry , Thomas Gleixner , Yuichi Ito , linux-kernel@vger.kernel.org Subject: Re: [PATCHv2 1/5] arm64/entry-common: push the judgement of nmi ahead Message-ID: References: <20210924132837.45994-1-kernelfans@gmail.com> <20210924132837.45994-2-kernelfans@gmail.com> <20210924175306.GB42068@C02TD0UTHF1T.local> <20210930133257.GB18258@lakrids.cambridge.arm.com> <20211008154523.GP880162@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20211008154523.GP880162@paulmck-ThinkPad-P17-Gen-1> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211008_211502_109640_C164421F X-CRM114-Status: GOOD ( 24.30 ) 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 Fri, Oct 08, 2021 at 08:45:23AM -0700, Paul E. McKenney wrote: > On Fri, Oct 08, 2021 at 12:01:25PM +0800, Pingfan Liu wrote: > > Sorry that I missed this message and I am just back from a long > > festival. > > > > Adding Paul for RCU guidance. > > Didn't the recent patch series cover this, or is this a new problem? > Sorry not to explain it clearly. This is a new problem. The acked recent series derive from [3-4/5], which addresses the nested calling: in a single normal interrupt handler rcu_irq_enter() rcu_irq_enter() ... rcu_irq_exit() rcu_irq_exit() While this new problem [1-2/5] is about pNMI (similar to NMI in this context). On arm64, the current process in a pNMI handler looks like: rcu_irq_enter(){ rcu_nmi_enter()} ^^^ At this point, the handler is treated as a normal interrupt temporary, (no chance to __preempt_count_add(NMI_OFFSET + HARDIRQ_OFFSET);). So rcu_nmi_enter() can not distinguish NMI, because "if (!in_nmi())" can not tell it. (goto "questionA") nmi_enter() NMI handler nmi_exit() rcu_irq_exit() [...] > > Refer to rcu_nmi_enter(), which can be called by > > enter_from_kernel_mode(): > > > > ||noinstr void rcu_nmi_enter(void) > > ||{ > > || ... > > || if (rcu_dynticks_curr_cpu_in_eqs()) { > > || > > || if (!in_nmi()) > > || rcu_dynticks_task_exit(); > > || > > || // RCU is not watching here ... > > || rcu_dynticks_eqs_exit(); > > || // ... but is watching here. > > || > > || if (!in_nmi()) { > > || instrumentation_begin(); > > || rcu_cleanup_after_idle(); > > || instrumentation_end(); > > || } > > || > > || instrumentation_begin(); > > || // instrumentation for the noinstr rcu_dynticks_curr_cpu_in_eqs() > > || instrument_atomic_read(&rdp->dynticks, sizeof(rdp->dynticks)); > > || // instrumentation for the noinstr rcu_dynticks_eqs_exit() > > || instrument_atomic_write(&rdp->dynticks, sizeof(rdp->dynticks)); > > || > > || incby = 1; > > || } else if (!in_nmi()) { > > || instrumentation_begin(); > > || rcu_irq_enter_check_tick(); > > || } else { > > || instrumentation_begin(); > > || } > > || ... > > ||} > > > > There is 3 pieces of code put under the > > protection of if (!in_nmi()). At least the last one > > "rcu_irq_enter_check_tick()" can trigger a hard lock up bug. Because it > > is supposed to hold a spin lock with irqoff by > > "raw_spin_lock_rcu_node(rdp->mynode)", but pNMI can breach it. The same > > scenario in rcu_nmi_exit()->rcu_prepare_for_idle(). > > questionA: > > As for the first two "if (!in_nmi())", I have no idea of why, except > > breaching spin_lock_irq() by NMI. Hope Paul can give some guide. > > Thanks, Pingfan _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel