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 X-Spam-Level: X-Spam-Status: No, score=-4.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A8ADC4338F for ; Thu, 29 Jul 2021 16:07:58 +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 CEA0360241 for ; Thu, 29 Jul 2021 16:07:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CEA0360241 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linutronix.de 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=w1ai+JDwNeH994AjzJu/PxNGLqwesDpv1CEmLseUQmc=; b=Vvckit6FWX1DRk Bk7K8FHWms0WXek26stinnnCPQgKa3WUsFYd4Jrf2KvF7Jj5Y2Fu0lGNQeatRyzOxIIxYHx1RJLDE r7fffbRWwFfF08VBFBAc3ixYo3IOJLkyrkf3t1lPM6vA0jSZY2kK4zFz/vE4AY9rYPyAH1mhPPeJL 9JnKIxMVjEQ7kglsWGa2R821I5vRiBhg+a5Md2OZaac/E+Q5Gx18lw871kGfP/aLy44v/VDDvnATN gmayuf82hhf/Q9oc81uyX8sV9L3aT27DpwPKcevjVBgZphi3SqVy0G4TCMwTqilZpeMOM8E9q5XLY r2bAoUdO3Qg1fUAKEZuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m98XV-004wRJ-Dp; Thu, 29 Jul 2021 16:05:42 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m98SY-004tDt-FH for linux-arm-kernel@lists.infradead.org; Thu, 29 Jul 2021 16:00:36 +0000 Date: Thu, 29 Jul 2021 18:00:30 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1627574431; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Po97hmTAFZTN10+bmmExcMr6YAmCZDZsDwlsPsBx3GU=; b=Hu4WyxPieS9y133dcD17lpbY3VwcJT/dIdcOiizCPl0uv2qrAKIXkh8R+xa/1fDVwP+Kqu FZ3oMLiN+D8yIG3CQX6HVKvEICALR9V1ZK/rscd7p5ztSTbGPStci72sXToQ7kQmuTkIWg e1cRiRqc9zo+QPgEeeNyclAdLuwgjLf6rHc3DzGcH6GL7RIi/exqTjFxco2mcQRvFQsOHu i8wcLaPF28PDyTEYer2ehpEXKuOplHEgnQkEk0C1fI/9PsJpeQU/hTw6NCm4T94rJkFZtv 4ZaAnNkaZUotRt/zfarWWA8N+iukPq1agmlJ5/oIPXD1AwKrBLXBtfnDUZoL1w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1627574431; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Po97hmTAFZTN10+bmmExcMr6YAmCZDZsDwlsPsBx3GU=; b=gUtaxH9ETQ10Ft0YLOT2aFP0HPyOBFP4TzjGDBGGcCv98htTNyeo/kvlNScjCE+C6kM9eX eju+K1ZaLmZDvkDw== From: Sebastian Andrzej Siewior To: Dave Martin Cc: linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon , Thomas Gleixner Subject: Re: [PATCH] arm64/sve: Make kernel FPU protection RT friendly Message-ID: <20210729160030.p76p56r56vx4qoql@linutronix.de> References: <20210729105215.2222338-1-bigeasy@linutronix.de> <20210729105215.2222338-3-bigeasy@linutronix.de> <20210729135459.GL1724@arm.com> <20210729141748.q66pfjoma2a2qd2k@linutronix.de> <20210729153422.GN1724@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210729153422.GN1724@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210729_090034_721021_1EA02089 X-CRM114-Status: GOOD ( 22.29 ) 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 2021-07-29 16:34:22 [+0100], Dave Martin wrote: > > That rather suggests to me that it is worth factoring this and giving it > a name, precisely because irrespectively of CONFIG_PREEMPT_RT, we need to > make sure that to task swtich _and_ no bh runs on the same cpu. The > problem seems to be that the local_bh_disable() API doesn't express the > difference between wanting to prevent local bh processing and wanting to > prevent local bh _and_ task switch. > > So, could this be wrapped up and called something like: > > preempt_and_local_bh_disable() > ... > local_bh_and_preempt_enable()? We don't disable both on RT. It is preemption on RT and BH + implicit preemption on non-RT. The difference is that on RT a softirq may have been preempted and in this case get_cpu_fpsimd_context() won't force its completion. However since get_cpu_fpsimd_context() disables preemption on RT it won't be preempted in the section where the SIMD registers are modified. And the softirq does not run on HARDIRQ-exit but in task context so it is okay. But I get what you mean. I'm just not sure regarding the naming since the code behaves the same on x86 and arm64 here. > I do wonder whether there are other places making the same assumption > about the local_irq > local_bh > preempt hierarchy that have been > missed... Based on memory we had a few cases of those while cleaning up in_atomic(), in_softirq() and friends. > > > If bh (as a preempting context) doesn't exist on RT, then can't > > > local_bh_disable() just suppress all preemption up to but excluding > > > hardirq? Would anything break? > > > > Yes. A lot. Starting with spin_lock_bh() itself because it does: > > local_bh_disable(); > > spin_lock() > > > > and with disabled preemption you can't do spin_lock() and you have to > > because the owner may be preempted. The next thing is that kmalloc() and > > friends won't work in a local_bh_disable() section for the same reason. > > Couldn't this be solved with a trylock loop that re-enables bh (and > preemption) on the sleeping path? But that may still be trying to > achieve something that doesn't make sense given the goals of > PREEMPT_RT(?) What about spin_lock_bh(a); spin_lock_bh(b); ? And then still you can't kmalloc() in a spin_lock_bh() section if you disable preemption as part of local_bh_disable( if you disable preemption as part of local_bh_disable()). > Cheers > ---Dave Sebastian _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel