From nobody Mon Apr 13 21:06:47 2026 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C52138642F for ; Wed, 4 Mar 2026 07:47:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772610453; cv=none; b=h9VK28V+WVYXnqcayj3Cs3IZaVJwPDw4fadosPZRtVx6IrFFs+ekjIjYU6hpnYVWnIUefSbR2oySVe3dFq0XGB5m6k+WZMDhDVOUG8acMfLzDKu/LwZPSwlafdCtrHzJYb+GwGOhELUcBBBmG6WV+W8om1KR251EopqpWxkCI0s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772610453; c=relaxed/simple; bh=6RIg3+xlc56a9TiATGgbmkLKt/1FmZfcHuoKSyt/chw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=briFYsqylzPfLy2ivKDJuYJbewwM8tEypB2eMHOnM2/KjNXNEG8hdGUbMmHmgtlZTaLHIvXYJWKl5w0PZtDgJhFKN4rzsFCk7vuiYWfHuZrvfKj4+xtqbMldOYxFAZc4ZFebeFeA/ZScoUWGTlA6rbTQTjuiBtragxWMvFSjW8c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nNP3pDQl; arc=none smtp.client-ip=209.85.216.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nNP3pDQl" Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-3597c40a838so1447843a91.1 for ; Tue, 03 Mar 2026 23:47:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772610446; x=1773215246; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7ugG+Q6CRrXfDVHr7sdXkPMCc63GqTD3eiVmBzfzheY=; b=nNP3pDQlHa0AD2Z3QzLIf7NljbzABm10nlytc7vp9yxz53wgzeWTCV7GMyc0rfko9T xk7Yk6wmIIP9qgDh7FRZASMGD+j979z8KxMtZS5JnOEIjwQDssr+ws5flZV+jkzUSWSf t+Yiyf5FYZEwG7XtPxP9/YgBsEMxa9kypdMhM1N650hGKlQ/pFK1FUqjAINQIA1fa7rq yN3evzG9uW0tdL5a18zNQx/VVKTwLHQlMlF6jv2vaKwo4CoQ/GA1ByXtNUUB8vJKYYhB PZvdjkV6WMV/s7cD98bnkPKTpj+UP97jE9wY4vdmMlsVKYT9F0O00yE3fWzrKQ6pWXPC 8s5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772610446; x=1773215246; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=7ugG+Q6CRrXfDVHr7sdXkPMCc63GqTD3eiVmBzfzheY=; b=nRw2mKiXMPkexYbq6EzvH1JMyJJnhtd5UoJo/Dw4Zkax+S4T+fS9NdUv4+nw6Thv/0 ZEe14ag/ZOKA5HRd76kuzT9LqRavXTlkGnCrdp1/7+SgCXHPzklu1g/5RlQI5yNkpJIe SLroA1pEU02K+LCd3OGjc1kQJ7Td3vEkd+5kUwS+S5k5ylp0GDKA8LSD9Tsu2UzpVhN/ Gpdkq5K2tYeoS/1/KEn/BCMr7LcJ+cfGv3mGWauoRsTnbT1nXUXp9iqknf19LNQuk1D8 TFfrgE8KRzW2BQZ5f6ZuT4ulXnhyQ+CTE2ar3NHFx6xRccatyiYDtVyp+dGQ+Lb/IuFc 4gnA== X-Gm-Message-State: AOJu0Yy5y6WWhYulW4MNJlsFXkmgJlCVPVOhFeAmvO5OVHRDHT317ffJ h//vJXBYD+7fj9biNk04y7SYl9Bstdx9DSwG3tXkzVTTXqJV0Dxscpm5 X-Gm-Gg: ATEYQzyzncsYUrnqu104h7+NGk5ybyP5F2OIcQRom6BjMp/iCWEwGTSKTGEGXsoU/ZA E8PjXcDHP6Q8ZUcSbV/5EI/L/ZK4DiTAYcFsN0HU2okX1XDejBWYQsvcgjOf6dUr4+e8fnMW7+U l3hb9p026hWE3BYHcK1lQKds/heJEKGJfE47LHwDH4ah+nPhFWbQ59o6qpLXuB5FSLPLy5ac5kT SOYj0ugED0f4TUUEA10ppBljFGbHkdkHQT6GLnRpO0nqd0N+6Q9emlynfKpuS++/n2re7JfZmil nvj87FvPYW6cKJopbpvp/MUh+Ofh1XP5lzR+jvCM/r3SGO7BF7miPnMQZy/SxcaZXbsIXhd01mN c4Si0yewTNi2LhyhEDuzk9+EzJYy9+7/23kKQL2j+qPTRa7vvWTa3dyw3wZrvGkiXv7vXaDVxda CyDg61G2oyywwiIOtZmqmXe9K7/2HvQrZBS7cspAa0JAu43Yz5/8a+d0ylH7kSaQ== X-Received: by 2002:a17:90b:1a92:b0:356:7b41:d348 with SMTP id 98e67ed59e1d1-359a6a3d157mr1010057a91.20.1772610446311; Tue, 03 Mar 2026 23:47:26 -0800 (PST) Received: from localhost.localdomain ([2409:891f:1ba6:a29e:d73:6202:f71f:51b0]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3599c39def7sm4352078a91.12.2026.03.03.23.47.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 03 Mar 2026 23:47:25 -0800 (PST) From: Yafang Shao To: peterz@infradead.org, mingo@redhat.com, will@kernel.org, boqun@kernel.org, longman@redhat.com, rostedt@goodmis.org, mhiramat@kernel.org, mark.rutland@arm.com, mathieu.desnoyers@efficios.com Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org, Yafang Shao Subject: [RFC PATCH 1/2] locking: add mutex_lock_nospin() Date: Wed, 4 Mar 2026 15:46:49 +0800 Message-ID: <20260304074650.58165-2-laoar.shao@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260304074650.58165-1-laoar.shao@gmail.com> References: <20260304074650.58165-1-laoar.shao@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Introduce mutex_lock_nospin(), a helper that disables optimistic spinning on the owner for specific heavy locks. This prevents long spinning times that can lead to latency spikes for other tasks on the same runqueue. Signed-off-by: Yafang Shao --- include/linux/mutex.h | 3 +++ kernel/locking/mutex.c | 39 ++++++++++++++++++++++++++++++++------- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/include/linux/mutex.h b/include/linux/mutex.h index ecaa0440f6ec..1e488bb24b57 100644 --- a/include/linux/mutex.h +++ b/include/linux/mutex.h @@ -189,11 +189,13 @@ extern int __must_check mutex_lock_interruptible_nest= ed(struct mutex *lock, extern int __must_check _mutex_lock_killable(struct mutex *lock, unsigned int subclass, struct lockdep_map *nest_lock) __cond_acquires(0,= lock); extern void mutex_lock_io_nested(struct mutex *lock, unsigned int subclass= ) __acquires(lock); +extern void mutex_lock_nospin_nested(struct mutex *lock, unsigned int subc= lass); =20 #define mutex_lock(lock) mutex_lock_nested(lock, 0) #define mutex_lock_interruptible(lock) mutex_lock_interruptible_nested(loc= k, 0) #define mutex_lock_killable(lock) _mutex_lock_killable(lock, 0, NULL) #define mutex_lock_io(lock) mutex_lock_io_nested(lock, 0) +#define mutex_lock_nospin(lock) mutex_lock_nospin_nested(lock, 0) =20 #define mutex_lock_nest_lock(lock, nest_lock) \ do { \ @@ -215,6 +217,7 @@ extern void mutex_lock(struct mutex *lock) __acquires(l= ock); extern int __must_check mutex_lock_interruptible(struct mutex *lock) __con= d_acquires(0, lock); extern int __must_check mutex_lock_killable(struct mutex *lock) __cond_acq= uires(0, lock); extern void mutex_lock_io(struct mutex *lock) __acquires(lock); +extern void mutex_lock_nospin(struct mutex *lock) __acquires(lock); =20 # define mutex_lock_nested(lock, subclass) mutex_lock(lock) # define mutex_lock_interruptible_nested(lock, subclass) mutex_lock_interr= uptible(lock) diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c index 2a1d165b3167..03d3b0749882 100644 --- a/kernel/locking/mutex.c +++ b/kernel/locking/mutex.c @@ -290,6 +290,14 @@ void __sched mutex_lock(struct mutex *lock) __mutex_lock_slowpath(lock); } EXPORT_SYMBOL(mutex_lock); + +void __sched mutex_lock_nospin(struct mutex *lock) +{ + might_sleep(); + + if (!__mutex_trylock_fast(lock)) + __mutex_lock_nospin(lock); +} #endif =20 #include "ww_mutex.h" @@ -443,8 +451,11 @@ static inline int mutex_can_spin_on_owner(struct mutex= *lock) */ static __always_inline bool mutex_optimistic_spin(struct mutex *lock, struct ww_acquire_ctx *ww_ctx, - struct mutex_waiter *waiter) + struct mutex_waiter *waiter, const bool nospin) { + if (nospin) + return false; + if (!waiter) { /* * The purpose of the mutex_can_spin_on_owner() function is @@ -577,7 +588,8 @@ EXPORT_SYMBOL(ww_mutex_unlock); static __always_inline int __sched __mutex_lock_common(struct mutex *lock, unsigned int state, unsigned int s= ubclass, struct lockdep_map *nest_lock, unsigned long ip, - struct ww_acquire_ctx *ww_ctx, const bool use_ww_ctx) + struct ww_acquire_ctx *ww_ctx, const bool use_ww_ctx, + const bool nospin) { DEFINE_WAKE_Q(wake_q); struct mutex_waiter waiter; @@ -615,7 +627,7 @@ __mutex_lock_common(struct mutex *lock, unsigned int st= ate, unsigned int subclas =20 trace_contention_begin(lock, LCB_F_MUTEX | LCB_F_SPIN); if (__mutex_trylock(lock) || - mutex_optimistic_spin(lock, ww_ctx, NULL)) { + mutex_optimistic_spin(lock, ww_ctx, NULL, nospin)) { /* got the lock, yay! */ lock_acquired(&lock->dep_map, ip); if (ww_ctx) @@ -716,7 +728,7 @@ __mutex_lock_common(struct mutex *lock, unsigned int st= ate, unsigned int subclas * to run. */ clear_task_blocked_on(current, lock); - if (mutex_optimistic_spin(lock, ww_ctx, &waiter)) + if (mutex_optimistic_spin(lock, ww_ctx, &waiter, nospin)) break; set_task_blocked_on(current, lock); trace_contention_begin(lock, LCB_F_MUTEX); @@ -773,14 +785,21 @@ static int __sched __mutex_lock(struct mutex *lock, unsigned int state, unsigned int subclass, struct lockdep_map *nest_lock, unsigned long ip) { - return __mutex_lock_common(lock, state, subclass, nest_lock, ip, NULL, fa= lse); + return __mutex_lock_common(lock, state, subclass, nest_lock, ip, NULL, fa= lse, false); +} + +static int __sched +__mutex_lock_nospin(struct mutex *lock, unsigned int state, unsigned int s= ubclass, + struct lockdep_map *nest_lock, unsigned long ip) +{ + return __mutex_lock_common(lock, state, subclass, nest_lock, ip, NULL, fa= lse, true); } =20 static int __sched __ww_mutex_lock(struct mutex *lock, unsigned int state, unsigned int subcl= ass, unsigned long ip, struct ww_acquire_ctx *ww_ctx) { - return __mutex_lock_common(lock, state, subclass, NULL, ip, ww_ctx, true); + return __mutex_lock_common(lock, state, subclass, NULL, ip, ww_ctx, true,= false); } =20 /** @@ -861,11 +880,17 @@ mutex_lock_io_nested(struct mutex *lock, unsigned int= subclass) =20 token =3D io_schedule_prepare(); __mutex_lock_common(lock, TASK_UNINTERRUPTIBLE, - subclass, NULL, _RET_IP_, NULL, 0); + subclass, NULL, _RET_IP_, NULL, 0, false); io_schedule_finish(token); } EXPORT_SYMBOL_GPL(mutex_lock_io_nested); =20 +void __sched +mutex_lock_nospin_nested(struct mutex *lock, unsigned int subclass) +{ + __mutex_lock_nospin(lock, TASK_UNINTERRUPTIBLE, subclass, NULL, _RET_IP_); +} + static inline int ww_mutex_deadlock_injection(struct ww_mutex *lock, struct ww_acquire_ctx *= ctx) { --=20 2.47.3 From nobody Mon Apr 13 21:06:47 2026 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0111F386547 for ; Wed, 4 Mar 2026 07:47:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772610456; cv=none; b=GwYlHjpStJdi66dNCjJ0Zg/qU8DGnC8JO2sFXXEKLF+keqHbCzUvCm4eCB5X0jmLdLMSw6jM+puPr7LMf+Jbmq3y9Btoo9PuNfGm1YHZvn0DqjZW9czuvn5jlGwP1/uU8pBR7s5DG/9/X5BGFFgpHELT0Gws0Wc4r+j65yFxZrs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772610456; c=relaxed/simple; bh=xij/w7IGsHGa0OZ+mD8D9GCI3hfE/hii5pckeZ7EKcg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dtVPX57Ip4c6c6GLQkG3BgjZxl05rDmlqF3GMzIyfHBrROsNq0KWz1QJJpbCTjkvFSNdBkcw/ndCySxoo9AehNnebX1Tk2pc9yWNe//wDLWzwK9JdgLKRSoubJvXG+TrOMa5o6hyYCHDnhr4iYGB1WTlD21q4HNA5Y2JIH1UppI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=QH9TtQTB; arc=none smtp.client-ip=209.85.216.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QH9TtQTB" Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-3590042fa8eso3949056a91.1 for ; Tue, 03 Mar 2026 23:47:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772610450; x=1773215250; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4RAdqO2lKtYGLna+N0CaieqoPJ8dofo0McAImpjYXR8=; b=QH9TtQTBc7urRW59mULbeHi3KLE5EFNv1YX9TriWcYeHNJfGddaLGBT4UDTGL1VNdI /aRPPZP54PgzdaFoEs9dXbexfOgctqotpnZzOD0Sa5iKs9wJ49oNnb6aFiaVTf2L+rBe labLFM3yK+9ulTrwDE3fHvSxFHojth2ibpl9up5jQBXtSEGW5CbRFJaOad1Nan1pdygx clXrzaOYkc7Ugb1tqCcSo4u9TQbdSl/c/uVeCuPExw2srqFUknLfTwFCRgNqpA0XTJ1+ 57ywf6/wly7qSXauH95f6kf+u/nor4AYXAIvcDc67AvLKyyu7M3TwZVNSoCZx8aETRwm 2e0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772610450; x=1773215250; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=4RAdqO2lKtYGLna+N0CaieqoPJ8dofo0McAImpjYXR8=; b=FgbPm4+YBIMhV7QO76Lg3pQBQZW8e9q3E6y2LSoNM9bfY4xtk35oZLAPmxmIXkkb6B Qzd2k9H7Wl373rs/VUwR3YdATgDxKLxBK97aA24pYj6DAXDgAZqdpsdhzGiWoALvx2CO 9Ii3WEfCBU85XRHxhOoh5FKJmeKYseYVql9evEnNOP+fUX4hTk5iW7NVGePBeeEUorJT guIuYkQ/lU3uy7CNBlaosRArv6KJhGMuwwgPUset8RidwMFGjzqHBp5M/9y6kPxMhdN1 GZt5KKPI+FjVyv3BPt10ejVEQpzUJWMyRB17gsvhEg/h48o5EFCLUxQsMThOiVTYJhLE XxTA== X-Gm-Message-State: AOJu0Yw8hOSAB+7OyrnrDJdyM1LGD4C+hGVcE5qDyIgpoKCfXnRYin8+ Hwot1ijSl1OgWpIjjfKHsM9jiCIICi+juXQeK1Xl4pcMHC5y8uWEmLuM X-Gm-Gg: ATEYQzwIqGiHn0WdOhmc4fXbbu9sCpW8ON9OEGH+t+qDJWXPDD+K4IbGq/wYCy62nGe SqJmsiYspfgeI06LfDl5yv2+r0vwa832yZWPjVRvEw5969zlEXP9DjjBSI8oUb+Xz7cJBcy46Jh h74gm+f1ztrsR4VGAz1gpj+shpXTxWx7RRNkGoz/yUyOqZ8Jnb9+PT4ov7ZJAqx8JpxjGbB2akJ ncELDUjOV7oyIhtHcSQ1e2gj69CGi5LqLyVWXWcjUEFFJ+DnoxCxb2VSM9wd5dHfHqcGpzELFOP TkBAug3xhDn4iC/HNDpjiWgQe7E9omH/wMiYGukbewvJ9w2Oa/no45Fa7YqPgOcNkg0yHUbwlff 7+PTyt6UL8IUN+3KF6IJLSm5G9HJFBB0jNoGmHcV4SABOb0LzyVAH6GzTYYKJDEOpDehiQhqCgI YAvGByi0spEnoRscvRUzeu13Rb/MPH2abZ0BlEbd5DcT1hiK6tkPx7dhB1OtpdYQ== X-Received: by 2002:a17:90b:3c90:b0:359:8c89:96cd with SMTP id 98e67ed59e1d1-359a69dae40mr1105809a91.12.1772610449953; Tue, 03 Mar 2026 23:47:29 -0800 (PST) Received: from localhost.localdomain ([2409:891f:1ba6:a29e:d73:6202:f71f:51b0]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3599c39def7sm4352078a91.12.2026.03.03.23.47.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 03 Mar 2026 23:47:29 -0800 (PST) From: Yafang Shao To: peterz@infradead.org, mingo@redhat.com, will@kernel.org, boqun@kernel.org, longman@redhat.com, rostedt@goodmis.org, mhiramat@kernel.org, mark.rutland@arm.com, mathieu.desnoyers@efficios.com Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org, Yafang Shao Subject: [RFC PATCH 2/2] ftrace: disable optimistic spinning for ftrace_lock Date: Wed, 4 Mar 2026 15:46:50 +0800 Message-ID: <20260304074650.58165-3-laoar.shao@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20260304074650.58165-1-laoar.shao@gmail.com> References: <20260304074650.58165-1-laoar.shao@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" mutex_lock_nospin() is used for ftrace_lock to selectively disable optimistic spinning. Signed-off-by: Yafang Shao --- kernel/trace/ftrace.c | 52 +++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 827fb9a0bf0d..b8cca4f76118 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -1284,7 +1284,7 @@ static void clear_ftrace_mod_list(struct list_head *h= ead) if (!head) return; =20 - mutex_lock(&ftrace_lock); + mutex_lock_nospin(&ftrace_lock); list_for_each_entry_safe(p, n, head, list) free_ftrace_mod(p); mutex_unlock(&ftrace_lock); @@ -4254,7 +4254,7 @@ static void *t_start(struct seq_file *m, loff_t *pos) void *p =3D NULL; loff_t l; =20 - mutex_lock(&ftrace_lock); + mutex_lock_nospin(&ftrace_lock); =20 if (unlikely(ftrace_disabled)) return NULL; @@ -4362,7 +4362,7 @@ static __init void ftrace_check_work_func(struct work= _struct *work) struct ftrace_page *pg; struct dyn_ftrace *rec; =20 - mutex_lock(&ftrace_lock); + mutex_lock_nospin(&ftrace_lock); do_for_each_ftrace_rec(pg, rec) { test_for_valid_rec(rec); } while_for_each_ftrace_rec(); @@ -5123,7 +5123,7 @@ static void process_mod_list(struct list_head *head, = struct ftrace_ops *ops, if (!new_hash) goto out; /* warn? */ =20 - mutex_lock(&ftrace_lock); + mutex_lock_nospin(&ftrace_lock); =20 list_for_each_entry_safe(ftrace_mod, n, head, list) { =20 @@ -5159,7 +5159,7 @@ static void process_mod_list(struct list_head *head, = struct ftrace_ops *ops, if (enable && list_empty(head)) new_hash->flags &=3D ~FTRACE_HASH_FL_MOD; =20 - mutex_lock(&ftrace_lock); + mutex_lock_nospin(&ftrace_lock); =20 ftrace_hash_move_and_update_ops(ops, orig_hash, new_hash, enable); @@ -5465,7 +5465,7 @@ register_ftrace_function_probe(char *glob, struct tra= ce_array *tr, return -EINVAL; =20 =20 - mutex_lock(&ftrace_lock); + mutex_lock_nospin(&ftrace_lock); /* Check if the probe_ops is already registered */ list_for_each_entry(iter, &tr->func_probes, list) { if (iter->probe_ops =3D=3D probe_ops) { @@ -5540,7 +5540,7 @@ register_ftrace_function_probe(char *glob, struct tra= ce_array *tr, } } =20 - mutex_lock(&ftrace_lock); + mutex_lock_nospin(&ftrace_lock); =20 if (!count) { /* Nothing was added? */ @@ -5619,7 +5619,7 @@ unregister_ftrace_function_probe_func(char *glob, str= uct trace_array *tr, return -EINVAL; } =20 - mutex_lock(&ftrace_lock); + mutex_lock_nospin(&ftrace_lock); /* Check if the probe_ops is already registered */ list_for_each_entry(iter, &tr->func_probes, list) { if (iter->probe_ops =3D=3D probe_ops) { @@ -5679,7 +5679,7 @@ unregister_ftrace_function_probe_func(char *glob, str= uct trace_array *tr, goto out_unlock; } =20 - mutex_lock(&ftrace_lock); + mutex_lock_nospin(&ftrace_lock); =20 WARN_ON(probe->ref < count); =20 @@ -5943,7 +5943,7 @@ ftrace_set_hash(struct ftrace_ops *ops, unsigned char= *buf, int len, goto out_regex_unlock; } =20 - mutex_lock(&ftrace_lock); + mutex_lock_nospin(&ftrace_lock); ret =3D ftrace_hash_move_and_update_ops(ops, orig_hash, hash, enable); mutex_unlock(&ftrace_lock); =20 @@ -6205,7 +6205,7 @@ __modify_ftrace_direct(struct ftrace_ops *ops, unsign= ed long addr) * Now the ftrace_ops_list_func() is called to do the direct callers. * We can safely change the direct functions attached to each entry. */ - mutex_lock(&ftrace_lock); + mutex_lock_nospin(&ftrace_lock); =20 size =3D 1 << hash->size_bits; for (i =3D 0; i < size; i++) { @@ -6625,7 +6625,7 @@ int update_ftrace_direct_mod(struct ftrace_ops *ops, = struct ftrace_hash *hash, b * Now the ftrace_ops_list_func() is called to do the direct callers. * We can safely change the direct functions attached to each entry. */ - mutex_lock(&ftrace_lock); + mutex_lock_nospin(&ftrace_lock); =20 size =3D 1 << hash->size_bits; for (i =3D 0; i < size; i++) { @@ -6980,7 +6980,7 @@ int ftrace_regex_release(struct inode *inode, struct = file *file) } else orig_hash =3D &iter->ops->func_hash->notrace_hash; =20 - mutex_lock(&ftrace_lock); + mutex_lock_nospin(&ftrace_lock); ftrace_hash_move_and_update_ops(iter->ops, orig_hash, iter->hash, filter_hash); mutex_unlock(&ftrace_lock); @@ -7464,7 +7464,7 @@ void ftrace_create_filter_files(struct ftrace_ops *op= s, */ void ftrace_destroy_filter_files(struct ftrace_ops *ops) { - mutex_lock(&ftrace_lock); + mutex_lock_nospin(&ftrace_lock); if (ops->flags & FTRACE_OPS_FL_ENABLED) ftrace_shutdown(ops, 0); ops->flags |=3D FTRACE_OPS_FL_DELETED; @@ -7571,7 +7571,7 @@ static int ftrace_process_locs(struct module *mod, if (!start_pg) return -ENOMEM; =20 - mutex_lock(&ftrace_lock); + mutex_lock_nospin(&ftrace_lock); =20 /* * Core and each module needs their own pages, as @@ -7868,7 +7868,7 @@ void ftrace_release_mod(struct module *mod) struct ftrace_page *tmp_page =3D NULL; struct ftrace_page *pg; =20 - mutex_lock(&ftrace_lock); + mutex_lock_nospin(&ftrace_lock); =20 /* * To avoid the UAF problem after the module is unloaded, the @@ -7938,7 +7938,7 @@ void ftrace_module_enable(struct module *mod) struct dyn_ftrace *rec; struct ftrace_page *pg; =20 - mutex_lock(&ftrace_lock); + mutex_lock_nospin(&ftrace_lock); =20 if (ftrace_disabled) goto out_unlock; @@ -8267,7 +8267,7 @@ void ftrace_free_mem(struct module *mod, void *start_= ptr, void *end_ptr) key.ip =3D start; key.flags =3D end; /* overload flags, as it is unsigned long */ =20 - mutex_lock(&ftrace_lock); + mutex_lock_nospin(&ftrace_lock); =20 /* * If we are freeing module init memory, then check if @@ -8686,7 +8686,7 @@ static void clear_ftrace_pids(struct trace_array *tr,= int type) =20 void ftrace_clear_pids(struct trace_array *tr) { - mutex_lock(&ftrace_lock); + mutex_lock_nospin(&ftrace_lock); =20 clear_ftrace_pids(tr, TRACE_PIDS | TRACE_NO_PIDS); =20 @@ -8695,7 +8695,7 @@ void ftrace_clear_pids(struct trace_array *tr) =20 static void ftrace_pid_reset(struct trace_array *tr, int type) { - mutex_lock(&ftrace_lock); + mutex_lock_nospin(&ftrace_lock); clear_ftrace_pids(tr, type); =20 ftrace_update_pid_func(); @@ -8713,7 +8713,7 @@ static void *fpid_start(struct seq_file *m, loff_t *p= os) struct trace_pid_list *pid_list; struct trace_array *tr =3D m->private; =20 - mutex_lock(&ftrace_lock); + mutex_lock_nospin(&ftrace_lock); rcu_read_lock_sched(); =20 pid_list =3D rcu_dereference_sched(tr->function_pids); @@ -8766,7 +8766,7 @@ static void *fnpid_start(struct seq_file *m, loff_t *= pos) struct trace_pid_list *pid_list; struct trace_array *tr =3D m->private; =20 - mutex_lock(&ftrace_lock); + mutex_lock_nospin(&ftrace_lock); rcu_read_lock_sched(); =20 pid_list =3D rcu_dereference_sched(tr->function_no_pids); @@ -9057,7 +9057,7 @@ static int prepare_direct_functions_for_ipmodify(stru= ct ftrace_ops *ops) unsigned long ip =3D entry->ip; bool found_op =3D false; =20 - mutex_lock(&ftrace_lock); + mutex_lock_nospin(&ftrace_lock); do_for_each_ftrace_op(op, ftrace_ops_list) { if (!(op->flags & FTRACE_OPS_FL_DIRECT)) continue; @@ -9106,7 +9106,7 @@ static void cleanup_direct_functions_after_ipmodify(s= truct ftrace_ops *ops) unsigned long ip =3D entry->ip; bool found_op =3D false; =20 - mutex_lock(&ftrace_lock); + mutex_lock_nospin(&ftrace_lock); do_for_each_ftrace_op(op, ftrace_ops_list) { if (!(op->flags & FTRACE_OPS_FL_DIRECT)) continue; @@ -9153,7 +9153,7 @@ static int register_ftrace_function_nolock(struct ftr= ace_ops *ops) =20 ftrace_ops_init(ops); =20 - mutex_lock(&ftrace_lock); + mutex_lock_nospin(&ftrace_lock); =20 ret =3D ftrace_startup(ops, 0); =20 @@ -9200,7 +9200,7 @@ int unregister_ftrace_function(struct ftrace_ops *ops) { int ret; =20 - mutex_lock(&ftrace_lock); + mutex_lock_nospin(&ftrace_lock); ret =3D ftrace_shutdown(ops, 0); mutex_unlock(&ftrace_lock); =20 --=20 2.47.3