Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1231703lqt; Tue, 19 Mar 2024 17:59:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUSEr8nE60E7EAtyTOwYJRWQDgtCAW45hls92TdlAL7Ie7AW8YprIUdO+bAT392CWYFc6OjmKhKsgHB2t4D96cceAVzoZHVxF/9QXJ6bA== X-Google-Smtp-Source: AGHT+IHrfVVg4boyMFgpZXwCBG0SpUsJsrWnB5Pl74L63z1j/p/AHk3zUeS9YeIWTfseXCmgGC7Y X-Received: by 2002:a05:6a00:23d6:b0:6e6:c73b:bec2 with SMTP id g22-20020a056a0023d600b006e6c73bbec2mr1419936pfc.14.1710896355120; Tue, 19 Mar 2024 17:59:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710896355; cv=pass; d=google.com; s=arc-20160816; b=APPVPsqMfq0oTiKDXv1uhD3K/rFsIioi33riH18BelTOP7sCLbUFQ8e9QjPuKE1luH gWP8Eu7qx//uAX8Gwl89SdHbNc33+BMP5TDBcGDmcaAFt1kwZt02f84Zp1AmoOoGm7+Q wuorPVYdYagMnmBghjccDJPGVZ6n7OvSErxI690WCgvEkqMZ8qagPx7DCYPF0gjMef3L gy/ywbiFBEFLWtwL6U+Xd0kyVNWrNlLM31KnSBbdanmdH/y9YNLLJWoAfNqmBfZ24LtN lfVgSo8hmB7LtjUkeCyLApnMKjWUdjH96tWOqla4W8aq0hB038h+Cenzypq6z0QROWgO P0GA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=IZevwqzcF4VmkqXpA8LuwY1scKO7py2l61oxTNHbrbs=; fh=4cUVXmwsTHB/oSS/NM6QhlOT9+SRfVjdo2mAiGcvewc=; b=RFN4311yw0afio+UfRdTg2QbZ7w40hv3Jf3Q6Atf/Wkg6phcEn3N8aQ2DIIr1tfhK1 dmdO1BhMTVSbO/Cd5ud3/STMH5YkE+UsGf13K3LJSWooII/Xsx/R+xpEPVBnEXffrQ4x N5NlORftAS/RtJHu+Qaen+21sjpNjHgKOT2+Ge5eRuRfSGVM5vpXH16R889MQ3IsBx9z XiLfGWxIDRBg+6ZOx8x5u+rJzV1j19P58lhg3ITnCO1QmGspcPtrBDRkdKC7iCKhL7aF kiSwZn5Muag+MwgaWTBwEQP/5wt3vr42+SK5AiVjnfdaRQzvDUzTny/9EKxOccyLdhQL DOrw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fybXy7YT; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-108292-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108292-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id h6-20020a63e146000000b005cddfe0c82bsi11080499pgk.211.2024.03.19.17.59.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 17:59:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108292-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=@redhat.com header.s=mimecast20190719 header.b=fybXy7YT; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-108292-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108292-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 171B3B231AE for ; Wed, 20 Mar 2024 00:58:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5E3BF138C; Wed, 20 Mar 2024 00:58:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fybXy7YT" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 E00CE10EB for ; Wed, 20 Mar 2024 00:58:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710896304; cv=none; b=lg4C6VQDGvPSBMWDpgT0bIFi4214sA4LvnjDPx0tL9fksMMFZdohtgBrA5y0dVvod43KInAPjJTN5vdRt5j7L2+wu2IgI6bcCXipGDYAYeYQ//hkPR8SqOWWdCUSUB8O5Jw4AoNFJr6ThxqzTD4d/j0hfqTH1qL4t+HSxaCuvL0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710896304; c=relaxed/simple; bh=ODDLhKu+1KU4V9mcHaNAcljdYol6uu6w9jDZtEjqggQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=KL3UdZuhMzdysMNypdHe1jLxDyzYMiYwCZ3xAj1uWsQ7qUEyqow8jzXJpJ1Rf+fSWqd30fbRFf65NPJzi5CdYKmW+1Bbzzh0x+E0QpDpuK/DtdhXCXXw/g+WpDO4IX1DkiW292if2x89ESpN+ftuQI+3uETHcSABtD1ME1Ny4aA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=fybXy7YT; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710896301; 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=IZevwqzcF4VmkqXpA8LuwY1scKO7py2l61oxTNHbrbs=; b=fybXy7YTJrx5bSOsOBkElIl2faihnSPSoQOmTbseAaVyZNNmhdvgC9LZIQnYW+niKJNpOL 5es5ti0QSKLlx0AD9Ue5fZDXiau7W8phChl2m3bwXzQJRaPpCpcj0KN/5oI0ys/qhyvhEG W6DPNpNgt4aEZBWTtzCLV1KDBFEEcd4= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-674-KC4uT-v_NJ6GNUJID8XoVA-1; Tue, 19 Mar 2024 20:58:19 -0400 X-MC-Unique: KC4uT-v_NJ6GNUJID8XoVA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id ABE9F1C031B0; Wed, 20 Mar 2024 00:58:18 +0000 (UTC) Received: from [10.22.10.159] (unknown [10.22.10.159]) by smtp.corp.redhat.com (Postfix) with ESMTP id 39AEE492BD1; Wed, 20 Mar 2024 00:58:18 +0000 (UTC) Message-ID: Date: Tue, 19 Mar 2024 20:58:13 -0400 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] Locking: Let PREEMPT_RT compile again with new rwsem asserts. Content-Language: en-US To: Sebastian Andrzej Siewior Cc: Matthew Wilcox , linux-kernel@vger.kernel.org, Boqun Feng , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , Will Deacon , Clark Williams References: <20240319070550.ws_uO21-@linutronix.de> <20240319141506.DUd9NKl4@linutronix.de> <9b4f3dac-779a-4eef-945b-3ca1455c0dfe@redhat.com> <20240319182050.U4AzUF3I@linutronix.de> From: Waiman Long In-Reply-To: <20240319182050.U4AzUF3I@linutronix.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 On 3/19/24 14:20, Sebastian Andrzej Siewior wrote: > 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_held_write()") > Reported-by: Clark Williams > Signed-off-by: Sebastian Andrzej Siewior > --- > v1…v2: > - 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 struct rwbase_rt *rwb) > return atomic_read(&rwb->readers) != READER_BIAS; > } > > -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) != WRITER_BIAS); > + return atomic_read(&rwb->readers) == WRITER_BIAS; > } > > static __always_inline bool rw_base_is_contended(const struct rwbase_rt *rwb) > 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 struct rw_semaphore *sem) > return rw_base_is_locked(&sem->rwbase); > } > > -static inline void rwsem_assert_held_nolockdep(const struct rw_semaphore *sem) > +static __always_inline void rwsem_assert_held_nolockdep(const struct rw_semaphore *sem) > { > WARN_ON(!rwsem_is_locked(sem)); > } > > -static inline void rwsem_assert_held_write_nolockdep(const struct rw_semaphore *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)); > } > > static __always_inline int rwsem_is_contended(struct rw_semaphore *sem) Reviewed-by: Waiman Long