Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp7103995rdb; Fri, 15 Dec 2023 19:28:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IG4JlC5PvwkMiZXffGIcAvtb4VjiV80jbhZN4oI7nqUtoiRKrcEEWYoidCqG9gxjJ8hWVYx X-Received: by 2002:a05:600c:4f82:b0:40c:691e:3543 with SMTP id n2-20020a05600c4f8200b0040c691e3543mr1283398wmq.248.1702697312158; Fri, 15 Dec 2023 19:28:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702697312; cv=none; d=google.com; s=arc-20160816; b=G5a5r6ZXr+uU+a+UcsBj6mQ7Yn6SC+p9iFhMaNVMK1zWf6X0vQDbmn/Pufo3YqjFyS 1B8AB6LWy8ivqQADzBZO2DEFWyDdsd9gg9h3w8ByaQWaqNEJIuthneqleFyrqcHyc5XP rDl/t/M4A7DRIanNQTAhuCSZ/IG1MjMd/yExmo2CWtcNRq9uGz7hGeC45ilDgvvTe17U 8ouz9c4n8/payKMYXMoQkVH7Fg77g7wOc/SMZIJ+F65s8NbwORMffefOUThUqgo/eaZM 5zi5Dy6SZHtYBioOPyCS18XAnY+zXYFqjLZB1eUJkW5ynARlv/OyQAMXjQNBK2LEynDT QpZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=2XkiID2+CLzOQYD7Bz1wsynJpFZEAYT3tSVjrTRZ4z8=; fh=vHhjxHftTECn/hRvIWNlq1eDzDsn74Roqz0kmRcPgcE=; b=dxOwTLlIfpvjKvSp/driPH+8K+X1dTsIP3RlO+EtRI7PsfKlJNZXOG3IFwa9Fsrxgx VREelctLPeSiokxlsrsifFtCQYPZMrqX2Es9qqluSJqoNUYIYZDNyVVri9pzZdy2Cgex LdsSpXqJYmQGJa0eAkDTOBXpeI0ijLixttJqWt9P42X44YwZLPb85PmrfqgL2iBuGu0w /szyhi2aPg8+7ImrUqLgRLvJMmxXGdMmE3lUPKKBFCwhmGV7UJh2IaZ2wlbU9B0IIKk9 4jVOOFXh8cZnqjVdBRlUcG+zLio/q8F9jPx4m0NZ9mV+MWFKxryMIHt+7x2+SvbIjaX8 iLmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Lj55Mo0L; spf=pass (google.com: domain of linux-kernel+bounces-1991-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1991-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id u10-20020a17090657ca00b00a1d2851c02dsi7642088ejr.301.2023.12.15.19.28.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 19:28:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-1991-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Lj55Mo0L; spf=pass (google.com: domain of linux-kernel+bounces-1991-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1991-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 am.mirrors.kernel.org (Postfix) with ESMTPS id E2F2E1F25805 for ; Sat, 16 Dec 2023 03:28:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 347BE168AA; Sat, 16 Dec 2023 03:27:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Lj55Mo0L" X-Original-To: linux-kernel@vger.kernel.org Received: from out-187.mta0.migadu.com (out-187.mta0.migadu.com [91.218.175.187]) (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 15A7B14016 for ; Sat, 16 Dec 2023 03:27:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1702697231; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2XkiID2+CLzOQYD7Bz1wsynJpFZEAYT3tSVjrTRZ4z8=; b=Lj55Mo0LMcD929wkauv0VAl43vVATsnzWM+J3oGUI/ar0ExbibBATJI9Ex1s17yuwcQsEq z1vlDGtmUVc6CIIBXy7jDvdn59nvo3wlVAKYmzivDHXAQEtV4qXJrU/UMbfyh12jJZMo78 pWac8uDIn1XU0PF37u7zF7u+nQIdi+U= From: Kent Overstreet To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Cc: Kent Overstreet , tglx@linutronix.de, x86@kernel.org, tj@kernel.org, peterz@infradead.org, mathieu.desnoyers@efficios.com, paulmck@kernel.org, keescook@chromium.org, dave.hansen@linux.intel.com, mingo@redhat.com, will@kernel.org, longman@redhat.com, boqun.feng@gmail.com, brauner@kernel.org Subject: [PATCH 16/50] sched.h: Move (spin|rwlock)_needbreak() to spinlock.h Date: Fri, 15 Dec 2023 22:26:15 -0500 Message-ID: <20231216032651.3553101-6-kent.overstreet@linux.dev> In-Reply-To: <20231216032651.3553101-1-kent.overstreet@linux.dev> References: <20231216024834.3510073-1-kent.overstreet@linux.dev> <20231216032651.3553101-1-kent.overstreet@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT This lets us kill the dependency on spinlock.h. Signed-off-by: Kent Overstreet --- include/linux/sched.h | 31 ------------------------------- include/linux/spinlock.h | 31 +++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 5a5b7b122682..7501a3451a20 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -2227,37 +2227,6 @@ static inline bool preempt_model_preemptible(void) return preempt_model_full() || preempt_model_rt(); } -/* - * Does a critical section need to be broken due to another - * task waiting?: (technically does not depend on CONFIG_PREEMPTION, - * but a general need for low latency) - */ -static inline int spin_needbreak(spinlock_t *lock) -{ -#ifdef CONFIG_PREEMPTION - return spin_is_contended(lock); -#else - return 0; -#endif -} - -/* - * Check if a rwlock is contended. - * Returns non-zero if there is another task waiting on the rwlock. - * Returns zero if the lock is not contended or the system / underlying - * rwlock implementation does not support contention detection. - * Technically does not depend on CONFIG_PREEMPTION, but a general need - * for low latency. - */ -static inline int rwlock_needbreak(rwlock_t *lock) -{ -#ifdef CONFIG_PREEMPTION - return rwlock_is_contended(lock); -#else - return 0; -#endif -} - static __always_inline bool need_resched(void) { return unlikely(tif_need_resched()); diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h index 31d3d747a9db..0c71f06454d9 100644 --- a/include/linux/spinlock.h +++ b/include/linux/spinlock.h @@ -449,6 +449,37 @@ static __always_inline int spin_is_contended(spinlock_t *lock) return raw_spin_is_contended(&lock->rlock); } +/* + * Does a critical section need to be broken due to another + * task waiting?: (technically does not depend on CONFIG_PREEMPTION, + * but a general need for low latency) + */ +static inline int spin_needbreak(spinlock_t *lock) +{ +#ifdef CONFIG_PREEMPTION + return spin_is_contended(lock); +#else + return 0; +#endif +} + +/* + * Check if a rwlock is contended. + * Returns non-zero if there is another task waiting on the rwlock. + * Returns zero if the lock is not contended or the system / underlying + * rwlock implementation does not support contention detection. + * Technically does not depend on CONFIG_PREEMPTION, but a general need + * for low latency. + */ +static inline int rwlock_needbreak(rwlock_t *lock) +{ +#ifdef CONFIG_PREEMPTION + return rwlock_is_contended(lock); +#else + return 0; +#endif +} + #define assert_spin_locked(lock) assert_raw_spin_locked(&(lock)->rlock) #else /* !CONFIG_PREEMPT_RT */ -- 2.43.0