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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 AA107EF8FF4 for ; Wed, 4 Mar 2026 15:03:04 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4fQws26q8xz3c1T; Thu, 05 Mar 2026 02:03:02 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1772636582; cv=none; b=EYy6BlM40jM3fhf8zwqMUmlOLbBMSpB7sP+ibQt8NH74q/NLn9IcWBEdlrFv5I2aDw2l6Zaqpl1UvQF8PSCecLhUUk8doEcIUjvcGa4mU6pMsOxd5fXMAQv2iGZQzRsjwK0TXHm93JP+SaukDidcUgyGN/i/W+rwPteZNeQzHl+Id+st7gpNaGIM+MHRI3GGXpMsmpBN0kqvfTX0EcDMP5O6DGFsVOHYmd3qn8g4ULvCPFTFwhSJ5TFWHE2CiLnXEpNXMfNSKzDBDFu4jP8yX/P8aR17Pa8fsWCb51MjzrsXLdVJeIrwT/1uBeXVwsTPoPCF69vyrst36Yf92EuYWQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1772636582; c=relaxed/relaxed; bh=Z19h6WgrjTCw0z8nSioTBlVzaZSe2HgmhCgm4ck5sz4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Rra0y8Hd3lPE2a630VQ6gUC+cUs/OhBRjJRSYk/Ncg+a2fsje6cjW6jqAhddcpjWva7+G+N1S6dCbj9IuXnnWq+PYXhYZ/RIeBA2PFy2EvzLeRK+aZjqGDlNk0ljBWezFC1M4dxhhp70Rjcc4LioLFS0ghb1uHOoQqw4LvTGCaxLnFM7MZXfOjPgtexxiSZEi1EXEUpIaLafaDK4Zh1BqVwBOrLgJoDO+/iji8whO22nhz8+gvoWMH7UtuJbmsidrJzNfk313ejn8RqLNPS14ZhVvL01BmT/Qti1seQSRHlZU3WzGi7zn78xKHwwnh583tHmUNABt1fsJ+HPQZbTvQ== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=CQs6CI0C; dkim-atps=neutral; spf=pass (client-ip=148.163.158.5; helo=mx0b-001b2d01.pphosted.com; envelope-from=hca@linux.ibm.com; receiver=lists.ozlabs.org) smtp.mailfrom=linux.ibm.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=CQs6CI0C; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.158.5; helo=mx0b-001b2d01.pphosted.com; envelope-from=hca@linux.ibm.com; receiver=lists.ozlabs.org) Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4fQws16gRwz3btw for ; Thu, 05 Mar 2026 02:03:01 +1100 (AEDT) Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 624AhOOk1787677; Wed, 4 Mar 2026 15:01:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to; s=pp1; bh=Z19h6WgrjTCw0z8nSioTBlVzaZSe2H gmhCgm4ck5sz4=; b=CQs6CI0CEBF28d38x3UgoKsWhnkqI02/m7t6ONNbGNxdoc 3m+coBKpl6wNGEU+q2J7atfBmLj3qjNOl/ymmpM0faaO7/q3OUsVvIzNRfwLS+hc K+xHcf8KsWDQuntrHaohVLUNM/p2a/1KUM8ftLbS16eUDGJO8AlbdBYhjaDZpSHm Ucr1VYuZHV06cOpANC+jRZ19DHDZlYqcLvmp2fGEQdVjD+5Ri1FQ+sA6An98fbKv gQk6yZCFuwKIw5vSN/TmxnQk10MMSY73WWSJYsTjSjEDWeXvMjGPnRUCMgjQNGv/ h+NRpjv/31gLWcbdYVindpkNHA6ypdPBLELXPs6w== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4ckssmqfge-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Mar 2026 15:01:51 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 624E81GF003266; Wed, 4 Mar 2026 15:01:50 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4cmb2y77mx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Mar 2026 15:01:50 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 624F1kew29885020 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 4 Mar 2026 15:01:46 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 775D420043; Wed, 4 Mar 2026 15:01:46 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A172120040; Wed, 4 Mar 2026 15:01:43 +0000 (GMT) Received: from osiris (unknown [9.111.25.254]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTPS; Wed, 4 Mar 2026 15:01:43 +0000 (GMT) Date: Wed, 4 Mar 2026 16:01:42 +0100 From: Heiko Carstens To: Eric Biggers Cc: Christoph Hellwig , Peter Zijlstra , Andrew Morton , Richard Henderson , Matt Turner , Magnus Lindholm , Russell King , Catalin Marinas , Will Deacon , Huacai Chen , WANG Xuerui , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , "Christophe Leroy (CS GROUP)" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , "David S. Miller" , Andreas Larsson , Richard Weinberger , Anton Ivanov , Johannes Berg , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Herbert Xu , Dan Williams , Chris Mason , David Sterba , Arnd Bergmann , Song Liu , Yu Kuai , Li Nan , linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, linux-um@lists.infradead.org, linux-crypto@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-arch@vger.kernel.org, linux-raid@vger.kernel.org Subject: Re: [PATCH 01/25] xor: assert that xor_blocks is not called from interrupt context Message-ID: <20260304150142.10892A0b-hca@linux.ibm.com> References: <20260226151106.144735-1-hch@lst.de> <20260226151106.144735-2-hch@lst.de> <20260227142455.GG1282955@noisy.programming.kicks-ass.net> <20260303160050.GB7021@lst.de> <20260303195517.GC2846@sol> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260303195517.GC2846@sol> X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA0MDExOCBTYWx0ZWRfXxUsUtXWxLU0g tOf9MkgFvTvS3iU6cDfKOn4aNolsTtOVPcZcXf1hUWj5wzTqP1Jl3+/Pm1cQVpOnkbFqwFNMhf6 s+RzCypo6nWpEuKNhutPo8iGmRcRoJdPPeW2AHlivR0pa3WvG7MuKg6LhCcWrG1WOM0rkgfm19k qgAb59DROFK7ep/NcAuDgpnw0JZPbBrXcLu+FzFLE1z/pziDLja646pVdwK+IBBTRDR1FQEcZJp lfowdfxrkcZzLwHH+LflcIL8dIXBqbnVe5qsIr2WyyWonlYBWIkG2NU4qQkn3RkrdFvpk5bMnfx y6ZnU/ob1zljXV+Bvs7eICxTvlTjJerN5LTcEbwG9785zRtEi8PpmmpjVgPHHt/QSDnTPmdU2FM ORBAnPiiMlkrZ3OuR96PF0PhhS06e2TRrNxeZd60P8WuqA8hDS63eVa4RHuW0mUSWw36XnZPzR1 yRlWiLRJO8vVTj1uMIQ== X-Proofpoint-ORIG-GUID: 3wYtRTuLNljAHWLrazsX9evHAr6tDNHS X-Proofpoint-GUID: tYQX-PAFkE56knElIo5jilP_p3jXLSWx X-Authority-Analysis: v=2.4 cv=AobjHe9P c=1 sm=1 tr=0 ts=69a84960 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=kj9zAlcOel0A:10 a=Yq5XynenixoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=CCDUfiGXGlpCvJ-ZZpMA:9 a=CjuIK1q_8ugA:10 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-04_06,2026-03-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 lowpriorityscore=0 bulkscore=0 impostorscore=0 malwarescore=0 spamscore=0 clxscore=1015 suspectscore=0 adultscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2602130000 definitions=main-2603040118 On Tue, Mar 03, 2026 at 11:55:17AM -0800, Eric Biggers wrote: > On Tue, Mar 03, 2026 at 05:00:50PM +0100, Christoph Hellwig wrote: > > On Fri, Feb 27, 2026 at 03:24:55PM +0100, Peter Zijlstra wrote: > > > > unsigned long *p1, *p2, *p3, *p4; > > > > > > > > + WARN_ON_ONCE(in_interrupt()); > > > > > > Your changelog makes it sound like you want: > > > > > > WARN_ON_ONCE(!in_task()); > > > > > > But perhaps something like so: > > > > > > lockdep_assert_preempt_enabled(); > > > > > > Would do? That ensures we are in preemptible context, which is much the > > > same. That also ensures the cost of this assertion is only paid on debug > > > kernels. > > > > No idea honestly. The kernel FPU/vector helpers generally don't work > > from irq context, and I want to assert that. Happy to do whatever > > version works best for that. > > may_use_simd() is the "generic" way to check "can the FPU/vector/SIMD > registers be used". However, what it does varies by architecture, and > it's kind of a questionable abstraction in the first place. It's used > mostly by architecture-specific code. > > If you union together the context restrictions from all the > architectures, I think you get: "For may_use_simd() to be guaranteed not > to return false due to the context, the caller needs to be running in > task context without hardirqs or softirqs disabled." > > However, some architectures also incorporate a CPU feature check in > may_use_simd() as well, which makes it return false if some > CPU-dependent SIMD feature is not supported. Oh, interesting. I wasn't aware of may_use_simd(), and of course this is missing on s390, and hence we fallback to the generic !in_interrupt() variant. In fact the s390 simd implementation allows for usage in any context, also interrupt context. So the s390 implementation of may_use_simd() would always return true, _except_ for the feature check you mention. Let me try to change that and see if anything explodes. > Because of that CPU feature check, I don't think > "WARN_ON_ONCE(!may_use_simd())" would actually be correct here. > > How about "WARN_ON_ONCE(!preemptible())"? I think that covers the union > of the context restrictions correctly. (Compared to in_task(), it > handles the cases where hardirqs or softirqs are disabled.) I guess, this is not true, since there is at least one architecture which allows to run simd code in interrupt context (but which missed to implement may_use_simd()).