Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1060936lqt; Tue, 19 Mar 2024 11:24:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUMvsDC1MScnKmgqR3buU8boyfFktCVrQngJjTDjNNFNRTh/ODmeIEtPV85b66a5snd0FrfUEvKWDk8WU034IeEBcejVbhcHEsBdaz5pA== X-Google-Smtp-Source: AGHT+IH2xMFDfYcGCi7jxHjmDHmMtSqfrUwLOGeMksP8WHSku4hL2kQwtCUErZd4KHI0CmFLZguy X-Received: by 2002:a05:6a20:9596:b0:1a3:6fbb:e31f with SMTP id iu22-20020a056a20959600b001a36fbbe31fmr4720747pzb.4.1710872665123; Tue, 19 Mar 2024 11:24:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710872665; cv=pass; d=google.com; s=arc-20160816; b=T4OIl4ajfkotgNweuuhSAgBjGPi1p/RLO056rczZB0Elni8TQaufxMGHAqK3DZlgGM H3i+rYyJsAF3oSEIyzcD5LemUDOFhu0/pN9prHvpmXjqcHG+oWHu3XZrDC+OHeP9Xdhw GLfqYTcSlWe0qmEouqsj0iiurOhe+dxn4xyK2qSZlKiGKPtRxO0FWuQqutqRo6nqbIIe FSkVLE0df7N/By39ti2QwUs0nEoXt0Rv3xzAwb9NjdIrAin+82gmd5/Xmi6/mBHd3H2j FuHl/czxg0BIs623bQfsXRTSwi+gN4BcyNh5pkoQ7VTe6Bd8TfuTgzXNqi5F3owCrF5p d/Cw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:dkim-signature :dkim-signature:date; bh=wtVORP2D/yTcCKSC2Tvz8uV5u/k11YR540YQz7tn4pQ=; fh=h3nIRmU8oVmHzfjOCYP0kBpUgMDVr4EvUgMt47ym6go=; b=Jw2dC83B7xrRNTjKpdhjol08wvZp4AQBENkRxpvSRfF7vDkTNcBdaT1ROGXUuWYPKU mj1LxTBMmSFgs6a/XxXSW3lDZMhGcCirU2pdsi93S5DjEju3jaABf0XKoTDvB/l8FoMW W/drJxZ3kOlfaPrJzfwV+S7GKIiPyCKqKDcW4Tsp6e3rJBVGSjz54zXnYEc7rAn1ESOB dCceayS/ujDItEWPbo5dJoQEr31bW+TucVuF9cVuot1aykCBjVjKGurYZ90y3q+fywp8 aPsiA9fJkJC477fo7XqJ5RkYUy1QHDMRWNFFexxjhjEIS/gTgmAhHh7K4hMa8+6jCQZO H7eg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=srB+PmBn; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-107999-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-107999-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id lp14-20020a056a003d4e00b006e7227efa2asi5341951pfb.305.2024.03.19.11.24.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 11:24:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-107999-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=srB+PmBn; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-107999-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-107999-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 52856B23067 for ; Tue, 19 Mar 2024 18:21:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B520A38384; Tue, 19 Mar 2024 18:20:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="srB+PmBn"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="PRmO38DY" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C63A37708 for ; Tue, 19 Mar 2024 18:20:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710872455; cv=none; b=L56rEYDozhPohtXjrYDyivRPqKGj5pH3DX3OprK96uo3EORI0o7AqeZT2vs020ezTVVOznVxJS+l9Vg7si0vKNBgGyapWxHhbAqpV0lwXBh06Bv/TOdFSzs8T1FecLwrXMdtq3oi8QC9fz19EiDGqpNppAwyHqx36V7XBqqjMlg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710872455; c=relaxed/simple; bh=IrD2CsLAg6bFdA1QgBrkSTZ7IAePgyDy6PNGrvKkQ5o=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=k/t8ugUdysdqzu6uvG0aRnb324UEr/qeVzfyZtTvBpuU085GauI5E/GuEfXqVw3ZhoPUq3aI5usQbpgushSMttuvs0uwwiKPnrKMtntqkg9Mx9acW9rKLiyGDM3g7l7dEA3FgV1BFwa/zFF5JpV953nPnG+Gv1ZS7oUF5h2k20k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=srB+PmBn; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=PRmO38DY; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Tue, 19 Mar 2024 19:20:50 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1710872452; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wtVORP2D/yTcCKSC2Tvz8uV5u/k11YR540YQz7tn4pQ=; b=srB+PmBnxzXy8ZoSiCPd/hElVynFSEAsATjBwvSfjC/U6bEIunoYgeFHdH3iKGyabf5j5t MTCea0q+KOVYpNT1ch92M/eLvoyJh/6AhV3jH0YqazADzR0wlrBJAc6maxDMKm2nb9K2eR QeHuOgptvYnSXmPvD2V55uih02NP5nPIJ+xsdm02TKHdVAepX5IlZR/UENuJ0PdrzIS/U3 /8hG9Os0GfxyLKYcABgUsoM+eYLJiNNhkEGrp5BMVOS6aTXEcfO24iTYRaBgmuuiqm8IA6 1Yl1sl6iWLYsNVU9Sbq5QjjPPYQ+JoDLoe8/MeLpVdAc38LxOs+ayxpYfHErJA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1710872452; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wtVORP2D/yTcCKSC2Tvz8uV5u/k11YR540YQz7tn4pQ=; b=PRmO38DY4V9A8MKEbL2FJVNUqnTHc+JU6QY2BVmOjyWMhpd1qqYGukRHY3eXDacFTSpliP qEtNFaxH+WI706BA== From: Sebastian Andrzej Siewior To: Waiman Long Cc: Matthew Wilcox , linux-kernel@vger.kernel.org, Boqun Feng , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , Will Deacon , Clark Williams Subject: [PATCH v2] Locking: Let PREEMPT_RT compile again with new rwsem asserts. Message-ID: <20240319182050.U4AzUF3I@linutronix.de> References: <20240319070550.ws_uO21-@linutronix.de> <20240319141506.DUd9NKl4@linutronix.de> <9b4f3dac-779a-4eef-945b-3ca1455c0dfe@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <9b4f3dac-779a-4eef-945b-3ca1455c0dfe@redhat.com> The commit cited below broke the build for PREEMPT_RT because rwsem_assert_held_write_nolockdep() passes a struct rw_semaphore but rw_base_assert_held_write() expects struct rwbase_rt. Fixing the type alone leads to the problem that WARN_ON() is not found because bug.h is missing. In order to resolve this: - Keep the assert (WARN_ON()) in rwsem.h (not rwbase_rt.h) - Make rwsem_assert_held_write_nolockdep() do the implementation specific (rw_base) writer check. - Replace the "inline" with __always_inline which was used before. Fixes: f70405afc99b1 ("locking: Add rwsem_assert_held() and rwsem_assert_he= ld_write()") Reported-by: Clark Williams Signed-off-by: Sebastian Andrzej Siewior --- v1=E2=80=A6v2: - Merge rwsem_held_write() into rwsem_assert_held_write_nolockdep() as per Waiman Long / Matthew Wilcox. include/linux/rwbase_rt.h | 4 ++-- include/linux/rwsem.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/rwbase_rt.h b/include/linux/rwbase_rt.h index 29c4e4f243e47..f2394a409c9d5 100644 --- a/include/linux/rwbase_rt.h +++ b/include/linux/rwbase_rt.h @@ -31,9 +31,9 @@ static __always_inline bool rw_base_is_locked(const struc= t rwbase_rt *rwb) return atomic_read(&rwb->readers) !=3D READER_BIAS; } =20 -static inline void rw_base_assert_held_write(const struct rwbase_rt *rwb) +static __always_inline bool rw_base_is_write_locked(const struct rwbase_rt= *rwb) { - WARN_ON(atomic_read(&rwb->readers) !=3D WRITER_BIAS); + return atomic_read(&rwb->readers) =3D=3D WRITER_BIAS; } =20 static __always_inline bool rw_base_is_contended(const struct rwbase_rt *r= wb) diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h index 4f1c18992f768..c8b543d428b0a 100644 --- a/include/linux/rwsem.h +++ b/include/linux/rwsem.h @@ -167,14 +167,14 @@ static __always_inline int rwsem_is_locked(const stru= ct rw_semaphore *sem) return rw_base_is_locked(&sem->rwbase); } =20 -static inline void rwsem_assert_held_nolockdep(const struct rw_semaphore *= sem) +static __always_inline void rwsem_assert_held_nolockdep(const struct rw_se= maphore *sem) { WARN_ON(!rwsem_is_locked(sem)); } =20 -static inline void rwsem_assert_held_write_nolockdep(const struct rw_semap= hore *sem) +static __always_inline void rwsem_assert_held_write_nolockdep(const struct= rw_semaphore *sem) { - rw_base_assert_held_write(sem); + WARN_ON(!rw_base_is_write_locked(&sem->rwbase)); } =20 static __always_inline int rwsem_is_contended(struct rw_semaphore *sem) --=20 2.43.0