Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1396154lqe; Mon, 8 Apr 2024 07:49:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXjn3+tBsfztA/QeYJOwX5AHC/60sNMDEgQaJ1067+vnYhdgt+JHqFlq1HMyfmMf4p69jAemEJVqz+K4QIuxddETW+ZHvd9DrzjkYDVQg== X-Google-Smtp-Source: AGHT+IHzO1vRhM8xy9F0n8jWM5xGXQ2+thbO1FUwNI40UhCxifJbGZX5so0tEQA+NFzrnFJnCWEE X-Received: by 2002:a05:6a00:3ccc:b0:6ed:21f6:ce18 with SMTP id ln12-20020a056a003ccc00b006ed21f6ce18mr3729178pfb.3.1712587763995; Mon, 08 Apr 2024 07:49:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712587763; cv=pass; d=google.com; s=arc-20160816; b=JG+XsVU+0ptfuIvEndk7hbaVnT+mMplEAvJwZ+KV+hf2KixdB/zeS51/J5gBdkFHWz qW0JovhzQ56IUKUtZwHNcPcYRjVwsLL+bPgdXGlSe0uXJyFY1bE593z/EM348/bbkxor 1775lzZcgYiZ0h5gOs2oSCaWTcZzv4tXy/OCEDtlALgHIM3/JW7LHCSrgk6uynXlaTYr RzRMb/ne6Y/CMzAk7/7izjfXc5oy3qUhBKVlyl34zblMrzjRNc/79wvkzJd0NwELo1cm KTbTp+F/uBn0VDwFr25ycpU21fZdMr/ozQIU4lVVxJ5f+e2IgydfhCwQGGjclXWxGNf9 o+VA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=ZSBZKxVagqSyyqgX5YL8fRhaTlaaIEoJrClKUTvlErk=; fh=X9bE4Un24+3oWmP/PwxzeFWeQWz2wkEBCNlS+VDH8Mw=; b=PukCTWn+zhLb9NiU2w1J/P4NF1AOYLNpg5M131UjtBcI3QRY73661zQG1EpZtfKh8U sRStCsvuPSxFHxfuQI6yJgCGp268mH96zc8AFcMhQMDYIoQ5vJl8m38ORwsnb9MDaAzN mKnit9ztJXX2BcdZNzUuHrIgC+X3L19S43A5GDylmnim7zq/Yr4QVVjd0C5Kjzy3r1KR cqICatRuxjVEIKhfUj7wnebQDnVU4RqUZ69QwEeg0UGsPHmgBg44GTuU9X94OEucWE5M kxRCWpaHGEip/AHWWfCKKJOm0ky0HcouCxyJF06r03oQ+C6xCeGw1XQDA37TbEiKodyC VdbQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=mf3Vn5ND; 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-135552-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135552-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id n6-20020a634d46000000b005dc81a30772si6592244pgl.301.2024.04.08.07.49.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 07:49:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-135552-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=mf3Vn5ND; 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-135552-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135552-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 9BEA5285221 for ; Mon, 8 Apr 2024 14:49:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1FADE13F00A; Mon, 8 Apr 2024 14:49:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="mf3Vn5ND"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="K9Bd285U" 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 BFA561CD21; Mon, 8 Apr 2024 14:49:16 +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=1712587758; cv=none; b=jU4iBcA/Ulu4xaRyhbNVHnhxWsFwnnrkutL4YjEzsIKyeXZP8AnPSAUsQwikjgL+V/wprfzRZSrfTexco5Abzmz8FzgmW3k2LrQimt86m2Obq9QdQI4Hv0Ks6A+vbWiNwTSzCaVSfDOaIAYSW5dRrOEQc63FMQzo53w+jt9wuFA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712587758; c=relaxed/simple; bh=jNMK47ZUmrpZUfLl5QCOPVV6yzsTpHyaMvQaLUlYv5g=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=oRgYkl5ER06+VHc5zDfDBbPLuSrFcUz/Ckna3/JtceIXHeW9eb27EP24JiTRmZK3wJDfouSjgxRmPAUOPKYpRcHRhXHsSEV5B+gvRimW3CA22nx2FHxhyuqMxBOZuDDaCh23VnZ68azdT9RaDLbC+VbK6wLoF1OcH8zUgqxULpQ= 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=mf3Vn5ND; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=K9Bd285U; 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: Mon, 08 Apr 2024 14:49:14 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1712587755; h=from:from:sender:sender:reply-to: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=ZSBZKxVagqSyyqgX5YL8fRhaTlaaIEoJrClKUTvlErk=; b=mf3Vn5NDuJQaN/lzB3cxTV21tWLhq4nqO2rjNs5u8ywZYm7Q0j8MEbQ5mMloNtLiyI1oT8 VCm0+qgTT/wU+4Qnuwn2No/loTglgPF3lRmoq92u8rp1sk1JZq7lj2cY91prFiGxKTnU+y DCkU1Wm6sVvIo/32pZKCJu8VYyZ5gkynnMaIeB43YdfrpQRZqm7k+rLn5VDXHwl+zADkWZ +Peh80RDl4q3pF+WHaJlezboxXOWTG+XsgVXxN7s4XLSpmZSv1TYU7WeJufRZbVimWdUpq QQ0uzwteolFlZJunhzNnSDCiWrQLsqqY2Yd9tJHjhnXLcx+hAJyZZcMy08MGzg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1712587755; h=from:from:sender:sender:reply-to: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=ZSBZKxVagqSyyqgX5YL8fRhaTlaaIEoJrClKUTvlErk=; b=K9Bd285UeNBWe0e8XhNipjtbIFhfgTUv5qil1ZKXm1TqRLlQ3Rf/mT1VoJWZjqj9p1+EdF rbVsE42+DmuJNQCg== From: "tip-bot2 for Sebastian Andrzej Siewior" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/urgent] locking: Make rwsem_assert_held_write_nolockdep() build with PREEMPT_RT=y Cc: Clark Williams , Sebastian Andrzej Siewior , Thomas Gleixner , Waiman Long , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240319182050.U4AzUF3I@linutronix.de> References: <20240319182050.U4AzUF3I@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <171258775408.10875.1006562089920074677.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The following commit has been merged into the locking/urgent branch of tip: Commit-ID: fa1f51162338b3e2f520d4bfedc42b3b2e00da6d Gitweb: https://git.kernel.org/tip/fa1f51162338b3e2f520d4bfedc42b3b2e00da6d Author: Sebastian Andrzej Siewior AuthorDate: Tue, 19 Mar 2024 19:20:50 +01:00 Committer: Thomas Gleixner CommitterDate: Mon, 08 Apr 2024 16:39:16 +02:00 locking: Make rwsem_assert_held_write_nolockdep() build with PREEMPT_RT=y 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 Signed-off-by: Thomas Gleixner Reviewed-by: Waiman Long Link: https://lore.kernel.org/r/20240319182050.U4AzUF3I@linutronix.de --- 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 29c4e4f..f2394a4 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 4f1c189..c8b543d 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)